Skip to content

Instantly share code, notes, and snippets.

@micr0-dev
Forked from Gordin/README.md
Last active May 21, 2024 15:49
Show Gist options
  • Save micr0-dev/22531d7cf7be4a0540ef8dfd4fd0d9cb to your computer and use it in GitHub Desktop.
Save micr0-dev/22531d7cf7be4a0540ef8dfd4fd0d9cb to your computer and use it in GitHub Desktop.
Script that remaps Keys in Cyberpunk 2077 from qwertz to colemak. That's it :>
  1. Have python installed
  2. Download remap.py (from below) and put it next to the config file inputUserMappings.xml (Should be in ...\Cyberpunk 2077\r6\config)
  3. Open a terminal, cd into the directory with the script, and run python remap.py
  4. It should create a new file called inputUserMappings2.xml
  5. Now rename inputUserMappings.xml to something else, and rename inputUserMappings2.xml to inputUserMappings.xml
#!/usr/bin/env python
from lxml import objectify, etree
colemak_mapping = {
# key on (QWERTY) keyboard: letter in Colemak
'IK_A': 'IK_A',
'IK_B': 'IK_B',
'IK_C': 'IK_C',
'IK_D': 'IK_S',
'IK_E': 'IK_F',
'IK_F': 'IK_T',
'IK_G': 'IK_D',
'IK_H': 'IK_H',
'IK_I': 'IK_U',
'IK_J': 'IK_N',
'IK_K': 'IK_E',
'IK_L': 'IK_I',
'IK_M': 'IK_M',
'IK_N': 'IK_K',
'IK_O': 'IK_Y',
'IK_P': 'IK_SEMICOLON',
'IK_Q': 'IK_Q',
'IK_R': 'IK_P',
'IK_S': 'IK_R',
'IK_T': 'IK_G',
'IK_U': 'IK_L',
'IK_V': 'IK_V',
'IK_W': 'IK_W',
'IK_X': 'IK_X',
'IK_Y': 'IK_J',
'IK_Z': 'IK_Z',
}
def loadXML():
f = open("inputUserMappings.xml", "r", encoding="utf8")
text = f.read()
return objectify.fromstring(text)
def ignoreButton(name: str):
if name.startswith('IK_Pad'):
return True
if name.startswith('IK_PAD'):
return True
if name.startswith('IK_Mouse'):
return True
if name.startswith('IK_NumPad'):
return True
if name.startswith('IK_PS4'):
return True
if name.startswith('IK_F') and name != 'IK_F':
return True
if 'Mouse' in name:
return True
if 'Thumb' in name:
return True
return False
def remapButton(button):
old_id = button.attrib['id']
if ignoreButton(old_id):
return
new_id = colemak_mapping.get(old_id)
if new_id:
button.attrib['id'] = new_id
print('remapped {} to {}'.format(old_id, new_id))
else:
print('missing mapping for {}'.format(old_id))
def main():
tree = loadXML()
children = tree.getchildren()
for mapping in list(filter(lambda x: x != '', children)):
buttons = mapping.getchildren()
for button in list(filter(lambda x: x.tag == 'button', buttons)):
remapButton(button)
return tree
if __name__ == "__main__":
tree = main()
xmlString = etree.tostring(tree, pretty_print=True, encoding='unicode')
print(xmlString)
with open('inputUserMappings2.xml', 'w', encoding='utf8') as f:
f.write('<?xml version="1.0"?>\n')
f.write(xmlString)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment