From: kub Date: Wed, 15 Jan 2025 21:04:21 +0000 (+0100) Subject: platform, fixes for compiling with keyboard X-Git-Tag: v2.04~81 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fabe161e6b9cbc0236273e1d18afb570a0758ce9;p=picodrive.git platform, fixes for compiling with keyboard --- diff --git a/pico/pico.h b/pico/pico.h index c8f89050..3ec16e87 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -155,16 +155,16 @@ struct PicoEState; // pico.c #define XPCM_BUFFER_SIZE 64 enum { - KEY_RELEASED = 0, - KEY_DOWN, - KEY_UP, + PKEY_RELEASED = 0, + PKEY_DOWN, + PKEY_UP, }; enum { - SHIFT_RELEASED = 0, - SHIFT_DOWN, - SHIFT_UP_HELD_DOWN, - SHIFT_RELEASED_HELD_DOWN, - SHIFT_UP + PSHIFT_RELEASED = 0, + PSHIFT_DOWN, + PSHIFT_UP_HELD_DOWN, + PSHIFT_RELEASED_HELD_DOWN, + PSHIFT_UP }; typedef struct { diff --git a/pico/pico/memory.c b/pico/pico/memory.c index a97df654..b7e62223 100644 --- a/pico/pico/memory.c +++ b/pico/pico/memory.c @@ -152,10 +152,10 @@ static u32 PicoRead8_pico_kb(u32 a) // otherwise it will be zero and the game won't clear its Shift key state. u32 key_code = (key_shift && !key - && PicoPicohw.kb.key_state != KEY_UP - && PicoPicohw.kb.shift_state != SHIFT_UP_HELD_DOWN) + && PicoPicohw.kb.key_state != PKEY_UP + && PicoPicohw.kb.shift_state != PSHIFT_UP_HELD_DOWN) ? key_shift - : PicoPicohw.kb.shift_state == SHIFT_UP ? PEVB_KBD_LSHIFT : key; + : PicoPicohw.kb.shift_state == PSHIFT_UP ? PEVB_KBD_LSHIFT : key; u32 key_code_7654 = (key_code & 0xf0) >> 4; u32 key_code_3210 = (key_code & 0x0f); switch(PicoPicohw.kb.i) { @@ -186,31 +186,31 @@ static u32 PicoRead8_pico_kb(u32 a) d = 6; if (PicoPicohw.kb.active) { if (key) { - PicoPicohw.kb.key_state = KEY_DOWN; + PicoPicohw.kb.key_state = PKEY_DOWN; } if (!key) { - PicoPicohw.kb.key_state = !PicoPicohw.kb.key_state ? 0 : (PicoPicohw.kb.key_state + 1) % (KEY_UP + 1); + PicoPicohw.kb.key_state = !PicoPicohw.kb.key_state ? 0 : (PicoPicohw.kb.key_state + 1) % (PKEY_UP + 1); PicoPicohw.kb.start_time_keydown = 0; } if (key_shift && !key) { - if (PicoPicohw.kb.shift_state < SHIFT_RELEASED_HELD_DOWN) { + if (PicoPicohw.kb.shift_state < PSHIFT_RELEASED_HELD_DOWN) { PicoPicohw.kb.shift_state++; } PicoPicohw.kb.start_time_keydown = 0; } if (!key_shift) { - PicoPicohw.kb.shift_state = !PicoPicohw.kb.shift_state ? 0 : (PicoPicohw.kb.shift_state + 1) % (SHIFT_UP + 1); + PicoPicohw.kb.shift_state = !PicoPicohw.kb.shift_state ? 0 : (PicoPicohw.kb.shift_state + 1) % (PSHIFT_UP + 1); } - if (PicoPicohw.kb.key_state == KEY_DOWN || PicoPicohw.kb.shift_state == SHIFT_DOWN) { + if (PicoPicohw.kb.key_state == PKEY_DOWN || PicoPicohw.kb.shift_state == PSHIFT_DOWN) { if (PicoPicohw.kb.start_time_keydown == 0) { d |= 8; // Send key down a.k.a. make PicoPicohw.kb.time_keydown = 0; PicoPicohw.kb.start_time_keydown = get_ticks(); - if (PicoPicohw.kb.key_state == KEY_DOWN) - elprintf(EL_PICOHW, "PicoPicohw.kb.key_state: KEY DOWN\n"); + if (PicoPicohw.kb.key_state == PKEY_DOWN) + elprintf(EL_PICOHW, "PicoPicohw.kb.key_state: PKEY DOWN\n"); else - elprintf(EL_PICOHW, "PicoPicohw.kb.key_state: SHIFT DOWN\n"); + elprintf(EL_PICOHW, "PicoPicohw.kb.key_state: PSHIFT DOWN\n"); } // Simulate key repeat while held down a.k.a. typematic PicoPicohw.kb.time_keydown = get_ticks() - PicoPicohw.kb.start_time_keydown; @@ -219,25 +219,25 @@ static u32 PicoRead8_pico_kb(u32 a) && key_code != PEVB_KBD_CAPSLOCK && key_code != PEVB_KBD_LSHIFT) { d |= 8; // Send key down a.k.a. make - if (PicoPicohw.kb.key_state == KEY_DOWN) - elprintf(EL_PICOHW, "PicoPicohw.kb.key_state: KEY DOWN\n"); + if (PicoPicohw.kb.key_state == PKEY_DOWN) + elprintf(EL_PICOHW, "PicoPicohw.kb.key_state: PKEY DOWN\n"); else - elprintf(EL_PICOHW, "PicoPicohw.kb.key_state: SHIFT DOWN\n"); + elprintf(EL_PICOHW, "PicoPicohw.kb.key_state: PSHIFT DOWN\n"); } // Must register key up while typematic not active (expected by Kibodeu Piko) if ((d & 8) == 0) { d |= 1; // Send key up a.k.a. break } } - if (PicoPicohw.kb.key_state == KEY_UP - || PicoPicohw.kb.shift_state == SHIFT_UP_HELD_DOWN - || PicoPicohw.kb.shift_state == SHIFT_UP) { + if (PicoPicohw.kb.key_state == PKEY_UP + || PicoPicohw.kb.shift_state == PSHIFT_UP_HELD_DOWN + || PicoPicohw.kb.shift_state == PSHIFT_UP) { d |= 1; // Send key up a.k.a. break PicoPicohw.kb.start_time_keydown = 0; - if (PicoPicohw.kb.key_state == KEY_UP) - elprintf(EL_PICOHW, "PicoPicohw.kb.key_state: KEY UP\n"); + if (PicoPicohw.kb.key_state == PKEY_UP) + elprintf(EL_PICOHW, "PicoPicohw.kb.key_state: PKEY UP\n"); else - elprintf(EL_PICOHW, "PicoPicohw.kb.key_state: SHIFT UP\n"); + elprintf(EL_PICOHW, "PicoPicohw.kb.key_state: PSHIFT UP\n"); } } break; diff --git a/platform/common/emu.c b/platform/common/emu.c index 89d0c29a..e8f2a07d 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -1299,7 +1299,7 @@ void emu_update_input(void) int actions[IN_BINDTYPE_COUNT] = { 0, }; int actions_kbd[IN_BIND_LAST] = { 0, }; int pl_actions[4]; - int events; + int events, i; in_update(actions); @@ -1357,7 +1357,7 @@ void emu_update_input(void) // update keyboard input, actions only updated if keyboard mode active PicoIn.kbd = 0; - for (int i = 0; i < IN_BIND_LAST; i++) { + for (i = 0; i < IN_BIND_LAST; i++) { if (actions_kbd[i]) { unsigned int action = actions_kbd[i]; unsigned int key = (action & 0xff); diff --git a/platform/libpicofe b/platform/libpicofe index d4428e4e..c567bf4c 160000 --- a/platform/libpicofe +++ b/platform/libpicofe @@ -1 +1 @@ -Subproject commit d4428e4e21c79064dea669dfc6c93f1a1cb9c536 +Subproject commit c567bf4c74221fccf1cd91f8faac8542aab63b28 diff --git a/platform/opendingux/inputmap.c b/platform/opendingux/inputmap.c index 30c4639a..46d37bbb 100644 --- a/platform/opendingux/inputmap.c +++ b/platform/opendingux/inputmap.c @@ -95,6 +95,11 @@ const char * _in_sdl_key_names[SDLK_LAST] = { }; const char * const *in_sdl_key_names = _in_sdl_key_names; +const struct in_default_bind in_sdl_kbd_map[] = { + // Opendingux devices usually don't have a keyboard. + { 0, 0, 0 } +}; + static void nameset(int x1, const char *name) { diff --git a/platform/ps2/in_ps2.c b/platform/ps2/in_ps2.c index f7e80334..a8014c79 100644 --- a/platform/ps2/in_ps2.c +++ b/platform/ps2/in_ps2.c @@ -271,6 +271,6 @@ void in_ps2_init(struct in_default_bind *defbinds) in_ps2_keys[lg2(PAD_CROSS)] = "Cross"; in_ps2_keys[lg2(PAD_SQUARE)] = "Square"; - in_register_driver(&in_ps2_drv, defbinds, NULL); + in_register_driver(&in_ps2_drv, defbinds, NULL, NULL); } diff --git a/platform/psp/in_psp.c b/platform/psp/in_psp.c index 779c02cc..2cc617aa 100644 --- a/platform/psp/in_psp.c +++ b/platform/psp/in_psp.c @@ -229,6 +229,6 @@ void in_psp_init(struct in_default_bind *defbinds) in_psp_keys[lg2(PSP_NUB_DOWN)] = "Analog down"; in_psp_keys[lg2(PSP_NUB_RIGHT)] = "Analog right"; - in_register_driver(&in_psp_drv, defbinds, NULL); + in_register_driver(&in_psp_drv, defbinds, NULL, NULL); }