Changeset View
Changeset View
Standalone View
Standalone View
source/ps/Hotkey.cpp
Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | else if ((int)key.code < MOUSE_LAST && (int)key.code > MOUSE_BASE && g_mouse_buttons[key.code - MOUSE_BASE] == key.negated) | ||||
return false; | return false; | ||||
// Modifier keycodes are between the normal keys and the mouse 'keys' | // Modifier keycodes are between the normal keys and the mouse 'keys' | ||||
else if ((int)key.code < UNIFIED_LAST && (int)key.code > SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES) && unified[key.code - UNIFIED_SHIFT] == key.negated) | else if ((int)key.code < UNIFIED_LAST && (int)key.code > SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES) && unified[key.code - UNIFIED_SHIFT] == key.negated) | ||||
return false; | return false; | ||||
else | else | ||||
return true; | return true; | ||||
} | } | ||||
InReaction HotkeyStateChange(const SDL_Event_* ev) | |||||
{ | |||||
if (ev->ev.type == SDL_HOTKEYDOWN) | |||||
g_HotkeyStatus[static_cast<const char*>(ev->ev.user.data1)] = true; | |||||
else if (ev->ev.type == SDL_HOTKEYUP) | |||||
g_HotkeyStatus[static_cast<const char*>(ev->ev.user.data1)] = false; | |||||
return IN_PASS; | |||||
} | |||||
InReaction HotkeyInputHandler(const SDL_Event_* ev) | InReaction HotkeyInputHandler(const SDL_Event_* ev) | ||||
{ | { | ||||
int keycode = 0; | int keycode = 0; | ||||
switch(ev->ev.type) | switch(ev->ev.type) | ||||
{ | { | ||||
case SDL_KEYDOWN: | case SDL_KEYDOWN: | ||||
case SDL_KEYUP: | case SDL_KEYUP: | ||||
Show All 28 Lines | case SDL_MOUSEWHEEL: | ||||
} | } | ||||
else if (ev->ev.wheel.x < 0) | else if (ev->ev.wheel.x < 0) | ||||
{ | { | ||||
keycode = MOUSE_X1; | keycode = MOUSE_X1; | ||||
break; | break; | ||||
} | } | ||||
return IN_PASS; | return IN_PASS; | ||||
case SDL_HOTKEYDOWN: | |||||
g_HotkeyStatus[static_cast<const char*>(ev->ev.user.data1)] = true; | |||||
return IN_PASS; | |||||
case SDL_HOTKEYUP: | |||||
g_HotkeyStatus[static_cast<const char*>(ev->ev.user.data1)] = false; | |||||
return IN_PASS; | |||||
default: | default: | ||||
return IN_PASS; | return IN_PASS; | ||||
} | } | ||||
// Somewhat hackish: | // Somewhat hackish: | ||||
// Create phantom 'unified-modifier' events when left- or right- modifier keys are pressed | // Create phantom 'unified-modifier' events when left- or right- modifier keys are pressed | ||||
// Just send them to this handler; don't let the imaginary event codes leak back to real SDL. | // Just send them to this handler; don't let the imaginary event codes leak back to real SDL. | ||||
Show All 29 Lines | InReaction HotkeyInputHandler(const SDL_Event_* ev) | ||||
if (g_HotkeyMap.find(keycode) == g_HotkeyMap.end()) | if (g_HotkeyMap.find(keycode) == g_HotkeyMap.end()) | ||||
return (IN_PASS); | return (IN_PASS); | ||||
// Inhibit the dispatch of hotkey events caused by real keys (not fake mouse button | // Inhibit the dispatch of hotkey events caused by real keys (not fake mouse button | ||||
// events) while the console is up. | // events) while the console is up. | ||||
bool consoleCapture = false; | bool consoleCapture = false; | ||||
if (g_Console->IsActive() && keycode < SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES)) | if (g_Console && g_Console->IsActive() && keycode < SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES)) | ||||
wraitii: Likewise added to allow using InitInput in testing. | |||||
consoleCapture = true; | consoleCapture = true; | ||||
// Here's an interesting bit: | // Here's an interesting bit: | ||||
// If you have an event bound to, say, 'F', and another to, say, 'Ctrl+F', pressing | // If you have an event bound to, say, 'F', and another to, say, 'Ctrl+F', pressing | ||||
// 'F' while control is down would normally fire off both. | // 'F' while control is down would normally fire off both. | ||||
// To avoid this, set the modifier keys for /all/ events this key would trigger | // To avoid this, set the modifier keys for /all/ events this key would trigger | ||||
// (Ctrl, for example, is both group-save and bookmark-save) | // (Ctrl, for example, is both group-save and bookmark-save) | ||||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Likewise added to allow using InitInput in testing.