Hacking Kingdom Hearts - Remapping game controllers

39ster

Member
OP
Newcomer
Joined
Jul 22, 2019
Messages
8
Trophies
0
Age
41
XP
55
Country
United Kingdom
I've been doing some analysis of the way Kingdom Hearts on the PC stores joypad button remapping, after discovering the built-in button remapping is very poor. One of it's problems is if you don't have a game controller with 24 individual inputs (an analog stick counts as 4 inputs) you can't map any of them as you have to map all 24 to save them.

The game controller settings are stored in a binary file called config1525.dat which is the same location as the saved games are stored. (in my case a sub folder in My Documents.) If the file does not exist, it's created on first launch, It's 504bytes long, and looks like this.

53 45 54 2D 08 00 00 00 F8 01 00 00 00 00 00 00
00 00 00 00 01 00 80 07 38 04 01 00 00 00 01 00
00 00 01 00 0A 00 0A 00 0A 00 0A 00 00 00 00 00
00 00 00 00 14 00 00 00 38 00 00 00 00 00 00 00
00 10 00 00 1C 00 00 00 39 00 00 00 0E 00 00 00
21 00 00 00 9D 00 00 00 01 10 00 00 36 00 00 00
2A 00 00 00 00 00 00 00 13 00 00 00 00 00 00 00
2E 00 00 00 00 00 00 00 12 00 00 00 00 00 00 00
2D 00 00 00 00 00 00 00 02 10 00 00 B8 00 00 00
CD 00 00 00 04 10 00 00 D0 00 00 00 0A 10 00 00
C8 00 00 00 09 10 00 00 CB 00 00 00 03 10 00 00
31 00 00 00 04 00 00 00 32 00 00 00 05 00 00 00
11 00 00 00 00 00 00 00 1F 00 00 00 00 00 00 00
1E 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00
05 10 00 00 06 10 00 00 07 10 00 00 08 10 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C
03 02 07 06 0B 0A 0F 0E 00 00 00 00 01 00 00 00
00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C
03 02 07 06 0B 0A 0F 0E 00 00 00 00 FF FF 00 00
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF 00 00 00 00 FF FF 00 00
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF 00 00 00 00 FF FF 00 00
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF 00 00 00 00 FF FF 00 00
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF 00 00 00 00 FF FF 00 00
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF 00 00 00 00 FF FF 00 00
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF


Whist several game settings are stored in this file, the data relating to game controllers starts at offset 0xF8 (highlighted in red.) From this offset there are eight lots of 32 byte entries. The first two entries are populated and this leaves 6 blank entries, for 6 different customisations. I don't know what the first two entries mean (one may be the default config which is used when no user button remapping has been done), but a blank entry can be identified with 00 00 00 00 FF FF 00 00, then the remaining 24 bytes are FF. This allows for several different game controllers to have their own mapping, identified by their hardware VID and PID. I've confirmed this by storing 3 different game controllers inside.

For each configured 32byte entry the values are as follows
0x00 2 bytes little endian VID
0x02 2 bytes little endian PID
0x04 1 byte unknown, always seems to be 02 except for first two entries
0x05 3 bytes unknown, all 3 bytes always seems to be 00

The following 24 bytes are used to store custom values, the second column is what appears on the on screen game controller button mapping in game, the third column is the in game function (taken from KH1.5)
0x08 Select Button First-Person View
0x09 L Stick Button No Known Function in KH1.5
0x0A R Stick Button Shift Camera Behind Sora
0x0B Start Button Menu/Pause
0x0C D Pad Up Select Command Up
0x0D D Pad Right Select Command Right
0x0E D Pad Down Select Command Down
0x0F D Pad Left Select Command Left
0x10 L Back Change Target
0x11 R Back No Known Function in KH1.5
0x12 L Front Magic Shortcut
0x13 R Front Lock On
0x14 X Left Button Special Action
0x15 B Right Button Jump
0x16 A Bottom Button Execute Command
0x17 Y Top Button Call Help
0x18 R Stick Left Camera Left
0x19 R Stick Right Camera Right
0x1A R Stick Up Camera Up
0x1B R Stick Down Camera down
0x1C L Stick Left Move Sora Left
0x1D L Stick Right Move Sora Right
0x1E L Stick Up Move Sora Up
0x1F L Stick Down Move Sora Down

Below are the Hex values I've discovered for each input from the game controller, which can be used in any of the 24 bytes above.
X Axis Left 0B
X Axis Right 0A
Y Axis Up 0F
Y Axis Down 0E
Z Axis Up 03
Z Axis Down 02

X Rotate Left* 13
X Rotate Right 12
Y Rotate Up* 17
Y Rotate Down 16
Z Rotate Right 06
Z Rotate Left 07

Slider Down 1A
Slider Up* 1B
Dial control not detected by game

*These are suspected Hex values but do not work and didn't appear in game controller remapping

POV Left 1C
POV Right 14
POV Up 10
POV Down 18

Only POV1 buttons detected by game. Additional POVs not detected.

Joypad Buttons
1 3C
2 38
3 34
4 30
5 28
6 2C
7 20
8 24
9 44
10 0C
11 04
12 08
13 40
14 00
15 48
16 4C
17 50
18 54
19 58
20 5C
21 60
22 64
23 68
24 6C
25 70
26 74
27 78
28 7C
29 80
30 84
31 88
32 8C

Buttons above 32 not detected.

If anyone wants to add to this documentation of the file or refine it further that would be great and if anyone wishes to make a small program to edit this file (I've editted the file with a hex editor to customise it) feel free to do so as it could be really useful for others. Please give credit where it's due.
 
General chit-chat
Help Users
    KenniesNewName @ KenniesNewName: Honey on strawberries such a treat