mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-17 14:22:00 +00:00
Update keycodes for SDL
This commit is contained in:
+13
-3
@@ -103,10 +103,20 @@ int sdlinput_handle_event(SDL_Event* event) {
|
|||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
button = event->key.keysym.sym;
|
button = event->key.keysym.sym;
|
||||||
if (button >= (0x40000000 + 0x39) && button < (0x40000000 + 0x39 + sizeof(keyCodes)))
|
if (button >= 0x21 && button <= 0x2f)
|
||||||
button = keyCodes[button - 0x40000039];
|
button = keyCodes1[button - 0x21];
|
||||||
else if (button >= 0x61)
|
else if (button >= 0x3a && button <= 0x40)
|
||||||
|
button = keyCodes2[button - 0x3a];
|
||||||
|
else if (button >= 0x5b && button <= 0x60)
|
||||||
|
button = keyCodes3[button - 0x5b];
|
||||||
|
else if (button >= 0x40000039 && button < 0x40000039 + sizeof(keyCodes4))
|
||||||
|
button = keyCodes4[button - 0x40000039];
|
||||||
|
else if (button >= 0x400000E0 && button <= 0x400000E7)
|
||||||
|
button = keyCodes5[button - 0x400000E0];
|
||||||
|
else if (button >= 0x61 && button <= 0x7a)
|
||||||
button -= 0x20;
|
button -= 0x20;
|
||||||
|
else if (button == 0x7f)
|
||||||
|
button = 0x2e;
|
||||||
|
|
||||||
int modifier = 0;
|
int modifier = 0;
|
||||||
switch (event->key.keysym.sym) {
|
switch (event->key.keysym.sym) {
|
||||||
|
|||||||
+49
-1
@@ -22,7 +22,44 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
static const short keyCodes[] = {
|
static const short keyCodes1[] = {
|
||||||
|
0, //SDLK_EXCLAIM
|
||||||
|
0, //SDLK_QUOTEDBL
|
||||||
|
0, //SDLK_HASH
|
||||||
|
0, //SDLK_DOLLAR
|
||||||
|
0, //SDLK_PERCENT
|
||||||
|
0, //SDLK_AMPERSAND
|
||||||
|
0xDE, //SDLK_QUOTE
|
||||||
|
0, //SDLK_LEFTPAREN
|
||||||
|
0, //SDLK_RIGHTPAREN
|
||||||
|
0, //SDLK_ASTERISK
|
||||||
|
0, //SDLK_PLUS
|
||||||
|
0xBC, //SDLK_COMMA
|
||||||
|
0xBD, //SDLK_MINUS
|
||||||
|
0xBE, //SDLK_PERIOD
|
||||||
|
0xBF, //SDLK_SLASH
|
||||||
|
};
|
||||||
|
|
||||||
|
static const short keyCodes2[] = {
|
||||||
|
0, //SDLK_COLON
|
||||||
|
0xBA, //SDLK_SEMICOLON
|
||||||
|
0, //SDLK_LESS
|
||||||
|
0xBB, //SDLK_EQUALS
|
||||||
|
0, //SDLK_GREATER
|
||||||
|
0, //SDLK_QUESTION
|
||||||
|
0, //SDLK_AT
|
||||||
|
};
|
||||||
|
|
||||||
|
static const short keyCodes3[] = {
|
||||||
|
0xDB, //SDLK_LEFTBRACKET
|
||||||
|
0xDC, //SDLK_BACKSLASH
|
||||||
|
0xDD, //SDLK_RIGHTBRACKET
|
||||||
|
0, //SDLK_CARET
|
||||||
|
0, //SDLK_UNDERSCORE
|
||||||
|
0xC0, //SDLK_BACKQUOTE
|
||||||
|
};
|
||||||
|
|
||||||
|
static const short keyCodes4[] = {
|
||||||
0x14, //SDLK_CAPSLOCK
|
0x14, //SDLK_CAPSLOCK
|
||||||
0x70, //SDLK_F1
|
0x70, //SDLK_F1
|
||||||
0x71, //SDLK_F2
|
0x71, //SDLK_F2
|
||||||
@@ -51,6 +88,17 @@ static const short keyCodes[] = {
|
|||||||
0x26, //SDLK_UP
|
0x26, //SDLK_UP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const short keyCodes5[] = {
|
||||||
|
0x11, //SDLK_LCTRL
|
||||||
|
0x10, //SDLK_LSHIFT
|
||||||
|
0x12, //SDLK_LALT
|
||||||
|
0x5B, //SDLK_LGUI
|
||||||
|
0x11, //SDLK_LRCTRL
|
||||||
|
0x10, //SDLK_RSHIFT
|
||||||
|
0x12, //SDLK_RALT
|
||||||
|
0x5C, //SDLK_RGUI
|
||||||
|
};
|
||||||
|
|
||||||
void sdlinput_init(char* mappings);
|
void sdlinput_init(char* mappings);
|
||||||
int sdlinput_handle_event(SDL_Event* event);
|
int sdlinput_handle_event(SDL_Event* event);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user