mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-16 23:37:11 +00:00
Keyboard input overlays can now be used as input device
for keyboard line events
This commit is contained in:
parent
0373e6490f
commit
f258950bcf
@ -77,10 +77,12 @@ void apple_rarch_exited(void)
|
||||
mod |= RETROKMOD_NUMLOCK;
|
||||
|
||||
for (i = 1; i < ch.length; i ++)
|
||||
apple_input_keyboard_event(event_type == NSKeyDown, 0, [ch characterAtIndex:i], mod);
|
||||
apple_input_keyboard_event(event_type == NSKeyDown,
|
||||
0, [ch characterAtIndex:i], mod, false);
|
||||
}
|
||||
|
||||
apple_input_keyboard_event(event_type == NSKeyDown, event.keyCode, character, mod);
|
||||
apple_input_keyboard_event(event_type == NSKeyDown,
|
||||
event.keyCode, character, mod, false);
|
||||
}
|
||||
break;
|
||||
case NSFlagsChanged:
|
||||
@ -90,7 +92,8 @@ void apple_rarch_exited(void)
|
||||
bool down = (new_flags & old_flags) == old_flags;
|
||||
old_flags = new_flags;
|
||||
|
||||
apple_input_keyboard_event(down, event.keyCode, 0, event.modifierFlags);
|
||||
apple_input_keyboard_event(down, event.keyCode,
|
||||
0, event.modifierFlags, false);
|
||||
}
|
||||
break;
|
||||
case NSMouseMoved:
|
||||
|
@ -176,13 +176,16 @@ enum
|
||||
if (ch && ch.length != 0)
|
||||
{
|
||||
character = [ch characterAtIndex:0];
|
||||
apple_input_keyboard_event(event._isKeyDown, (uint32_t)event._keyCode, 0, mod);
|
||||
apple_input_keyboard_event(event._isKeyDown,
|
||||
(uint32_t)event._keyCode, 0, mod, false);
|
||||
|
||||
for (i = 1; i < ch.length; i++)
|
||||
apple_input_keyboard_event(event._isKeyDown, 0, [ch characterAtIndex:i], mod);
|
||||
apple_input_keyboard_event(event._isKeyDown,
|
||||
0, [ch characterAtIndex:i], mod, false);
|
||||
}
|
||||
|
||||
apple_input_keyboard_event(event._isKeyDown, (uint32_t)event._keyCode, character, mod);
|
||||
apple_input_keyboard_event(event._isKeyDown,
|
||||
(uint32_t)event._keyCode, character, mod, false);
|
||||
}
|
||||
|
||||
return [super _keyCommandForEvent:event];
|
||||
@ -205,7 +208,8 @@ enum
|
||||
int eventType = eventMem ? *(int*)&eventMem[8] : 0;
|
||||
|
||||
if (eventType == GSEVENT_TYPE_KEYDOWN || eventType == GSEVENT_TYPE_KEYUP)
|
||||
apple_input_keyboard_event(eventType == GSEVENT_TYPE_KEYDOWN, *(uint16_t*)&eventMem[0x3C], 0, 0);
|
||||
apple_input_keyboard_event(eventType == GSEVENT_TYPE_KEYDOWN,
|
||||
*(uint16_t*)&eventMem[0x3C], 0, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,9 @@ static void rwebinput_input_poll(void *data)
|
||||
for (k = 0; diff; diff >>= 1, k++)
|
||||
{
|
||||
if (diff & 1)
|
||||
input_keyboard_event((state->keys[i] & (1 << k)) != 0, input_keymaps_translate_keysym_to_rk(i * 8 + k), 0, 0);
|
||||
input_keyboard_event((state->keys[i] & (1 << k)) != 0,
|
||||
input_keymaps_translate_keysym_to_rk(i * 8 + k), 0, 0,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ static void sdl_input_poll(void *data)
|
||||
if (event.key.keysym.mod & KMOD_CAPS)
|
||||
mod |= RETROKMOD_CAPSLOCK;
|
||||
|
||||
input_keyboard_event(event.type == SDL_KEYDOWN, code, code, mod);
|
||||
input_keyboard_event(event.type == SDL_KEYDOWN, code, code, mod, false);
|
||||
}
|
||||
#ifdef HAVE_SDL2
|
||||
else if (event.type == SDL_MOUSEWHEEL)
|
||||
|
@ -158,5 +158,6 @@ void apple_input_keyboard_event(bool down,
|
||||
apple->key_state[code] = down;
|
||||
|
||||
input_keyboard_event(down,
|
||||
input_keymaps_translate_keysym_to_rk(code), character, (enum retro_mod)mod);
|
||||
input_keymaps_translate_keysym_to_rk(code),
|
||||
character, (enum retro_mod)mod, false);
|
||||
}
|
||||
|
@ -46,25 +46,25 @@ LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message,
|
||||
* WM_CHAR and WM_KEYDOWN properly.
|
||||
*/
|
||||
case WM_CHAR:
|
||||
input_keyboard_event(true, RETROK_UNKNOWN, wparam, mod);
|
||||
input_keyboard_event(true, RETROK_UNKNOWN, wparam, mod, false);
|
||||
return TRUE;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
/* DirectInput uses scancodes directly. */
|
||||
input_keyboard_event(true, keycode, 0, mod);
|
||||
input_keyboard_event(true, keycode, 0, mod, false);
|
||||
return 0;
|
||||
|
||||
case WM_KEYUP:
|
||||
/* DirectInput uses scancodes directly. */
|
||||
input_keyboard_event(false, keycode, 0, mod);
|
||||
input_keyboard_event(false, keycode, 0, mod, false);
|
||||
return 0;
|
||||
|
||||
case WM_SYSKEYUP:
|
||||
input_keyboard_event(false, keycode, 0, mod);
|
||||
input_keyboard_event(false, keycode, 0, mod, false);
|
||||
return 0;
|
||||
|
||||
case WM_SYSKEYDOWN:
|
||||
input_keyboard_event(true, keycode, 0, mod);
|
||||
input_keyboard_event(true, keycode, 0, mod, false);
|
||||
|
||||
switch (wparam)
|
||||
{
|
||||
|
@ -122,8 +122,9 @@ void x11_handle_key_event(XEvent *event, XIC ic, bool filter)
|
||||
if (state & Mod4Mask)
|
||||
mod |= RETROKMOD_META;
|
||||
|
||||
input_keyboard_event(down, key, chars[0], mod);
|
||||
input_keyboard_event(down, key, chars[0], mod, false);
|
||||
|
||||
for (i = 1; i < num; i++)
|
||||
input_keyboard_event(down, RETROK_UNKNOWN, chars[i], mod);
|
||||
input_keyboard_event(down, RETROK_UNKNOWN,
|
||||
chars[i], mod, false);
|
||||
}
|
||||
|
@ -61,8 +61,9 @@ void handle_xkb(
|
||||
}
|
||||
|
||||
input_keyboard_event(value, input_keymaps_translate_keysym_to_rk(code),
|
||||
num_syms ? xkb_keysym_to_utf32(syms[0]) : 0, mod);
|
||||
num_syms ? xkb_keysym_to_utf32(syms[0]) : 0, mod, false);
|
||||
|
||||
for (i = 1; i < num_syms; i++)
|
||||
input_keyboard_event(value, RETROK_UNKNOWN, xkb_keysym_to_utf32(syms[i]), mod);
|
||||
input_keyboard_event(value, RETROK_UNKNOWN,
|
||||
xkb_keysym_to_utf32(syms[i]), mod, false);
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ void input_keyboard_wait_keys_cancel(void)
|
||||
* This interfaces with the global driver struct and libretro callbacks.
|
||||
**/
|
||||
void input_keyboard_event(bool down, unsigned code,
|
||||
uint32_t character, uint16_t mod)
|
||||
uint32_t character, uint16_t mod, bool enable_osk)
|
||||
{
|
||||
static bool deferred_wait_keys;
|
||||
|
||||
@ -242,7 +242,13 @@ void input_keyboard_event(bool down, unsigned code,
|
||||
{
|
||||
if (!down)
|
||||
return;
|
||||
if (!input_keyboard_line_event(g_keyboard_line, character))
|
||||
|
||||
if (enable_osk && code != 0x12d)
|
||||
{
|
||||
if (!input_keyboard_line_event(g_keyboard_line, (char)code))
|
||||
return;
|
||||
}
|
||||
else if (!input_keyboard_line_event(g_keyboard_line, character))
|
||||
return;
|
||||
|
||||
/* Line is complete, can free it now. */
|
||||
|
@ -92,12 +92,13 @@ void input_keyboard_line_free(input_keyboard_line_t *state);
|
||||
* @code : Keycode.
|
||||
* @character : Character inputted.
|
||||
* @mod : TODO/FIXME: ???
|
||||
* @enable_osk : Fire off keyboard event from OSK
|
||||
*
|
||||
* Keyboard event utils. Called by drivers when keyboard events are fired.
|
||||
* This interfaces with the global driver struct and libretro callbacks.
|
||||
**/
|
||||
void input_keyboard_event(bool down, unsigned code, uint32_t character,
|
||||
uint16_t mod);
|
||||
uint16_t mod, bool enable_osk);
|
||||
|
||||
/**
|
||||
* input_keyboard_start_line:
|
||||
|
@ -535,7 +535,8 @@ static inline void input_poll_overlay(void)
|
||||
|
||||
for (j = 0; j < 32; j++)
|
||||
if ((orig_bits & (1 << j)) != (new_bits & (1 << j)))
|
||||
input_keyboard_event(new_bits & (1 << j), i * 32 + j, 0, key_mod);
|
||||
input_keyboard_event(new_bits & (1 << j),
|
||||
i * 32 + j, 0, key_mod, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,6 +152,16 @@ void menu_input_key_event(bool down, unsigned keycode,
|
||||
}
|
||||
}
|
||||
|
||||
void menu_input_osk_key_event(bool down, unsigned keycode,
|
||||
uint32_t character, uint16_t mod)
|
||||
{
|
||||
if (!driver.menu)
|
||||
return;
|
||||
|
||||
RARCH_LOG("down: %d, keycode: %d, character: %d, mod: %d.\n",
|
||||
down, keycode, character, mod);
|
||||
}
|
||||
|
||||
void menu_input_poll_bind_state(struct menu_bind_state *state)
|
||||
{
|
||||
unsigned i, b, a, h;
|
||||
|
@ -46,6 +46,9 @@ typedef enum
|
||||
void menu_input_key_event(bool down, unsigned keycode, uint32_t character,
|
||||
uint16_t key_modifiers);
|
||||
|
||||
void menu_input_osk_key_event(bool down, unsigned keycode,
|
||||
uint32_t character, uint16_t mod);
|
||||
|
||||
void menu_input_key_start_line(void *data, const char *label,
|
||||
const char *label_setting, unsigned type, unsigned idx,
|
||||
input_keyboard_line_complete_t cb);
|
||||
|
Loading…
Reference in New Issue
Block a user