Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Changelog
* Tools: fixed a crash in projects containing resources with particular filenames.
* Tools: fixed favorites entries disappearing when saved from some external applications.
* Tools: fixed ``Ctrl+O`` keyboard shortcut for opening levels.
* Runtime: added missing keyboard punctuation and special keys on HTML5, Linux and Windows platforms.
* Runtime: fixed a crash in the Graph subsystem.
* Runtime: fixed ``smoothed`` timestep policy not honoring average_cap during the very first frames.
* Data Compiler: fixed an issue that caused misdetected file changes before compilation.
Expand Down
3 changes: 2 additions & 1 deletion docs/lua_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,11 @@ Keyboard Button Names
* ``tab``, ``enter``, ``escape``, ``space``, ``backspace``
* ``num_lock``, ``numpad_enter``, ``numpad_.``, ``numpad_*``, ``numpad_+``, ``numpad_-``, ``numpad_/``, ``numpad_0``, ``numpad_1``, ``numpad_2``, ``numpad_3``, ``numpad_4``, ``numpad_5``, ``numpad_6``, ``numpad_7``, ``numpad_8``, ``numpad_9``
* ``f1``, ``f2``, ``f3``, ``f4``, ``f5``, ``f6``, ``f7``, ``f8``, ``f9``, ``f10``, ``f11``, ``f12``
* ``home``, ``left``, ``up``, ``right``, ``down``, ``page_up``, ``page_down``, ``ins``, ``del``, ``end``
* ``home``, ``left``, ``up``, ``right``, ``down``, ``page_up``, ``page_down``, ``ins``, ``del``, ``end``, ``print_screen``, ``scroll_lock``, ``break``
* ``ctrl_left``, ``ctrl_right``, ``shift_left``, ``shift_right``, ``caps_lock``, ``alt_left``, ``alt_right``, ``super_left``, ``super_right``
* ``0``, ``1``, ``2``, ``3``, ``4``, ``5``, ``6``, ``7``, ``8``, ``9``
* ``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``
* ``backtick``, ``minus``, ``equal``, ``open_bracket``, ``close_bracket``, ``backslash``, ``semicolon``, ``quote``, ``comma``, ``period``, ``slash``

Keyboard Axis Names
~~~~~~~~~~~~~~~~~~~
Expand Down
18 changes: 17 additions & 1 deletion src/device/input_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ static const char *s_keyboard_button_names[] =
"ins", // KeyboardButton::INS
"del", // KeyboardButton::DEL
"end", // KeyboardButton::END
"print_screen", // KeyboardButton::PRINT_SCREEN
"scroll_lock", // KeyboardButton::SCROLL_LOCK
"break", // KeyboardButton::BREAK
"ctrl_left", // KeyboardButton::CTRL_LEFT
"ctrl_right", // KeyboardButton::CTRL_RIGHT
"shift_left", // KeyboardButton::SHIFT_LEFT
Expand Down Expand Up @@ -101,7 +104,20 @@ static const char *s_keyboard_button_names[] =
"w", // KeyboardButton::W
"x", // KeyboardButton::X
"y", // KeyboardButton::Y
"z" // KeyboardButton::Z
"z", // KeyboardButton::Z

/* Punctuation */
"backtick", // KeyboardButton::BACKTICK
"minus", // KeyboardButton::MINUS
"equal", // KeyboardButton::EQUAL
"open_bracket", // KeyboardButton::OPEN_BRACKET
"close_bracket",// KeyboardButton::CLOSE_BRACKET
"backslash", // KeyboardButton::BACKSLASH
"semicolon", // KeyboardButton::SEMICOLON
"quote", // KeyboardButton::QUOTE
"comma", // KeyboardButton::COMMA
"period", // KeyboardButton::PERIOD
"slash" // KeyboardButton::SLASH
};
CE_STATIC_ASSERT(countof(s_keyboard_button_names) == KeyboardButton::COUNT);

Expand Down
16 changes: 16 additions & 0 deletions src/device/input_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ struct KeyboardButton
INS,
DEL,
END,
PRINT_SCREEN,
SCROLL_LOCK,
BREAK,

/* Modifier keys */
CTRL_LEFT,
Expand Down Expand Up @@ -135,6 +138,19 @@ struct KeyboardButton
Y,
Z,

/* Punctuation */
BACKTICK,
MINUS,
EQUAL,
OPEN_BRACKET,
CLOSE_BRACKET,
BACKSLASH,
SEMICOLON,
QUOTE,
COMMA,
PERIOD,
SLASH,

COUNT
};
};
Expand Down
14 changes: 14 additions & 0 deletions src/device/main_html5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ static const EmKeyInfo em_key_info[] =
{ "Insert", KeyboardButton::INS },
{ "Delete", KeyboardButton::DEL },
{ "End", KeyboardButton::END },
{ "PrintScreen", KeyboardButton::PRINT_SCREEN },
{ "ScrollLock", KeyboardButton::SCROLL_LOCK },
{ "Pause", KeyboardButton::BREAK },
{ "ShiftLeft", KeyboardButton::SHIFT_LEFT },
{ "ShiftRight", KeyboardButton::SHIFT_RIGHT },
{ "ControlLeft", KeyboardButton::CTRL_LEFT },
Expand Down Expand Up @@ -268,6 +271,17 @@ static const EmKeyInfo em_key_info[] =
{ "Digit7", KeyboardButton::NUMBER_7 },
{ "Digit8", KeyboardButton::NUMBER_8 },
{ "Digit9", KeyboardButton::NUMBER_9 },
{ "Backquote", KeyboardButton::BACKTICK },
{ "Minus", KeyboardButton::MINUS },
{ "Equal", KeyboardButton::EQUAL },
{ "BracketLeft", KeyboardButton::OPEN_BRACKET },
{ "BracketRight", KeyboardButton::CLOSE_BRACKET },
{ "Backslash", KeyboardButton::BACKSLASH },
{ "Semicolon", KeyboardButton::SEMICOLON },
{ "Quote", KeyboardButton::QUOTE },
{ "Comma", KeyboardButton::COMMA },
{ "Period", KeyboardButton::PERIOD },
{ "Slash", KeyboardButton::SLASH },
{ "KeyA", KeyboardButton::A },
{ "KeyB", KeyboardButton::B },
{ "KeyC", KeyboardButton::C },
Expand Down
34 changes: 34 additions & 0 deletions src/device/main_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
#include <errno.h>
#include <stdio.h>

#ifndef KEY_BREAK
#define KEY_BREAK 0x19b
#endif

struct wl_display;
struct wl_proxy;
struct wl_interface;
Expand Down Expand Up @@ -125,6 +129,10 @@ static KeyboardButton::Enum x11_translate_key(KeySym x11_key)
case XK_Insert: return KeyboardButton::INS;
case XK_Delete: return KeyboardButton::DEL;
case XK_End: return KeyboardButton::END;
case XK_Print: return KeyboardButton::PRINT_SCREEN;
case XK_Scroll_Lock: return KeyboardButton::SCROLL_LOCK;
case XK_Pause:
case XK_Break: return KeyboardButton::BREAK;
case XK_Shift_L: return KeyboardButton::SHIFT_LEFT;
case XK_Shift_R: return KeyboardButton::SHIFT_RIGHT;
case XK_Control_L: return KeyboardButton::CTRL_LEFT;
Expand Down Expand Up @@ -197,6 +205,17 @@ static KeyboardButton::Enum x11_translate_key(KeySym x11_key)
case 'x': return KeyboardButton::X;
case 'y': return KeyboardButton::Y;
case 'z': return KeyboardButton::Z;
case XK_grave: return KeyboardButton::BACKTICK;
case XK_minus: return KeyboardButton::MINUS;
case XK_equal: return KeyboardButton::EQUAL;
case XK_bracketleft: return KeyboardButton::OPEN_BRACKET;
case XK_bracketright: return KeyboardButton::CLOSE_BRACKET;
case XK_backslash: return KeyboardButton::BACKSLASH;
case XK_semicolon: return KeyboardButton::SEMICOLON;
case XK_apostrophe: return KeyboardButton::QUOTE;
case XK_comma: return KeyboardButton::COMMA;
case XK_period: return KeyboardButton::PERIOD;
case XK_slash: return KeyboardButton::SLASH;
default: return KeyboardButton::COUNT;
}
}
Expand Down Expand Up @@ -231,6 +250,10 @@ static KeyboardButton::Enum evdev_translate_key(uint32_t key)
case KEY_INSERT: return KeyboardButton::INS;
case KEY_DELETE: return KeyboardButton::DEL;
case KEY_END: return KeyboardButton::END;
case KEY_SYSRQ: return KeyboardButton::PRINT_SCREEN;
case KEY_SCROLLLOCK: return KeyboardButton::SCROLL_LOCK;
case KEY_PAUSE: return KeyboardButton::BREAK;
case KEY_BREAK: return KeyboardButton::BREAK;
case KEY_LEFTSHIFT: return KeyboardButton::SHIFT_LEFT;
case KEY_RIGHTSHIFT: return KeyboardButton::SHIFT_RIGHT;
case KEY_LEFTCTRL: return KeyboardButton::CTRL_LEFT;
Expand Down Expand Up @@ -293,6 +316,17 @@ static KeyboardButton::Enum evdev_translate_key(uint32_t key)
case KEY_X: return KeyboardButton::X;
case KEY_Y: return KeyboardButton::Y;
case KEY_Z: return KeyboardButton::Z;
case KEY_GRAVE: return KeyboardButton::BACKTICK;
case KEY_MINUS: return KeyboardButton::MINUS;
case KEY_EQUAL: return KeyboardButton::EQUAL;
case KEY_LEFTBRACE: return KeyboardButton::OPEN_BRACKET;
case KEY_RIGHTBRACE: return KeyboardButton::CLOSE_BRACKET;
case KEY_BACKSLASH: return KeyboardButton::BACKSLASH;
case KEY_SEMICOLON: return KeyboardButton::SEMICOLON;
case KEY_APOSTROPHE: return KeyboardButton::QUOTE;
case KEY_COMMA: return KeyboardButton::COMMA;
case KEY_DOT: return KeyboardButton::PERIOD;
case KEY_SLASH: return KeyboardButton::SLASH;
default: return KeyboardButton::COUNT;
}
}
Expand Down
192 changes: 103 additions & 89 deletions src/device/main_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,95 +34,109 @@ namespace crown
static KeyboardButton::Enum win_translate_key(s32 winkey)
{
switch (winkey) {
case VK_BACK: return KeyboardButton::BACKSPACE;
case VK_TAB: return KeyboardButton::TAB;
case VK_SPACE: return KeyboardButton::SPACE;
case VK_ESCAPE: return KeyboardButton::ESCAPE;
case VK_RETURN: return KeyboardButton::ENTER;
case VK_F1: return KeyboardButton::F1;
case VK_F2: return KeyboardButton::F2;
case VK_F3: return KeyboardButton::F3;
case VK_F4: return KeyboardButton::F4;
case VK_F5: return KeyboardButton::F5;
case VK_F6: return KeyboardButton::F6;
case VK_F7: return KeyboardButton::F7;
case VK_F8: return KeyboardButton::F8;
case VK_F9: return KeyboardButton::F9;
case VK_F10: return KeyboardButton::F10;
case VK_F11: return KeyboardButton::F11;
case VK_F12: return KeyboardButton::F12;
case VK_HOME: return KeyboardButton::HOME;
case VK_LEFT: return KeyboardButton::LEFT;
case VK_UP: return KeyboardButton::UP;
case VK_RIGHT: return KeyboardButton::RIGHT;
case VK_DOWN: return KeyboardButton::DOWN;
case VK_PRIOR: return KeyboardButton::PAGE_UP;
case VK_NEXT: return KeyboardButton::PAGE_DOWN;
case VK_INSERT: return KeyboardButton::INS;
case VK_DELETE: return KeyboardButton::DEL;
case VK_END: return KeyboardButton::END;
case VK_LSHIFT: return KeyboardButton::SHIFT_LEFT;
case VK_RSHIFT: return KeyboardButton::SHIFT_RIGHT;
case VK_LCONTROL: return KeyboardButton::CTRL_LEFT;
case VK_RCONTROL: return KeyboardButton::CTRL_RIGHT;
case VK_CAPITAL: return KeyboardButton::CAPS_LOCK;
case VK_LMENU: return KeyboardButton::ALT_LEFT;
case VK_RMENU: return KeyboardButton::ALT_RIGHT;
case VK_LWIN: return KeyboardButton::SUPER_LEFT;
case VK_RWIN: return KeyboardButton::SUPER_RIGHT;
case VK_NUMLOCK: return KeyboardButton::NUM_LOCK;
case VK_DECIMAL: return KeyboardButton::NUMPAD_DELETE;
case VK_MULTIPLY: return KeyboardButton::NUMPAD_MULTIPLY;
case VK_ADD: return KeyboardButton::NUMPAD_ADD;
case VK_SUBTRACT: return KeyboardButton::NUMPAD_SUBTRACT;
case VK_DIVIDE: return KeyboardButton::NUMPAD_DIVIDE;
case VK_NUMPAD0: return KeyboardButton::NUMPAD_0;
case VK_NUMPAD1: return KeyboardButton::NUMPAD_1;
case VK_NUMPAD2: return KeyboardButton::NUMPAD_2;
case VK_NUMPAD3: return KeyboardButton::NUMPAD_3;
case VK_NUMPAD4: return KeyboardButton::NUMPAD_4;
case VK_NUMPAD5: return KeyboardButton::NUMPAD_5;
case VK_NUMPAD6: return KeyboardButton::NUMPAD_6;
case VK_NUMPAD7: return KeyboardButton::NUMPAD_7;
case VK_NUMPAD8: return KeyboardButton::NUMPAD_8;
case VK_NUMPAD9: return KeyboardButton::NUMPAD_9;
case '0': return KeyboardButton::NUMBER_0;
case '1': return KeyboardButton::NUMBER_1;
case '2': return KeyboardButton::NUMBER_2;
case '3': return KeyboardButton::NUMBER_3;
case '4': return KeyboardButton::NUMBER_4;
case '5': return KeyboardButton::NUMBER_5;
case '6': return KeyboardButton::NUMBER_6;
case '7': return KeyboardButton::NUMBER_7;
case '8': return KeyboardButton::NUMBER_8;
case '9': return KeyboardButton::NUMBER_9;
case 'A': return KeyboardButton::A;
case 'B': return KeyboardButton::B;
case 'C': return KeyboardButton::C;
case 'D': return KeyboardButton::D;
case 'E': return KeyboardButton::E;
case 'F': return KeyboardButton::F;
case 'G': return KeyboardButton::G;
case 'H': return KeyboardButton::H;
case 'I': return KeyboardButton::I;
case 'J': return KeyboardButton::J;
case 'K': return KeyboardButton::K;
case 'L': return KeyboardButton::L;
case 'M': return KeyboardButton::M;
case 'N': return KeyboardButton::N;
case 'O': return KeyboardButton::O;
case 'P': return KeyboardButton::P;
case 'Q': return KeyboardButton::Q;
case 'R': return KeyboardButton::R;
case 'S': return KeyboardButton::S;
case 'T': return KeyboardButton::T;
case 'U': return KeyboardButton::U;
case 'V': return KeyboardButton::V;
case 'W': return KeyboardButton::W;
case 'X': return KeyboardButton::X;
case 'Y': return KeyboardButton::Y;
case 'Z': return KeyboardButton::Z;
default: return KeyboardButton::COUNT;
case VK_BACK: return KeyboardButton: : BACKSPACE;
case VK_TAB: return KeyboardButton: : TAB;
case VK_SPACE: return KeyboardButton: : SPACE;
case VK_ESCAPE: return KeyboardButton: : ESCAPE;
case VK_RETURN: return KeyboardButton: : ENTER;
case VK_F1: return KeyboardButton: : F1;
case VK_F2: return KeyboardButton: : F2;
case VK_F3: return KeyboardButton: : F3;
case VK_F4: return KeyboardButton: : F4;
case VK_F5: return KeyboardButton: : F5;
case VK_F6: return KeyboardButton: : F6;
case VK_F7: return KeyboardButton: : F7;
case VK_F8: return KeyboardButton: : F8;
case VK_F9: return KeyboardButton: : F9;
case VK_F10: return KeyboardButton: : F10;
case VK_F11: return KeyboardButton: : F11;
case VK_F12: return KeyboardButton: : F12;
case VK_HOME: return KeyboardButton: : HOME;
case VK_LEFT: return KeyboardButton: : LEFT;
case VK_UP: return KeyboardButton: : UP;
case VK_RIGHT: return KeyboardButton: : RIGHT;
case VK_DOWN: return KeyboardButton: : DOWN;
case VK_PRIOR: return KeyboardButton: : PAGE_UP;
case VK_NEXT: return KeyboardButton: : PAGE_DOWN;
case VK_INSERT: return KeyboardButton: : INS;
case VK_DELETE: return KeyboardButton: : DEL;
case VK_END: return KeyboardButton: : END;
case VK_SNAPSHOT: return KeyboardButton: : PRINT_SCREEN;
case VK_SCROLL: return KeyboardButton: : SCROLL_LOCK;
case VK_PAUSE: return KeyboardButton: : BREAK;
case VK_LSHIFT: return KeyboardButton: : SHIFT_LEFT;
case VK_RSHIFT: return KeyboardButton: : SHIFT_RIGHT;
case VK_LCONTROL: return KeyboardButton: : CTRL_LEFT;
case VK_RCONTROL: return KeyboardButton: : CTRL_RIGHT;
case VK_CAPITAL: return KeyboardButton: : CAPS_LOCK;
case VK_LMENU: return KeyboardButton: : ALT_LEFT;
case VK_RMENU: return KeyboardButton: : ALT_RIGHT;
case VK_LWIN: return KeyboardButton: : SUPER_LEFT;
case VK_RWIN: return KeyboardButton: : SUPER_RIGHT;
case VK_NUMLOCK: return KeyboardButton: : NUM_LOCK;
case VK_DECIMAL: return KeyboardButton: : NUMPAD_DELETE;
case VK_MULTIPLY: return KeyboardButton: : NUMPAD_MULTIPLY;
case VK_ADD: return KeyboardButton: : NUMPAD_ADD;
case VK_SUBTRACT: return KeyboardButton: : NUMPAD_SUBTRACT;
case VK_DIVIDE: return KeyboardButton: : NUMPAD_DIVIDE;
case VK_NUMPAD0: return KeyboardButton: : NUMPAD_0;
case VK_NUMPAD1: return KeyboardButton: : NUMPAD_1;
case VK_NUMPAD2: return KeyboardButton: : NUMPAD_2;
case VK_NUMPAD3: return KeyboardButton: : NUMPAD_3;
case VK_NUMPAD4: return KeyboardButton: : NUMPAD_4;
case VK_NUMPAD5: return KeyboardButton: : NUMPAD_5;
case VK_NUMPAD6: return KeyboardButton: : NUMPAD_6;
case VK_NUMPAD7: return KeyboardButton: : NUMPAD_7;
case VK_NUMPAD8: return KeyboardButton: : NUMPAD_8;
case VK_NUMPAD9: return KeyboardButton: : NUMPAD_9;
case '0': return KeyboardButton: : NUMBER_0;
case '1': return KeyboardButton: : NUMBER_1;
case '2': return KeyboardButton: : NUMBER_2;
case '3': return KeyboardButton: : NUMBER_3;
case '4': return KeyboardButton: : NUMBER_4;
case '5': return KeyboardButton: : NUMBER_5;
case '6': return KeyboardButton: : NUMBER_6;
case '7': return KeyboardButton: : NUMBER_7;
case '8': return KeyboardButton: : NUMBER_8;
case '9': return KeyboardButton: : NUMBER_9;
case 'A': return KeyboardButton: : A;
case 'B': return KeyboardButton: : B;
case 'C': return KeyboardButton: : C;
case 'D': return KeyboardButton: : D;
case 'E': return KeyboardButton: : E;
case 'F': return KeyboardButton: : F;
case 'G': return KeyboardButton: : G;
case 'H': return KeyboardButton: : H;
case 'I': return KeyboardButton: : I;
case 'J': return KeyboardButton: : J;
case 'K': return KeyboardButton: : K;
case 'L': return KeyboardButton: : L;
case 'M': return KeyboardButton: : M;
case 'N': return KeyboardButton: : N;
case 'O': return KeyboardButton: : O;
case 'P': return KeyboardButton: : P;
case 'Q': return KeyboardButton: : Q;
case 'R': return KeyboardButton: : R;
case 'S': return KeyboardButton: : S;
case 'T': return KeyboardButton: : T;
case 'U': return KeyboardButton: : U;
case 'V': return KeyboardButton: : V;
case 'W': return KeyboardButton: : W;
case 'X': return KeyboardButton: : X;
case 'Y': return KeyboardButton: : Y;
case 'Z': return KeyboardButton: : Z;
case VK_OEM_3: return KeyboardButton: : BACKTICK;
case VK_OEM_MINUS: return KeyboardButton: : MINUS;
case VK_OEM_PLUS: return KeyboardButton: : EQUAL;
case VK_OEM_4: return KeyboardButton: : OPEN_BRACKET;
case VK_OEM_6: return KeyboardButton: : CLOSE_BRACKET;
case VK_OEM_5: return KeyboardButton: : BACKSLASH;
case VK_OEM_1: return KeyboardButton: : SEMICOLON;
case VK_OEM_7: return KeyboardButton: : QUOTE;
case VK_OEM_COMMA: return KeyboardButton: : COMMA;
case VK_OEM_PERIOD: return KeyboardButton: : PERIOD;
case VK_OEM_2: return KeyboardButton: : SLASH;
default: return KeyboardButton: : COUNT;
}
}

Expand Down
Loading