platform, fixes for compiling with keyboard
authorkub <derkub@gmail.com>
Wed, 15 Jan 2025 21:04:21 +0000 (22:04 +0100)
committerkub <derkub@gmail.com>
Thu, 16 Jan 2025 17:47:50 +0000 (18:47 +0100)
pico/pico.h
pico/pico/memory.c
platform/common/emu.c
platform/libpicofe
platform/opendingux/inputmap.c
platform/ps2/in_ps2.c
platform/psp/in_psp.c

index c8f8905..3ec16e8 100644 (file)
@@ -155,16 +155,16 @@ struct PicoEState;
 // pico.c\r
 #define XPCM_BUFFER_SIZE 64\r
 enum {\r
-  KEY_RELEASED = 0,\r
-  KEY_DOWN,\r
-  KEY_UP,\r
+  PKEY_RELEASED = 0,\r
+  PKEY_DOWN,\r
+  PKEY_UP,\r
 };\r
 enum {\r
-  SHIFT_RELEASED = 0,\r
-  SHIFT_DOWN,\r
-  SHIFT_UP_HELD_DOWN,\r
-  SHIFT_RELEASED_HELD_DOWN,\r
-  SHIFT_UP\r
+  PSHIFT_RELEASED = 0,\r
+  PSHIFT_DOWN,\r
+  PSHIFT_UP_HELD_DOWN,\r
+  PSHIFT_RELEASED_HELD_DOWN,\r
+  PSHIFT_UP\r
 };\r
 typedef struct\r
 {\r
index a97df65..b7e6222 100644 (file)
@@ -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;
index 89d0c29..e8f2a07 100644 (file)
@@ -1299,7 +1299,7 @@ void emu_update_input(void)
        int actions[IN_BINDTYPE_COUNT] = { 0, };\r
        int actions_kbd[IN_BIND_LAST] = { 0, };\r
        int pl_actions[4];\r
-       int events;\r
+       int events, i;\r
 \r
        in_update(actions);\r
 \r
@@ -1357,7 +1357,7 @@ void emu_update_input(void)
 \r
        // update keyboard input, actions only updated if keyboard mode active\r
        PicoIn.kbd = 0;\r
-       for (int i = 0; i < IN_BIND_LAST; i++) {\r
+       for (i = 0; i < IN_BIND_LAST; i++) {\r
                if (actions_kbd[i]) {\r
                        unsigned int action = actions_kbd[i];\r
                        unsigned int key = (action & 0xff);\r
index d4428e4..c567bf4 160000 (submodule)
@@ -1 +1 @@
-Subproject commit d4428e4e21c79064dea669dfc6c93f1a1cb9c536
+Subproject commit c567bf4c74221fccf1cd91f8faac8542aab63b28
index 30c4639..46d37bb 100644 (file)
@@ -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)
 {
index f7e8033..a8014c7 100644 (file)
@@ -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);
 }
 
index 779c02c..2cc617a 100644 (file)
@@ -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);
 }