From 9ebfb36b4e4157315af6399d4d09ab5b9facdd64 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 6 Jun 2017 05:17:25 +0200 Subject: [PATCH] Use rarch_keysym_lut directly --- gfx/drivers_context/wayland_ctx.c | 6 +- input/drivers/dinput.c | 23 +- input/drivers/linuxraw_input.c | 24 +- input/drivers/qnx_input.c | 4 +- input/drivers/rwebinput_input.c | 8 +- input/drivers/sdl_input.c | 27 +-- input/drivers/udev_input.c | 12 +- input/drivers/winraw_input.c | 21 +- input/drivers/x11_input.c | 2 +- .../drivers_keyboard/keyboard_event_android.c | 2 +- input/drivers_keyboard/keyboard_event_apple.c | 210 +++++++++--------- input/drivers_keyboard/keyboard_event_dos.c | 4 +- input/input_keymaps.c | 16 +- input/input_keymaps.h | 13 +- 14 files changed, 163 insertions(+), 209 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 2deee78efb..292cd405fd 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -195,7 +195,7 @@ static void keyboard_handle_key(void *data, return; #endif input_keyboard_event(value, - input_keymaps_translate_keysym_to_rk(key), + rarch_keysym_lut[key], 0, 0, RETRO_DEVICE_KEYBOARD); } @@ -1244,7 +1244,7 @@ bool input_wl_is_pressed(gfx_ctx_wayland_data_t *wl, const struct retro_keybind if (id < RARCH_BIND_LIST_END) { const struct retro_keybind *bind = &binds[id]; - unsigned bit = input_keymaps_translate_rk_to_keysym(binds[id].key); + unsigned bit = rarch_keysym_lut[binds[id].key]; return BIT_GET(wl->key_state, bit); } return false; @@ -1271,7 +1271,7 @@ static int16_t input_wl_analog_pressed(gfx_ctx_wayland_data_t *wl, const struct bool input_wl_state_kb(gfx_ctx_wayland_data_t *wl, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned idx, unsigned id) { - unsigned bit = input_keymaps_translate_rk_to_keysym((enum retro_key)id); + unsigned bit = rarch_keysym_lut[(enum retro_key)id]; return id < RETROK_LAST && BIT_GET(wl->key_state, bit); } diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 9443d93717..909a8b96a8 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -267,12 +267,7 @@ static void dinput_poll(void *data) static bool dinput_keyboard_pressed(struct dinput_input *di, unsigned key) { - unsigned sym; - - if (key >= RETROK_LAST) - return false; - - sym = input_keymaps_translate_rk_to_keysym((enum retro_key)key); + unsigned sym = rarch_keysym_lut[(enum retro_key)key]; return di->state[sym] & 0x80; } @@ -283,10 +278,7 @@ static bool dinput_is_pressed(struct dinput_input *di, { const struct retro_keybind *bind = &binds[id]; - if (id >= RARCH_BIND_LIST_END) - return false; - - if (!di->blocked && dinput_keyboard_pressed(di, bind->key)) + if (!di->blocked && (bind->key < RETROK_LAST) && dinput_keyboard_pressed(di, bind->key)) return true; if (binds && binds[id].valid && input_joypad_pressed(di->joypad, joypad_info, port, binds, id)) return true; @@ -310,9 +302,9 @@ static int16_t dinput_pressed_analog(struct dinput_input *di, if (!bind_minus->valid || !bind_plus->valid) return 0; - if (dinput_keyboard_pressed(di, bind_minus->key)) + if ((bind_minus->key < RETROK_LAST) && dinput_keyboard_pressed(di, bind_minus->key)) pressed_minus = -0x7fff; - if (dinput_keyboard_pressed(di, bind_plus->key)) + if ((bind_plus->key < RETROK_LAST) && dinput_keyboard_pressed(di, bind_plus->key)) pressed_plus = 0x7fff; return pressed_plus + pressed_minus; @@ -485,10 +477,11 @@ static int16_t dinput_input_state(void *data, switch (device) { case RETRO_DEVICE_JOYPAD: - return dinput_is_pressed(di, joypad_info, binds[port], port, id); + if (id < RARCH_BIND_LIST_END) + return dinput_is_pressed(di, joypad_info, binds[port], port, id); + break; case RETRO_DEVICE_KEYBOARD: - return dinput_keyboard_pressed(di, id); - + return (id < RETROK_LAST) && dinput_keyboard_pressed(di, id); case RETRO_DEVICE_ANALOG: if (binds[port]) { diff --git a/input/drivers/linuxraw_input.c b/input/drivers/linuxraw_input.c index 0a7553b07a..8fd73715ab 100644 --- a/input/drivers/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -73,21 +73,12 @@ static void *linuxraw_input_init(const char *joypad_driver) return linuxraw; } -static bool linuxraw_key_pressed(linuxraw_input_t *linuxraw, int key) -{ - unsigned sym = input_keymaps_translate_rk_to_keysym((enum retro_key)key); - return linuxraw->state[sym]; -} - static bool linuxraw_is_pressed(linuxraw_input_t *linuxraw, const struct retro_keybind *binds, unsigned id) { - const struct retro_keybind *bind = binds ? &binds[id] : NULL; - - if (id >= RARCH_BIND_LIST_END) - return false; - - return bind && bind->valid && linuxraw_key_pressed(linuxraw, binds[id].key); + const struct retro_keybind *bind = &binds[id]; + unsigned sym = rarch_keysym_lut[(enum retro_key)binds[id].key]; + return linuxraw->state[sym]; } static int16_t linuxraw_analog_pressed(linuxraw_input_t *linuxraw, @@ -99,9 +90,11 @@ static int16_t linuxraw_analog_pressed(linuxraw_input_t *linuxraw, input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus); - if (linuxraw_is_pressed(linuxraw, binds, id_minus)) + if ((id_minus < RARCH_BIND_LIST_END) && binds && binds->valid && + linuxraw_is_pressed(linuxraw, binds, id_minus)) pressed_minus = -0x7fff; - if (linuxraw_is_pressed(linuxraw, binds, id_plus)) + if ((id_plus < RARCH_BIND_LIST_END) && binds && binds->valid && + linuxraw_is_pressed(linuxraw, binds, id_plus)) pressed_plus = 0x7fff; return pressed_plus + pressed_minus; @@ -123,7 +116,8 @@ static int16_t linuxraw_input_state(void *data, switch (device) { case RETRO_DEVICE_JOYPAD: - return linuxraw_is_pressed(linuxraw, binds[port], id) || + return ((id < RARCH_BIND_LIST_END) && binds[port]->valid && + linuxraw_is_pressed(linuxraw, binds[port], id)) || input_joypad_pressed(linuxraw->joypad, joypad_info, port, binds[port], id); case RETRO_DEVICE_ANALOG: if (binds[port]) diff --git a/input/drivers/qnx_input.c b/input/drivers/qnx_input.c index 6e15030001..ec1c97f727 100644 --- a/input/drivers/qnx_input.c +++ b/input/drivers/qnx_input.c @@ -725,9 +725,9 @@ static void qnx_input_poll(void *data) } } -bool qnx_keyboard_pressed(qnx_input_t *qnx, unsigned id) +static bool qnx_keyboard_pressed(qnx_input_t *qnx, unsigned id) { - unsigned bit = input_keymaps_translate_rk_to_keysym((enum retro_key)id); + unsigned bit = rarch_keysym_lut[(enum retro_key)id]; return id < RETROK_LAST && BIT_GET(qnx->keyboard_state, bit); } diff --git a/input/drivers/rwebinput_input.c b/input/drivers/rwebinput_input.c index 450dbc700d..527a65695c 100644 --- a/input/drivers/rwebinput_input.c +++ b/input/drivers/rwebinput_input.c @@ -69,7 +69,7 @@ error: return NULL; } -static bool rwebinput_key_pressed__(void *data, int key) +static bool rwebinput_key_pressed_internal(void *data, int key) { unsigned sym; bool ret; @@ -78,7 +78,7 @@ static bool rwebinput_key_pressed__(void *data, int key) if (key >= RETROK_LAST) return false; - sym = input_keymaps_translate_rk_to_keysym((enum retro_key)key); + sym = rarch_keysym_lut[(enum retro_key)key]; ret = rwebinput->state.keys[sym >> 3] & (1 << (sym & 7)); return ret; @@ -97,7 +97,9 @@ static bool rwebinput_is_pressed(rwebinput_input_t *rwebinput, if (id < RARCH_BIND_LIST_END) { const struct retro_keybind *bind = &binds[id]; - return bind->valid && rwebinput_key_pressed__(rwebinput, binds[id].key); + int key = binds[id].key; + return bind->valid && (key < RETROK_LAST) + && rwebinput_key_pressed_internal(rwebinput, key); } return false; diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index 096c11c8d6..0f1adce46f 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -61,29 +61,24 @@ static void *sdl_input_init(const char *joypad_driver) static bool sdl_key_pressed(int key) { int num_keys; - const uint8_t *keymap; - unsigned sym; - - if (key >= RETROK_LAST) - return false; - - sym = input_keymaps_translate_rk_to_keysym((enum retro_key)key); - + unsigned sym = rarch_keysym_lut[(enum retro_key)key]; #ifdef HAVE_SDL2 - sym = SDL_GetScancodeFromKey(sym); - keymap = SDL_GetKeyboardState(&num_keys); + const uint8_t *keymap = SDL_GetKeyboardState(&num_keys); + sym = SDL_GetScancodeFromKey(sym); #else - keymap = SDL_GetKeyState(&num_keys); + const uint8_t *keymap = SDL_GetKeyState(&num_keys); #endif + if (sym >= (unsigned)num_keys) return false; return keymap[sym]; } -static bool sdl_is_pressed(sdl_input_t *sdl, unsigned port_num, const struct retro_keybind *binds, unsigned key) +static bool sdl_is_pressed(sdl_input_t *sdl, unsigned port_num, + const struct retro_keybind *binds, unsigned key) { - if (sdl_key_pressed(binds[key].key)) + if ((binds[key].key < RETROK_LAST) && sdl_key_pressed(binds[key].key)) return true; return false; } @@ -97,9 +92,9 @@ static int16_t sdl_analog_pressed(sdl_input_t *sdl, const struct retro_keybind * input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus); - if (sdl_key_pressed(binds[id_minus].key)) + if ((binds[id_minus].key < RETROK_LAST) && sdl_key_pressed(binds[id_minus].key)) pressed_minus = -0x7fff; - if (sdl_key_pressed(binds[id_plus].key)) + if ((binds[id_plus].key < RETROK_LAST) && sdl_key_pressed(binds[id_plus].key)) pressed_plus = 0x7fff; return pressed_plus + pressed_minus; @@ -148,7 +143,7 @@ static int16_t sdl_analog_device_state(sdl_input_t *sdl, static int16_t sdl_keyboard_device_state(sdl_input_t *sdl, unsigned id) { - return sdl_key_pressed(id); + return (id < RETROK_LAST) && sdl_key_pressed(id); } static int16_t sdl_mouse_device_state(sdl_input_t *sdl, unsigned id) diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index c1e652bc7e..843047dc8d 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -583,11 +583,11 @@ static int16_t udev_analog_pressed(const struct retro_keybind *binds, if (binds && binds[id_minus].valid && BIT_GET(udev_key_state, - input_keymaps_translate_rk_to_keysym(binds[id_minus].key))) + rarch_keysym_lut[binds[id_minus].key])) pressed_minus = -0x7fff; if (binds && binds[id_plus].valid && BIT_GET(udev_key_state, - input_keymaps_translate_rk_to_keysym(binds[id_plus].key))) + rarch_keysym_lut[binds[id_plus].key])) pressed_plus = 0x7fff; return pressed_plus + pressed_minus; @@ -661,14 +661,12 @@ static int16_t udev_input_state(void *data, unsigned port, unsigned device, unsigned idx, unsigned id) { int16_t ret; - unsigned bit; udev_input_t *udev = (udev_input_t*)data; switch (device) { case RETRO_DEVICE_JOYPAD: - bit = input_keymaps_translate_rk_to_keysym(binds[port][id].key); - if (BIT_GET(udev_key_state, bit)) + if (BIT_GET(udev_key_state, rarch_keysym_lut[binds[port][id].key])) return true; return input_joypad_pressed(udev->joypad, joypad_info, port, binds[port], id); @@ -679,8 +677,8 @@ static int16_t udev_input_state(void *data, joypad_info, port, idx, id, binds[port]); return ret; case RETRO_DEVICE_KEYBOARD: - bit = input_keymaps_translate_rk_to_keysym((enum retro_key)id); - return id < RETROK_LAST && BIT_GET(udev_key_state, bit); + return id < RETROK_LAST && BIT_GET(udev_key_state, + rarch_keysym_lut[(enum retro_key)id]); case RETRO_DEVICE_MOUSE: return udev_mouse_state(udev, port, id, false); case RARCH_DEVICE_MOUSE_SCREEN: diff --git a/input/drivers/winraw_input.c b/input/drivers/winraw_input.c index 404ee24505..6c61295814 100644 --- a/input/drivers/winraw_input.c +++ b/input/drivers/winraw_input.c @@ -230,17 +230,6 @@ static bool winraw_set_mouse_input(HWND window, bool grab) return true; } -static int16_t winraw_keyboard_state(winraw_input_t *wr, unsigned id) -{ - unsigned key; - - if (id >= RETROK_LAST) - return 0; - - key = input_keymaps_translate_rk_to_keysym((enum retro_key)id); - return wr->keyboard.keys[key]; -} - static int16_t winraw_mouse_state(winraw_mouse_t *mouse, bool abs, unsigned id) { switch (id) @@ -270,8 +259,9 @@ static int16_t winraw_joypad_state(winraw_input_t *wr, unsigned port, unsigned id) { const struct retro_keybind *bind = &binds[id]; + unsigned key = rarch_keysym_lut[(enum retro_key)bind->key]; - if (!wr->kbd_mapp_block && winraw_keyboard_state(wr, bind->key)) + if (!wr->kbd_mapp_block && (bind->key < RETROK_LAST) && wr->keyboard.keys[key]) return 1; return input_joypad_pressed(wr->joypad, joypad_info, port, binds, id); @@ -486,7 +476,12 @@ static int16_t winraw_input_state(void *d, switch (device) { case RETRO_DEVICE_KEYBOARD: - return winraw_keyboard_state(wr, id); + if (id < RETROK_LAST) + { + unsigned key = rarch_keysym_lut[(enum retro_key)id]; + return wr->keyboard.keys[key] + } + break; case RETRO_DEVICE_MOUSE: if (port < g_mouse_cnt) return winraw_mouse_state(&wr->mice[port], false, id); diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index 4932a11d02..5efb9b72ca 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -75,7 +75,7 @@ static void *x_input_init(const char *joypad_driver) static bool x_key_pressed(x11_input_t *x11, int key) { - unsigned sym = input_keymaps_translate_rk_to_keysym((enum retro_key)key); + unsigned sym = rarch_keysym_lut[(enum retro_key)key]; int keycode = XKeysymToKeycode(x11->display, sym); return x11->state[keycode >> 3] & (1 << (keycode & 7)); diff --git a/input/drivers_keyboard/keyboard_event_android.c b/input/drivers_keyboard/keyboard_event_android.c index 0a39d89988..cd7b7e27dd 100644 --- a/input/drivers_keyboard/keyboard_event_android.c +++ b/input/drivers_keyboard/keyboard_event_android.c @@ -31,7 +31,7 @@ bool android_keyboard_port_input_pressed(const struct retro_keybind *binds, unsi if (id < RARCH_BIND_LIST_END) { const struct retro_keybind *bind = &binds[id]; - unsigned bit = input_keymaps_translate_rk_to_keysym(bind->key); + unsigned bit = rarch_keysym_lut[bind->key]; return BIT_GET(android_key_state[ANDROID_KEYBOARD_PORT], bit); } return false; diff --git a/input/drivers_keyboard/keyboard_event_apple.c b/input/drivers_keyboard/keyboard_event_apple.c index 4373204562..f2a7ba6c93 100644 --- a/input/drivers_keyboard/keyboard_event_apple.c +++ b/input/drivers_keyboard/keyboard_event_apple.c @@ -144,119 +144,119 @@ static bool handle_icade_event(unsigned *code, bool *keydown) /* iPega PG-9017 */ j = 1; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_s; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_s; + icade_maps[j][rarch_keysym_lut[RETROK_a]].key = RETROK_LEFT; + icade_maps[j][rarch_keysym_lut[RETROK_q]].key = RETROK_LEFT; + icade_maps[j][rarch_keysym_lut[RETROK_c]].key = RETROK_RIGHT; + icade_maps[j][rarch_keysym_lut[RETROK_d]].key = RETROK_RIGHT; + icade_maps[j][rarch_keysym_lut[RETROK_e]].key = RETROK_UP; + icade_maps[j][rarch_keysym_lut[RETROK_w]].key = RETROK_UP; + icade_maps[j][rarch_keysym_lut[RETROK_x]].key = RETROK_DOWN; + icade_maps[j][rarch_keysym_lut[RETROK_z]].key = RETROK_DOWN; + icade_maps[j][rarch_keysym_lut[RETROK_f]].key = RETROK_z; + icade_maps[j][rarch_keysym_lut[RETROK_u]].key = RETROK_z; + icade_maps[j][rarch_keysym_lut[RETROK_i]].key = RETROK_q; + icade_maps[j][rarch_keysym_lut[RETROK_m]].key = RETROK_q; + icade_maps[j][rarch_keysym_lut[RETROK_j]].key = RETROK_a; + icade_maps[j][rarch_keysym_lut[RETROK_n]].key = RETROK_a; + icade_maps[j][rarch_keysym_lut[RETROK_k]].key = RETROK_w; + icade_maps[j][rarch_keysym_lut[RETROK_p]].key = RETROK_w; + icade_maps[j][rarch_keysym_lut[RETROK_h]].key = RETROK_x; + icade_maps[j][rarch_keysym_lut[RETROK_r]].key = RETROK_x; + icade_maps[j][rarch_keysym_lut[RETROK_y]].key = RETROK_s; + icade_maps[j][rarch_keysym_lut[RETROK_t]].key = RETROK_s; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_e]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_z]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_q]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_c]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_f]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_m]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_t]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_n]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_p]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_r]].up = true; /* 8-bitty */ j = 2; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_RSHIFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_RSHIFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_RETURN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_RETURN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_l)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_o)].key = RETROK_s; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].key = RETROK_s; + icade_maps[j][rarch_keysym_lut[RETROK_a]].key = RETROK_LEFT; + icade_maps[j][rarch_keysym_lut[RETROK_q]].key = RETROK_LEFT; + icade_maps[j][rarch_keysym_lut[RETROK_c]].key = RETROK_RIGHT; + icade_maps[j][rarch_keysym_lut[RETROK_d]].key = RETROK_RIGHT; + icade_maps[j][rarch_keysym_lut[RETROK_e]].key = RETROK_UP; + icade_maps[j][rarch_keysym_lut[RETROK_w]].key = RETROK_UP; + icade_maps[j][rarch_keysym_lut[RETROK_x]].key = RETROK_DOWN; + icade_maps[j][rarch_keysym_lut[RETROK_z]].key = RETROK_DOWN; + icade_maps[j][rarch_keysym_lut[RETROK_h]].key = RETROK_q; + icade_maps[j][rarch_keysym_lut[RETROK_r]].key = RETROK_q; + icade_maps[j][rarch_keysym_lut[RETROK_j]].key = RETROK_w; + icade_maps[j][rarch_keysym_lut[RETROK_n]].key = RETROK_w; + icade_maps[j][rarch_keysym_lut[RETROK_i]].key = RETROK_a; + icade_maps[j][rarch_keysym_lut[RETROK_m]].key = RETROK_a; + icade_maps[j][rarch_keysym_lut[RETROK_k]].key = RETROK_z; + icade_maps[j][rarch_keysym_lut[RETROK_p]].key = RETROK_z; + icade_maps[j][rarch_keysym_lut[RETROK_y]].key = RETROK_RSHIFT; + icade_maps[j][rarch_keysym_lut[RETROK_t]].key = RETROK_RSHIFT; + icade_maps[j][rarch_keysym_lut[RETROK_u]].key = RETROK_RETURN; + icade_maps[j][rarch_keysym_lut[RETROK_f]].key = RETROK_RETURN; + icade_maps[j][rarch_keysym_lut[RETROK_l]].key = RETROK_x; + icade_maps[j][rarch_keysym_lut[RETROK_v]].key = RETROK_x; + icade_maps[j][rarch_keysym_lut[RETROK_o]].key = RETROK_s; + icade_maps[j][rarch_keysym_lut[RETROK_g]].key = RETROK_s; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_e]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_z]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_q]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_c]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_r]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_n]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_m]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_p]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_t]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_f]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_v]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_g]].up = true; /* SNES30 8bitDo */ j = 3; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_w)].key = RETROK_UP; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_x)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].key = RETROK_DOWN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_a)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].key = RETROK_LEFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_d)].key = RETROK_RIGHT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_u)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].key = RETROK_x; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_h)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].key = RETROK_z; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_y)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].key = RETROK_a; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_j)].key = RETROK_s; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].key = RETROK_s; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_k)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].key = RETROK_q; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_i)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].key = RETROK_w; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_l)].key = RETROK_RSHIFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].key = RETROK_RSHIFT; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_o)].key = RETROK_RETURN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].key = RETROK_RETURN; + icade_maps[j][rarch_keysym_lut[RETROK_e]].key = RETROK_UP; + icade_maps[j][rarch_keysym_lut[RETROK_w]].key = RETROK_UP; + icade_maps[j][rarch_keysym_lut[RETROK_x]].key = RETROK_DOWN; + icade_maps[j][rarch_keysym_lut[RETROK_z]].key = RETROK_DOWN; + icade_maps[j][rarch_keysym_lut[RETROK_a]].key = RETROK_LEFT; + icade_maps[j][rarch_keysym_lut[RETROK_q]].key = RETROK_LEFT; + icade_maps[j][rarch_keysym_lut[RETROK_c]].key = RETROK_RIGHT; + icade_maps[j][rarch_keysym_lut[RETROK_d]].key = RETROK_RIGHT; + icade_maps[j][rarch_keysym_lut[RETROK_u]].key = RETROK_x; + icade_maps[j][rarch_keysym_lut[RETROK_f]].key = RETROK_x; + icade_maps[j][rarch_keysym_lut[RETROK_h]].key = RETROK_z; + icade_maps[j][rarch_keysym_lut[RETROK_r]].key = RETROK_z; + icade_maps[j][rarch_keysym_lut[RETROK_y]].key = RETROK_a; + icade_maps[j][rarch_keysym_lut[RETROK_t]].key = RETROK_a; + icade_maps[j][rarch_keysym_lut[RETROK_j]].key = RETROK_s; + icade_maps[j][rarch_keysym_lut[RETROK_n]].key = RETROK_s; + icade_maps[j][rarch_keysym_lut[RETROK_k]].key = RETROK_q; + icade_maps[j][rarch_keysym_lut[RETROK_p]].key = RETROK_q; + icade_maps[j][rarch_keysym_lut[RETROK_i]].key = RETROK_w; + icade_maps[j][rarch_keysym_lut[RETROK_m]].key = RETROK_w; + icade_maps[j][rarch_keysym_lut[RETROK_l]].key = RETROK_RSHIFT; + icade_maps[j][rarch_keysym_lut[RETROK_v]].key = RETROK_RSHIFT; + icade_maps[j][rarch_keysym_lut[RETROK_o]].key = RETROK_RETURN; + icade_maps[j][rarch_keysym_lut[RETROK_g]].key = RETROK_RETURN; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_v)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_g)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_e)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_z)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_q)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_c)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_r)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_f)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_n)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_t)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_p)].up = true; - icade_maps[j][input_keymaps_translate_rk_to_keysym(RETROK_m)].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_v]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_g]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_e]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_z]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_q]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_c]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_r]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_f]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_n]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_t]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_p]].up = true; + icade_maps[j][rarch_keysym_lut[RETROK_m]].up = true; initialized = true; } @@ -265,7 +265,7 @@ static bool handle_icade_event(unsigned *code, bool *keydown) { *keydown = icade_maps[kb_type_idx][*code].up ? false : true; ret = true; - *code = input_keymaps_translate_rk_to_keysym(icade_maps[kb_type_idx][*code].key); + *code = rarch_keysym_lut[icade_maps[kb_type_idx][*code].key]; } return ret; @@ -312,7 +312,7 @@ int16_t apple_input_is_pressed(unsigned port_num, if (id < RARCH_BIND_LIST_END) { const struct retro_keybind *bind = &binds[id]; - unsigned bit = input_keymaps_translate_rk_to_keysym(bind->key); + unsigned bit = rarch_keysym_lut[bind->key]; return apple_key_state[bit]; } return 0; @@ -320,7 +320,7 @@ int16_t apple_input_is_pressed(unsigned port_num, int16_t apple_keyboard_state(unsigned id) { - unsigned bit = input_keymaps_translate_rk_to_keysym((enum retro_key)id); + unsigned bit = rarch_keysym_lut[(enum retro_key)id]; return (id < RETROK_LAST) && apple_key_state[bit]; } diff --git a/input/drivers_keyboard/keyboard_event_dos.c b/input/drivers_keyboard/keyboard_event_dos.c index f7f8f373ef..f9b76ad4a6 100644 --- a/input/drivers_keyboard/keyboard_event_dos.c +++ b/input/drivers_keyboard/keyboard_event_dos.c @@ -29,7 +29,7 @@ bool dos_keyboard_port_input_pressed(const struct retro_keybind *binds, unsigned if (id < RARCH_BIND_LIST_END) { const struct retro_keybind *bind = &binds[id]; - unsigned key = input_keymaps_translate_rk_to_keysym(bind->key); + unsigned key = rarch_keysym_lut[bind->key]; return dos_key_state[DOS_KEYBOARD_PORT][key]; } return false; @@ -37,7 +37,7 @@ bool dos_keyboard_port_input_pressed(const struct retro_keybind *binds, unsigned bool dos_keyboard_input_pressed(unsigned key) { - unsigned keysym = input_keymaps_translate_rk_to_keysym(key); + unsigned keysym = rarch_keysym_lut[key]; return dos_key_state[DOS_KEYBOARD_PORT][keysym]; } diff --git a/input/input_keymaps.c b/input/input_keymaps.c index 0b9c2600de..2cba560a49 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -1631,7 +1631,7 @@ const struct rarch_key_map rarch_key_map_winraw[] = { }; #endif -static enum retro_key rarch_keysym_lut[RETROK_LAST]; +enum retro_key rarch_keysym_lut[RETROK_LAST]; /** * input_keymaps_init_keyboard_lut: @@ -1703,17 +1703,3 @@ void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t siz break; } } - -/** - * input_keymaps_translate_rk_to_keysym: - * @key : Retro key identifier - * - * Translates a retro key identifier to a key symbol - * from the keyboard layout table. - * - * Returns: key symbol from the keyboard layout table. - **/ -unsigned input_keymaps_translate_rk_to_keysym(enum retro_key key) -{ - return rarch_keysym_lut[key]; -} diff --git a/input/input_keymaps.h b/input/input_keymaps.h index 001727a760..a42f915734 100644 --- a/input/input_keymaps.h +++ b/input/input_keymaps.h @@ -80,17 +80,6 @@ void input_keymaps_init_keyboard_lut(const struct rarch_key_map *map); **/ enum retro_key input_keymaps_translate_keysym_to_rk(unsigned sym); -/** - * input_keymaps_translate_rk_to_keysym: - * @key : Retro key identifier - * - * Translates a retro key identifier to a key symbol - * from the keyboard layout table. - * - * Returns: key symbol from the keyboard layout table. - **/ -unsigned input_keymaps_translate_rk_to_keysym(enum retro_key key); - /** * input_keymaps_translate_rk_to_str: * @key : Retro key identifier. @@ -102,6 +91,8 @@ unsigned input_keymaps_translate_rk_to_keysym(enum retro_key key); **/ void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t size); +enum retro_key rarch_keysym_lut[RETROK_LAST]; + RETRO_END_DECLS #endif