The Forest – How To Remap Locked Keys and Mouse Buttons

The Forest – How To Remap Locked Keys and Mouse Buttons 1 - steamlists.com
The Forest – How To Remap Locked Keys and Mouse Buttons 1 - steamlists.com
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.

 
 

Intro

 
I recently started playing The Forest, and the first thing I noticed is that I couldn’t rebind mouse4 to the Run command. So I started searching around and found that it’s generally impossible. Undeterred, I decided to see what I can accomplish anyways. 
 
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.

Process overview: 
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. 
6. Enjoy. 
 
 

Background Information

 

  1. The bindings are stored in the registry at 
    Computer\HKEY_CURRENT_USER\SOFTWARE\SKS\TheForest 
  2. There are four keys starting with UserRemapping that seem to hold the information we want. 
  3. The first two keys appear to be joystick/gamepad related: 
    UserRemapping_v3&playerName=System&dataType=InputBehavior&id=0_h1699203952 
    UserRemapping_v3&playerName=Player&dataType=InputBehavior&id=0_h2177795462 
  4. The third contains all the keyboard mapping information: 
    UserRemapping_v3&playerName=Player&dataType=ControllerMap&controllerMapType=KeyboardMap&categoryId=0&layoutId=1&hardwareIdentifier=Keyboard_h4275277544 
  5. The fourth contains all the mouse mapping information: 
    UserRemapping_v3&playerName=Player&dataType=ControllerMap&controllerMapType=MouseMap&categoryId=0&layoutId=0&hardwareIdentifier=Mouse_h3996039753 
  6. All the bindings are stored in a binary format. We can convert to xml format pretty easily using online converters. 
  7. The keybindings use the guavaman.com – https://guavaman.com/projects/rewired/ API for mapping. 
  8. We can acquire keyboard and mouse maps from the Rewired website. Go guavaman.com – https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action-keyboard, 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. 
  9. 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. 
  10. 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. 
  11. 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

 

  1. Open the registry (Windows+R, then run regedit), then navigate to Computer\HKEY_CURRENT_USER\SOFTWARE\SKS\TheForest
  2. Right-click TheForest in the left pane, then click Export
  3. Name it something, like “The Forest”, then save it somewhere, like your desktop. 
  4. Right click the file on your desktop and “open with” a text editor. I prefer Notepad++. 
  5. Find the keys you want to look for. Search for “hardwareIdentifier=Keyboard” and/or “hardwareIdentifier=Mouse”. 
  6. 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. 
  7. 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). 
  8. 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. 
  9. Copy that xml into Notepad++ to start digging through it. 
  10. Repeat steps 6 to 9 if you want to do multiple keys (keyboard and mouse, for example).

 
 
 

Finding your Action Codes

 
Looking at my current keybinding, I can figure out what a specific action code is. 

  1. I see that Run is bound to Left Shift
  2. 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.) 
  3. 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 drive.google.com – https://drive.google.com/file/d/1F71Rlxwvpv2EGlfikhPrcvdjzlAvwIiV/view?usp=sharing 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

 
If I want to bind Run to mouse4, I can simply add an element to the mouse bindings xml. Noting that there are “buttonMaps” and “axisMaps” in the mouse xml, we’ll add an ActionElementMap to the buttonMaps list. 

<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>

We copied the actionCategoryId (6) and actionId (16) from the values we got out of the keyboard defaults (found on the spreadsheet I created). Then we copied the elementType (1) and elementIdentifierId (7) from the Rewired mouse spreadsheet. Everything else is just copied from one of the other buttonMaps items. 
 
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

 

  1. 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. 
  2. 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. 
  3. 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.) 
  4. 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.) 
  5. Now, paste the comma-delimited hex right after “=hex:”. 
  6. Save the registry file. Go back to where you saved it, and right-click then Merge it into the registry. 
  7. Open the game and hope it worked.

 
 
 

Miscellaneous Notes

 
Thus far I’ve gotten the following to work successfully: 

  • 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. 
 
 

Troubleshooting

 
The xml parser for Rewired seems to be very finicky. Try to get the xml as close to the original configuration as possible. 
 
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. 
 

Written by fosley

Hope you enjoy the Guide about The Forest – How To Remap Locked Keys and Mouse Buttons, if you think we should add extra information or forget something, please let us know via comment below, and we will do our best to fix or update as soon as possible!
 
 
 
 


Be the first to comment

Leave a Reply

Your email address will not be published.


*