From 63bdbdbb191d236c6c45917cd61dcaac74e649be Mon Sep 17 00:00:00 2001 From: David Rosca Date: Thu, 28 Sep 2017 21:19:40 +0200 Subject: [PATCH] Read keymap number from ux0:ps4linkcontrols.txt file --- README.md | 4 ++++ main.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 07baa3f..4433552 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ taiHEN plugin that allows to force preferred Remote Play button configuration +### Configuration + +By default it sets **keymap 0** - everything on back touchpad. Changing the keymap can be done +by creating `ux0:ps4linkcontrols.txt` file and writing the keymap number (0-7) there. ### Installation diff --git a/main.c b/main.c index c75bd28..49dbf68 100644 --- a/main.c +++ b/main.c @@ -24,6 +24,7 @@ #include #include +#include #include static SceUID g_hooks[3]; @@ -58,6 +59,19 @@ static int rpjob_constructor_patched(struct RPJob *a1, int a2, int a3) return out; } +static void load_config() +{ + SceUID fd = sceIoOpen("ux0:ps4linkcontrols.txt", SCE_O_RDONLY, 0); + if (fd >= 0) { + char value = 0; + sceIoRead(fd, &value, sizeof(value)); + if (value >= '0' && value <= '7') { + keymap_number = value - '0'; + } + sceIoClose(fd); + } +} + void _start() __attribute__ ((weak, alias ("module_start"))); int module_start(SceSize argc, const void *args) { @@ -92,6 +106,10 @@ int module_start(SceSize argc, const void *args) 1, // thumb rpjob_constructor_patched); + load_config(); + + LOG("Using keymap %d", keymap_number); + return SCE_KERNEL_START_SUCCESS; }