diff --git a/src/Entity.c b/src/Entity.c index 51701ce8a..494578202 100644 --- a/src/Entity.c +++ b/src/Entity.c @@ -1028,7 +1028,7 @@ static cc_bool LocalPlayer_HandleNoClip(void) { return false; } -cc_bool LocalPlayer_HandlesKey(Key key) { +cc_bool LocalPlayer_HandlesKey(int key) { struct LocalPlayer* p = &LocalPlayer_Instance; struct HacksComp* hacks = &p->Hacks; struct PhysicsComp* physics = &p->Physics; diff --git a/src/Entity.h b/src/Entity.h index f1620aa81..d8e27f0a0 100644 --- a/src/Entity.h +++ b/src/Entity.h @@ -3,7 +3,6 @@ #include "EntityComponents.h" #include "Physics.h" #include "Constants.h" -#include "Input.h" #include "PackedCol.h" /* Represents an in-game entity. Copyright 2014-2019 ClassiCube | Licensed under BSD-3 @@ -202,5 +201,5 @@ float LocalPlayer_JumpHeight(void); void LocalPlayer_SetInterpPosition(float t); /* Returns whether local player handles a key being pressed. */ /* e.g. for respawn, toggle fly, etc. */ -cc_bool LocalPlayer_HandlesKey(Key key); +cc_bool LocalPlayer_HandlesKey(int key); #endif diff --git a/src/Gui.h b/src/Gui.h index e07cce589..2a202510b 100644 --- a/src/Gui.h +++ b/src/Gui.h @@ -1,6 +1,5 @@ #ifndef CC_GUI_H #define CC_GUI_H -#include "Input.h" #include "Event.h" #include "VertexStructs.h" /* Describes and manages 2D GUI elements on screen. @@ -44,11 +43,14 @@ struct ScreenVTABLE { /* Frees/releases persistent state. */ void (*Free)(void* elem); /* Returns non-zero if an input press is handled. */ - int (*HandlesKeyDown)(void* elem, Key key); + int (*HandlesKeyDown)(void* elem, int key); /* Returns non-zero if an input release is handled. */ - int (*HandlesKeyUp)(void* elem, Key key); + int (*HandlesKeyUp)(void* elem, int key); /* Returns non-zero if a key character press is handled. */ int (*HandlesKeyPress)(void* elem, char keyChar); + /* Returns non-zero if a key character press is handled. */ + /* Currently only raised by on-screen keyboard in web client. */ + int (*HandlesTextChanged)(void* elem, const String* str); /* Returns non-zero if a pointer press is handled. */ int (*HandlesPointerDown)(void* elem, int id, int x, int y); /* Returns non-zero if a pointer release is handled. */ @@ -82,9 +84,9 @@ struct WidgetVTABLE { /* Positions this widget on-screen. */ void (*Reposition)(void* elem); /* Returns non-zero if an input press is handled. */ - int (*HandlesKeyDown)(void* elem, Key key); + int (*HandlesKeyDown)(void* elem, int key); /* Returns non-zero if an input release is handled. */ - int (*HandlesKeyUp)(void* elem, Key key); + int (*HandlesKeyUp)(void* elem, int key); /* Returns non-zero if a mouse wheel scroll is handled. */ int (*HandlesMouseScroll)(void* elem, float delta); /* Returns non-zero if a pointer press is handled. */ diff --git a/src/Input.c b/src/Input.c index 753dd8f93..59ebb5607 100644 --- a/src/Input.c +++ b/src/Input.c @@ -185,7 +185,7 @@ const char* const Input_Names[INPUT_COUNT] = { "XBUTTON1", "XBUTTON2", "MMOUSE" };*/ -void Input_SetPressed(Key key, cc_bool pressed) { +void Input_SetPressed(int key, cc_bool pressed) { cc_bool wasPressed = Input_Pressed[key]; Input_Pressed[key] = pressed; @@ -277,7 +277,7 @@ cc_bool KeyBind_IsPressed(KeyBind binding) { return Input_Pressed[KeyBinds[bindi static void KeyBind_Load(void) { String name; char nameBuffer[STRING_SIZE + 1]; - Key mapping; + int mapping; int i; String_InitArray_NT(name, nameBuffer); @@ -306,7 +306,7 @@ static void KeyBind_Save(void) { } } -void KeyBind_Set(KeyBind binding, Key key) { +void KeyBind_Set(KeyBind binding, int key) { KeyBinds[binding] = key; KeyBind_Save(); } @@ -363,7 +363,7 @@ static void Hotkeys_QuickSort(int left, int right) { } } -static void Hotkeys_AddNewHotkey(Key trigger, cc_uint8 modifiers, const String* text, cc_bool more) { +static void Hotkeys_AddNewHotkey(int trigger, cc_uint8 modifiers, const String* text, cc_bool more) { struct HotkeyData hKey; hKey.Trigger = trigger; hKey.Flags = modifiers; @@ -392,7 +392,7 @@ static void Hotkeys_RemoveText(int index) { } -void Hotkeys_Add(Key trigger, cc_uint8 modifiers, const String* text, cc_bool more) { +void Hotkeys_Add(int trigger, cc_uint8 modifiers, const String* text, cc_bool more) { struct HotkeyData* hk = HotkeysList; int i; @@ -408,7 +408,7 @@ void Hotkeys_Add(Key trigger, cc_uint8 modifiers, const String* text, cc_bool mo Hotkeys_AddNewHotkey(trigger, modifiers, text, more); } -cc_bool Hotkeys_Remove(Key trigger, cc_uint8 modifiers) { +cc_bool Hotkeys_Remove(int trigger, cc_uint8 modifiers) { struct HotkeyData* hk = HotkeysList; int i, j; @@ -424,7 +424,7 @@ cc_bool Hotkeys_Remove(Key trigger, cc_uint8 modifiers) { return false; } -int Hotkeys_FindPartial(Key key) { +int Hotkeys_FindPartial(int key) { struct HotkeyData hk; int i, modifiers = 0; @@ -447,7 +447,7 @@ static void Hotkeys_Init(void) { String entry, key, value; int i; - Key trigger; + int trigger; cc_uint8 modifiers; cc_bool more; @@ -471,7 +471,7 @@ static void Hotkeys_Init(void) { } } -void Hotkeys_UserRemovedHotkey(Key trigger, cc_uint8 modifiers) { +void Hotkeys_UserRemovedHotkey(int trigger, cc_uint8 modifiers) { String key; char keyBuffer[STRING_SIZE]; String_InitArray(key, keyBuffer); @@ -479,7 +479,7 @@ void Hotkeys_UserRemovedHotkey(Key trigger, cc_uint8 modifiers) { Options_SetString(&key, NULL); } -void Hotkeys_UserAddedHotkey(Key trigger, cc_uint8 modifiers, cc_bool moreInput, const String* text) { +void Hotkeys_UserAddedHotkey(int trigger, cc_uint8 modifiers, cc_bool moreInput, const String* text) { String key; char keyBuffer[STRING_SIZE]; String value; char valueBuffer[STRING_SIZE * 2]; String_InitArray(key, keyBuffer); @@ -728,7 +728,7 @@ void InputHandler_PickBlocks(void) { /*########################################################################################################################* *------------------------------------------------------Key helpers--------------------------------------------------------* *#########################################################################################################################*/ -static cc_bool InputHandler_IsShutdown(Key key) { +static cc_bool InputHandler_IsShutdown(int key) { if (key == KEY_F4 && Key_IsAltPressed()) return true; /* On OSX, Cmd+Q should also terminate the process */ @@ -739,7 +739,7 @@ static cc_bool InputHandler_IsShutdown(Key key) { #endif } -static void InputHandler_Toggle(Key key, cc_bool* target, const char* enableMsg, const char* disableMsg) { +static void InputHandler_Toggle(int key, cc_bool* target, const char* enableMsg, const char* disableMsg) { *target = !(*target); if (*target) { Chat_Add2("%c. &ePress &a%c &eto disable.", enableMsg, Input_Names[key]); @@ -800,7 +800,7 @@ static void InputHandler_CheckZoomFov(void* obj) { if (!h->Enabled || !h->CanUseThirdPersonCamera) Game_SetFov(Game_DefaultFov); } -static cc_bool HandleBlockKey(Key key) { +static cc_bool HandleBlockKey(int key) { if (Gui_GetInputGrab()) return false; if (key == KeyBinds[KEYBIND_DELETE_BLOCK]) { @@ -818,7 +818,7 @@ static cc_bool HandleBlockKey(Key key) { return true; } -static cc_bool HandleNonClassicKey(Key key) { +static cc_bool HandleNonClassicKey(int key) { if (key == KeyBinds[KEYBIND_HIDE_GUI]) { Game_HideGui = !Game_HideGui; } else if (key == KeyBinds[KEYBIND_SMOOTH_CAMERA]) { @@ -854,7 +854,7 @@ static cc_bool HandleNonClassicKey(Key key) { return true; } -static cc_bool HandleCoreKey(Key key) { +static cc_bool HandleCoreKey(int key) { cc_result res; if (key == KeyBinds[KEYBIND_HIDE_FPS]) { @@ -888,7 +888,7 @@ static cc_bool HandleCoreKey(Key key) { return true; } -static void HandleHotkeyDown(Key key) { +static void HandleHotkeyDown(int key) { struct HotkeyData* hkey; String text; int i = Hotkeys_FindPartial(key); diff --git a/src/Input.h b/src/Input.h index f7657c51b..5ac74eade 100644 --- a/src/Input.h +++ b/src/Input.h @@ -6,7 +6,7 @@ Copyright 2014-2019 ClassiCube | Licensed under BSD-3 */ -enum Key_ { +enum Key { KEY_NONE, /* Unrecognised key */ KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, @@ -44,7 +44,6 @@ enum Key_ { KEY_XBUTTON1, KEY_XBUTTON2, KEY_LMOUSE, KEY_RMOUSE, KEY_MMOUSE, INPUT_COUNT }; -typedef int Key; /* Simple names for each keyboard button. */ extern const char* const Input_Names[INPUT_COUNT]; @@ -66,7 +65,7 @@ extern cc_bool Input_Pressed[INPUT_COUNT]; /* Sets the pressed state of a keyboard button. */ /* Raises InputEvents.Up if not pressed, but was pressed before. */ /* Raises InputEvents.Down if pressed (repeating is whether it was pressed before) */ -void Input_SetPressed(Key key, cc_bool pressed); +void Input_SetPressed(int key, cc_bool pressed); /* Resets all keyboard keys to released state. */ /* Raises InputEvents.Up for each previously pressed key. */ void Key_Clear(void); @@ -125,7 +124,7 @@ extern const cc_uint8 KeyBind_Defaults[KEYBIND_COUNT]; /* Gets whether the key bound to the given key binding is pressed. */ cc_bool KeyBind_IsPressed(KeyBind binding); /* Set the key that the given key binding is bound to. (also updates options list) */ -void KeyBind_Set(KeyBind binding, Key key); +void KeyBind_Set(KeyBind binding, int key); extern const cc_uint8 Hotkeys_LWJGL[256]; struct HotkeyData { @@ -143,16 +142,16 @@ enum HotkeyModifiers { }; /* Adds or updates a new hotkey. */ -void Hotkeys_Add(Key trigger, cc_uint8 modifiers, const String* text, cc_bool more); +void Hotkeys_Add(int trigger, cc_uint8 modifiers, const String* text, cc_bool more); /* Removes the given hotkey. */ -cc_bool Hotkeys_Remove(Key trigger, cc_uint8 modifiers); +cc_bool Hotkeys_Remove(int trigger, cc_uint8 modifiers); /* Returns the first hotkey which is bound to the given key and has its modifiers pressed. */ /* NOTE: The hotkeys list is sorted, so hotkeys with most modifiers are checked first. */ -int Hotkeys_FindPartial(Key key); +int Hotkeys_FindPartial(int key); /* Called when user has removed a hotkey. (removes it from options) */ -void Hotkeys_UserRemovedHotkey(Key trigger, cc_uint8 modifiers); +void Hotkeys_UserRemovedHotkey(int trigger, cc_uint8 modifiers); /* Called when user has added a hotkey. (Adds it to options) */ -void Hotkeys_UserAddedHotkey(Key trigger, cc_uint8 modifiers, cc_bool moreInput, const String* text); +void Hotkeys_UserAddedHotkey(int trigger, cc_uint8 modifiers, cc_bool moreInput, const String* text); cc_bool InputHandler_SetFOV(int fov); void InputHandler_PickBlocks(void); diff --git a/src/LScreens.c b/src/LScreens.c index 7ed80014e..4ee6ef9ec 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -12,6 +12,7 @@ #include "Resources.h" #include "Logger.h" #include "Window.h" +#include "Input.h" #ifndef CC_BUILD_WEB /*########################################################################################################################* @@ -91,7 +92,7 @@ static void LScreen_HandleTab(struct LScreen* s) { } } -static void LScreen_KeyDown(struct LScreen* s, Key key, cc_bool was) { +static void LScreen_KeyDown(struct LScreen* s, int key, cc_bool was) { if (key == KEY_TAB) { LScreen_HandleTab(s); } else if (key == KEY_ENTER) { @@ -400,7 +401,7 @@ static void ColoursScreen_MouseWheel(struct LScreen* s_, float delta) { ColoursScreen_AdjustSelected(s_, steps); } -static void ColoursScreen_KeyDown(struct LScreen* s, Key key, cc_bool was) { +static void ColoursScreen_KeyDown(struct LScreen* s, int key, cc_bool was) { if (key == KEY_LEFT) { ColoursScreen_AdjustSelected(s, -1); } else if (key == KEY_RIGHT) { @@ -1265,7 +1266,7 @@ static void ServersScreen_MouseWheel(struct LScreen* s_, float delta) { s->table.VTABLE->MouseWheel(&s->table, delta); } -static void ServersScreen_KeyDown(struct LScreen* s_, Key key, cc_bool was) { +static void ServersScreen_KeyDown(struct LScreen* s_, int key, cc_bool was) { struct ServersScreen* s = (struct ServersScreen*)s_; if (!LTable_HandlesKey(key)) { LScreen_KeyDown(s_, key, was); diff --git a/src/LScreens.h b/src/LScreens.h index d41510db7..deb1c5211 100644 --- a/src/LScreens.h +++ b/src/LScreens.h @@ -1,6 +1,6 @@ #ifndef CC_LSCREENS_H #define CC_LSCREENS_H -#include "Input.h" +#include "Core.h" /* Implements screens/menus for the launcher. Copyright 2014-2019 ClassiCube | Licensed under BSD-3 */ @@ -17,7 +17,7 @@ typedef void (*LWidget_Func)(struct LScreen* s, struct LWidget* w); LScreen_Func Draw; /* Draws all widgets and any other features such as lines/rectangles. */ \ LScreen_Func Tick; /* Repeatedly called multiple times every second. */ \ LScreen_Func OnDisplay; /* Called when framebuffer is about to be displayed. */ \ - void (*KeyDown)(struct LScreen* s, Key key, cc_bool wasDown); \ + void (*KeyDown)(struct LScreen* s, int key, cc_bool wasDown); \ void (*KeyPress)(struct LScreen* s, char c); \ void (*MouseDown)(struct LScreen* s, int btn); \ void (*MouseUp)(struct LScreen* s, int btn); \ diff --git a/src/LWidgets.c b/src/LWidgets.c index 3c62c7ac9..cdf8cef2b 100644 --- a/src/LWidgets.c +++ b/src/LWidgets.c @@ -8,6 +8,7 @@ #include "LWeb.h" #include "Platform.h" #include "LScreens.h" +#include "Input.h" #ifndef CC_BUILD_WEB #define BORDER 1 @@ -404,7 +405,7 @@ static void LInput_CopyFromClipboard(String* text, void* widget) { LInput_AppendString(w, text); } -static void LInput_KeyDown(void* widget, Key key, cc_bool was) { +static void LInput_KeyDown(void* widget, int key, cc_bool was) { struct LInput* w = (struct LInput*)widget; if (key == KEY_BACKSPACE) { LInput_Backspace(w); @@ -924,11 +925,11 @@ static void LTable_DrawScrollbar(struct LTable* w) { x, w->Y + y, w->ScrollbarWidth, height); } -cc_bool LTable_HandlesKey(Key key) { +cc_bool LTable_HandlesKey(int key) { return key == KEY_UP || key == KEY_DOWN || key == KEY_PAGEUP || key == KEY_PAGEDOWN; } -static void LTable_KeyDown(void* widget, Key key, cc_bool was) { +static void LTable_KeyDown(void* widget, int key, cc_bool was) { struct LTable* w = (struct LTable*)widget; int index = LTable_GetSelectedIndex(w); diff --git a/src/LWidgets.h b/src/LWidgets.h index 2618a769c..19d33187b 100644 --- a/src/LWidgets.h +++ b/src/LWidgets.h @@ -2,7 +2,7 @@ #define CC_LWIDGETS_H #include "Bitmap.h" #include "Constants.h" -#include "Input.h" +#include "String.h" /* Describes and manages individual 2D GUI elements in the launcher. Copyright 2014-2019 ClassiCube | Licensed under BSD-3 */ @@ -15,7 +15,7 @@ struct LWidgetVTABLE { /* Called repeatedly to update this widget when selected. */ void (*Tick)(void* widget); /* Called when key is pressed and this widget is selected. */ - void (*KeyDown)(void* widget, Key key, cc_bool wasDown); + void (*KeyDown)(void* widget, int key, cc_bool wasDown); /* Called when key is pressed and this widget is selected. */ void (*KeyPress)(void* widget, char c); /* Called when mouse hovers/moves over this widget. */ @@ -195,7 +195,7 @@ void LTable_Reset(struct LTable* table); void LTable_Reposition(struct LTable* table); /* Whether this table would handle the given key being pressed. */ /* e.g. used so pressing up/down works even when another widget is selected */ -cc_bool LTable_HandlesKey(Key key); +cc_bool LTable_HandlesKey(int key); /* Filters rows to only show those containing 'w->Filter' in the name. */ void LTable_ApplyFilter(struct LTable* table); /* Sorts the rows in the table by current Sorter function of table */ diff --git a/src/Menus.c b/src/Menus.c index 474ff3bcc..566c7743d 100644 --- a/src/Menus.c +++ b/src/Menus.c @@ -371,7 +371,7 @@ static void ListScreen_Select(struct ListScreen* s, const String* str) { } } -static int ListScreen_KeyDown(void* screen, Key key) { +static int ListScreen_KeyDown(void* screen, int key) { struct ListScreen* s = (struct ListScreen*)screen; if (key == KEY_LEFT || key == KEY_PAGEUP) { ListScreen_PageClick(s, false); @@ -448,7 +448,7 @@ static void ListScreen_ContextRecreated(void* screen) { static const struct ScreenVTABLE ListScreen_VTABLE = { ListScreen_Init, ListScreen_Render, ListScreen_Free, - ListScreen_KeyDown, Screen_TInput, Screen_TKeyPress, + ListScreen_KeyDown, Screen_TInput, Screen_TKeyPress, Screen_TText, Menu_PointerDown, Screen_TPointer, Menu_PointerMove, ListScreen_MouseScroll, Menu_Layout, ListScreen_ContextLost, ListScreen_ContextRecreated }; @@ -464,7 +464,7 @@ void ListScreen_Show(void) { /*########################################################################################################################* *--------------------------------------------------------MenuScreen-------------------------------------------------------* *#########################################################################################################################*/ -static int MenuScreen_KeyDown(void* screen, Key key) { return key < KEY_F1 || key > KEY_F35; } +static int MenuScreen_KeyDown(void* screen, int key) { return key < KEY_F1 || key > KEY_F35; } static void MenuScreen_Render(void* screen, double delta) { Menu_RenderBounds(); @@ -559,7 +559,7 @@ static void PauseScreen_Free(void* screen) { static const struct ScreenVTABLE PauseScreen_VTABLE = { PauseScreen_Init, MenuScreen_Render, PauseScreen_Free, - MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress, + MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress, Screen_TText, Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll, Menu_Layout, Menu_ContextLost, PauseScreen_ContextRecreated }; @@ -584,7 +584,7 @@ static struct OptionsGroupScreen { struct ButtonWidget done; } OptionsGroupScreen; -static const char* optsGroup_descs[7] = { +static const char* const optsGroup_descs[7] = { "&eMusic/Sound, view bobbing, and more", "&eChat options, gui scale, font settings, and more", "&eFPS limit, view distance, entity names/shadows", @@ -664,7 +664,7 @@ static int OptionsGroupScreen_PointerMove(void* screen, int id, int x, int y) { static const struct ScreenVTABLE OptionsGroupScreen_VTABLE = { OptionsGroupScreen_Init, MenuScreen_Render, OptionsGroupScreen_Free, - MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress, + MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress, Screen_TText, Menu_PointerDown, Screen_TPointer, OptionsGroupScreen_PointerMove, Screen_TMouseScroll, Menu_Layout, OptionsGroupScreen_ContextLost, OptionsGroupScreen_ContextRecreated }; @@ -812,7 +812,7 @@ static int EditHotkeyScreen_KeyPress(void* screen, char keyChar) { return true; } -static int EditHotkeyScreen_KeyDown(void* screen, Key key) { +static int EditHotkeyScreen_KeyDown(void* screen, int key) { struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen; if (s->selectedI >= 0) { if (s->selectedI == 0) { @@ -887,7 +887,7 @@ static void EditHotkeyScreen_Init(void* screen) { static const struct ScreenVTABLE EditHotkeyScreen_VTABLE = { EditHotkeyScreen_Init, EditHotkeyScreen_Render, Menu_CloseKeyboard, - EditHotkeyScreen_KeyDown, Screen_TInput, EditHotkeyScreen_KeyPress, + EditHotkeyScreen_KeyDown, Screen_TInput, EditHotkeyScreen_KeyPress, Screen_TText, Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll, Menu_Layout, EditHotkeyScreen_ContextLost, EditHotkeyScreen_ContextRecreated }; @@ -981,7 +981,7 @@ static void GenLevelScreen_Make(struct GenLevelScreen* s, int i, int y, int def) s->labels[i].col = col; } -static int GenLevelScreen_KeyDown(void* screen, Key key) { +static int GenLevelScreen_KeyDown(void* screen, int key) { struct GenLevelScreen* s = (struct GenLevelScreen*)screen; if (s->selected && Elem_HandlesKeyDown(&s->selected->base, key)) return true; return MenuScreen_KeyDown(s, key); @@ -1058,7 +1058,7 @@ static void GenLevelScreen_Init(void* screen) { static const struct ScreenVTABLE GenLevelScreen_VTABLE = { GenLevelScreen_Init, MenuScreen_Render, Menu_CloseKeyboard, - GenLevelScreen_KeyDown, Screen_TInput, GenLevelScreen_KeyPress, + GenLevelScreen_KeyDown, Screen_TInput, GenLevelScreen_KeyPress, Screen_TText, GenLevelScreen_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll, Menu_Layout, GenLevelScreen_ContextLost, GenLevelScreen_ContextRecreated }; @@ -1123,7 +1123,7 @@ static void ClassicGenScreen_Init(void* screen) { static const struct ScreenVTABLE ClassicGenScreen_VTABLE = { ClassicGenScreen_Init, MenuScreen_Render, Menu_NullFunc, - MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress, + MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress, Screen_TText, Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll, Menu_Layout, Menu_ContextLost, ClassicGenScreen_ContextRecreated }; @@ -1320,7 +1320,7 @@ static int SaveLevelScreen_KeyPress(void* screen, char keyChar) { return true; } -static int SaveLevelScreen_KeyDown(void* screen, Key key) { +static int SaveLevelScreen_KeyDown(void* screen, int key) { struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen; if (Elem_HandlesKeyDown(&s->input.base, key)) { SaveLevelScreen_RemoveOverwrites(s); @@ -1386,7 +1386,7 @@ static void SaveLevelScreen_Init(void* screen) { static const struct ScreenVTABLE SaveLevelScreen_VTABLE = { SaveLevelScreen_Init, SaveLevelScreen_Render, Menu_CloseKeyboard, - SaveLevelScreen_KeyDown, Screen_TInput, SaveLevelScreen_KeyPress, + SaveLevelScreen_KeyDown, Screen_TInput, SaveLevelScreen_KeyPress, Screen_TText, Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll, Menu_Layout, SaveLevelScreen_ContextLost, SaveLevelScreen_ContextRecreated }; @@ -1503,7 +1503,7 @@ static void HotkeyListScreen_EntryClick(void* screen, void* widget) { struct ListScreen* s = (struct ListScreen*)screen; struct HotkeyData h, original = { 0 }; String text, key, value; - Key trigger; + int trigger; int i, flags = 0; text = ListScreen_UNSAFE_GetCur(s, widget); @@ -1650,7 +1650,7 @@ static void KeyBindingsScreen_OnBindingClick(void* screen, void* widget) { if (old >= 0) KeyBindingsScreen_Update(s, old); } -static int KeyBindingsScreen_KeyDown(void* screen, Key key) { +static int KeyBindingsScreen_KeyDown(void* screen, int key) { struct KeyBindingsScreen* s = (struct KeyBindingsScreen*)screen; KeyBind bind; int idx; @@ -1738,7 +1738,7 @@ static void KeyBindingsScreen_Init(void* screen) { static const struct ScreenVTABLE KeyBindingsScreen_VTABLE = { KeyBindingsScreen_Init, MenuScreen_Render, Menu_NullFunc, - KeyBindingsScreen_KeyDown, Screen_TInput, Screen_TKeyPress, + KeyBindingsScreen_KeyDown, Screen_TInput, Screen_TKeyPress, Screen_TText, Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll, Menu_Layout, KeyBindingsScreen_ContextLost, KeyBindingsScreen_ContextRecreated }; @@ -1984,7 +1984,7 @@ static int MenuOptionsScreen_KeyPress(void* screen, char keyChar) { return true; } -static int MenuOptionsScreen_KeyDown(void* screen, Key key) { +static int MenuOptionsScreen_KeyDown(void* screen, int key) { struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen; if (s->activeI >= 0) { if (Elem_HandlesKeyDown(&s->input.base, key)) return true; @@ -2185,7 +2185,7 @@ static void MenuOptionsScreen_ContextRecreated(void* screen) { static const struct ScreenVTABLE MenuOptionsScreen_VTABLE = { MenuOptionsScreen_Init, MenuOptionsScreen_Render, MenuOptionsScreen_Free, - MenuOptionsScreen_KeyDown, Screen_TInput, MenuOptionsScreen_KeyPress, + MenuOptionsScreen_KeyDown, Screen_TInput, MenuOptionsScreen_KeyPress, Screen_TText, Menu_PointerDown, Screen_TPointer, MenuOptionsScreen_PointerMove, Screen_TMouseScroll, MenuOptionsScreen_Layout, MenuOptionsScreen_ContextLost, MenuOptionsScreen_ContextRecreated }; @@ -3015,7 +3015,7 @@ static void TexIdsOverlay_Render(void* screen, double delta) { Gfx_SetTexturing(false); } -static int TexIdsOverlay_KeyDown(void* screen, Key key) { +static int TexIdsOverlay_KeyDown(void* screen, int key) { struct Screen* s = (struct Screen*)screen; if (key == KeyBinds[KEYBIND_IDOVERLAY]) { Gui_Remove(s); return true; } return false; @@ -3023,7 +3023,7 @@ static int TexIdsOverlay_KeyDown(void* screen, Key key) { static const struct ScreenVTABLE TexIdsOverlay_VTABLE = { TexIdsOverlay_Init, TexIdsOverlay_Render, Menu_NullFunc, - TexIdsOverlay_KeyDown, Screen_FInput, Screen_FKeyPress, + TexIdsOverlay_KeyDown, Screen_FInput, Screen_FKeyPress, Screen_FText, Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll, Menu_Layout, TexIdsOverlay_ContextLost, TexIdsOverlay_ContextRecreated }; @@ -3090,7 +3090,7 @@ static void UrlWarningOverlay_Init(void* screen) { static const struct ScreenVTABLE UrlWarningOverlay_VTABLE = { UrlWarningOverlay_Init, MenuScreen_Render, Menu_NullFunc, - Screen_TInput, Screen_TInput, Screen_TKeyPress, + Screen_TInput, Screen_TInput, Screen_TKeyPress, Screen_TText, Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll, Menu_Layout, Menu_ContextLost, UrlWarningOverlay_ContextRecreated }; @@ -3239,7 +3239,7 @@ static void TexPackOverlay_Init(void* screen) { static const struct ScreenVTABLE TexPackOverlay_VTABLE = { TexPackOverlay_Init, TexPackOverlay_Render, Menu_NullFunc, - Screen_TInput, Screen_TInput, Screen_TKeyPress, + Screen_TInput, Screen_TInput, Screen_TKeyPress, Screen_TText, Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll, Menu_Layout, TexPackOverlay_ContextLost, TexPackOverlay_ContextRecreated }; @@ -3268,7 +3268,7 @@ static struct TouchMoreOverlay { } TouchMoreOverlay_Instance; static void TouchMore_Toggle(KeyBind bind) { - Key key = KeyBinds[bind]; + int key = KeyBinds[bind]; Gui_Remove((struct Screen*)&TouchMoreOverlay_Instance); Input_SetPressed(key, !Input_Pressed[key]); } diff --git a/src/Protocol.c b/src/Protocol.c index 01ed977cc..1e0da99b3 100644 --- a/src/Protocol.c +++ b/src/Protocol.c @@ -939,7 +939,7 @@ static void CPE_SetTextHotkey(cc_uint8* data) { String action = Protocol_UNSAFE_GetString(&data[64]); cc_uint32 keyCode = Stream_GetU32_BE(&data[128]); cc_uint8 keyMods = data[132]; - Key key; + int key; if (keyCode > 255) return; key = Hotkeys_LWJGL[keyCode]; diff --git a/src/Screens.c b/src/Screens.c index 21f879b00..12622742a 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -26,15 +26,15 @@ int Screen_FInput(void* s, int key) { return false; } int Screen_FKeyPress(void* s, char keyChar) { return false; } +int Screen_FText(void* s, const String* str) { return false; } int Screen_FMouseScroll(void* s, float delta) { return false; } -int Screen_FPointer(void* s, int id, int x, int y) { return false; } -int Screen_FPointerMove(void* s, int id, int x, int y) { return false; } +int Screen_FPointer(void* s, int id, int x, int y) { return false; } -int Screen_TInput(void* s, int key) { return true; } +int Screen_TInput(void* s, int key) { return true; } int Screen_TKeyPress(void* s, char keyChar) { return true; } +int Screen_TText(void* s, const String* str) { return false; } int Screen_TMouseScroll(void* s, float delta) { return true; } -int Screen_TPointer(void* s, int id, int x, int y) { return true; } -int Screen_TPointerMove(void* s, int id, int x, int y) { return true; } +int Screen_TPointer(void* s, int id, int x, int y) { return true; } static void Screen_NullFunc(void* screen) { } CC_NOINLINE static cc_bool IsOnlyHudActive(void) { @@ -226,8 +226,8 @@ static void HUDScreen_Render(void* screen, double delta) { static const struct ScreenVTABLE HUDScreen_VTABLE = { Screen_NullFunc, HUDScreen_Render, Screen_NullFunc, - Screen_FInput, Screen_FInput, Screen_FKeyPress, - Screen_FPointer, Screen_FPointer, Screen_FPointerMove, Screen_FMouseScroll, + Screen_FInput, Screen_FInput, Screen_FKeyPress, Screen_FText, + Screen_FPointer, Screen_FPointer, Screen_FPointer, Screen_FMouseScroll, Screen_NullFunc, HUDScreen_ContextLost, HUDScreen_ContextRecreated }; void HUDScreen_Show(void) { @@ -624,10 +624,10 @@ static int ChatScreen_KeyPress(void* screen, char keyChar) { return true; } -static int ChatScreen_KeyDown(void* screen, Key key) { +static int ChatScreen_KeyDown(void* screen, int key) { static const String slash = String_FromConst("/"); struct ChatScreen* s = (struct ChatScreen*)screen; - Key playerListKey = KeyBinds[KEYBIND_PLAYER_LIST]; + int playerListKey = KeyBinds[KEYBIND_PLAYER_LIST]; cc_bool handlesList = playerListKey != KEY_TAB || !Gui_TabAutocomplete || !s->grabsInput; if (key == playerListKey && handlesList) { @@ -671,7 +671,7 @@ static int ChatScreen_KeyDown(void* screen, Key key) { return true; } -static int ChatScreen_KeyUp(void* screen, Key key) { +static int ChatScreen_KeyUp(void* screen, int key) { struct ChatScreen* s = (struct ChatScreen*)screen; if (key == KeyBinds[KEYBIND_PLAYER_LIST] && s->showingList) { s->showingList = false; @@ -813,8 +813,8 @@ static void ChatScreen_Free(void* screen) { static const struct ScreenVTABLE ChatScreen_VTABLE = { ChatScreen_Init, ChatScreen_Render, ChatScreen_Free, - ChatScreen_KeyDown, ChatScreen_KeyUp, ChatScreen_KeyPress, - ChatScreen_PointerDown, Screen_FPointer, Screen_FPointerMove, ChatScreen_MouseScroll, + ChatScreen_KeyDown, ChatScreen_KeyUp, ChatScreen_KeyPress, Screen_TText, + ChatScreen_PointerDown, Screen_FPointer, Screen_FPointer, ChatScreen_MouseScroll, ChatScreen_Layout, ChatScreen_ContextLost, ChatScreen_ContextRecreated }; void ChatScreen_Show(void) { @@ -935,7 +935,7 @@ static void InventoryScreen_Free(void* screen) { Event_UnregisterVoid(&BlockEvents.BlockDefChanged, s, InventoryScreen_OnBlockChanged); } -static int InventoryScreen_KeyDown(void* screen, Key key) { +static int InventoryScreen_KeyDown(void* screen, int key) { struct InventoryScreen* s = (struct InventoryScreen*)screen; struct TableWidget* table = &s->table; @@ -952,7 +952,7 @@ static int InventoryScreen_KeyDown(void* screen, Key key) { return true; } -static int InventoryScreen_KeyUp(void* screen, Key key) { +static int InventoryScreen_KeyUp(void* screen, int key) { struct InventoryScreen* s = (struct InventoryScreen*)screen; struct ChatScreen* hud; @@ -1001,7 +1001,7 @@ static int InventoryScreen_MouseScroll(void* screen, float delta) { static const struct ScreenVTABLE InventoryScreen_VTABLE = { InventoryScreen_Init, InventoryScreen_Render, InventoryScreen_Free, - InventoryScreen_KeyDown, InventoryScreen_KeyUp, Screen_TKeyPress, + InventoryScreen_KeyDown, InventoryScreen_KeyUp, Screen_TKeyPress, Screen_TText, InventoryScreen_PointerDown, InventoryScreen_PointerUp, InventoryScreen_PointerMove, InventoryScreen_MouseScroll, InventoryScreen_Layout, InventoryScreen_ContextLost, InventoryScreen_ContextRecreated }; @@ -1166,8 +1166,8 @@ CC_NOINLINE static void LoadingScreen_ShowCommon(const String* title, const Stri static const struct ScreenVTABLE LoadingScreen_VTABLE = { LoadingScreen_Init, LoadingScreen_Render, LoadingScreen_Free, - Screen_TInput, Screen_TInput, Screen_TKeyPress, - Screen_TPointer, Screen_TPointer, Screen_TPointerMove, Screen_TMouseScroll, + Screen_TInput, Screen_TInput, Screen_TKeyPress, Screen_TText, + Screen_TPointer, Screen_TPointer, Screen_TPointer, Screen_TMouseScroll, LoadingScreen_Layout, LoadingScreen_ContextLost, LoadingScreen_ContextRecreated }; void LoadingScreen_Show(const String* title, const String* message) { @@ -1236,8 +1236,8 @@ static void GeneratingScreen_Render(void* screen, double delta) { static const struct ScreenVTABLE GeneratingScreen_VTABLE = { GeneratingScreen_Init, GeneratingScreen_Render, LoadingScreen_Free, - Screen_TInput, Screen_TInput, Screen_TKeyPress, - Screen_TPointer, Screen_TPointer, Screen_FPointerMove, Screen_TMouseScroll, + Screen_TInput, Screen_TInput, Screen_TKeyPress, Screen_TText, + Screen_TPointer, Screen_TPointer, Screen_FPointer, Screen_TMouseScroll, LoadingScreen_Layout, LoadingScreen_ContextLost, LoadingScreen_ContextRecreated }; void GeneratingScreen_Show(void) { @@ -1364,7 +1364,7 @@ static void DisconnectScreen_Layout(void* screen) { Widget_Layout(&s->reconnect); } -static int DisconnectScreen_KeyDown(void* s, Key key) { return key < KEY_F1 || key > KEY_F35; } +static int DisconnectScreen_KeyDown(void* s, int key) { return key < KEY_F1 || key > KEY_F35; } static int DisconnectScreen_PointerDown(void* screen, int id, int x, int y) { struct DisconnectScreen* s = (struct DisconnectScreen*)screen; @@ -1388,7 +1388,7 @@ static int DisconnectScreen_PointerMove(void* screen, int idx, int x, int y) { static const struct ScreenVTABLE DisconnectScreen_VTABLE = { DisconnectScreen_Init, DisconnectScreen_Render, DisconnectScreen_Free, - DisconnectScreen_KeyDown, Screen_TInput, Screen_TKeyPress, + DisconnectScreen_KeyDown, Screen_TInput, Screen_TKeyPress, Screen_TText, DisconnectScreen_PointerDown, Screen_TPointer, DisconnectScreen_PointerMove, Screen_TMouseScroll, DisconnectScreen_Layout, DisconnectScreen_ContextLost, DisconnectScreen_ContextRecreated }; @@ -1570,7 +1570,7 @@ static int TouchScreen_PointerUp(void* screen, int id, int x, int y) { static const struct ScreenVTABLE TouchScreen_VTABLE = { Screen_NullFunc, TouchScreen_Render, Screen_NullFunc, - Screen_FInput, Screen_FInput, Screen_FKeyPress, + Screen_FInput, Screen_FInput, Screen_FKeyPress, Screen_FText, TouchScreen_PointerDown, TouchScreen_PointerUp, Screen_FPointerMove, Screen_FMouseScroll, TouchScreen_Layout, TouchScreen_ContextLost, TouchScreen_ContextRecreated }; diff --git a/src/Screens.h b/src/Screens.h index dc8f7a428..c7791041f 100644 --- a/src/Screens.h +++ b/src/Screens.h @@ -10,16 +10,16 @@ struct Widget; /* These always return false */ int Screen_FInput(void* s, int key); int Screen_FKeyPress(void* s, char keyChar); +int Screen_FText(void* s, const String* str); int Screen_FMouseScroll(void* s, float delta); int Screen_FPointer(void* s, int id, int x, int y); -int Screen_FPointerMove(void* s, int id, int x, int y); /* These always return true */ int Screen_TInput(void* s, int key); int Screen_TKeyPress(void* s, char keyChar); +int Screen_TText(void* s, const String* str); int Screen_TMouseScroll(void* s, float delta); int Screen_TPointer(void* s, int id, int x, int y); -int Screen_TPointerMove(void* s, int id, int x, int y); void InventoryScreen_Show(void); void HUDScreen_Show(void); diff --git a/src/Widgets.c b/src/Widgets.c index 2b3ca9d73..55cb07c86 100644 --- a/src/Widgets.c +++ b/src/Widgets.c @@ -21,7 +21,7 @@ #define Widget_UV(u1,v1, u2,v2) Tex_UV(u1/256.0f,v1/256.0f, u2/256.0f,v2/256.0f) static void Widget_NullFunc(void* widget) { } static int Widget_Pointer(void* elem, int id, int x, int y) { return false; } -static int Widget_Key(void* elem, Key key) { return false; } +static int Widget_Key(void* elem, int key) { return false; } static int Widget_PointerMove(void* elem, int id, int x, int y) { return false; } static int Widget_MouseScroll(void* elem, float delta) { return false; } @@ -398,7 +398,7 @@ static void HotbarWidget_Render(void* widget, double delta) { HotbarWidget_RenderHotbarBlocks(w); } -static int HotbarWidget_KeyDown(void* widget, Key key) { +static int HotbarWidget_KeyDown(void* widget, int key) { struct HotbarWidget* w = (struct HotbarWidget*)widget; int index; if (key < '1' || key > '9') return false; @@ -414,7 +414,7 @@ static int HotbarWidget_KeyDown(void* widget, Key key) { return true; } -static int HotbarWidget_KeyUp(void* widget, Key key) { +static int HotbarWidget_KeyUp(void* widget, int key) { struct HotbarWidget* w = (struct HotbarWidget*)widget; int index; @@ -768,7 +768,7 @@ static int TableWidget_PointerMove(void* widget, int id, int x, int y) { return true; } -static int TableWidget_KeyDown(void* widget, Key key) { +static int TableWidget_KeyDown(void* widget, int key) { struct TableWidget* w = (struct TableWidget*)widget; if (w->selectedIndex == -1) return false; @@ -1106,7 +1106,7 @@ static void InputWidget_CopyFromClipboard(String* text, void* w) { InputWidget_AppendString((struct InputWidget*)w, text); } -static cc_bool InputWidget_OtherKey(struct InputWidget* w, Key key) { +static cc_bool InputWidget_OtherKey(struct InputWidget* w, int key) { int maxChars = w->GetMaxLines() * INPUTWIDGET_LEN; if (!Key_IsActionPressed()) return false; @@ -1150,7 +1150,7 @@ static void InputWidget_Reposition(void* widget) { w->inputTex.X += w->x - oldX; w->inputTex.Y += w->y - oldY; } -static int InputWidget_KeyDown(void* widget, Key key) { +static int InputWidget_KeyDown(void* widget, int key) { struct InputWidget* w = (struct InputWidget*)widget; if (key == KEY_LEFT) { InputWidget_LeftKey(w); @@ -1170,7 +1170,7 @@ static int InputWidget_KeyDown(void* widget, Key key) { return true; } -static int InputWidget_KeyUp(void* widget, Key key) { return true; } +static int InputWidget_KeyUp(void* widget, int key) { return true; } static int InputWidget_PointerDown(void* widget, int id, int x, int y) { String line; char lineBuffer[STRING_SIZE]; @@ -1666,7 +1666,7 @@ static void ChatInputWidget_TabKey(struct InputWidget* w) { } } -static int ChatInputWidget_KeyDown(void* widget, Key key) { +static int ChatInputWidget_KeyDown(void* widget, int key) { struct InputWidget* w = (struct InputWidget*)widget; if (key == KEY_TAB) { ChatInputWidget_TabKey(w); return true; } if (key == KEY_UP) { ChatInputWidget_UpKey(w); return true; } diff --git a/src/Window.c b/src/Window.c index 79c7f342e..b85cd1da4 100644 --- a/src/Window.c +++ b/src/Window.c @@ -166,7 +166,7 @@ static const cc_uint8 key_map[14 * 16] = { KEY_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, }; -static Key Window_MapKey(WPARAM key) { return key < Array_Elems(key_map) ? key_map[key] : 0; } +static int Window_MapKey(WPARAM key) { return key < Array_Elems(key_map) ? key_map[key] : 0; } static void Window_RefreshBounds(void) { RECT rect; @@ -296,7 +296,7 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara LPARAM ext = lParam & (1UL << 24); cc_bool lShiftDown, rShiftDown; - Key key; + int key; switch (wParam) { case VK_SHIFT: @@ -747,7 +747,7 @@ static long win_eventMask; /*########################################################################################################################* *-----------------------------------------------------Private details-----------------------------------------------------* *#########################################################################################################################*/ -static Key Window_MapKey(KeySym key) { +static int Window_MapKey(KeySym key) { if (key >= XK_0 && key <= XK_9) { return '0' + (key - XK_0); } if (key >= XK_A && key <= XK_Z) { return 'A' + (key - XK_A); } if (key >= XK_a && key <= XK_z) { return 'A' + (key - XK_a); } @@ -1052,7 +1052,7 @@ static void Window_ToggleKey(XKeyEvent* keyEvent, cc_bool pressed) { KeySym keysym1 = XLookupKeysym(keyEvent, 0); KeySym keysym2 = XLookupKeysym(keyEvent, 1); - Key key = Window_MapKey(keysym1); + int key = Window_MapKey(keysym1); if (!key) key = Window_MapKey(keysym2); if (key) Input_SetPressed(key, pressed); } @@ -1708,7 +1708,7 @@ static const cc_uint8 key_map[8 * 16] = { 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, '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, }; -static Key Window_MapKey(UInt32 key) { return key < Array_Elems(key_map) ? key_map[key] : 0; } +static int Window_MapKey(UInt32 key) { return key < Array_Elems(key_map) ? key_map[key] : 0; } /* TODO: Check these.. */ /* case 0x37: return KEY_LWIN; */ /* case 0x38: return KEY_LSHIFT; */ @@ -1853,7 +1853,7 @@ static void Window_RefreshBounds(void) { static OSStatus Window_ProcessKeyboardEvent(EventRef inEvent) { UInt32 kind, code; - Key key; + int key; OSStatus res; kind = GetEventKind(inEvent); @@ -2524,7 +2524,7 @@ void Window_Close(void) { SDL_PushEvent(&e); } -static Key Window_MapKey(SDL_Keycode k) { +static int Window_MapKey(SDL_Keycode k) { 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_F1 && k <= SDLK_F12) { return KEY_F1 + (k - SDLK_F1); } @@ -2587,7 +2587,7 @@ static Key Window_MapKey(SDL_Keycode k) { static void Window_HandleKeyEvent(const SDL_Event* e) { cc_bool pressed = e->key.state == SDL_PRESSED; - Key key = Window_MapKey(e->key.keysym.sym); + int key = Window_MapKey(e->key.keysym.sym); if (key) Input_SetPressed(key, pressed); } @@ -2911,7 +2911,7 @@ static const char* Window_BeforeUnload(int type, const void* ev, void *data) { return NULL; } -static Key Window_MapKey(int k) { +static int Window_MapKey(int k) { if (k >= '0' && k <= '9') 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); } @@ -2971,7 +2971,7 @@ static Key Window_MapKey(int k) { } static EM_BOOL Window_Key(int type, const EmscriptenKeyboardEvent* ev , void* data) { - Key key = Window_MapKey(ev->keyCode); + int key = Window_MapKey(ev->keyCode); Window_CorrectFocus(); if (!key) return false; @@ -3344,7 +3344,7 @@ static void Window_RefreshBounds(void) { Event_RaiseVoid(&WindowEvents.Resized); } -static Key Window_MapKey(int code) { +static int Window_MapKey(int code) { 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_F1 && code <= AKEYCODE_F12) return (code - AKEYCODE_F1) + KEY_F1;