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

Function M_Responder

source/common/menu/menu.cpp:605–791  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

603//=============================================================================
604
605bool M_Responder (event_t *ev)
606{
607 int ch = 0;
608 bool keyup = false;
609 int mkey = NUM_MKEYS;
610 bool fromcontroller = true;
611
612 if (chatmodeon)
613 {
614 return false;
615 }
616
617 if (CurrentMenu != nullptr && menuactive != MENU_Off)
618 {
619 // There are a few input sources we are interested in:
620 //
621 // EV_KeyDown / EV_KeyUp : joysticks/gamepads/controllers
622 // EV_GUI_KeyDown / EV_GUI_KeyUp : the keyboard
623 // EV_GUI_Char : printable characters, which we want in string input mode
624 //
625 // This code previously listened for EV_GUI_KeyRepeat to handle repeating
626 // in the menus, but that doesn't work with gamepads, so now we combine
627 // the multiple inputs into buttons and handle the repetition manually.
628 if (ev->type == EV_GUI_Event)
629 {
630 fromcontroller = false;
631 if (ev->subtype == EV_GUI_KeyRepeat)
632 {
633 // We do our own key repeat handling but still want to eat the
634 // OS's repeated keys.
635 if (CurrentMenu->TranslateKeyboardEvents()) return true;
636 else return CurrentMenu->CallResponder(ev);
637 }
638 else if (ev->subtype == EV_GUI_BackButtonDown || ev->subtype == EV_GUI_BackButtonUp)
639 {
640 mkey = MKEY_Back;
641 keyup = ev->subtype == EV_GUI_BackButtonUp;
642 }
643 else if (ev->subtype != EV_GUI_KeyDown && ev->subtype != EV_GUI_KeyUp)
644 {
645 // do we want mouse input?
646 if (ev->subtype >= EV_GUI_FirstMouseEvent && ev->subtype <= EV_GUI_LastMouseEvent)
647 {
648 if (!m_use_mouse)
649 return true;
650 }
651
652 // pass everything else on to the current menu
653 return CurrentMenu->CallResponder(ev);
654 }
655 else if (CurrentMenu->TranslateKeyboardEvents())
656 {
657 ch = ev->data1;
658 keyup = ev->subtype == EV_GUI_KeyUp;
659 switch (ch)
660 {
661 case GK_BACK: mkey = MKEY_Back; break;
662 case GK_ESCAPE: mkey = MKEY_Back; break;

Callers 1

D_ProcessEventsFunction · 0.85

Calls 7

M_StartControlPanelFunction · 0.85
M_SetMenuFunction · 0.85
CallResponderMethod · 0.80
ReleaseKeyMethod · 0.80
PressKeyMethod · 0.80
CallMenuEventMethod · 0.80

Tested by

no test coverage detected