MCPcopy Create free account
hub / github.com/ZDoom/Raze / C_DoKey

Function C_DoKey

source/common/console/c_bind.cpp:812–879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

810//=============================================================================
811
812bool C_DoKey (event_t *ev, FKeyBindings *binds, FKeyBindings *doublebinds)
813{
814 FString binding;
815 bool dclick;
816 unsigned int nowtime;
817
818 if (ev->type != EV_KeyDown && ev->type != EV_KeyUp)
819 return false;
820
821 if ((unsigned int)ev->data1 >= NUM_KEYS)
822 return false;
823
824 dclick = false;
825
826 nowtime = (unsigned)I_msTime();
827 if (doublebinds != nullptr && int(DClickTime[ev->data1] - nowtime) > 0 && ev->type == EV_KeyDown)
828 {
829 // Key pressed for a double click
830 binding = doublebinds->GetBinding(ev->data1);
831 DClicked.Set(ev->data1);
832 dclick = true;
833 }
834 else
835 {
836 if (ev->type == EV_KeyDown)
837 { // Key pressed for a normal press
838 binding = binds->GetBinding(ev->data1);
839 if (doublebinds != nullptr) DClickTime[ev->data1] = nowtime + 571;
840 }
841 else if (doublebinds != nullptr && DClicked[ev->data1])
842 { // Key released from a double click
843 binding = doublebinds->GetBinding(ev->data1);
844 DClicked.Clear(ev->data1);
845 DClickTime[ev->data1] = 0;
846 dclick = true;
847 }
848 else
849 { // Key released from a normal press
850 binding = binds->GetBinding(ev->data1);
851 }
852 }
853
854
855 if (binding.IsEmpty())
856 {
857 binding = binds->GetBinding(ev->data1);
858 dclick = false;
859 }
860
861 if (ev->type == EV_KeyUp && binding[0] != '+')
862 {
863 return false;
864 }
865
866 if (!binding.IsEmpty() && (chatmodeon == 0 || ev->data1 < 256))
867 {
868 char *copy = binding.LockBuffer();
869

Callers 2

AM_ResponderFunction · 0.85
G_ResponderFunction · 0.85

Calls 7

I_msTimeFunction · 0.85
AddCommandStringFunction · 0.85
LockBufferMethod · 0.80
GetBindingMethod · 0.45
SetMethod · 0.45
ClearMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected