Skip to content

Commit

Permalink
Read keymap number from ux0:ps4linkcontrols.txt file
Browse files Browse the repository at this point in the history
  • Loading branch information
nowrep committed Sep 28, 2017
1 parent 7d2c52f commit 63bdbdb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 18 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <psp2/kernel/modulemgr.h>
#include <psp2/kernel/clib.h>
#include <psp2/io/fcntl.h>
#include <taihen.h>

static SceUID g_hooks[3];
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 63bdbdb

Please sign in to comment.