diff options
-rw-r--r-- | include/mgl/window/key.h | 3 | ||||
-rw-r--r-- | meson.build | 1 | ||||
-rw-r--r-- | src/window/key.c | 110 |
3 files changed, 114 insertions, 0 deletions
diff --git a/include/mgl/window/key.h b/include/mgl/window/key.h index 0cd3c03..c58fbcd 100644 --- a/include/mgl/window/key.h +++ b/include/mgl/window/key.h @@ -109,4 +109,7 @@ typedef enum { __MGL_NUM_KEYS__ } mgl_key; +/* Return NULL if unknown key */ +const char* mgl_key_to_string(mgl_key key); + #endif /* _MGL_KEY_H_ */ diff --git a/meson.build b/meson.build index 5cece60..7369b48 100644 --- a/meson.build +++ b/meson.build @@ -23,6 +23,7 @@ src = [ 'src/system/clock.c', 'src/mgl.c', 'src/window/window.c', + 'src/window/key.c', 'src/gl.c', ] diff --git a/src/window/key.c b/src/window/key.c new file mode 100644 index 0000000..7528a15 --- /dev/null +++ b/src/window/key.c @@ -0,0 +1,110 @@ +#include "../../include/mgl/window/key.h" + +const char* mgl_key_to_string(mgl_key key) { + switch(key) { + case MGL_KEY_UNKNOWN: return 0; + case MGL_KEY_A: return "A"; + case MGL_KEY_B: return "B"; + case MGL_KEY_C: return "C"; + case MGL_KEY_D: return "D"; + case MGL_KEY_E: return "E"; + case MGL_KEY_F: return "F"; + case MGL_KEY_G: return "G"; + case MGL_KEY_H: return "H"; + case MGL_KEY_I: return "I"; + case MGL_KEY_J: return "J"; + case MGL_KEY_K: return "K"; + case MGL_KEY_L: return "L"; + case MGL_KEY_M: return "M"; + case MGL_KEY_N: return "N"; + case MGL_KEY_O: return "O"; + case MGL_KEY_P: return "P"; + case MGL_KEY_Q: return "Q"; + case MGL_KEY_R: return "R"; + case MGL_KEY_S: return "S"; + case MGL_KEY_T: return "T"; + case MGL_KEY_U: return "U"; + case MGL_KEY_V: return "V"; + case MGL_KEY_W: return "W"; + case MGL_KEY_X: return "X"; + case MGL_KEY_Y: return "Y"; + case MGL_KEY_Z: return "Z"; + case MGL_KEY_NUM0: return "Num0"; + case MGL_KEY_NUM1: return "Num1"; + case MGL_KEY_NUM2: return "Num2"; + case MGL_KEY_NUM3: return "Num3"; + case MGL_KEY_NUM4: return "Num4"; + case MGL_KEY_NUM5: return "Num5"; + case MGL_KEY_NUM6: return "Num6"; + case MGL_KEY_NUM7: return "Num7"; + case MGL_KEY_NUM8: return "Num8"; + case MGL_KEY_NUM9: return "Num9"; + case MGL_KEY_ESCAPE: return "Escape"; + case MGL_KEY_LCONTROL: return "Left control"; + case MGL_KEY_LSHIFT: return "Left shift"; + case MGL_KEY_LALT: return "Left alt"; + case MGL_KEY_LSYSTEM: return "Left system"; + case MGL_KEY_RCONTROL: return "Right control"; + case MGL_KEY_RSHIFT: return "Right shift"; + case MGL_KEY_RALT: return "Right alt"; + case MGL_KEY_RSYSTEM: return "Right system"; + case MGL_KEY_MENU: return "Menu"; + case MGL_KEY_LBRACKET: return "["; + case MGL_KEY_RBRACKET: return "]"; + case MGL_KEY_SEMICOLON: return ";"; + case MGL_KEY_COMMA: return ","; + case MGL_KEY_PERIOD: return "."; + case MGL_KEY_QUOTE: return "'"; + case MGL_KEY_SLASH: return "/"; + case MGL_KEY_BACKSLASH: return "\\"; + case MGL_KEY_TILDE: return "~"; + case MGL_KEY_EQUAL: return "="; + case MGL_KEY_HYPHEN: return "-"; + case MGL_KEY_SPACE: return " "; + case MGL_KEY_ENTER: return "Enter"; + case MGL_KEY_BACKSPACE: return "Backspace"; + case MGL_KEY_TAB: return "Tab"; + case MGL_KEY_PAGEUP: return "PageUp"; + case MGL_KEY_PAGEDOWN: return "PageDown"; + case MGL_KEY_END: return "End"; + case MGL_KEY_HOME: return "Home"; + case MGL_KEY_INSERT: return "Insert"; + case MGL_KEY_DELETE: return "Delete"; + case MGL_KEY_ADD: return "Add"; + case MGL_KEY_SUBTRACT: return "Subtract"; + case MGL_KEY_MULTIPLY: return "Multiply"; + case MGL_KEY_DIVIDE: return "Divide"; + case MGL_KEY_LEFT: return "Left"; + case MGL_KEY_RIGHT: return "Right"; + case MGL_KEY_UP: return "Up"; + case MGL_KEY_DOWN: return "Down"; + case MGL_KEY_NUMPAD0: return "Numpad0"; + case MGL_KEY_NUMPAD1: return "Numpad1"; + case MGL_KEY_NUMPAD2: return "Numpad2"; + case MGL_KEY_NUMPAD3: return "Numpad3"; + case MGL_KEY_NUMPAD4: return "Numpad4"; + case MGL_KEY_NUMPAD5: return "Numpad5"; + case MGL_KEY_NUMPAD6: return "Numpad6"; + case MGL_KEY_NUMPAD7: return "Numpad7"; + case MGL_KEY_NUMPAD8: return "Numpad8"; + case MGL_KEY_NUMPAD9: return "Numpad9"; + case MGL_KEY_F1: return "F1"; + case MGL_KEY_F2: return "F2"; + case MGL_KEY_F3: return "F3"; + case MGL_KEY_F4: return "F4"; + case MGL_KEY_F5: return "F5"; + case MGL_KEY_F6: return "F6"; + case MGL_KEY_F7: return "F7"; + case MGL_KEY_F8: return "F8"; + case MGL_KEY_F9: return "F9"; + case MGL_KEY_F10: return "F10"; + case MGL_KEY_F11: return "F11"; + case MGL_KEY_F12: return "F12"; + case MGL_KEY_F13: return "F13"; + case MGL_KEY_F14: return "F14"; + case MGL_KEY_F15: return "F15"; + case MGL_KEY_PAUSE: return "Pause"; + case __MGL_NUM_KEYS__: return 0; + } + return 0; +} |