Rename KEY enum to IPT enum

Given that KEY enum was being misused for e.g. KEY_LMOUSE
This commit is contained in:
UnknownShadow200 2023-06-22 18:22:58 +10:00
parent 3ad0966590
commit 28aba23a1a
19 changed files with 475 additions and 475 deletions

View File

@ -94,7 +94,7 @@ static void PerspectiveCamera_UpdateMouseRotation(double delta) {
struct LocationUpdate update; struct LocationUpdate update;
Vec2 rot = PerspectiveCamera_GetMouseDelta(delta); Vec2 rot = PerspectiveCamera_GetMouseDelta(delta);
if (Key_IsAltPressed() && Camera.Active->isThirdPerson) { if (Input_IsAltPressed() && Camera.Active->isThirdPerson) {
cam_rotOffset.X += rot.X; cam_rotOffset.Y += rot.Y; cam_rotOffset.X += rot.X; cam_rotOffset.Y += rot.Y;
return; return;
} }

View File

@ -137,7 +137,7 @@ void Game_CycleViewDistance(void) {
const short* dists = Gui.ClassicMenu ? classicDists : normDists; const short* dists = Gui.ClassicMenu ? classicDists : normDists;
int count = Gui.ClassicMenu ? Array_Elems(classicDists) : Array_Elems(normDists); int count = Gui.ClassicMenu ? Array_Elems(classicDists) : Array_Elems(normDists);
if (Key_IsShiftPressed()) { if (Input_IsShiftPressed()) {
CycleViewDistanceBackwards(dists, count); CycleViewDistanceBackwards(dists, count);
} else { } else {
CycleViewDistanceForwards(dists, count); CycleViewDistanceForwards(dists, count);
@ -665,9 +665,9 @@ cc_bool Game_ShouldClose(void) {
} }
/* Try to intercept Ctrl+W or Cmd+W for multiplayer */ /* Try to intercept Ctrl+W or Cmd+W for multiplayer */
if (Key_IsCtrlPressed() || Key_IsWinPressed()) return false; if (Input_IsCtrlPressed() || Input_IsWinPressed()) return false;
/* Also try to intercept mouse back button (Mouse4) */ /* Also try to intercept mouse back button (Mouse4) */
return !Input_Pressed[KEY_XBUTTON1]; return !Input_Pressed[IPT_XBUTTON1];
} }
#else #else
static void Game_RunLoop(void) { static void Game_RunLoop(void) {

View File

@ -489,7 +489,7 @@ void Screen_ContextLost(void* screen) {
} }
} }
int Screen_InputDown(void* screen, int key) { return key < KEY_F1 || key > KEY_F24; } int Screen_InputDown(void* screen, int key) { return key < IPT_F1 || key > IPT_F24; }
void Screen_InputUp(void* screen, int key) { } void Screen_InputUp(void* screen, int key) { }
void Screen_PointerUp(void* s, int id, int x, int y) { } void Screen_PointerUp(void* s, int id, int x, int y) { }

View File

@ -239,11 +239,11 @@ void Input_SetPressed(int key) {
Input_Pressed[key] = true; Input_Pressed[key] = true;
Event_RaiseInput(&InputEvents.Down, key, wasPressed); Event_RaiseInput(&InputEvents.Down, key, wasPressed);
if (key == 'C' && Key_IsActionPressed()) Event_RaiseInput(&InputEvents.Down, INPUT_CLIPBOARD_COPY, 0); if (key == 'C' && Input_IsActionPressed()) Event_RaiseInput(&InputEvents.Down, INPUT_CLIPBOARD_COPY, 0);
if (key == 'V' && Key_IsActionPressed()) Event_RaiseInput(&InputEvents.Down, INPUT_CLIPBOARD_PASTE, 0); if (key == 'V' && Input_IsActionPressed()) Event_RaiseInput(&InputEvents.Down, INPUT_CLIPBOARD_PASTE, 0);
/* don't allow multiple left mouse down events */ /* don't allow multiple left mouse down events */
if (key != KEY_LMOUSE || wasPressed) return; if (key != IPT_LMOUSE || wasPressed) return;
Pointer_SetPressed(0, true); Pointer_SetPressed(0, true);
} }
@ -252,7 +252,7 @@ void Input_SetReleased(int key) {
Input_Pressed[key] = false; Input_Pressed[key] = false;
Event_RaiseInt(&InputEvents.Up, key); Event_RaiseInt(&InputEvents.Up, key);
if (key == KEY_LMOUSE) Pointer_SetPressed(0, false); if (key == IPT_LMOUSE) Pointer_SetPressed(0, false);
} }
void Input_Set(int key, int pressed) { void Input_Set(int key, int pressed) {
@ -318,14 +318,14 @@ void Pointer_SetPosition(int idx, int x, int y) {
cc_uint8 KeyBinds[KEYBIND_COUNT]; cc_uint8 KeyBinds[KEYBIND_COUNT];
const cc_uint8 KeyBind_Defaults[KEYBIND_COUNT] = { const cc_uint8 KeyBind_Defaults[KEYBIND_COUNT] = {
'W', 'S', 'A', 'D', 'W', 'S', 'A', 'D',
KEY_SPACE, 'R', KEY_ENTER, 'T', IPT_SPACE, 'R', IPT_ENTER, 'T',
'B', 'F', KEY_ENTER, KEY_TAB, 'B', 'F', IPT_ENTER, IPT_TAB,
KEY_LSHIFT, 'X', 'Z', 'Q', 'E', IPT_LSHIFT, 'X', 'Z', 'Q', 'E',
KEY_LALT, KEY_F3, KEY_F12, KEY_F11, IPT_LALT, IPT_F3, IPT_F12, IPT_F11,
KEY_F5, KEY_F1, KEY_F7, 'C', IPT_F5, IPT_F1, IPT_F7, 'C',
KEY_LCTRL, KEY_LMOUSE, KEY_MMOUSE, KEY_RMOUSE, IPT_LCTRL, IPT_LMOUSE, IPT_MMOUSE, IPT_RMOUSE,
KEY_F6, KEY_LALT, KEY_F8, IPT_F6, IPT_LALT, IPT_F8,
'G', KEY_F10, 0, 'G', IPT_F10, 0,
0, 0, 0, 0 0, 0, 0, 0
}; };
static const char* const keybindNames[KEYBIND_COUNT] = { static const char* const keybindNames[KEYBIND_COUNT] = {
@ -355,7 +355,7 @@ static void KeyBind_Load(void) {
name.buffer[name.length] = '\0'; name.buffer[name.length] = '\0';
mapping = Options_GetEnum(name.buffer, KeyBind_Defaults[i], Input_StorageNames, INPUT_COUNT); mapping = Options_GetEnum(name.buffer, KeyBind_Defaults[i], Input_StorageNames, INPUT_COUNT);
if (mapping != KEY_ESCAPE) KeyBinds[i] = mapping; if (mapping != IPT_ESCAPE) KeyBinds[i] = mapping;
} }
} }
@ -384,20 +384,20 @@ static void KeyBind_Init(void) {
*---------------------------------------------------------Hotkeys---------------------------------------------------------* *---------------------------------------------------------Hotkeys---------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
const cc_uint8 Hotkeys_LWJGL[256] = { const cc_uint8 Hotkeys_LWJGL[256] = {
0, KEY_ESCAPE, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', KEY_MINUS, KEY_EQUALS, KEY_BACKSPACE, KEY_TAB, 0, IPT_ESCAPE, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', IPT_MINUS, IPT_EQUALS, IPT_BACKSPACE, IPT_TAB,
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', KEY_LBRACKET, KEY_RBRACKET, KEY_ENTER, KEY_LCTRL, 'A', 'S', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', IPT_LBRACKET, IPT_RBRACKET, IPT_ENTER, IPT_LCTRL, 'A', 'S',
'D', 'F', 'G', 'H', 'J', 'K', 'L', KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_LSHIFT, KEY_BACKSLASH, 'Z', 'X', 'C', 'V', 'D', 'F', 'G', 'H', 'J', 'K', 'L', IPT_SEMICOLON, IPT_QUOTE, IPT_TILDE, IPT_LSHIFT, IPT_BACKSLASH, 'Z', 'X', 'C', 'V',
'B', 'N', 'M', KEY_COMMA, KEY_PERIOD, KEY_SLASH, KEY_RSHIFT, 0, KEY_LALT, KEY_SPACE, KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, 'B', 'N', 'M', IPT_COMMA, IPT_PERIOD, IPT_SLASH, IPT_RSHIFT, 0, IPT_LALT, IPT_SPACE, IPT_CAPSLOCK, IPT_F1, IPT_F2, IPT_F3, IPT_F4, IPT_F5,
KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_NUMLOCK, KEY_SCROLLLOCK, KEY_KP7, KEY_KP8, KEY_KP9, KEY_KP_MINUS, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP_PLUS, KEY_KP1, IPT_F6, IPT_F7, IPT_F8, IPT_F9, IPT_F10, IPT_NUMLOCK, IPT_SCROLLLOCK, IPT_KP7, IPT_KP8, IPT_KP9, IPT_KP_MINUS, IPT_KP4, IPT_KP5, IPT_KP6, IPT_KP_PLUS, IPT_KP1,
KEY_KP2, KEY_KP3, KEY_KP0, KEY_KP_DECIMAL, 0, 0, 0, KEY_F11, KEY_F12, 0, 0, 0, 0, 0, 0, 0, IPT_KP2, IPT_KP3, IPT_KP0, IPT_KP_DECIMAL, 0, 0, 0, IPT_F11, IPT_F12, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, KEY_F13, KEY_F14, KEY_F15, KEY_F16, KEY_F17, KEY_F18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IPT_F13, IPT_F14, IPT_F15, IPT_F16, IPT_F17, IPT_F18, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_KP_PLUS, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IPT_KP_PLUS, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_KP_ENTER, KEY_RCTRL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IPT_KP_ENTER, IPT_RCTRL, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, KEY_KP_DIVIDE, 0, 0, KEY_RALT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IPT_KP_DIVIDE, 0, 0, IPT_RALT, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, KEY_PAUSE, 0, KEY_HOME, KEY_UP, KEY_PAGEUP, 0, KEY_LEFT, 0, KEY_RIGHT, 0, KEY_END, 0, 0, 0, 0, 0, IPT_PAUSE, 0, IPT_HOME, IPT_UP, IPT_PAGEUP, 0, IPT_LEFT, 0, IPT_RIGHT, 0, IPT_END,
KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, 0, 0, 0, 0, 0, 0, 0, KEY_LWIN, KEY_RWIN, 0, 0, 0, IPT_DOWN, IPT_PAGEDOWN, IPT_INSERT, IPT_DELETE, 0, 0, 0, 0, 0, 0, 0, IPT_LWIN, IPT_RWIN, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}; };
@ -487,9 +487,9 @@ int Hotkeys_FindPartial(int key) {
struct HotkeyData hk; struct HotkeyData hk;
int i, modifiers = 0; int i, modifiers = 0;
if (Key_IsCtrlPressed()) modifiers |= HOTKEY_MOD_CTRL; if (Input_IsCtrlPressed()) modifiers |= HOTIPT_MOD_CTRL;
if (Key_IsShiftPressed()) modifiers |= HOTKEY_MOD_SHIFT; if (Input_IsShiftPressed()) modifiers |= HOTIPT_MOD_SHIFT;
if (Key_IsAltPressed()) modifiers |= HOTKEY_MOD_ALT; if (Input_IsAltPressed()) modifiers |= HOTIPT_MOD_ALT;
for (i = 0; i < HotkeysText.count; i++) { for (i = 0; i < HotkeysText.count; i++) {
hk = HotkeysList[i]; hk = HotkeysList[i];
@ -512,8 +512,8 @@ static void StoredHotkey_Parse(cc_string* key, cc_string* value) {
if (!String_UNSAFE_Separate(key, '&', &strKey, &strMods)) return; if (!String_UNSAFE_Separate(key, '&', &strKey, &strMods)) return;
if (!String_UNSAFE_Separate(value, '&', &strMore, &strText)) return; if (!String_UNSAFE_Separate(value, '&', &strMore, &strText)) return;
trigger = Utils_ParseEnum(&strKey, KEY_NONE, Input_StorageNames, INPUT_COUNT); trigger = Utils_ParseEnum(&strKey, IPT_NONE, Input_StorageNames, INPUT_COUNT);
if (trigger == KEY_NONE) return; if (trigger == IPT_NONE) return;
if (!Convert_ParseUInt8(&strMods, &modifiers)) return; if (!Convert_ParseUInt8(&strMods, &modifiers)) return;
if (!Convert_ParseBool(&strMore, &more)) return; if (!Convert_ParseBool(&strMore, &more)) return;
@ -813,11 +813,11 @@ void InputHandler_Tick(void) {
*-----------------------------------------------------Input helpers-------------------------------------------------------* *-----------------------------------------------------Input helpers-------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
static cc_bool InputHandler_IsShutdown(int key) { static cc_bool InputHandler_IsShutdown(int key) {
if (key == KEY_F4 && Key_IsAltPressed()) return true; if (key == IPT_F4 && Input_IsAltPressed()) return true;
/* On macOS, Cmd+Q should also end the process */ /* On macOS, Cmd+Q should also end the process */
#ifdef CC_BUILD_DARWIN #ifdef CC_BUILD_DARWIN
return key == 'Q' && Key_IsWinPressed(); return key == 'Q' && Input_IsWinPressed();
#else #else
return false; return false;
#endif #endif
@ -845,7 +845,7 @@ cc_bool Input_HandleMouseWheel(float delta) {
struct HacksComp* h; struct HacksComp* h;
cc_bool hotbar; cc_bool hotbar;
hotbar = Key_IsAltPressed() || Key_IsCtrlPressed() || Key_IsShiftPressed(); hotbar = Input_IsAltPressed() || Input_IsCtrlPressed() || Input_IsShiftPressed();
if (!hotbar && Camera.Active->Zoom(delta)) return true; if (!hotbar && Camera.Active->Zoom(delta)) return true;
if (!KeyBind_IsPressed(KEYBIND_ZOOM_SCROLL)) return false; if (!KeyBind_IsPressed(KEYBIND_ZOOM_SCROLL)) return false;
@ -925,7 +925,7 @@ static cc_bool HandleCoreKey(int key) {
Game_ToggleFullscreen(); Game_ToggleFullscreen();
} else if (key == KeyBinds[KEYBIND_FOG]) { } else if (key == KeyBinds[KEYBIND_FOG]) {
Game_CycleViewDistance(); Game_CycleViewDistance();
} else if (key == KEY_F5 && Game_ClassicMode) { } else if (key == IPT_F5 && Game_ClassicMode) {
int weather = Env.Weather == WEATHER_SUNNY ? WEATHER_RAINY : WEATHER_SUNNY; int weather = Env.Weather == WEATHER_SUNNY ? WEATHER_RAINY : WEATHER_SUNNY;
Env_SetWeather(weather); Env_SetWeather(weather);
} else { } else {
@ -1044,7 +1044,7 @@ static void OnInputDown(void* obj, int key, cc_bool was) {
int i; int i;
#ifndef CC_BUILD_WEB #ifndef CC_BUILD_WEB
if (key == KEY_ESCAPE && (s = Gui_GetClosable())) { if (key == IPT_ESCAPE && (s = Gui_GetClosable())) {
/* Don't want holding down escape to go in and out of pause menu */ /* Don't want holding down escape to go in and out of pause menu */
if (!was) Gui_Remove(s); if (!was) Gui_Remove(s);
return; return;
@ -1064,7 +1064,7 @@ static void OnInputDown(void* obj, int key, cc_bool was) {
if (s->VTABLE->HandlesInputDown(s, key)) return; if (s->VTABLE->HandlesInputDown(s, key)) return;
} }
if ((key == KEY_ESCAPE || key == KEY_PAUSE) && !Gui.InputGrab) { if ((key == IPT_ESCAPE || key == IPT_PAUSE) && !Gui.InputGrab) {
#ifdef CC_BUILD_WEB #ifdef CC_BUILD_WEB
/* Can't do this in KeyUp, because pressing escape without having */ /* Can't do this in KeyUp, because pressing escape without having */
/* explicitly disabled mouse lock means a KeyUp event isn't sent. */ /* explicitly disabled mouse lock means a KeyUp event isn't sent. */
@ -1093,7 +1093,7 @@ static void OnInputUp(void* obj, int key) {
/* When closing menus (which reacquires mouse focus) in key down, */ /* When closing menus (which reacquires mouse focus) in key down, */
/* this still leaves the cursor visible. But if this is instead */ /* this still leaves the cursor visible. But if this is instead */
/* done in key up, the cursor disappears as expected. */ /* done in key up, the cursor disappears as expected. */
if (key == KEY_ESCAPE && (s = Gui_GetClosable())) { if (key == IPT_ESCAPE && (s = Gui_GetClosable())) {
if (suppressEscape) { suppressEscape = false; return; } if (suppressEscape) { suppressEscape = false; return; }
Gui_Remove(s); return; Gui_Remove(s); return;
} }

View File

@ -10,40 +10,40 @@ struct StringsBuffer;
extern struct IGameComponent Input_Component; extern struct IGameComponent Input_Component;
enum InputButtons { enum InputButtons {
KEY_NONE, /* Unrecognised key */ IPT_NONE, /* Unrecognised key */
KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, IPT_F1, IPT_F2, IPT_F3, IPT_F4, IPT_F5, IPT_F6, IPT_F7, IPT_F8, IPT_F9, IPT_F10,
KEY_F11, KEY_F12, KEY_F13, KEY_F14, KEY_F15, KEY_F16, KEY_F17, KEY_F18, KEY_F19, KEY_F20, IPT_F11, IPT_F12, IPT_F13, IPT_F14, IPT_F15, IPT_F16, IPT_F17, IPT_F18, IPT_F19, IPT_F20,
KEY_F21, KEY_F22, KEY_F23, KEY_F24, IPT_F21, IPT_F22, IPT_F23, IPT_F24,
KEY_TILDE, KEY_MINUS, KEY_EQUALS, KEY_LBRACKET, KEY_RBRACKET, KEY_SLASH, IPT_TILDE, IPT_MINUS, IPT_EQUALS, IPT_LBRACKET, IPT_RBRACKET, IPT_SLASH,
KEY_SEMICOLON, KEY_QUOTE, KEY_COMMA, KEY_PERIOD, KEY_BACKSLASH, IPT_SEMICOLON, IPT_QUOTE, IPT_COMMA, IPT_PERIOD, IPT_BACKSLASH,
KEY_LSHIFT, KEY_RSHIFT, KEY_LCTRL, KEY_RCTRL, IPT_LSHIFT, IPT_RSHIFT, IPT_LCTRL, IPT_RCTRL,
KEY_LALT, KEY_RALT, KEY_LWIN, KEY_RWIN, IPT_LALT, IPT_RALT, IPT_LWIN, IPT_RWIN,
KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, IPT_UP, IPT_DOWN, IPT_LEFT, IPT_RIGHT,
KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, IPT_0, IPT_1, IPT_2, IPT_3, IPT_4,
KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, /* same as '0'-'9' */ IPT_5, IPT_6, IPT_7, IPT_8, IPT_9, /* same as '0'-'9' */
KEY_INSERT, KEY_DELETE, KEY_HOME, KEY_END, KEY_PAGEUP, KEY_PAGEDOWN, IPT_INSERT, IPT_DELETE, IPT_HOME, IPT_END, IPT_PAGEUP, IPT_PAGEDOWN,
KEY_MENU, IPT_MENU,
KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, IPT_A, IPT_B, IPT_C, IPT_D, IPT_E, IPT_F, IPT_G, IPT_H, IPT_I, IPT_J,
KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, IPT_K, IPT_L, IPT_M, IPT_N, IPT_O, IPT_P, IPT_Q, IPT_R, IPT_S, IPT_T,
KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, /* same as 'A'-'Z' */ IPT_U, IPT_V, IPT_W, IPT_X, IPT_Y, IPT_Z, /* same as 'A'-'Z' */
KEY_ENTER, KEY_ESCAPE, KEY_SPACE, KEY_BACKSPACE, KEY_TAB, KEY_CAPSLOCK, IPT_ENTER, IPT_ESCAPE, IPT_SPACE, IPT_BACKSPACE, IPT_TAB, IPT_CAPSLOCK,
KEY_SCROLLLOCK, KEY_PRINTSCREEN, KEY_PAUSE, KEY_NUMLOCK, IPT_SCROLLLOCK, IPT_PRINTSCREEN, IPT_PAUSE, IPT_NUMLOCK,
KEY_KP0, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP4, IPT_KP0, IPT_KP1, IPT_KP2, IPT_KP3, IPT_KP4,
KEY_KP5, KEY_KP6, KEY_KP7, KEY_KP8, KEY_KP9, IPT_KP5, IPT_KP6, IPT_KP7, IPT_KP8, IPT_KP9,
KEY_KP_DIVIDE, KEY_KP_MULTIPLY, KEY_KP_MINUS, IPT_KP_DIVIDE, IPT_KP_MULTIPLY, IPT_KP_MINUS,
KEY_KP_PLUS, KEY_KP_DECIMAL, KEY_KP_ENTER, IPT_KP_PLUS, IPT_KP_DECIMAL, IPT_KP_ENTER,
/* NOTE: RMOUSE must be before MMOUSE for PlayerClick compatibility */ /* NOTE: RMOUSE must be before MMOUSE for PlayerClick compatibility */
KEY_XBUTTON1, KEY_XBUTTON2, KEY_LMOUSE, KEY_RMOUSE, KEY_MMOUSE, IPT_XBUTTON1, IPT_XBUTTON2, IPT_LMOUSE, IPT_RMOUSE, IPT_MMOUSE,
INPUT_COUNT, INPUT_COUNT,
INPUT_CLIPBOARD_COPY = 1001, INPUT_CLIPBOARD_COPY = 1001,
@ -55,19 +55,19 @@ extern const char* const Input_StorageNames[INPUT_COUNT];
/* Simple display names for each input button */ /* Simple display names for each input button */
extern const char* const Input_DisplayNames[INPUT_COUNT]; extern const char* const Input_DisplayNames[INPUT_COUNT];
#define Key_IsWinPressed() (Input_Pressed[KEY_LWIN] || Input_Pressed[KEY_RWIN]) #define Input_IsWinPressed() (Input_Pressed[IPT_LWIN] || Input_Pressed[IPT_RWIN])
#define Key_IsAltPressed() (Input_Pressed[KEY_LALT] || Input_Pressed[KEY_RALT]) #define Input_IsAltPressed() (Input_Pressed[IPT_LALT] || Input_Pressed[IPT_RALT])
#define Key_IsCtrlPressed() (Input_Pressed[KEY_LCTRL] || Input_Pressed[KEY_RCTRL]) #define Input_IsCtrlPressed() (Input_Pressed[IPT_LCTRL] || Input_Pressed[IPT_RCTRL])
#define Key_IsShiftPressed() (Input_Pressed[KEY_LSHIFT] || Input_Pressed[KEY_RSHIFT]) #define Input_IsShiftPressed() (Input_Pressed[IPT_LSHIFT] || Input_Pressed[IPT_RSHIFT])
#if defined CC_BUILD_HAIKU #if defined CC_BUILD_HAIKU
/* Haiku uses ALT instead of CTRL for clipboard and stuff */ /* Haiku uses ALT instead of CTRL for clipboard and stuff */
#define Key_IsActionPressed() Key_IsAltPressed() #define Input_IsActionPressed() Input_IsAltPressed()
#elif defined CC_BUILD_DARWIN #elif defined CC_BUILD_DARWIN
/* macOS uses CMD instead of CTRL for clipboard and stuff */ /* macOS uses CMD instead of CTRL for clipboard and stuff */
#define Key_IsActionPressed() Key_IsWinPressed() #define Input_IsActionPressed() Input_IsWinPressed()
#else #else
#define Key_IsActionPressed() Key_IsCtrlPressed() #define Input_IsActionPressed() Input_IsCtrlPressed()
#endif #endif
/* Pressed state of each input button. Use Input_Set to change. */ /* Pressed state of each input button. Use Input_Set to change. */
@ -157,14 +157,14 @@ struct HotkeyData {
int textIndex; /* contents to copy directly into the input bar */ int textIndex; /* contents to copy directly into the input bar */
cc_uint8 trigger; /* Member of Key enumeration */ cc_uint8 trigger; /* Member of Key enumeration */
cc_uint8 mods; /* HotkeyModifiers bitflags */ cc_uint8 mods; /* HotkeyModifiers bitflags */
cc_uint8 flags; /* HOTKEY_FLAG flags */ cc_uint8 flags; /* HOTIPT_FLAG flags */
}; };
#define HOTKEYS_MAX_COUNT 256 #define HOTKEYS_MAX_COUNT 256
extern struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT]; extern struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
extern struct StringsBuffer HotkeysText; extern struct StringsBuffer HotkeysText;
enum HotkeyModifiers { enum HotkeyModifiers {
HOTKEY_MOD_CTRL = 1, HOTKEY_MOD_SHIFT = 2, HOTKEY_MOD_ALT = 4 HOTIPT_MOD_CTRL = 1, HOTIPT_MOD_SHIFT = 2, HOTIPT_MOD_ALT = 4
}; };
/* Adds or updates a new hotkey. */ /* Adds or updates a new hotkey. */

View File

@ -61,7 +61,7 @@ void LScreen_UnselectWidget(struct LScreen* s, int idx, struct LWidget* w) {
static void LScreen_HandleTab(struct LScreen* s) { static void LScreen_HandleTab(struct LScreen* s) {
struct LWidget* w; struct LWidget* w;
int dir = Key_IsShiftPressed() ? -1 : 1; int dir = Input_IsShiftPressed() ? -1 : 1;
int index = 0, i, j; int index = 0, i, j;
if (s->selectedWidget) { if (s->selectedWidget) {
@ -82,9 +82,9 @@ static void LScreen_HandleTab(struct LScreen* s) {
} }
static void LScreen_KeyDown(struct LScreen* s, int key, cc_bool was) { static void LScreen_KeyDown(struct LScreen* s, int key, cc_bool was) {
if (key == KEY_TAB) { if (key == IPT_TAB) {
LScreen_HandleTab(s); LScreen_HandleTab(s);
} else if (key == KEY_ENTER || key == KEY_KP_ENTER) { } else if (key == IPT_ENTER || key == IPT_KP_ENTER) {
/* Shouldn't multi click when holding down Enter */ /* Shouldn't multi click when holding down Enter */
if (was) return; if (was) return;
@ -369,13 +369,13 @@ static void ColoursScreen_MouseWheel(struct LScreen* s_, float delta) {
} }
static void ColoursScreen_KeyDown(struct LScreen* s, int key, cc_bool was) { static void ColoursScreen_KeyDown(struct LScreen* s, int key, cc_bool was) {
if (key == KEY_LEFT) { if (key == IPT_LEFT) {
ColoursScreen_AdjustSelected(s, -1); ColoursScreen_AdjustSelected(s, -1);
} else if (key == KEY_RIGHT) { } else if (key == IPT_RIGHT) {
ColoursScreen_AdjustSelected(s, +1); ColoursScreen_AdjustSelected(s, +1);
} else if (key == KEY_UP) { } else if (key == IPT_UP) {
ColoursScreen_AdjustSelected(s, +10); ColoursScreen_AdjustSelected(s, +10);
} else if (key == KEY_DOWN) { } else if (key == IPT_DOWN) {
ColoursScreen_AdjustSelected(s, -10); ColoursScreen_AdjustSelected(s, -10);
} else { } else {
LScreen_KeyDown(s, key, was); LScreen_KeyDown(s, key, was);

View File

@ -249,19 +249,19 @@ static void LInput_Delete(struct LInput* w) {
static void LInput_KeyDown(void* widget, int key, cc_bool was) { static void LInput_KeyDown(void* widget, int key, cc_bool was) {
struct LInput* w = (struct LInput*)widget; struct LInput* w = (struct LInput*)widget;
if (key == KEY_BACKSPACE) { if (key == IPT_BACKSPACE) {
LInput_Backspace(w); LInput_Backspace(w);
} else if (key == KEY_DELETE) { } else if (key == IPT_DELETE) {
LInput_Delete(w); LInput_Delete(w);
} else if (key == INPUT_CLIPBOARD_COPY) { } else if (key == INPUT_CLIPBOARD_COPY) {
if (w->text.length) Clipboard_SetText(&w->text); if (w->text.length) Clipboard_SetText(&w->text);
} else if (key == INPUT_CLIPBOARD_PASTE) { } else if (key == INPUT_CLIPBOARD_PASTE) {
LInput_CopyFromClipboard(w); LInput_CopyFromClipboard(w);
} else if (key == KEY_ESCAPE) { } else if (key == IPT_ESCAPE) {
if (w->text.length) LInput_SetString(w, &String_Empty); if (w->text.length) LInput_SetString(w, &String_Empty);
} else if (key == KEY_LEFT) { } else if (key == IPT_LEFT) {
LInput_AdvanceCaretPos(w, false); LInput_AdvanceCaretPos(w, false);
} else if (key == KEY_RIGHT) { } else if (key == IPT_RIGHT) {
LInput_AdvanceCaretPos(w, true); LInput_AdvanceCaretPos(w, true);
} }
} }
@ -561,20 +561,20 @@ void LTable_RowClick(struct LTable* w, int row) {
} }
cc_bool LTable_HandlesKey(int key) { cc_bool LTable_HandlesKey(int key) {
return key == KEY_UP || key == KEY_DOWN || key == KEY_PAGEUP || key == KEY_PAGEDOWN; return key == IPT_UP || key == IPT_DOWN || key == IPT_PAGEUP || key == IPT_PAGEDOWN;
} }
static void LTable_KeyDown(void* widget, int key, cc_bool was) { static void LTable_KeyDown(void* widget, int key, cc_bool was) {
struct LTable* w = (struct LTable*)widget; struct LTable* w = (struct LTable*)widget;
int index = LTable_GetSelectedIndex(w); int index = LTable_GetSelectedIndex(w);
if (key == KEY_UP) { if (key == IPT_UP) {
index--; index--;
} else if (key == KEY_DOWN) { } else if (key == IPT_DOWN) {
index++; index++;
} else if (key == KEY_PAGEUP) { } else if (key == IPT_PAGEUP) {
index -= w->visibleRows; index -= w->visibleRows;
} else if (key == KEY_PAGEDOWN) { } else if (key == IPT_PAGEDOWN) {
index += w->visibleRows; index += w->visibleRows;
} else { return; } } else { return; }

View File

@ -174,11 +174,11 @@ static void OnResize(void* obj) {
} }
static cc_bool IsShutdown(int key) { static cc_bool IsShutdown(int key) {
if (key == KEY_F4 && Key_IsAltPressed()) return true; if (key == IPT_F4 && Input_IsAltPressed()) return true;
/* On macOS, Cmd+Q should also end the process */ /* On macOS, Cmd+Q should also end the process */
#ifdef CC_BUILD_DARWIN #ifdef CC_BUILD_DARWIN
return key == 'Q' && Key_IsWinPressed(); return key == 'Q' && Input_IsWinPressed();
#else #else
return false; return false;
#endif #endif

View File

@ -309,9 +309,9 @@ static void ListScreen_Select(struct ListScreen* s, const cc_string* str) {
static int ListScreen_KeyDown(void* screen, int key) { static int ListScreen_KeyDown(void* screen, int key) {
struct ListScreen* s = (struct ListScreen*)screen; struct ListScreen* s = (struct ListScreen*)screen;
if (key == KEY_LEFT || key == KEY_PAGEUP) { if (key == IPT_LEFT || key == IPT_PAGEUP) {
ListScreen_PageClick(s, false); ListScreen_PageClick(s, false);
} else if (key == KEY_RIGHT || key == KEY_PAGEDOWN) { } else if (key == IPT_RIGHT || key == IPT_PAGEDOWN) {
ListScreen_PageClick(s, true); ListScreen_PageClick(s, true);
} }
return true; return true;
@ -742,7 +742,7 @@ static struct Widget* edithotkey_widgets[7] = {
(struct Widget*)&EditHotkeyScreen.btns[4], (struct Widget*)&EditHotkeyScreen.input, (struct Widget*)&EditHotkeyScreen.btns[4], (struct Widget*)&EditHotkeyScreen.input,
(struct Widget*)&EditHotkeyScreen.cancel (struct Widget*)&EditHotkeyScreen.cancel
}; };
#define EDITHOTKEY_MAX_VERTICES (MENUINPUTWIDGET_MAX + 6 * BUTTONWIDGET_MAX) #define EDITHOTIPT_MAX_VERTICES (MENUINPUTWIDGET_MAX + 6 * BUTTONWIDGET_MAX)
static void HotkeyListScreen_MakeFlags(int flags, cc_string* str); static void HotkeyListScreen_MakeFlags(int flags, cc_string* str);
static void EditHotkeyScreen_MakeFlags(int flags, cc_string* str) { static void EditHotkeyScreen_MakeFlags(int flags, cc_string* str) {
@ -879,9 +879,9 @@ static int EditHotkeyScreen_KeyDown(void* screen, int key) {
if (s->selectedI == 0) { if (s->selectedI == 0) {
s->curHotkey.trigger = key; s->curHotkey.trigger = key;
} else if (s->selectedI == 1) { } else if (s->selectedI == 1) {
if (key == KEY_LCTRL || key == KEY_RCTRL) s->curHotkey.mods |= HOTKEY_MOD_CTRL; if (key == IPT_LCTRL || key == IPT_RCTRL) s->curHotkey.mods |= HOTIPT_MOD_CTRL;
else if (key == KEY_LSHIFT || key == KEY_RSHIFT) s->curHotkey.mods |= HOTKEY_MOD_SHIFT; else if (key == IPT_LSHIFT || key == IPT_RSHIFT) s->curHotkey.mods |= HOTIPT_MOD_SHIFT;
else if (key == KEY_LALT || key == KEY_RALT) s->curHotkey.mods |= HOTKEY_MOD_ALT; else if (key == IPT_LALT || key == IPT_RALT) s->curHotkey.mods |= HOTIPT_MOD_ALT;
else s->curHotkey.mods = 0; else s->curHotkey.mods = 0;
} }
@ -904,7 +904,7 @@ static void EditHotkeyScreen_ContextLost(void* screen) {
static void EditHotkeyScreen_ContextRecreated(void* screen) { static void EditHotkeyScreen_ContextRecreated(void* screen) {
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen; struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
cc_bool existed = s->origHotkey.trigger != KEY_NONE; cc_bool existed = s->origHotkey.trigger != IPT_NONE;
Gui_MakeTitleFont(&s->titleFont); Gui_MakeTitleFont(&s->titleFont);
Gui_MakeBodyFont(&s->textFont); Gui_MakeBodyFont(&s->textFont);
@ -953,7 +953,7 @@ static void EditHotkeyScreen_Init(void* screen) {
s->widgets = edithotkey_widgets; s->widgets = edithotkey_widgets;
s->numWidgets = Array_Elems(edithotkey_widgets); s->numWidgets = Array_Elems(edithotkey_widgets);
s->selectedI = -1; s->selectedI = -1;
s->maxVertices = EDITHOTKEY_MAX_VERTICES; s->maxVertices = EDITHOTIPT_MAX_VERTICES;
MenuInput_String(desc); MenuInput_String(desc);
ButtonWidget_Init(&s->btns[0], 300, EditHotkeyScreen_BaseKey); ButtonWidget_Init(&s->btns[0], 300, EditHotkeyScreen_BaseKey);
@ -1629,11 +1629,11 @@ static void HotkeyListScreen_EntryClick(void* screen, void* widget) {
} }
String_UNSAFE_Separate(&text, '+', &key, &value); String_UNSAFE_Separate(&text, '+', &key, &value);
if (String_ContainsConst(&value, "Ctrl")) mods |= HOTKEY_MOD_CTRL; if (String_ContainsConst(&value, "Ctrl")) mods |= HOTIPT_MOD_CTRL;
if (String_ContainsConst(&value, "Shift")) mods |= HOTKEY_MOD_SHIFT; if (String_ContainsConst(&value, "Shift")) mods |= HOTIPT_MOD_SHIFT;
if (String_ContainsConst(&value, "Alt")) mods |= HOTKEY_MOD_ALT; if (String_ContainsConst(&value, "Alt")) mods |= HOTIPT_MOD_ALT;
trigger = Utils_ParseEnum(&key, KEY_NONE, Input_DisplayNames, INPUT_COUNT); trigger = Utils_ParseEnum(&key, IPT_NONE, Input_DisplayNames, INPUT_COUNT);
for (i = 0; i < HotkeysText.count; i++) { for (i = 0; i < HotkeysText.count; i++) {
h = HotkeysList[i]; h = HotkeysList[i];
if (h.trigger == trigger && h.mods == mods) { original = h; break; } if (h.trigger == trigger && h.mods == mods) { original = h; break; }
@ -1643,9 +1643,9 @@ static void HotkeyListScreen_EntryClick(void* screen, void* widget) {
} }
static void HotkeyListScreen_MakeFlags(int flags, cc_string* str) { static void HotkeyListScreen_MakeFlags(int flags, cc_string* str) {
if (flags & HOTKEY_MOD_CTRL) String_AppendConst(str, " Ctrl"); if (flags & HOTIPT_MOD_CTRL) String_AppendConst(str, " Ctrl");
if (flags & HOTKEY_MOD_SHIFT) String_AppendConst(str, " Shift"); if (flags & HOTIPT_MOD_SHIFT) String_AppendConst(str, " Shift");
if (flags & HOTKEY_MOD_ALT) String_AppendConst(str, " Alt"); if (flags & HOTIPT_MOD_ALT) String_AppendConst(str, " Alt");
} }
static void HotkeyListScreen_LoadEntries(struct ListScreen* s) { static void HotkeyListScreen_LoadEntries(struct ListScreen* s) {
@ -1810,7 +1810,7 @@ static int KeyBindsScreen_KeyDown(void* screen, int key) {
if (s->curI == -1) return Screen_InputDown(s, key); if (s->curI == -1) return Screen_InputDown(s, key);
bind = s->binds[s->curI]; bind = s->binds[s->curI];
if (key == KEY_ESCAPE) key = KeyBind_Defaults[bind]; if (key == IPT_ESCAPE) key = KeyBind_Defaults[bind];
KeyBind_Set(bind, key); KeyBind_Set(bind, key);
idx = s->curI; idx = s->curI;
@ -2064,7 +2064,7 @@ static int MenuInputOverlay_KeyDown(void* screen, int key) {
struct MenuInputOverlay* s = (struct MenuInputOverlay*)screen; struct MenuInputOverlay* s = (struct MenuInputOverlay*)screen;
if (Elem_HandlesKeyDown(&s->input.base, key)) return true; if (Elem_HandlesKeyDown(&s->input.base, key)) return true;
if (key == KEY_ENTER || key == KEY_KP_ENTER) { if (key == IPT_ENTER || key == IPT_KP_ENTER) {
MenuInputOverlay_EnterInput(s); return true; MenuInputOverlay_EnterInput(s); return true;
} }
return Screen_InputDown(screen, key); return Screen_InputDown(screen, key);

View File

@ -1193,7 +1193,7 @@ static int ChatScreen_KeyDown(void* screen, int key) {
static const cc_string slash = String_FromConst("/"); static const cc_string slash = String_FromConst("/");
struct ChatScreen* s = (struct ChatScreen*)screen; struct ChatScreen* s = (struct ChatScreen*)screen;
int playerListKey = KeyBinds[KEYBIND_TABLIST]; int playerListKey = KeyBinds[KEYBIND_TABLIST];
cc_bool handlesList = playerListKey != KEY_TAB || !Gui.TabAutocomplete || !s->grabsInput; cc_bool handlesList = playerListKey != IPT_TAB || !Gui.TabAutocomplete || !s->grabsInput;
if (key == playerListKey && handlesList) { if (key == playerListKey && handlesList) {
if (!tablist_active && !Server.IsSinglePlayer) { if (!tablist_active && !Server.IsSinglePlayer) {
@ -1207,25 +1207,25 @@ static int ChatScreen_KeyDown(void* screen, int key) {
if (s->grabsInput) { if (s->grabsInput) {
#ifdef CC_BUILD_WEB #ifdef CC_BUILD_WEB
/* See reason for this in HandleInputUp */ /* See reason for this in HandleInputUp */
if (key == KeyBinds[KEYBIND_SEND_CHAT] || key == KEY_KP_ENTER) { if (key == KeyBinds[KEYBIND_SEND_CHAT] || key == IPT_KP_ENTER) {
ChatScreen_EnterChatInput(s, false); ChatScreen_EnterChatInput(s, false);
#else #else
if (key == KeyBinds[KEYBIND_SEND_CHAT] || key == KEY_KP_ENTER || key == KEY_ESCAPE) { if (key == KeyBinds[KEYBIND_SEND_CHAT] || key == IPT_KP_ENTER || key == IPT_ESCAPE) {
ChatScreen_EnterChatInput(s, key == KEY_ESCAPE); ChatScreen_EnterChatInput(s, key == IPT_ESCAPE);
#endif #endif
} else if (key == KEY_PAGEUP) { } else if (key == IPT_PAGEUP) {
ChatScreen_ScrollChatBy(s, -Gui.Chatlines); ChatScreen_ScrollChatBy(s, -Gui.Chatlines);
} else if (key == KEY_PAGEDOWN) { } else if (key == IPT_PAGEDOWN) {
ChatScreen_ScrollChatBy(s, +Gui.Chatlines); ChatScreen_ScrollChatBy(s, +Gui.Chatlines);
} else { } else {
Elem_HandlesKeyDown(&s->input.base, key); Elem_HandlesKeyDown(&s->input.base, key);
} }
return key < KEY_F1 || key > KEY_F24; return key < IPT_F1 || key > IPT_F24;
} }
if (key == KeyBinds[KEYBIND_CHAT]) { if (key == KeyBinds[KEYBIND_CHAT]) {
ChatScreen_OpenInput(&String_Empty); ChatScreen_OpenInput(&String_Empty);
} else if (key == KEY_SLASH) { } else if (key == IPT_SLASH) {
ChatScreen_OpenInput(&slash); ChatScreen_OpenInput(&slash);
} else if (key == KeyBinds[KEYBIND_INVENTORY]) { } else if (key == KeyBinds[KEYBIND_INVENTORY]) {
InventoryScreen_Show(); InventoryScreen_Show();
@ -1246,7 +1246,7 @@ static void ChatScreen_KeyUp(void* screen, int key) {
#ifdef CC_BUILD_WEB #ifdef CC_BUILD_WEB
/* See reason for this in HandleInputUp */ /* See reason for this in HandleInputUp */
if (key == KEY_ESCAPE) ChatScreen_EnterChatInput(s, true); if (key == IPT_ESCAPE) ChatScreen_EnterChatInput(s, true);
#endif #endif
if (Server.SupportsFullCP437 && key == KeyBinds[KEYBIND_EXT_INPUT]) { if (Server.SupportsFullCP437 && key == KeyBinds[KEYBIND_EXT_INPUT]) {
@ -1560,7 +1560,7 @@ static int InventoryScreen_KeyDown(void* screen, int key) {
if (key == KeyBinds[KEYBIND_INVENTORY] && s->releasedInv) { if (key == KeyBinds[KEYBIND_INVENTORY] && s->releasedInv) {
Gui_Remove((struct Screen*)s); Gui_Remove((struct Screen*)s);
} else if (key == KEY_ENTER && table->selectedIndex != -1) { } else if (key == IPT_ENTER && table->selectedIndex != -1) {
Inventory_SetSelectedBlock(table->blocks[table->selectedIndex]); Inventory_SetSelectedBlock(table->blocks[table->selectedIndex]);
Gui_Remove((struct Screen*)s); Gui_Remove((struct Screen*)s);
} else if (Elem_HandlesKeyDown(table, key)) { } else if (Elem_HandlesKeyDown(table, key)) {
@ -1591,7 +1591,7 @@ static int InventoryScreen_PointerDown(void* screen, int id, int x, int y) {
handled = Elem_HandlesPointerDown(table, id, x, y); handled = Elem_HandlesPointerDown(table, id, x, y);
if (!handled || table->pendingClose) { if (!handled || table->pendingClose) {
hotbar = Key_IsCtrlPressed() || Key_IsShiftPressed(); hotbar = Input_IsCtrlPressed() || Input_IsShiftPressed();
if (!hotbar) Gui_Remove((struct Screen*)s); if (!hotbar) Gui_Remove((struct Screen*)s);
} }
return TOUCH_TYPE_GUI; return TOUCH_TYPE_GUI;
@ -1610,7 +1610,7 @@ static int InventoryScreen_PointerMove(void* screen, int id, int x, int y) {
static int InventoryScreen_MouseScroll(void* screen, float delta) { static int InventoryScreen_MouseScroll(void* screen, float delta) {
struct InventoryScreen* s = (struct InventoryScreen*)screen; struct InventoryScreen* s = (struct InventoryScreen*)screen;
cc_bool hotbar = Key_IsAltPressed() || Key_IsCtrlPressed() || Key_IsShiftPressed(); cc_bool hotbar = Input_IsAltPressed() || Input_IsCtrlPressed() || Input_IsShiftPressed();
if (hotbar) return false; if (hotbar) return false;
return Elem_HandlesMouseScroll(&s->table, delta); return Elem_HandlesMouseScroll(&s->table, delta);
} }

View File

@ -881,13 +881,13 @@ static int TableWidget_KeyDown(void* widget, int key) {
struct TableWidget* w = (struct TableWidget*)widget; struct TableWidget* w = (struct TableWidget*)widget;
if (w->selectedIndex == -1) return false; if (w->selectedIndex == -1) return false;
if (key == KEY_LEFT || key == KEY_KP4) { if (key == IPT_LEFT || key == IPT_KP4) {
TableWidget_ScrollRelative(w, -1); TableWidget_ScrollRelative(w, -1);
} else if (key == KEY_RIGHT || key == KEY_KP6) { } else if (key == IPT_RIGHT || key == IPT_KP6) {
TableWidget_ScrollRelative(w, 1); TableWidget_ScrollRelative(w, 1);
} else if (key == KEY_UP || key == KEY_KP8) { } else if (key == IPT_UP || key == IPT_KP8) {
TableWidget_ScrollRelative(w, -w->blocksPerRow); TableWidget_ScrollRelative(w, -w->blocksPerRow);
} else if (key == KEY_DOWN || key == KEY_KP2) { } else if (key == IPT_DOWN || key == IPT_KP2) {
TableWidget_ScrollRelative(w, w->blocksPerRow); TableWidget_ScrollRelative(w, w->blocksPerRow);
} else { } else {
return false; return false;
@ -1146,7 +1146,7 @@ static void InputWidget_DeleteChar(struct InputWidget* w) {
static void InputWidget_BackspaceKey(struct InputWidget* w) { static void InputWidget_BackspaceKey(struct InputWidget* w) {
int i, len; int i, len;
if (Key_IsActionPressed()) { if (Input_IsActionPressed()) {
if (w->caretPos == -1) { w->caretPos = w->text.length - 1; } if (w->caretPos == -1) { w->caretPos = w->text.length - 1; }
len = WordWrap_GetBackLength(&w->text, w->caretPos); len = WordWrap_GetBackLength(&w->text, w->caretPos);
if (!len) return; if (!len) return;
@ -1180,7 +1180,7 @@ static void InputWidget_DeleteKey(struct InputWidget* w) {
} }
static void InputWidget_LeftKey(struct InputWidget* w) { static void InputWidget_LeftKey(struct InputWidget* w) {
if (Key_IsActionPressed()) { if (Input_IsActionPressed()) {
if (w->caretPos == -1) { w->caretPos = w->text.length - 1; } if (w->caretPos == -1) { w->caretPos = w->text.length - 1; }
w->caretPos -= WordWrap_GetBackLength(&w->text, w->caretPos); w->caretPos -= WordWrap_GetBackLength(&w->text, w->caretPos);
InputWidget_UpdateCaret(w); InputWidget_UpdateCaret(w);
@ -1196,7 +1196,7 @@ static void InputWidget_LeftKey(struct InputWidget* w) {
} }
static void InputWidget_RightKey(struct InputWidget* w) { static void InputWidget_RightKey(struct InputWidget* w) {
if (Key_IsActionPressed()) { if (Input_IsActionPressed()) {
w->caretPos += WordWrap_GetForwardLength(&w->text, w->caretPos); w->caretPos += WordWrap_GetForwardLength(&w->text, w->caretPos);
if (w->caretPos >= w->text.length) { w->caretPos = -1; } if (w->caretPos >= w->text.length) { w->caretPos = -1; }
InputWidget_UpdateCaret(w); InputWidget_UpdateCaret(w);
@ -1281,17 +1281,17 @@ static void InputWidget_Reposition(void* widget) {
static int InputWidget_KeyDown(void* widget, int key) { static int InputWidget_KeyDown(void* widget, int key) {
struct InputWidget* w = (struct InputWidget*)widget; struct InputWidget* w = (struct InputWidget*)widget;
if (key == KEY_LEFT) { if (key == IPT_LEFT) {
InputWidget_LeftKey(w); InputWidget_LeftKey(w);
} else if (key == KEY_RIGHT) { } else if (key == IPT_RIGHT) {
InputWidget_RightKey(w); InputWidget_RightKey(w);
} else if (key == KEY_BACKSPACE) { } else if (key == IPT_BACKSPACE) {
InputWidget_BackspaceKey(w); InputWidget_BackspaceKey(w);
} else if (key == KEY_DELETE) { } else if (key == IPT_DELETE) {
InputWidget_DeleteKey(w); InputWidget_DeleteKey(w);
} else if (key == KEY_HOME) { } else if (key == IPT_HOME) {
InputWidget_HomeKey(w); InputWidget_HomeKey(w);
} else if (key == KEY_END) { } else if (key == IPT_END) {
InputWidget_EndKey(w); InputWidget_EndKey(w);
} else if (!InputWidget_OtherKey(w, key)) { } else if (!InputWidget_OtherKey(w, key)) {
return false; return false;
@ -1719,7 +1719,7 @@ static void ChatInputWidget_UpKey(struct InputWidget* w) {
cc_string prevInput; cc_string prevInput;
int pos; int pos;
if (Key_IsActionPressed()) { if (Input_IsActionPressed()) {
pos = w->caretPos == -1 ? w->text.length : w->caretPos; pos = w->caretPos == -1 ? w->text.length : w->caretPos;
if (pos < INPUTWIDGET_LEN) return; if (pos < INPUTWIDGET_LEN) return;
@ -1748,7 +1748,7 @@ static void ChatInputWidget_DownKey(struct InputWidget* w) {
struct ChatInputWidget* W = (struct ChatInputWidget*)w; struct ChatInputWidget* W = (struct ChatInputWidget*)w;
cc_string prevInput; cc_string prevInput;
if (Key_IsActionPressed()) { if (Input_IsActionPressed()) {
if (w->caretPos == -1) return; if (w->caretPos == -1) return;
w->caretPos += INPUTWIDGET_LEN; w->caretPos += INPUTWIDGET_LEN;
@ -1837,9 +1837,9 @@ static void ChatInputWidget_TabKey(struct InputWidget* w) {
static int ChatInputWidget_KeyDown(void* widget, int key) { static int ChatInputWidget_KeyDown(void* widget, int key) {
struct InputWidget* w = (struct InputWidget*)widget; struct InputWidget* w = (struct InputWidget*)widget;
if (key == KEY_TAB) { ChatInputWidget_TabKey(w); return true; } if (key == IPT_TAB) { ChatInputWidget_TabKey(w); return true; }
if (key == KEY_UP) { ChatInputWidget_UpKey(w); return true; } if (key == IPT_UP) { ChatInputWidget_UpKey(w); return true; }
if (key == KEY_DOWN) { ChatInputWidget_DownKey(w); return true; } if (key == IPT_DOWN) { ChatInputWidget_DownKey(w); return true; }
return InputWidget_KeyDown(w, key); return InputWidget_KeyDown(w, key);
} }

View File

@ -29,57 +29,57 @@ static void RefreshWindowBounds(void) {
static int MapNativeKey(int code) { static int MapNativeKey(int code) {
if (code >= AKEYCODE_0 && code <= AKEYCODE_9) return (code - AKEYCODE_0) + '0'; if (code >= AKEYCODE_0 && code <= AKEYCODE_9) return (code - AKEYCODE_0) + '0';
if (code >= AKEYCODE_A && code <= AKEYCODE_Z) return (code - AKEYCODE_A) + 'A'; if (code >= AKEYCODE_A && code <= AKEYCODE_Z) return (code - AKEYCODE_A) + 'A';
if (code >= AKEYCODE_F1 && code <= AKEYCODE_F12) return (code - AKEYCODE_F1) + KEY_F1; if (code >= AKEYCODE_F1 && code <= AKEYCODE_F12) return (code - AKEYCODE_F1) + IPT_F1;
if (code >= AKEYCODE_NUMPAD_0 && code <= AKEYCODE_NUMPAD_9) return (code - AKEYCODE_NUMPAD_0) + KEY_KP0; if (code >= AKEYCODE_NUMPAD_0 && code <= AKEYCODE_NUMPAD_9) return (code - AKEYCODE_NUMPAD_0) + IPT_KP0;
switch (code) { switch (code) {
/* TODO: AKEYCODE_STAR */ /* TODO: AKEYCODE_STAR */
/* TODO: AKEYCODE_POUND */ /* TODO: AKEYCODE_POUND */
case AKEYCODE_BACK: return KEY_ESCAPE; case AKEYCODE_BACK: return IPT_ESCAPE;
case AKEYCODE_COMMA: return KEY_COMMA; case AKEYCODE_COMMA: return IPT_COMMA;
case AKEYCODE_PERIOD: return KEY_PERIOD; case AKEYCODE_PERIOD: return IPT_PERIOD;
case AKEYCODE_ALT_LEFT: return KEY_LALT; case AKEYCODE_ALT_LEFT: return IPT_LALT;
case AKEYCODE_ALT_RIGHT: return KEY_RALT; case AKEYCODE_ALT_RIGHT: return IPT_RALT;
case AKEYCODE_SHIFT_LEFT: return KEY_LSHIFT; case AKEYCODE_SHIFT_LEFT: return IPT_LSHIFT;
case AKEYCODE_SHIFT_RIGHT: return KEY_RSHIFT; case AKEYCODE_SHIFT_RIGHT: return IPT_RSHIFT;
case AKEYCODE_TAB: return KEY_TAB; case AKEYCODE_TAB: return IPT_TAB;
case AKEYCODE_SPACE: return KEY_SPACE; case AKEYCODE_SPACE: return IPT_SPACE;
case AKEYCODE_ENTER: return KEY_ENTER; case AKEYCODE_ENTER: return IPT_ENTER;
case AKEYCODE_DEL: return KEY_BACKSPACE; case AKEYCODE_DEL: return IPT_BACKSPACE;
case AKEYCODE_GRAVE: return KEY_TILDE; case AKEYCODE_GRAVE: return IPT_TILDE;
case AKEYCODE_MINUS: return KEY_MINUS; case AKEYCODE_MINUS: return IPT_MINUS;
case AKEYCODE_EQUALS: return KEY_EQUALS; case AKEYCODE_EQUALS: return IPT_EQUALS;
case AKEYCODE_LEFT_BRACKET: return KEY_LBRACKET; case AKEYCODE_LEFT_BRACKET: return IPT_LBRACKET;
case AKEYCODE_RIGHT_BRACKET: return KEY_RBRACKET; case AKEYCODE_RIGHT_BRACKET: return IPT_RBRACKET;
case AKEYCODE_BACKSLASH: return KEY_BACKSLASH; case AKEYCODE_BACKSLASH: return IPT_BACKSLASH;
case AKEYCODE_SEMICOLON: return KEY_SEMICOLON; case AKEYCODE_SEMICOLON: return IPT_SEMICOLON;
case AKEYCODE_APOSTROPHE: return KEY_QUOTE; case AKEYCODE_APOSTROPHE: return IPT_QUOTE;
case AKEYCODE_SLASH: return KEY_SLASH; case AKEYCODE_SLASH: return IPT_SLASH;
/* TODO: AKEYCODE_AT */ /* TODO: AKEYCODE_AT */
/* TODO: AKEYCODE_PLUS */ /* TODO: AKEYCODE_PLUS */
/* TODO: AKEYCODE_MENU */ /* TODO: AKEYCODE_MENU */
case AKEYCODE_PAGE_UP: return KEY_PAGEUP; case AKEYCODE_PAGE_UP: return IPT_PAGEUP;
case AKEYCODE_PAGE_DOWN: return KEY_PAGEDOWN; case AKEYCODE_PAGE_DOWN: return IPT_PAGEDOWN;
case AKEYCODE_ESCAPE: return KEY_ESCAPE; case AKEYCODE_ESCAPE: return IPT_ESCAPE;
case AKEYCODE_FORWARD_DEL: return KEY_DELETE; case AKEYCODE_FORWARD_DEL: return IPT_DELETE;
case AKEYCODE_CTRL_LEFT: return KEY_LCTRL; case AKEYCODE_CTRL_LEFT: return IPT_LCTRL;
case AKEYCODE_CTRL_RIGHT: return KEY_RCTRL; case AKEYCODE_CTRL_RIGHT: return IPT_RCTRL;
case AKEYCODE_CAPS_LOCK: return KEY_CAPSLOCK; case AKEYCODE_CAPS_LOCK: return IPT_CAPSLOCK;
case AKEYCODE_SCROLL_LOCK: return KEY_SCROLLLOCK; case AKEYCODE_SCROLL_LOCK: return IPT_SCROLLLOCK;
case AKEYCODE_META_LEFT: return KEY_LWIN; case AKEYCODE_META_LEFT: return IPT_LWIN;
case AKEYCODE_META_RIGHT: return KEY_RWIN; case AKEYCODE_META_RIGHT: return IPT_RWIN;
case AKEYCODE_SYSRQ: return KEY_PRINTSCREEN; case AKEYCODE_SYSRQ: return IPT_PRINTSCREEN;
case AKEYCODE_BREAK: return KEY_PAUSE; case AKEYCODE_BREAK: return IPT_PAUSE;
case AKEYCODE_INSERT: return KEY_INSERT; case AKEYCODE_INSERT: return IPT_INSERT;
case AKEYCODE_NUM_LOCK: return KEY_NUMLOCK; case AKEYCODE_NUM_LOCK: return IPT_NUMLOCK;
case AKEYCODE_NUMPAD_DIVIDE: return KEY_KP_DIVIDE; case AKEYCODE_NUMPAD_DIVIDE: return IPT_KP_DIVIDE;
case AKEYCODE_NUMPAD_MULTIPLY: return KEY_KP_MULTIPLY; case AKEYCODE_NUMPAD_MULTIPLY: return IPT_KP_MULTIPLY;
case AKEYCODE_NUMPAD_SUBTRACT: return KEY_KP_MINUS; case AKEYCODE_NUMPAD_SUBTRACT: return IPT_KP_MINUS;
case AKEYCODE_NUMPAD_ADD: return KEY_KP_PLUS; case AKEYCODE_NUMPAD_ADD: return IPT_KP_PLUS;
case AKEYCODE_NUMPAD_DOT: return KEY_KP_DECIMAL; case AKEYCODE_NUMPAD_DOT: return IPT_KP_DECIMAL;
case AKEYCODE_NUMPAD_ENTER: return KEY_KP_ENTER; case AKEYCODE_NUMPAD_ENTER: return IPT_KP_ENTER;
} }
return KEY_NONE; return IPT_NONE;
} }
static void JNICALL java_processKeyDown(JNIEnv* env, jobject o, jint code) { static void JNICALL java_processKeyDown(JNIEnv* env, jobject o, jint code) {

View File

@ -42,23 +42,23 @@ static void Window_CommonCreate(void) {
/* Sourced from https://www.meandmark.com/keycodes.html */ /* Sourced from https://www.meandmark.com/keycodes.html */
static const cc_uint8 key_map[8 * 16] = { static const cc_uint8 key_map[8 * 16] = {
'A', 'S', 'D', 'F', 'H', 'G', 'Z', 'X', 'C', 'V', 0, 'B', 'Q', 'W', 'E', 'R', 'A', 'S', 'D', 'F', 'H', 'G', 'Z', 'X', 'C', 'V', 0, 'B', 'Q', 'W', 'E', 'R',
'Y', 'T', '1', '2', '3', '4', '6', '5', KEY_EQUALS, '9', '7', KEY_MINUS, '8', '0', KEY_RBRACKET, 'O', 'Y', 'T', '1', '2', '3', '4', '6', '5', IPT_EQUALS, '9', '7', IPT_MINUS, '8', '0', IPT_RBRACKET, 'O',
'U', KEY_LBRACKET, 'I', 'P', KEY_ENTER, 'L', 'J', KEY_QUOTE, 'K', KEY_SEMICOLON, KEY_BACKSLASH, KEY_COMMA, KEY_SLASH, 'N', 'M', KEY_PERIOD, 'U', IPT_LBRACKET, 'I', 'P', IPT_ENTER, 'L', 'J', IPT_QUOTE, 'K', IPT_SEMICOLON, IPT_BACKSLASH, IPT_COMMA, IPT_SLASH, 'N', 'M', IPT_PERIOD,
KEY_TAB, KEY_SPACE, KEY_TILDE, KEY_BACKSPACE, 0, KEY_ESCAPE, 0, 0, 0, KEY_CAPSLOCK, 0, 0, 0, 0, 0, 0, IPT_TAB, IPT_SPACE, IPT_TILDE, IPT_BACKSPACE, 0, IPT_ESCAPE, 0, 0, 0, IPT_CAPSLOCK, 0, 0, 0, 0, 0, 0,
0, KEY_KP_DECIMAL, 0, KEY_KP_MULTIPLY, 0, KEY_KP_PLUS, 0, KEY_NUMLOCK, 0, 0, 0, KEY_KP_DIVIDE, KEY_KP_ENTER, 0, KEY_KP_MINUS, 0, 0, IPT_KP_DECIMAL, 0, IPT_KP_MULTIPLY, 0, IPT_KP_PLUS, 0, IPT_NUMLOCK, 0, 0, 0, IPT_KP_DIVIDE, IPT_KP_ENTER, 0, IPT_KP_MINUS, 0,
0, KEY_KP_ENTER, KEY_KP0, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP7, 0, KEY_KP8, KEY_KP9, 'N', 'M', KEY_PERIOD, 0, IPT_KP_ENTER, IPT_KP0, IPT_KP1, IPT_KP2, IPT_KP3, IPT_KP4, IPT_KP5, IPT_KP6, IPT_KP7, 0, IPT_KP8, IPT_KP9, 'N', 'M', IPT_PERIOD,
KEY_F5, KEY_F6, KEY_F7, KEY_F3, KEY_F8, KEY_F9, 0, KEY_F11, 0, KEY_F13, 0, KEY_F14, 0, KEY_F10, 0, KEY_F12, IPT_F5, IPT_F6, IPT_F7, IPT_F3, IPT_F8, IPT_F9, 0, IPT_F11, 0, IPT_F13, 0, IPT_F14, 0, IPT_F10, 0, IPT_F12,
'U', KEY_F15, KEY_INSERT, KEY_HOME, KEY_PAGEUP, KEY_DELETE, KEY_F4, KEY_END, KEY_F2, KEY_PAGEDOWN, KEY_F1, KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_UP, 0, 'U', IPT_F15, IPT_INSERT, IPT_HOME, IPT_PAGEUP, IPT_DELETE, IPT_F4, IPT_END, IPT_F2, IPT_PAGEDOWN, IPT_F1, IPT_LEFT, IPT_RIGHT, IPT_DOWN, IPT_UP, 0,
}; };
static int MapNativeKey(UInt32 key) { return key < Array_Elems(key_map) ? key_map[key] : 0; } static int MapNativeKey(UInt32 key) { return key < Array_Elems(key_map) ? key_map[key] : 0; }
/* TODO: Check these.. */ /* TODO: Check these.. */
/* case 0x37: return KEY_LWIN; */ /* case 0x37: return IPT_LWIN; */
/* case 0x38: return KEY_LSHIFT; */ /* case 0x38: return IPT_LSHIFT; */
/* case 0x3A: return KEY_LALT; */ /* case 0x3A: return IPT_LALT; */
/* case 0x3B: return Key_ControlLeft; */ /* case 0x3B: return Key_ControlLeft; */
/* TODO: Verify these differences from OpenTK */ /* TODO: Verify these differences from OpenTK */
/*Backspace = 51, (0x33, KEY_DELETE according to that link)*/ /*Backspace = 51, (0x33, IPT_DELETE according to that link)*/
/*Return = 52, (0x34, ??? according to that link)*/ /*Return = 52, (0x34, ??? according to that link)*/
/*Menu = 110, (0x6E, ??? according to that link)*/ /*Menu = 110, (0x6E, ??? according to that link)*/
@ -194,11 +194,11 @@ static OSStatus Window_ProcessKeyboardEvent(EventRef inEvent) {
NULL, sizeof(UInt32), NULL, &code); NULL, sizeof(UInt32), NULL, &code);
if (res) Logger_Abort2(res, "Getting key modifiers"); if (res) Logger_Abort2(res, "Getting key modifiers");
Input_Set(KEY_LCTRL, code & 0x1000); Input_Set(IPT_LCTRL, code & 0x1000);
Input_Set(KEY_LALT, code & 0x0800); Input_Set(IPT_LALT, code & 0x0800);
Input_Set(KEY_LSHIFT, code & 0x0200); Input_Set(IPT_LSHIFT, code & 0x0200);
Input_Set(KEY_LWIN, code & 0x0100); Input_Set(IPT_LWIN, code & 0x0100);
Input_Set(KEY_CAPSLOCK, code & 0x0400); Input_Set(IPT_CAPSLOCK, code & 0x0400);
return eventNotHandledErr; return eventNotHandledErr;
} }
return eventNotHandledErr; return eventNotHandledErr;
@ -244,12 +244,12 @@ static OSStatus Window_ProcessWindowEvent(EventRef inEvent) {
} }
static int MapNativeMouse(EventMouseButton button) { static int MapNativeMouse(EventMouseButton button) {
if (button == kEventMouseButtonPrimary) return KEY_LMOUSE; if (button == kEventMouseButtonPrimary) return IPT_LMOUSE;
if (button == kEventMouseButtonSecondary) return KEY_RMOUSE; if (button == kEventMouseButtonSecondary) return IPT_RMOUSE;
if (button == kEventMouseButtonTertiary) return KEY_MMOUSE; if (button == kEventMouseButtonTertiary) return IPT_MMOUSE;
if (button == 4) return KEY_XBUTTON1; if (button == 4) return IPT_XBUTTON1;
if (button == 5) return KEY_XBUTTON2; if (button == 5) return IPT_XBUTTON2;
return 0; return 0;
} }

View File

@ -104,62 +104,62 @@ void Window_Close(void) {
static int MapNativeKey(SDL_Keycode k) { static int MapNativeKey(SDL_Keycode k) {
if (k >= SDLK_0 && k <= SDLK_9) { return '0' + (k - SDLK_0); } if (k >= SDLK_0 && k <= SDLK_9) { return '0' + (k - SDLK_0); }
if (k >= SDLK_a && k <= SDLK_z) { return 'A' + (k - SDLK_a); } if (k >= SDLK_a && k <= SDLK_z) { return 'A' + (k - SDLK_a); }
if (k >= SDLK_F1 && k <= SDLK_F12) { return KEY_F1 + (k - SDLK_F1); } if (k >= SDLK_F1 && k <= SDLK_F12) { return IPT_F1 + (k - SDLK_F1); }
if (k >= SDLK_F13 && k <= SDLK_F24) { return KEY_F13 + (k - SDLK_F13); } if (k >= SDLK_F13 && k <= SDLK_F24) { return IPT_F13 + (k - SDLK_F13); }
/* SDLK_KP_0 isn't before SDLK_KP_1 */ /* SDLK_KP_0 isn't before SDLK_KP_1 */
if (k >= SDLK_KP_1 && k <= SDLK_KP_9) { return KEY_KP1 + (k - SDLK_KP_1); } if (k >= SDLK_KP_1 && k <= SDLK_KP_9) { return IPT_KP1 + (k - SDLK_KP_1); }
switch (k) { switch (k) {
case SDLK_RETURN: return KEY_ENTER; case SDLK_RETURN: return IPT_ENTER;
case SDLK_ESCAPE: return KEY_ESCAPE; case SDLK_ESCAPE: return IPT_ESCAPE;
case SDLK_BACKSPACE: return KEY_BACKSPACE; case SDLK_BACKSPACE: return IPT_BACKSPACE;
case SDLK_TAB: return KEY_TAB; case SDLK_TAB: return IPT_TAB;
case SDLK_SPACE: return KEY_SPACE; case SDLK_SPACE: return IPT_SPACE;
case SDLK_QUOTE: return KEY_QUOTE; case SDLK_QUOTE: return IPT_QUOTE;
case SDLK_EQUALS: return KEY_EQUALS; case SDLK_EQUALS: return IPT_EQUALS;
case SDLK_COMMA: return KEY_COMMA; case SDLK_COMMA: return IPT_COMMA;
case SDLK_MINUS: return KEY_MINUS; case SDLK_MINUS: return IPT_MINUS;
case SDLK_PERIOD: return KEY_PERIOD; case SDLK_PERIOD: return IPT_PERIOD;
case SDLK_SLASH: return KEY_SLASH; case SDLK_SLASH: return IPT_SLASH;
case SDLK_SEMICOLON: return KEY_SEMICOLON; case SDLK_SEMICOLON: return IPT_SEMICOLON;
case SDLK_LEFTBRACKET: return KEY_LBRACKET; case SDLK_LEFTBRACKET: return IPT_LBRACKET;
case SDLK_BACKSLASH: return KEY_BACKSLASH; case SDLK_BACKSLASH: return IPT_BACKSLASH;
case SDLK_RIGHTBRACKET: return KEY_RBRACKET; case SDLK_RIGHTBRACKET: return IPT_RBRACKET;
case SDLK_BACKQUOTE: return KEY_TILDE; case SDLK_BACKQUOTE: return IPT_TILDE;
case SDLK_CAPSLOCK: return KEY_CAPSLOCK; case SDLK_CAPSLOCK: return IPT_CAPSLOCK;
case SDLK_PRINTSCREEN: return KEY_PRINTSCREEN; case SDLK_PRINTSCREEN: return IPT_PRINTSCREEN;
case SDLK_SCROLLLOCK: return KEY_SCROLLLOCK; case SDLK_SCROLLLOCK: return IPT_SCROLLLOCK;
case SDLK_PAUSE: return KEY_PAUSE; case SDLK_PAUSE: return IPT_PAUSE;
case SDLK_INSERT: return KEY_INSERT; case SDLK_INSERT: return IPT_INSERT;
case SDLK_HOME: return KEY_HOME; case SDLK_HOME: return IPT_HOME;
case SDLK_PAGEUP: return KEY_PAGEUP; case SDLK_PAGEUP: return IPT_PAGEUP;
case SDLK_DELETE: return KEY_DELETE; case SDLK_DELETE: return IPT_DELETE;
case SDLK_END: return KEY_END; case SDLK_END: return IPT_END;
case SDLK_PAGEDOWN: return KEY_PAGEDOWN; case SDLK_PAGEDOWN: return IPT_PAGEDOWN;
case SDLK_RIGHT: return KEY_RIGHT; case SDLK_RIGHT: return IPT_RIGHT;
case SDLK_LEFT: return KEY_LEFT; case SDLK_LEFT: return IPT_LEFT;
case SDLK_DOWN: return KEY_DOWN; case SDLK_DOWN: return IPT_DOWN;
case SDLK_UP: return KEY_UP; case SDLK_UP: return IPT_UP;
case SDLK_NUMLOCKCLEAR: return KEY_NUMLOCK; case SDLK_NUMLOCKCLEAR: return IPT_NUMLOCK;
case SDLK_KP_DIVIDE: return KEY_KP_DIVIDE; case SDLK_KP_DIVIDE: return IPT_KP_DIVIDE;
case SDLK_KP_MULTIPLY: return KEY_KP_MULTIPLY; case SDLK_KP_MULTIPLY: return IPT_KP_MULTIPLY;
case SDLK_KP_MINUS: return KEY_KP_MINUS; case SDLK_KP_MINUS: return IPT_KP_MINUS;
case SDLK_KP_PLUS: return KEY_KP_PLUS; case SDLK_KP_PLUS: return IPT_KP_PLUS;
case SDLK_KP_ENTER: return KEY_KP_ENTER; case SDLK_KP_ENTER: return IPT_KP_ENTER;
case SDLK_KP_0: return KEY_KP0; case SDLK_KP_0: return IPT_KP0;
case SDLK_KP_PERIOD: return KEY_KP_DECIMAL; case SDLK_KP_PERIOD: return IPT_KP_DECIMAL;
case SDLK_LCTRL: return KEY_LCTRL; case SDLK_LCTRL: return IPT_LCTRL;
case SDLK_LSHIFT: return KEY_LSHIFT; case SDLK_LSHIFT: return IPT_LSHIFT;
case SDLK_LALT: return KEY_LALT; case SDLK_LALT: return IPT_LALT;
case SDLK_LGUI: return KEY_LWIN; case SDLK_LGUI: return IPT_LWIN;
case SDLK_RCTRL: return KEY_RCTRL; case SDLK_RCTRL: return IPT_RCTRL;
case SDLK_RSHIFT: return KEY_RSHIFT; case SDLK_RSHIFT: return IPT_RSHIFT;
case SDLK_RALT: return KEY_RALT; case SDLK_RALT: return IPT_RALT;
case SDLK_RGUI: return KEY_RWIN; case SDLK_RGUI: return IPT_RWIN;
} }
return KEY_NONE; return IPT_NONE;
} }
static void OnKeyEvent(const SDL_Event* e) { static void OnKeyEvent(const SDL_Event* e) {
@ -172,11 +172,11 @@ static void OnMouseEvent(const SDL_Event* e) {
cc_bool pressed = e->button.state == SDL_PRESSED; cc_bool pressed = e->button.state == SDL_PRESSED;
int btn; int btn;
switch (e->button.button) { switch (e->button.button) {
case SDL_BUTTON_LEFT: btn = KEY_LMOUSE; break; case SDL_BUTTON_LEFT: btn = IPT_LMOUSE; break;
case SDL_BUTTON_MIDDLE: btn = KEY_MMOUSE; break; case SDL_BUTTON_MIDDLE: btn = IPT_MMOUSE; break;
case SDL_BUTTON_RIGHT: btn = KEY_RMOUSE; break; case SDL_BUTTON_RIGHT: btn = IPT_RMOUSE; break;
case SDL_BUTTON_X1: btn = KEY_XBUTTON1; break; case SDL_BUTTON_X1: btn = IPT_XBUTTON1; break;
case SDL_BUTTON_X2: btn = KEY_XBUTTON2; break; case SDL_BUTTON_X2: btn = IPT_XBUTTON2; break;
default: return; default: return;
} }
Input_Set(btn, pressed); Input_Set(btn, pressed);

View File

@ -57,11 +57,11 @@ static EM_BOOL OnMouseButton(int type, const EmscriptenMouseEvent* ev, void* dat
cc_bool down = type == EMSCRIPTEN_EVENT_MOUSEDOWN; cc_bool down = type == EMSCRIPTEN_EVENT_MOUSEDOWN;
/* https://stackoverflow.com/questions/60895686/how-to-get-mouse-buttons-4-5-browser-back-browser-forward-working-in-firef */ /* https://stackoverflow.com/questions/60895686/how-to-get-mouse-buttons-4-5-browser-back-browser-forward-working-in-firef */
switch (ev->button) { switch (ev->button) {
case 0: Input_Set(KEY_LMOUSE, down); break; case 0: Input_Set(IPT_LMOUSE, down); break;
case 1: Input_Set(KEY_MMOUSE, down); break; case 1: Input_Set(IPT_MMOUSE, down); break;
case 2: Input_Set(KEY_RMOUSE, down); break; case 2: Input_Set(IPT_RMOUSE, down); break;
case 3: Input_Set(KEY_XBUTTON1, down); break; case 3: Input_Set(IPT_XBUTTON1, down); break;
case 4: Input_Set(KEY_XBUTTON2, down); break; case 4: Input_Set(IPT_XBUTTON2, down); break;
} }
DeferredEnableRawMouse(); DeferredEnableRawMouse();
@ -85,9 +85,9 @@ static void RescaleXY(int* x, int* y) {
static EM_BOOL OnMouseMove(int type, const EmscriptenMouseEvent* ev, void* data) { static EM_BOOL OnMouseMove(int type, const EmscriptenMouseEvent* ev, void* data) {
int x, y, buttons = ev->buttons; int x, y, buttons = ev->buttons;
/* Set before position change, in case mouse buttons changed when outside window */ /* Set before position change, in case mouse buttons changed when outside window */
Input_SetNonRepeatable(KEY_LMOUSE, buttons & 0x01); Input_SetNonRepeatable(IPT_LMOUSE, buttons & 0x01);
Input_SetNonRepeatable(KEY_RMOUSE, buttons & 0x02); Input_SetNonRepeatable(IPT_RMOUSE, buttons & 0x02);
Input_SetNonRepeatable(KEY_MMOUSE, buttons & 0x04); Input_SetNonRepeatable(IPT_MMOUSE, buttons & 0x04);
x = ev->targetX; y = ev->targetY; x = ev->targetX; y = ev->targetY;
RescaleXY(&x, &y); RescaleXY(&x, &y);
@ -199,66 +199,66 @@ static EM_BOOL OnVisibilityChanged(int eventType, const EmscriptenVisibilityChan
static int MapNativeKey(int k, int l) { static int MapNativeKey(int k, int l) {
if (k >= '0' && k <= '9') return k; if (k >= '0' && k <= '9') return k;
if (k >= 'A' && k <= 'Z') return k; if (k >= 'A' && k <= 'Z') return k;
if (k >= DOM_VK_F1 && k <= DOM_VK_F24) { return KEY_F1 + (k - DOM_VK_F1); } if (k >= DOM_VK_F1 && k <= DOM_VK_F24) { return IPT_F1 + (k - DOM_VK_F1); }
if (k >= DOM_VK_NUMPAD0 && k <= DOM_VK_NUMPAD9) { return KEY_KP0 + (k - DOM_VK_NUMPAD0); } if (k >= DOM_VK_NUMPAD0 && k <= DOM_VK_NUMPAD9) { return IPT_KP0 + (k - DOM_VK_NUMPAD0); }
switch (k) { switch (k) {
case DOM_VK_BACK_SPACE: return KEY_BACKSPACE; case DOM_VK_BACK_SPACE: return IPT_BACKSPACE;
case DOM_VK_TAB: return KEY_TAB; case DOM_VK_TAB: return IPT_TAB;
case DOM_VK_RETURN: return l == DOM_KEY_LOCATION_NUMPAD ? KEY_KP_ENTER : KEY_ENTER; case DOM_VK_RETURN: return l == DOM_KEY_LOCATION_NUMPAD ? IPT_KP_ENTER : IPT_ENTER;
case DOM_VK_SHIFT: return l == DOM_KEY_LOCATION_RIGHT ? KEY_RSHIFT : KEY_LSHIFT; case DOM_VK_SHIFT: return l == DOM_KEY_LOCATION_RIGHT ? IPT_RSHIFT : IPT_LSHIFT;
case DOM_VK_CONTROL: return l == DOM_KEY_LOCATION_RIGHT ? KEY_RCTRL : KEY_LCTRL; case DOM_VK_CONTROL: return l == DOM_KEY_LOCATION_RIGHT ? IPT_RCTRL : IPT_LCTRL;
case DOM_VK_ALT: return l == DOM_KEY_LOCATION_RIGHT ? KEY_RALT : KEY_LALT; case DOM_VK_ALT: return l == DOM_KEY_LOCATION_RIGHT ? IPT_RALT : IPT_LALT;
case DOM_VK_PAUSE: return KEY_PAUSE; case DOM_VK_PAUSE: return IPT_PAUSE;
case DOM_VK_CAPS_LOCK: return KEY_CAPSLOCK; case DOM_VK_CAPS_LOCK: return IPT_CAPSLOCK;
case DOM_VK_ESCAPE: return KEY_ESCAPE; case DOM_VK_ESCAPE: return IPT_ESCAPE;
case DOM_VK_SPACE: return KEY_SPACE; case DOM_VK_SPACE: return IPT_SPACE;
case DOM_VK_PAGE_UP: return KEY_PAGEUP; case DOM_VK_PAGE_UP: return IPT_PAGEUP;
case DOM_VK_PAGE_DOWN: return KEY_PAGEDOWN; case DOM_VK_PAGE_DOWN: return IPT_PAGEDOWN;
case DOM_VK_END: return KEY_END; case DOM_VK_END: return IPT_END;
case DOM_VK_HOME: return KEY_HOME; case DOM_VK_HOME: return IPT_HOME;
case DOM_VK_LEFT: return KEY_LEFT; case DOM_VK_LEFT: return IPT_LEFT;
case DOM_VK_UP: return KEY_UP; case DOM_VK_UP: return IPT_UP;
case DOM_VK_RIGHT: return KEY_RIGHT; case DOM_VK_RIGHT: return IPT_RIGHT;
case DOM_VK_DOWN: return KEY_DOWN; case DOM_VK_DOWN: return IPT_DOWN;
case DOM_VK_PRINTSCREEN: return KEY_PRINTSCREEN; case DOM_VK_PRINTSCREEN: return IPT_PRINTSCREEN;
case DOM_VK_INSERT: return KEY_INSERT; case DOM_VK_INSERT: return IPT_INSERT;
case DOM_VK_DELETE: return KEY_DELETE; case DOM_VK_DELETE: return IPT_DELETE;
case DOM_VK_SEMICOLON: return KEY_SEMICOLON; case DOM_VK_SEMICOLON: return IPT_SEMICOLON;
case DOM_VK_EQUALS: return KEY_EQUALS; case DOM_VK_EQUALS: return IPT_EQUALS;
case DOM_VK_WIN: return l == DOM_KEY_LOCATION_RIGHT ? KEY_RWIN : KEY_LWIN; case DOM_VK_WIN: return l == DOM_KEY_LOCATION_RIGHT ? IPT_RWIN : IPT_LWIN;
case DOM_VK_MULTIPLY: return KEY_KP_MULTIPLY; case DOM_VK_MULTIPLY: return IPT_KP_MULTIPLY;
case DOM_VK_ADD: return KEY_KP_PLUS; case DOM_VK_ADD: return IPT_KP_PLUS;
case DOM_VK_SUBTRACT: return KEY_KP_MINUS; case DOM_VK_SUBTRACT: return IPT_KP_MINUS;
case DOM_VK_DECIMAL: return KEY_KP_DECIMAL; case DOM_VK_DECIMAL: return IPT_KP_DECIMAL;
case DOM_VK_DIVIDE: return KEY_KP_DIVIDE; case DOM_VK_DIVIDE: return IPT_KP_DIVIDE;
case DOM_VK_NUM_LOCK: return KEY_NUMLOCK; case DOM_VK_NUM_LOCK: return IPT_NUMLOCK;
case DOM_VK_SCROLL_LOCK: return KEY_SCROLLLOCK; case DOM_VK_SCROLL_LOCK: return IPT_SCROLLLOCK;
case DOM_VK_HYPHEN_MINUS: return KEY_MINUS; case DOM_VK_HYPHEN_MINUS: return IPT_MINUS;
case DOM_VK_COMMA: return KEY_COMMA; case DOM_VK_COMMA: return IPT_COMMA;
case DOM_VK_PERIOD: return KEY_PERIOD; case DOM_VK_PERIOD: return IPT_PERIOD;
case DOM_VK_SLASH: return KEY_SLASH; case DOM_VK_SLASH: return IPT_SLASH;
case DOM_VK_BACK_QUOTE: return KEY_TILDE; case DOM_VK_BACK_QUOTE: return IPT_TILDE;
case DOM_VK_OPEN_BRACKET: return KEY_LBRACKET; case DOM_VK_OPEN_BRACKET: return IPT_LBRACKET;
case DOM_VK_BACK_SLASH: return KEY_BACKSLASH; case DOM_VK_BACK_SLASH: return IPT_BACKSLASH;
case DOM_VK_CLOSE_BRACKET: return KEY_RBRACKET; case DOM_VK_CLOSE_BRACKET: return IPT_RBRACKET;
case DOM_VK_QUOTE: return KEY_QUOTE; case DOM_VK_QUOTE: return IPT_QUOTE;
/* chrome */ /* chrome */
case 186: return KEY_SEMICOLON; case 186: return IPT_SEMICOLON;
case 187: return KEY_EQUALS; case 187: return IPT_EQUALS;
case 189: return KEY_MINUS; case 189: return IPT_MINUS;
} }
return KEY_NONE; return IPT_NONE;
} }
static EM_BOOL OnKeyDown(int type, const EmscriptenKeyboardEvent* ev, void* data) { static EM_BOOL OnKeyDown(int type, const EmscriptenKeyboardEvent* ev, void* data) {
int key = MapNativeKey(ev->keyCode, ev->location); int key = MapNativeKey(ev->keyCode, ev->location);
/* iOS safari still sends backspace key events, don't intercept those */ /* iOS safari still sends backspace key events, don't intercept those */
if (key == KEY_BACKSPACE && Input_TouchMode && keyboardOpen) return false; if (key == IPT_BACKSPACE && Input_TouchMode && keyboardOpen) return false;
if (key) Input_SetPressed(key); if (key) Input_SetPressed(key);
DeferredEnableRawMouse(); DeferredEnableRawMouse();
@ -267,26 +267,26 @@ static EM_BOOL OnKeyDown(int type, const EmscriptenKeyboardEvent* ev, void* data
/* If holding down Ctrl or Alt, keys aren't going to generate a KeyPress event anyways. */ /* If holding down Ctrl or Alt, keys aren't going to generate a KeyPress event anyways. */
/* This intercepts Ctrl+S etc. Ctrl+C and Ctrl+V are not intercepted for clipboard. */ /* This intercepts Ctrl+S etc. Ctrl+C and Ctrl+V are not intercepted for clipboard. */
/* NOTE: macOS uses Win (Command) key instead of Ctrl, have to account for that too */ /* NOTE: macOS uses Win (Command) key instead of Ctrl, have to account for that too */
if (Key_IsAltPressed()) return true; if (Input_IsAltPressed()) return true;
if (Key_IsWinPressed()) return key != 'C' && key != 'V'; if (Input_IsWinPressed()) return key != 'C' && key != 'V';
if (Key_IsCtrlPressed()) return key != 'C' && key != 'V'; if (Input_IsCtrlPressed()) return key != 'C' && key != 'V';
/* Space needs special handling, as intercepting this prevents the ' ' key press event */ /* Space needs special handling, as intercepting this prevents the ' ' key press event */
/* But on Safari, space scrolls the page - so need to intercept when keyboard is NOT open */ /* But on Safari, space scrolls the page - so need to intercept when keyboard is NOT open */
if (key == KEY_SPACE) return !keyboardOpen; if (key == IPT_SPACE) return !keyboardOpen;
/* Must not intercept KeyDown for regular keys, otherwise KeyPress doesn't get raised. */ /* Must not intercept KeyDown for regular keys, otherwise KeyPress doesn't get raised. */
/* However, do want to prevent browser's behaviour on F11, F5, home etc. */ /* However, do want to prevent browser's behaviour on F11, F5, home etc. */
/* e.g. not preventing F11 means browser makes page fullscreen instead of just canvas */ /* e.g. not preventing F11 means browser makes page fullscreen instead of just canvas */
return (key >= KEY_F1 && key <= KEY_F24) || (key >= KEY_UP && key <= KEY_RIGHT) || return (key >= IPT_F1 && key <= IPT_F24) || (key >= IPT_UP && key <= IPT_RIGHT) ||
(key >= KEY_INSERT && key <= KEY_MENU) || (key >= KEY_ENTER && key <= KEY_NUMLOCK); (key >= IPT_INSERT && key <= IPT_MENU) || (key >= IPT_ENTER && key <= IPT_NUMLOCK);
} }
static EM_BOOL OnKeyUp(int type, const EmscriptenKeyboardEvent* ev, void* data) { static EM_BOOL OnKeyUp(int type, const EmscriptenKeyboardEvent* ev, void* data) {
int key = MapNativeKey(ev->keyCode, ev->location); int key = MapNativeKey(ev->keyCode, ev->location);
if (key) Input_SetReleased(key); if (key) Input_SetReleased(key);
DeferredEnableRawMouse(); DeferredEnableRawMouse();
return key != KEY_NONE; return key != IPT_NONE;
} }
static EM_BOOL OnKeyPress(int type, const EmscriptenKeyboardEvent* ev, void* data) { static EM_BOOL OnKeyPress(int type, const EmscriptenKeyboardEvent* ev, void* data) {

View File

@ -53,31 +53,31 @@ static cc_bool is_ansiWindow, grabCursor;
static int windowX, windowY; static int windowX, windowY;
static const cc_uint8 key_map[14 * 16] = { static const cc_uint8 key_map[14 * 16] = {
0, 0, 0, 0, 0, 0, 0, 0, KEY_BACKSPACE, KEY_TAB, 0, 0, 0, KEY_ENTER, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IPT_BACKSPACE, IPT_TAB, 0, 0, 0, IPT_ENTER, 0, 0,
0, 0, 0, KEY_PAUSE, KEY_CAPSLOCK, 0, 0, 0, 0, 0, 0, KEY_ESCAPE, 0, 0, 0, 0, 0, 0, 0, IPT_PAUSE, IPT_CAPSLOCK, 0, 0, 0, 0, 0, 0, IPT_ESCAPE, 0, 0, 0, 0,
KEY_SPACE, KEY_PAGEUP, KEY_PAGEDOWN, KEY_END, KEY_HOME, KEY_LEFT, KEY_UP, KEY_RIGHT, KEY_DOWN, 0, KEY_PRINTSCREEN, 0, KEY_PRINTSCREEN, KEY_INSERT, KEY_DELETE, 0, IPT_SPACE, IPT_PAGEUP, IPT_PAGEDOWN, IPT_END, IPT_HOME, IPT_LEFT, IPT_UP, IPT_RIGHT, IPT_DOWN, 0, IPT_PRINTSCREEN, 0, IPT_PRINTSCREEN, IPT_INSERT, IPT_DELETE, 0,
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0, 0, 0, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0, 0, 0,
0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 0, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', KEY_LWIN, KEY_RWIN, KEY_MENU, 0, 0, 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', IPT_LWIN, IPT_RWIN, IPT_MENU, 0, 0,
KEY_KP0, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP7, KEY_KP8, KEY_KP9, KEY_KP_MULTIPLY, KEY_KP_PLUS, 0, KEY_KP_MINUS, KEY_KP_DECIMAL, KEY_KP_DIVIDE, IPT_KP0, IPT_KP1, IPT_KP2, IPT_KP3, IPT_KP4, IPT_KP5, IPT_KP6, IPT_KP7, IPT_KP8, IPT_KP9, IPT_KP_MULTIPLY, IPT_KP_PLUS, 0, IPT_KP_MINUS, IPT_KP_DECIMAL, IPT_KP_DIVIDE,
KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_F13, KEY_F14, KEY_F15, KEY_F16, IPT_F1, IPT_F2, IPT_F3, IPT_F4, IPT_F5, IPT_F6, IPT_F7, IPT_F8, IPT_F9, IPT_F10, IPT_F11, IPT_F12, IPT_F13, IPT_F14, IPT_F15, IPT_F16,
KEY_F17, KEY_F18, KEY_F19, KEY_F20, KEY_F21, KEY_F22, KEY_F23, KEY_F24, 0, 0, 0, 0, 0, 0, 0, 0, IPT_F17, IPT_F18, IPT_F19, IPT_F20, IPT_F21, IPT_F22, IPT_F23, IPT_F24, 0, 0, 0, 0, 0, 0, 0, 0,
KEY_NUMLOCK, KEY_SCROLLLOCK, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IPT_NUMLOCK, IPT_SCROLLLOCK, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
KEY_LSHIFT, KEY_RSHIFT, KEY_LCTRL, KEY_RCTRL, KEY_LALT, KEY_RALT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IPT_LSHIFT, IPT_RSHIFT, IPT_LCTRL, IPT_RCTRL, IPT_LALT, IPT_RALT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_SEMICOLON, KEY_EQUALS, KEY_COMMA, KEY_MINUS, KEY_PERIOD, KEY_SLASH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IPT_SEMICOLON, IPT_EQUALS, IPT_COMMA, IPT_MINUS, IPT_PERIOD, IPT_SLASH,
KEY_TILDE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IPT_TILDE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_LBRACKET, KEY_BACKSLASH, KEY_RBRACKET, KEY_QUOTE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IPT_LBRACKET, IPT_BACKSLASH, IPT_RBRACKET, IPT_QUOTE, 0,
}; };
static int MapNativeKey(WPARAM key, LPARAM meta) { static int MapNativeKey(WPARAM key, LPARAM meta) {
LPARAM ext = meta & (1UL << 24); LPARAM ext = meta & (1UL << 24);
switch (key) switch (key)
{ {
case VK_CONTROL: case VK_CONTROL:
return ext ? KEY_RCTRL : KEY_LCTRL; return ext ? IPT_RCTRL : IPT_LCTRL;
case VK_MENU: case VK_MENU:
return ext ? KEY_RALT : KEY_LALT; return ext ? IPT_RALT : IPT_LALT;
case VK_RETURN: case VK_RETURN:
return ext ? KEY_KP_ENTER : KEY_ENTER; return ext ? IPT_KP_ENTER : IPT_ENTER;
default: default:
return key < Array_Elems(key_map) ? key_map[key] : 0; return key < Array_Elems(key_map) ? key_map[key] : 0;
} }
@ -147,10 +147,10 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
/* Set before position change, in case mouse buttons changed when outside window */ /* Set before position change, in case mouse buttons changed when outside window */
if (!(wParam & 0x01)) Input_SetReleased(KEY_LMOUSE); if (!(wParam & 0x01)) Input_SetReleased(IPT_LMOUSE);
//Input_SetNonRepeatable(KEY_LMOUSE, wParam & 0x01); //Input_SetNonRepeatable(IPT_LMOUSE, wParam & 0x01);
Input_SetNonRepeatable(KEY_RMOUSE, wParam & 0x02); Input_SetNonRepeatable(IPT_RMOUSE, wParam & 0x02);
Input_SetNonRepeatable(KEY_MMOUSE, wParam & 0x10); Input_SetNonRepeatable(IPT_MMOUSE, wParam & 0x10);
/* TODO: do we need to set XBUTTON1/XBUTTON2 here */ /* TODO: do we need to set XBUTTON1/XBUTTON2 here */
Pointer_SetPosition(0, LOWORD(lParam), HIWORD(lParam)); Pointer_SetPosition(0, LOWORD(lParam), HIWORD(lParam));
break; break;
@ -161,23 +161,23 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara
return 0; return 0;
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
Input_SetPressed(KEY_LMOUSE); break; Input_SetPressed(IPT_LMOUSE); break;
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
Input_SetPressed(KEY_MMOUSE); break; Input_SetPressed(IPT_MMOUSE); break;
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
Input_SetPressed(KEY_RMOUSE); break; Input_SetPressed(IPT_RMOUSE); break;
case WM_XBUTTONDOWN: case WM_XBUTTONDOWN:
Input_SetPressed(HIWORD(wParam) == 1 ? KEY_XBUTTON1 : KEY_XBUTTON2); Input_SetPressed(HIWORD(wParam) == 1 ? IPT_XBUTTON1 : IPT_XBUTTON2);
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
Input_SetReleased(KEY_LMOUSE); break; Input_SetReleased(IPT_LMOUSE); break;
case WM_MBUTTONUP: case WM_MBUTTONUP:
Input_SetReleased(KEY_MMOUSE); break; Input_SetReleased(IPT_MMOUSE); break;
case WM_RBUTTONUP: case WM_RBUTTONUP:
Input_SetReleased(KEY_RMOUSE); break; Input_SetReleased(IPT_RMOUSE); break;
case WM_XBUTTONUP: case WM_XBUTTONUP:
Input_SetReleased(HIWORD(wParam) == 1 ? KEY_XBUTTON1 : KEY_XBUTTON2); Input_SetReleased(HIWORD(wParam) == 1 ? IPT_XBUTTON1 : IPT_XBUTTON2);
break; break;
case WM_INPUT: case WM_INPUT:
@ -235,8 +235,8 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara
rShiftDown = ((USHORT)GetKeyState(VK_RSHIFT)) >> 15; rShiftDown = ((USHORT)GetKeyState(VK_RSHIFT)) >> 15;
if (!pressed || lShiftDown != rShiftDown) { if (!pressed || lShiftDown != rShiftDown) {
Input_Set(KEY_LSHIFT, lShiftDown); Input_Set(IPT_LSHIFT, lShiftDown);
Input_Set(KEY_RSHIFT, rShiftDown); Input_Set(IPT_RSHIFT, rShiftDown);
} }
} else { } else {
key = MapNativeKey(wParam, lParam); key = MapNativeKey(wParam, lParam);

View File

@ -50,22 +50,22 @@ static int MapNativeKey(KeySym key, unsigned int state) {
if (key >= XK_A && key <= XK_Z) { return 'A' + (key - XK_A); } if (key >= XK_A && key <= XK_Z) { return 'A' + (key - XK_A); }
if (key >= XK_a && key <= XK_z) { return 'A' + (key - XK_a); } if (key >= XK_a && key <= XK_z) { return 'A' + (key - XK_a); }
if (key >= XK_F1 && key <= XK_F24) { return KEY_F1 + (key - XK_F1); } if (key >= XK_F1 && key <= XK_F24) { return IPT_F1 + (key - XK_F1); }
if (key >= XK_KP_0 && key <= XK_KP_9) { return KEY_KP0 + (key - XK_KP_0); } if (key >= XK_KP_0 && key <= XK_KP_9) { return IPT_KP0 + (key - XK_KP_0); }
/* Same Num Lock behaviour as Windows and text editors */ /* Same Num Lock behaviour as Windows and text editors */
if (key >= XK_KP_Home && key <= XK_KP_Delete && !(state & Mod2Mask)) { if (key >= XK_KP_Home && key <= XK_KP_Delete && !(state & Mod2Mask)) {
if (key == XK_KP_Home) return KEY_HOME; if (key == XK_KP_Home) return IPT_HOME;
if (key == XK_KP_Up) return KEY_UP; if (key == XK_KP_Up) return IPT_UP;
if (key == XK_KP_Page_Up) return KEY_PAGEUP; if (key == XK_KP_Page_Up) return IPT_PAGEUP;
if (key == XK_KP_Left) return KEY_LEFT; if (key == XK_KP_Left) return IPT_LEFT;
if (key == XK_KP_Insert) return KEY_INSERT; if (key == XK_KP_Insert) return IPT_INSERT;
if (key == XK_KP_Right) return KEY_RIGHT; if (key == XK_KP_Right) return IPT_RIGHT;
if (key == XK_KP_End) return KEY_END; if (key == XK_KP_End) return IPT_END;
if (key == XK_KP_Down) return KEY_DOWN; if (key == XK_KP_Down) return IPT_DOWN;
if (key == XK_KP_Page_Down) return KEY_PAGEDOWN; if (key == XK_KP_Page_Down) return IPT_PAGEDOWN;
} }
/* A chromebook user reported issues with pressing some keys: */ /* A chromebook user reported issues with pressing some keys: */
@ -77,101 +77,101 @@ static int MapNativeKey(KeySym key, unsigned int state) {
key &= 0xFFFF; key &= 0xFFFF;
switch (key) { switch (key) {
case XK_Escape: return KEY_ESCAPE; case XK_Escape: return IPT_ESCAPE;
case XK_Return: return KEY_ENTER; case XK_Return: return IPT_ENTER;
case XK_space: return KEY_SPACE; case XK_space: return IPT_SPACE;
case XK_BackSpace: return KEY_BACKSPACE; case XK_BackSpace: return IPT_BACKSPACE;
case XK_Shift_L: return KEY_LSHIFT; case XK_Shift_L: return IPT_LSHIFT;
case XK_Shift_R: return KEY_RSHIFT; case XK_Shift_R: return IPT_RSHIFT;
case XK_Alt_L: return KEY_LALT; case XK_Alt_L: return IPT_LALT;
case XK_Alt_R: return KEY_RALT; case XK_Alt_R: return IPT_RALT;
case XK_Control_L: return KEY_LCTRL; case XK_Control_L: return IPT_LCTRL;
case XK_Control_R: return KEY_RCTRL; case XK_Control_R: return IPT_RCTRL;
case XK_Super_L: return KEY_LWIN; case XK_Super_L: return IPT_LWIN;
case XK_Super_R: return KEY_RWIN; case XK_Super_R: return IPT_RWIN;
case XK_Meta_L: return KEY_LWIN; case XK_Meta_L: return IPT_LWIN;
case XK_Meta_R: return KEY_RWIN; case XK_Meta_R: return IPT_RWIN;
case XK_Menu: return KEY_MENU; case XK_Menu: return IPT_MENU;
case XK_Tab: return KEY_TAB; case XK_Tab: return IPT_TAB;
case XK_minus: return KEY_MINUS; case XK_minus: return IPT_MINUS;
case XK_plus: return KEY_EQUALS; case XK_plus: return IPT_EQUALS;
case XK_equal: return KEY_EQUALS; case XK_equal: return IPT_EQUALS;
case XK_Caps_Lock: return KEY_CAPSLOCK; case XK_Caps_Lock: return IPT_CAPSLOCK;
case XK_Num_Lock: return KEY_NUMLOCK; case XK_Num_Lock: return IPT_NUMLOCK;
case XK_Pause: return KEY_PAUSE; case XK_Pause: return IPT_PAUSE;
case XK_Break: return KEY_PAUSE; case XK_Break: return IPT_PAUSE;
case XK_Scroll_Lock: return KEY_SCROLLLOCK; case XK_Scroll_Lock: return IPT_SCROLLLOCK;
case XK_Insert: return KEY_INSERT; case XK_Insert: return IPT_INSERT;
case XK_Print: return KEY_PRINTSCREEN; case XK_Print: return IPT_PRINTSCREEN;
case XK_Sys_Req: return KEY_PRINTSCREEN; case XK_Sys_Req: return IPT_PRINTSCREEN;
case XK_backslash: return KEY_BACKSLASH; case XK_backslash: return IPT_BACKSLASH;
case XK_bar: return KEY_BACKSLASH; case XK_bar: return IPT_BACKSLASH;
case XK_braceleft: return KEY_LBRACKET; case XK_braceleft: return IPT_LBRACKET;
case XK_bracketleft: return KEY_LBRACKET; case XK_bracketleft: return IPT_LBRACKET;
case XK_braceright: return KEY_RBRACKET; case XK_braceright: return IPT_RBRACKET;
case XK_bracketright: return KEY_RBRACKET; case XK_bracketright: return IPT_RBRACKET;
case XK_colon: return KEY_SEMICOLON; case XK_colon: return IPT_SEMICOLON;
case XK_semicolon: return KEY_SEMICOLON; case XK_semicolon: return IPT_SEMICOLON;
case XK_quoteright: return KEY_QUOTE; case XK_quoteright: return IPT_QUOTE;
case XK_quotedbl: return KEY_QUOTE; case XK_quotedbl: return IPT_QUOTE;
case XK_quoteleft: return KEY_TILDE; case XK_quoteleft: return IPT_TILDE;
case XK_asciitilde: return KEY_TILDE; case XK_asciitilde: return IPT_TILDE;
case XK_comma: return KEY_COMMA; case XK_comma: return IPT_COMMA;
case XK_less: return KEY_COMMA; case XK_less: return IPT_COMMA;
case XK_period: return KEY_PERIOD; case XK_period: return IPT_PERIOD;
case XK_greater: return KEY_PERIOD; case XK_greater: return IPT_PERIOD;
case XK_slash: return KEY_SLASH; case XK_slash: return IPT_SLASH;
case XK_question: return KEY_SLASH; case XK_question: return IPT_SLASH;
case XK_Left: return KEY_LEFT; case XK_Left: return IPT_LEFT;
case XK_Down: return KEY_DOWN; case XK_Down: return IPT_DOWN;
case XK_Right: return KEY_RIGHT; case XK_Right: return IPT_RIGHT;
case XK_Up: return KEY_UP; case XK_Up: return IPT_UP;
case XK_Delete: return KEY_DELETE; case XK_Delete: return IPT_DELETE;
case XK_Home: return KEY_HOME; case XK_Home: return IPT_HOME;
case XK_End: return KEY_END; case XK_End: return IPT_END;
case XK_Page_Up: return KEY_PAGEUP; case XK_Page_Up: return IPT_PAGEUP;
case XK_Page_Down: return KEY_PAGEDOWN; case XK_Page_Down: return IPT_PAGEDOWN;
case XK_KP_Add: return KEY_KP_PLUS; case XK_KP_Add: return IPT_KP_PLUS;
case XK_KP_Subtract: return KEY_KP_MINUS; case XK_KP_Subtract: return IPT_KP_MINUS;
case XK_KP_Multiply: return KEY_KP_MULTIPLY; case XK_KP_Multiply: return IPT_KP_MULTIPLY;
case XK_KP_Divide: return KEY_KP_DIVIDE; case XK_KP_Divide: return IPT_KP_DIVIDE;
case XK_KP_Decimal: return KEY_KP_DECIMAL; case XK_KP_Decimal: return IPT_KP_DECIMAL;
case XK_KP_Insert: return KEY_KP0; case XK_KP_Insert: return IPT_KP0;
case XK_KP_End: return KEY_KP1; case XK_KP_End: return IPT_KP1;
case XK_KP_Down: return KEY_KP2; case XK_KP_Down: return IPT_KP2;
case XK_KP_Page_Down: return KEY_KP3; case XK_KP_Page_Down: return IPT_KP3;
case XK_KP_Left: return KEY_KP4; case XK_KP_Left: return IPT_KP4;
case XK_KP_Begin: return KEY_KP5; case XK_KP_Begin: return IPT_KP5;
case XK_KP_Right: return KEY_KP6; case XK_KP_Right: return IPT_KP6;
case XK_KP_Home: return KEY_KP7; case XK_KP_Home: return IPT_KP7;
case XK_KP_Up: return KEY_KP8; case XK_KP_Up: return IPT_KP8;
case XK_KP_Page_Up: return KEY_KP9; case XK_KP_Page_Up: return IPT_KP9;
case XK_KP_Delete: return KEY_KP_DECIMAL; case XK_KP_Delete: return IPT_KP_DECIMAL;
case XK_KP_Enter: return KEY_KP_ENTER; case XK_KP_Enter: return IPT_KP_ENTER;
} }
return KEY_NONE; return IPT_NONE;
} }
/* NOTE: This may not be entirely accurate, because user can configure keycode mappings */ /* NOTE: This may not be entirely accurate, because user can configure keycode mappings */
static const cc_uint8 keycodeMap[136] = { static const cc_uint8 keycodeMap[136] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_ESCAPE, '1', '2', '3', '4', '5', '6', 0, 0, 0, 0, 0, 0, 0, 0, 0, IPT_ESCAPE, '1', '2', '3', '4', '5', '6',
'7', '8', '9', '0', KEY_MINUS, KEY_EQUALS, KEY_BACKSPACE, KEY_TAB, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', '7', '8', '9', '0', IPT_MINUS, IPT_EQUALS, IPT_BACKSPACE, IPT_TAB, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
'O', 'P', KEY_LBRACKET, KEY_RBRACKET, KEY_ENTER, KEY_LCTRL, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', KEY_SEMICOLON, 'O', 'P', IPT_LBRACKET, IPT_RBRACKET, IPT_ENTER, IPT_LCTRL, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', IPT_SEMICOLON,
KEY_QUOTE, KEY_TILDE, KEY_LSHIFT, KEY_BACKSLASH, 'Z', 'X', 'C', 'V', 'B', 'N', 'M', KEY_PERIOD, KEY_COMMA, KEY_SLASH, KEY_RSHIFT, KEY_KP_MULTIPLY, IPT_QUOTE, IPT_TILDE, IPT_LSHIFT, IPT_BACKSLASH, 'Z', 'X', 'C', 'V', 'B', 'N', 'M', IPT_PERIOD, IPT_COMMA, IPT_SLASH, IPT_RSHIFT, IPT_KP_MULTIPLY,
KEY_LALT, KEY_SPACE, KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_NUMLOCK, KEY_SCROLLLOCK, KEY_KP7, IPT_LALT, IPT_SPACE, IPT_CAPSLOCK, IPT_F1, IPT_F2, IPT_F3, IPT_F4, IPT_F5, IPT_F6, IPT_F7, IPT_F8, IPT_F9, IPT_F10, IPT_NUMLOCK, IPT_SCROLLLOCK, IPT_KP7,
KEY_KP8, KEY_KP9, KEY_KP_MINUS, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP_PLUS, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP0, KEY_KP_DECIMAL, 0, 0, 0, KEY_F11, IPT_KP8, IPT_KP9, IPT_KP_MINUS, IPT_KP4, IPT_KP5, IPT_KP6, IPT_KP_PLUS, IPT_KP1, IPT_KP2, IPT_KP3, IPT_KP0, IPT_KP_DECIMAL, 0, 0, 0, IPT_F11,
KEY_F12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IPT_F12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
KEY_RALT, KEY_RCTRL, KEY_HOME, KEY_UP, KEY_PAGEUP, KEY_LEFT, KEY_RIGHT, KEY_END, KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, 0, 0, 0, 0, IPT_RALT, IPT_RCTRL, IPT_HOME, IPT_UP, IPT_PAGEUP, IPT_LEFT, IPT_RIGHT, IPT_END, IPT_DOWN, IPT_PAGEDOWN, IPT_INSERT, IPT_DELETE, 0, 0, 0, 0,
0, 0, 0, KEY_PAUSE, 0, 0, 0, 0, 0, KEY_LWIN, 0, KEY_RWIN 0, 0, 0, IPT_PAUSE, 0, 0, 0, 0, 0, IPT_LWIN, 0, IPT_RWIN
}; };
static int MapNativeKeycode(unsigned int keycode) { static int MapNativeKeycode(unsigned int keycode) {
@ -459,11 +459,11 @@ void Window_Close(void) {
} }
static int MapNativeMouse(int button) { static int MapNativeMouse(int button) {
if (button == 1) return KEY_LMOUSE; if (button == 1) return IPT_LMOUSE;
if (button == 2) return KEY_MMOUSE; if (button == 2) return IPT_MMOUSE;
if (button == 3) return KEY_RMOUSE; if (button == 3) return IPT_RMOUSE;
if (button == 8) return KEY_XBUTTON1; if (button == 8) return IPT_XBUTTON1;
if (button == 9) return KEY_XBUTTON2; if (button == 9) return IPT_XBUTTON2;
return 0; return 0;
} }

View File

@ -50,23 +50,23 @@ static void Window_CommonCreate(void) {
// Sourced from https://www.meandmark.com/keycodes.html // Sourced from https://www.meandmark.com/keycodes.html
static const cc_uint8 key_map[8 * 16] = { static const cc_uint8 key_map[8 * 16] = {
'A', 'S', 'D', 'F', 'H', 'G', 'Z', 'X', 'C', 'V', 0, 'B', 'Q', 'W', 'E', 'R', 'A', 'S', 'D', 'F', 'H', 'G', 'Z', 'X', 'C', 'V', 0, 'B', 'Q', 'W', 'E', 'R',
'Y', 'T', '1', '2', '3', '4', '6', '5', KEY_EQUALS, '9', '7', KEY_MINUS, '8', '0', KEY_RBRACKET, 'O', 'Y', 'T', '1', '2', '3', '4', '6', '5', IPT_EQUALS, '9', '7', IPT_MINUS, '8', '0', IPT_RBRACKET, 'O',
'U', KEY_LBRACKET, 'I', 'P', KEY_ENTER, 'L', 'J', KEY_QUOTE, 'K', KEY_SEMICOLON, KEY_BACKSLASH, KEY_COMMA, KEY_SLASH, 'N', 'M', KEY_PERIOD, 'U', IPT_LBRACKET, 'I', 'P', IPT_ENTER, 'L', 'J', IPT_QUOTE, 'K', IPT_SEMICOLON, IPT_BACKSLASH, IPT_COMMA, IPT_SLASH, 'N', 'M', IPT_PERIOD,
KEY_TAB, KEY_SPACE, KEY_TILDE, KEY_BACKSPACE, 0, KEY_ESCAPE, 0, 0, 0, KEY_CAPSLOCK, 0, 0, 0, 0, 0, 0, IPT_TAB, IPT_SPACE, IPT_TILDE, IPT_BACKSPACE, 0, IPT_ESCAPE, 0, 0, 0, IPT_CAPSLOCK, 0, 0, 0, 0, 0, 0,
0, KEY_KP_DECIMAL, 0, KEY_KP_MULTIPLY, 0, KEY_KP_PLUS, 0, KEY_NUMLOCK, 0, 0, 0, KEY_KP_DIVIDE, KEY_KP_ENTER, 0, KEY_KP_MINUS, 0, 0, IPT_KP_DECIMAL, 0, IPT_KP_MULTIPLY, 0, IPT_KP_PLUS, 0, IPT_NUMLOCK, 0, 0, 0, IPT_KP_DIVIDE, IPT_KP_ENTER, 0, IPT_KP_MINUS, 0,
0, KEY_KP_ENTER, KEY_KP0, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP7, 0, KEY_KP8, KEY_KP9, 'N', 'M', KEY_PERIOD, 0, IPT_KP_ENTER, IPT_KP0, IPT_KP1, IPT_KP2, IPT_KP3, IPT_KP4, IPT_KP5, IPT_KP6, IPT_KP7, 0, IPT_KP8, IPT_KP9, 'N', 'M', IPT_PERIOD,
KEY_F5, KEY_F6, KEY_F7, KEY_F3, KEY_F8, KEY_F9, 0, KEY_F11, 0, KEY_F13, 0, KEY_F14, 0, KEY_F10, 0, KEY_F12, IPT_F5, IPT_F6, IPT_F7, IPT_F3, IPT_F8, IPT_F9, 0, IPT_F11, 0, IPT_F13, 0, IPT_F14, 0, IPT_F10, 0, IPT_F12,
'U', KEY_F15, KEY_INSERT, KEY_HOME, KEY_PAGEUP, KEY_DELETE, KEY_F4, KEY_END, KEY_F2, KEY_PAGEDOWN, KEY_F1, KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_UP, 0, 'U', IPT_F15, IPT_INSERT, IPT_HOME, IPT_PAGEUP, IPT_DELETE, IPT_F4, IPT_END, IPT_F2, IPT_PAGEDOWN, IPT_F1, IPT_LEFT, IPT_RIGHT, IPT_DOWN, IPT_UP, 0,
}; };
static int MapNativeKey(UInt32 key) { return key < Array_Elems(key_map) ? key_map[key] : 0; } static int MapNativeKey(UInt32 key) { return key < Array_Elems(key_map) ? key_map[key] : 0; }
// TODO: Check these.. // TODO: Check these..
// case 0x37: return KEY_LWIN; // case 0x37: return IPT_LWIN;
// case 0x38: return KEY_LSHIFT; // case 0x38: return IPT_LSHIFT;
// case 0x3A: return KEY_LALT; // case 0x3A: return IPT_LALT;
// case 0x3B: return Key_ControlLeft; // case 0x3B: return Key_ControlLeft;
// TODO: Verify these differences from OpenTK // TODO: Verify these differences from OpenTK
//Backspace = 51, (0x33, KEY_DELETE according to that link) //Backspace = 51, (0x33, IPT_DELETE according to that link)
//Return = 52, (0x34, ??? according to that link) //Return = 52, (0x34, ??? according to that link)
//Menu = 110, (0x6E, ??? according to that link) //Menu = 110, (0x6E, ??? according to that link)
@ -257,7 +257,7 @@ static void DoDrawFramebuffer(CGRect dirty);
// Although the game receives a left mouse down event, it does NOT receive a left mouse up // Although the game receives a left mouse down event, it does NOT receive a left mouse up
// This causes the game to get stuck with left mouse down after user finishes resizing // This causes the game to get stuck with left mouse down after user finishes resizing
// So work arond that by always releasing left mouse when a live resize is finished // So work arond that by always releasing left mouse when a live resize is finished
Input_SetReleased(KEY_LMOUSE); Input_SetReleased(IPT_LMOUSE);
} }
@end @end
@ -393,11 +393,11 @@ void Window_Close(void) {
} }
static int MapNativeMouse(long button) { static int MapNativeMouse(long button) {
if (button == 0) return KEY_LMOUSE; if (button == 0) return IPT_LMOUSE;
if (button == 1) return KEY_RMOUSE; if (button == 1) return IPT_RMOUSE;
if (button == 2) return KEY_MMOUSE; if (button == 2) return IPT_MMOUSE;
if (button == 3) return KEY_XBUTTON1; if (button == 3) return IPT_XBUTTON1;
if (button == 4) return KEY_XBUTTON2; if (button == 4) return IPT_XBUTTON2;
return 0; return 0;
} }
@ -498,15 +498,15 @@ void Window_ProcessEvents(void) {
case 12: // NSFlagsChanged case 12: // NSFlagsChanged
key = [ev modifierFlags]; key = [ev modifierFlags];
// TODO: Figure out how to only get modifiers that changed // TODO: Figure out how to only get modifiers that changed
Input_Set(KEY_LCTRL, key & 0x000001); Input_Set(IPT_LCTRL, key & 0x000001);
Input_Set(KEY_LSHIFT, key & 0x000002); Input_Set(IPT_LSHIFT, key & 0x000002);
Input_Set(KEY_RSHIFT, key & 0x000004); Input_Set(IPT_RSHIFT, key & 0x000004);
Input_Set(KEY_LWIN, key & 0x000008); Input_Set(IPT_LWIN, key & 0x000008);
Input_Set(KEY_RWIN, key & 0x000010); Input_Set(IPT_RWIN, key & 0x000010);
Input_Set(KEY_LALT, key & 0x000020); Input_Set(IPT_LALT, key & 0x000020);
Input_Set(KEY_RALT, key & 0x000040); Input_Set(IPT_RALT, key & 0x000040);
Input_Set(KEY_RCTRL, key & 0x002000); Input_Set(IPT_RCTRL, key & 0x002000);
Input_Set(KEY_CAPSLOCK, key & 0x010000); Input_Set(IPT_CAPSLOCK, key & 0x010000);
break; break;
case 22: // NSScrollWheel case 22: // NSScrollWheel

View File

@ -431,8 +431,8 @@ void ShowDialogCore(const char* title, const char* msg) {
// === UITextFieldDelegate === // === UITextFieldDelegate ===
- (BOOL)textFieldShouldReturn:(UITextField *)textField { - (BOOL)textFieldShouldReturn:(UITextField *)textField {
Input_SetPressed(KEY_ENTER); Input_SetPressed(IPT_ENTER);
Input_SetReleased(KEY_ENTER); Input_SetReleased(IPT_ENTER);
return YES; return YES;
} }
@end @end