summaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorTwinaphex2014-12-09 13:28:17 +0100
committerTwinaphex2014-12-09 13:28:17 +0100
commit988c2e2655c7c1f724ba727f008d84e3faa6cd24 (patch)
treeda7bf131f33b9ae16d2a93a0a7615a3c0b9c7535 /input.c
parent7bb77f4fc090cadc23c3e05998ccebac7156e3cf (diff)
parente2d6ea9082a5ff977f834eda0bbb2362397422df (diff)
downloadpicogpsp-988c2e2655c7c1f724ba727f008d84e3faa6cd24.tar.gz
picogpsp-988c2e2655c7c1f724ba727f008d84e3faa6cd24.tar.bz2
picogpsp-988c2e2655c7c1f724ba727f008d84e3faa6cd24.zip
Merge pull request #2 from aliaspider/master
initial port of gpsp to libretro.
Diffstat (limited to 'input.c')
-rw-r--r--input.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/input.c b/input.c
index 06a8f8a..51e70cf 100644
--- a/input.c
+++ b/input.c
@@ -343,10 +343,33 @@ void init_input()
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
}
-#endif
+#elif defined(__LIBRETRO__)
+
+static retro_input_state_t input_state_cb;
+void retro_set_input_state(retro_input_state_t cb) { input_state_cb = cb; }
+
+u32 update_input(void)
+{
+// return;
+ unsigned i;
+ uint32_t new_key = 0;
+
+ if (!input_state_cb)
+ return 0;
+ for (i = 0; i < sizeof(btn_map) / sizeof(map); i++)
+ new_key |= input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, btn_map[i].retropad) ? btn_map[i].gba : 0;
+
+ if ((new_key | key) != key)
+ trigger_key(new_key);
+
+ key = new_key;
+ io_registers[REG_P1] = (~key) & 0x3FF;
+
+ return 0;
+}
-#if defined(PC_BUILD)
+#elif defined(PC_BUILD)
u32 key_map(SDLKey key_sym)
{