Added Keymap support
This commit is contained in:
parent
896d6a14da
commit
15837ff4e1
@ -30,7 +30,7 @@
|
||||
|
||||
#include "quinn.h"
|
||||
|
||||
static const int sdl_unicode_shift[] = {
|
||||
static const int SDLK_unicode_shift[] = {
|
||||
0, 0, 0x21, 0x40,
|
||||
0x23, 0x24, 0x25, 0x5e,
|
||||
0x26, 0x2a, 0x28, 0x29,
|
||||
@ -55,7 +55,7 @@ static const int sdl_unicode_shift[] = {
|
||||
0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const int sdl_unicode[] = {
|
||||
static const int SDLK_unicode[] = {
|
||||
0, 0, 0x31, 0x32,
|
||||
0x33, 0x34, 0x35, 0x36,
|
||||
0x37, 0x38, 0x39, 0x30,
|
||||
@ -80,7 +80,7 @@ static const int sdl_unicode[] = {
|
||||
0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const int sdl_keyset[] = {
|
||||
static const int SDLK_keyset[] = {
|
||||
0, SDLK_ESCAPE, SDLK_1, SDLK_2,
|
||||
SDLK_3, SDLK_4, SDLK_5, SDLK_6,
|
||||
SDLK_7, SDLK_8, SDLK_9, SDLK_0,
|
||||
@ -94,17 +94,43 @@ static const int sdl_keyset[] = {
|
||||
SDLK_QUOTE, SDLK_BACKQUOTE, SDLK_LSHIFT, SDLK_BACKSLASH,
|
||||
SDLK_z, SDLK_x, SDLK_c, SDLK_v,
|
||||
SDLK_b, SDLK_n, SDLK_m, SDLK_COMMA,
|
||||
SDLK_PERIOD, SDLK_SLASH, SDLK_RSHIFT, 0,
|
||||
SDLK_PERIOD, SDLK_SLASH, SDLK_RSHIFT, SDLK_KP_MULTIPLY,
|
||||
SDLK_LALT, SDLK_SPACE, SDLK_CAPSLOCK, SDLK_F1,
|
||||
SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5,
|
||||
SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9,
|
||||
SDLK_F10, 0, 0, SDLK_HOME,
|
||||
SDLK_UP, SDLK_PAGEUP, 0, SDLK_LEFT,
|
||||
0, SDLK_RIGHT, 0, SDLK_END,
|
||||
SDLK_DOWN, SDLK_PAGEDOWN, SDLK_INSERT, SDLK_DELETE,
|
||||
SDLK_F10, 0, 0, SDLK_KP7,
|
||||
SDLK_KP8, SDLK_KP9, SDLK_KP_MINUS, SDLK_KP4,
|
||||
SDLK_KP5, SDLK_KP6, SDLK_KP_PLUS, SDLK_KP1,
|
||||
SDLK_KP2, SDLK_KP3, SDLK_KP0, SDLK_KP_PERIOD,
|
||||
0, 0, 0, SDLK_F11, SDLK_F12
|
||||
};
|
||||
|
||||
static const int SDLK_keyset_e0[] = {
|
||||
0, 0, 0, 0, //3
|
||||
0, 0, 0, 0, //7
|
||||
0, 0, 0, 0, //0b
|
||||
0, 0, 0, 0, //0f
|
||||
0, 0, 0, 0, //13
|
||||
0, 0, 0, 0, //17
|
||||
0, 0, 0, 0, //1b
|
||||
SDLK_KP_ENTER, SDLK_RCTRL, 0, 0, //1f
|
||||
0, 0, 0, 0, //23
|
||||
0, 0, 0, 0, //27
|
||||
0, 0, 0, 0, //2b
|
||||
0, 0, 0, 0, //2f
|
||||
0, 0, 0, 0, //33
|
||||
0, SDLK_KP_DIVIDE, 0, 0, //37
|
||||
SDLK_RALT, 0, 0, 0, //3b
|
||||
0, 0, 0, 0, //3f
|
||||
0, 0, 0, 0, //43
|
||||
0, 0, 0, SDLK_HOME, //47
|
||||
SDLK_UP, SDLK_PAGEUP, 0, SDLK_LEFT, //4b
|
||||
0, SDLK_RIGHT, 0, SDLK_END, //4f
|
||||
SDLK_DOWN, SDLK_PAGEDOWN, SDLK_INSERT, SDLK_DELETE, //53
|
||||
0, 0, 0, 0, //57
|
||||
0
|
||||
};
|
||||
|
||||
static SDLKey keymap[256];
|
||||
static SDLMod modstate = KMOD_NONE;
|
||||
|
||||
@ -130,7 +156,7 @@ static int _mmstate = 0;
|
||||
|
||||
static char _k_last_state[256];
|
||||
|
||||
|
||||
static int _k_e0 = 0;
|
||||
|
||||
void QUINN_recv_event(struct window_update_req *req) {
|
||||
memcpy(¤t_req, req, sizeof(struct window_update_req));
|
||||
@ -142,7 +168,7 @@ void QUINN_PumpEvents(_THIS) {
|
||||
int i;
|
||||
int l;
|
||||
if (this->hidden->doexit == 1) {
|
||||
SDL_PrivateQuit();
|
||||
SDLK_PrivateQuit();
|
||||
}
|
||||
|
||||
if (current_req_current) {
|
||||
@ -151,24 +177,38 @@ void QUINN_PumpEvents(_THIS) {
|
||||
// keyboard
|
||||
SDL_keysym keysym;
|
||||
|
||||
if (_k_e0 == 0 && current_req.event_msgs[l].code == 0xe0) {
|
||||
_k_e0 = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_k_last_state[current_req.event_msgs[l].code] != current_req.event_msgs[l].state) {
|
||||
keysym.scancode = current_req.event_msgs[l].code;
|
||||
if (_k_last_state[42] == 1 || _k_last_state[54] == 1) {
|
||||
keysym.unicode = sdl_unicode_shift[current_req.event_msgs[l].code];
|
||||
keysym.unicode = SDLK_unicode_shift[current_req.event_msgs[l].code];
|
||||
} else {
|
||||
keysym.unicode = sdl_unicode[current_req.event_msgs[l].code];
|
||||
keysym.unicode = SDLK_unicode[current_req.event_msgs[l].code];
|
||||
}
|
||||
keysym.mod = make_mod(_k_last_state);
|
||||
|
||||
if (current_req.event_msgs[l].state == 1) {
|
||||
keysym.sym = sdl_keyset[current_req.event_msgs[l].code];
|
||||
if (_k_e0) {
|
||||
keysym.sym = SDLK_keyset_e0[current_req.event_msgs[l].code];
|
||||
} else {
|
||||
keysym.sym = SDLK_keyset[current_req.event_msgs[l].code];
|
||||
}
|
||||
SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
|
||||
} else {
|
||||
// key up
|
||||
keysym.sym = sdl_keyset[current_req.event_msgs[l].code];
|
||||
if (_k_e0) {
|
||||
keysym.sym = SDLK_keyset_e0[current_req.event_msgs[l].code];
|
||||
} else {
|
||||
keysym.sym = SDLK_keyset[current_req.event_msgs[l].code];
|
||||
}
|
||||
SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
|
||||
}
|
||||
}
|
||||
_k_e0 = 0;
|
||||
_k_last_state[current_req.event_msgs[l].code] = current_req.event_msgs[l].state;
|
||||
} else if (current_req.event_msgs[l].type == 2) {
|
||||
// mouse
|
||||
@ -218,4 +258,4 @@ void QUINN_InitOSKeymap(_THIS)
|
||||
memset(_k_last_state, 0, 256);
|
||||
}
|
||||
|
||||
/* end of SDL_nullevents.c ... */
|
||||
/* end of SDLK_nullevents.c ... */
|
||||
|
Loading…
x
Reference in New Issue
Block a user