A walkthrough of how to bind mouse buttons, keyboard buttons that aren’t allowed by default, etc. in The Forest. Requires some technical skills but isn’t super difficult.
After a couple days of dinking around, I have successfully bound mouse4 to the Run command. Read on to find out how.
- Obligatory warning that the registry is important, and if you screw it up you can brick your OS. Don’t be dumb and you should be fine.
- If you’ve made substantial changes to your keybinds already, I’d save a copy of the exported keys you can go back to instead of starting from scratch.
1. Extract keybind from the registry.
2. Convert to xml.
3a. Edit an existing bind you want to change. OR
3b. Add a new bind that didn’t exist.
4. Convert back to hex.
5. Merge new keybinds with the registry.
- The bindings are stored in the registry at
- There are four keys starting with UserRemapping that seem to hold the information we want.
- The first two keys appear to be joystick/gamepad related:
- The third contains all the keyboard mapping information:
- The fourth contains all the mouse mapping information:
- All the bindings are stored in a binary format. We can convert to xml format pretty easily using online converters.
- The keybindings use the Rewired API for mapping.
- We can acquire keyboard and mouse maps from the Rewired website. Go here, then download the CSV files for keyboard and mouse. They’ll open in Excel spreadsheet or similar. You can use them to determine what element Id and KeyCode correspond to what buttons on your keyboard or mouse.
- The actions are defined internally to the game. Without reverse engineering the game’s executable or having the source code, this will likely be trial and error. It’s possible there are actions we could bind to but don’t know about them yet.
- Rewired allows multiple commands to be bound to a single action. The game doesn’t know if you pressed mouse4 or leftControl, because Rewired takes care of that. If either of those is bound to Sprint, the game simply knows Sprint was pressed and goes from there. This potentially means we can create some complex sequences if we know the action ids and so forth. It also means we can have secondary bindings if desired.
- Rewired allows combination keys, such as Shift+J or Ctrl+Shift+W. This seems to be supported in game, allowing binds such as 1-4 for items, then Alt+1-4 for lighter/compass/etc.
Converting from Registry to XML
- Open the registry (Windows+R, then run regedit), then navigate to Computer\HKEY_CURRENT_USER\SOFTWARE\SKS\TheForest.
- Right-click TheForest in the left pane, then click Export.
- Name it something, like “The Forest”, then save it somewhere, like your desktop.
- Right click the file on your desktop and “open with” a text editor. I prefer Notepad++.
- Find the keys you want to look for. Search for “hardwareIdentifier=Keyboard” and/or “hardwareIdentifier=Mouse”.
- Select everything after “=hex:” until the last of the hex characters (there will be a new line with another key right after the hex characters, or a blank line at the end of file). Ignore the “=hex:” portion and just select the hex itself.
- Copy the hex into a converter. I used http://www.unit-conversion.info/texttools/hexadecimal. Make sure to select hex to text (text to hex was selected by default for me).
- Copy the converted text into an xml formatter to make it easy to read. I used https://www.freeformatter.com/xml-formatter.html and used 4 spaces per indent, but you can use default settings.
- Copy that xml into Notepad++ to start digging through it.
- Repeat steps 6 to 9 if you want to do multiple keys (keyboard and mouse, for example).
Finding your Action Codes
- I see that Run is bound to Left Shift.
- I can look in the Rewired spreadsheet for keyboard to find that Left Shift is KeyCode value 304, Element Identifier Id 117, Element Identifier Type 0. (Note: while all the keyboard Element Types should be 0 according to the spreadsheet, they’re listed as 1 in the xml. 1 seems to work, so go with it.)
- Looking through the xml I converted, I can search for “<elementIdentifierId>117<” to find the corresponding key. It’s assigned to ActionCategory 6, ActionId 16. This tells us Run is assigned to category-id 6-16.
I’ve done this for all the actions in the keybind menu. There are also actions for the mouse. Two actions are bound to left mouse, two to right mouse, and an action for each of the horizontal and vertical mouse axes. I uploaded a spreadsheet with what I found here for reference. I didn’t take the time to figure out exactly what the unlabeled actions are, but they’re probably not hard to figure out (Escape to cancel, Return to accept, for example).
Updating the XML to Add/Change a Bind
<ActionElementMap> <actionCategoryId>6</actionCategoryId> <actionId>16</actionId> <elementType>1</elementType> <elementIdentifierId>6</elementIdentifierId> <axisRange>0</axisRange> <invert>false</invert> <axisContribution>0</axisContribution> <keyboardKeyCode>0</keyboardKeyCode> <modifierKey1>0</modifierKey1> <modifierKey2>0</modifierKey2> <modifierKey3>0</modifierKey3> <enabled>true</enabled> </ActionElementMap>
If you just want to change a keybind (for example, change Jump to Enter), it’s the same thing except modifying the existing key instead of adding a new one. Also, you’d do that one in the Keyboard xml, instead of the Mouse xml.
Merging the XML back into the Registry
- Remove all the extra whitespace. Turns out your mouse will stop working entirely if you don’t. In Notepad++, you can replace all with the Regular Expression “\s” to “” (nothing). IMPORTANT: Select everything but the first two tags then replace all in the selection only. There are spaces in the xml tag and the MouseMap / KeyboardMap tags that need to be preserved. Just manually delete the newlines without replacing the whitespace inside the tags themselves.
- Convert from minified xml back to hexadecimal. We’ll use the same website, http://www.unit-conversion.info/texttools/hexadecimal, making sure to select text to hex this time.
- This outputs space-delimited hexadecimal. We need to convert to comma-delimited. Paste the output back into Notepad++ and replace all with ” ” (space) to “,” (comma). MAYBE IMPORTANT: Add “,00” to the end of the hex. This tells the parser it’s reached the end of the file and might be critical depending on the parser. (The original hex ends with 00, so I suggest adding it back.)
- This goes into the original .reg file we exported from regedit. Find the key with hardwareIdentifier=Mouse then delete everything after “=hex:” up to the next key. In my case, that was the last key in the file, so there’s just a blank line after it. (If you’re editing the keyboard settings, then you’d edit the hardwareIdentifier=Keyboard key instead.)
- Now, paste the comma-delimited hex right after “=hex:”.
- Save the registry file. Go back to where you saved it, and right-click then Merge it into the registry.
- Open the game and hope it worked.
- Binding Run to mouse4 as above.
- I’ve swapped left and right mouse buttons by simply changing elementIdentifierId from 3 to 4 and vice versa.
- I’ve also gotten mouse4 to behave like right mouse by adding new element values but using the actionCategory and Id from the existing values.
- I then swapped from mouse4 to mouse5 by changing from elementId 6 to 7, showing that both side buttons work.
One thing I’ve noted is that actionCategoryId doesn’t seem to matter. I initially made Run work with ActionCategory 0 instead of 6. And it seems to change depending on how the controls were changed. I haven’t tested every single action in the spreadsheet to make sure it’s correct, and I may have misread something when reading off the defaults. But it seems that you can just use 0 for the category and be fine.
To illustrate the weirdness: I changed the Save button from C to E in the in-game menu. Now, E is assigned to 2-17 (Take), 3-38 (Build), and 0-26 (Save). Save should be 2-26, but is instead listed in category 0.
Also, make sure you didn’t do something stupid. I forgot the opening tag for the ActionElementMap node, and it broke the entire parser. Generally, you’ll know you’re in the ballpark if the controls work. Otherwise, they’ll completely break and nothing works, even the stuff that worked before.
If the controls work, but your binding doesn’t, make sure you got the right element Id, that you’re using element Id and not Action Id or KeyCode, etc.
If all else fails, go into the registry and delete the 4 keys starting with UserRemapping. The game will automatically revert to defaults when you restart it. Worst case scenario, delete the entire TheForest node. Just don’t mess with anything outside the TheForest node because you can break things that way.
- None Found