Skip to content

Instantly share code, notes, and snippets.

@rambo
Last active November 19, 2024 17:26
Show Gist options
  • Save rambo/28d76d5d3a14d6ab6ab6a277b23cdf56 to your computer and use it in GitHub Desktop.
Save rambo/28d76d5d3a14d6ab6ab6a277b23cdf56 to your computer and use it in GitHub Desktop.
GameTouchController .profile file parser for editing looong macros
  • Setup your things with something recognizeable for where you want to do/edit long macros.
  • Sync profiles
  • Export the profile zip
  • Unzip it
  • under the "Custom_Profiles" directory find yourprofile.profile and copy it elsewhere, you might want to rename it to yourprofile_orig.profile
  • Copy the python script above to same location
  • Run it and give it the profile file name
  • Go editing the code, the macros themselves are also string encoded so be careful when editing them
  • This is basic Python stuff, Just Google for some tutorials I'm not going to teach you programming
    • If you already know how to program in Python and have questions about Deep Magic, I can be persuaded to discuss.
      • Nonetheless it's Wormi who knows the internals of GTC itself, not me.
  • Copy the output .profile file back to where you unzipped the profile
  • Re-zip (take note not to add the extra directory you probably created when unzipping)
  • Import
  • Delete the profile from clients
  • Sync clients

You might need to sync first with the Windows client before things work with the Android one, IDK why that would make a difference but it's easier to do a smoke-test in the windows client anyway.

from pathlib import Path
import ast
import pprint
import sys
if len(sys.argv) < 2:
print("Enter filename: ", end=None)
pname = Path(input())
else:
pname = Path(sys.argv[1])
readback = ast.literal_eval(pname.read_text())
newname = pname.with_stem(pname.stem.replace("_orig", ""))
pyname = newname.with_stem(newname.stem+"_profile").with_suffix(".py")
with pyname.open("wt", encoding="utf-8") as fpntr:
fpntr.write("data = ")
fpntr.write(pprint.pformat(readback, indent=2, width=120))
fpntr.write(f"""
import ast
import pprint
def verify_macros(data):
for cnt, widget in enumerate(data["widgets"]):
title = widget.get("label_id")
if not title:
title=f"widgets[{{cnt}}]"
if "press_command" in widget and widget["press_command"]:
print(f"=== BEGIN: {{title}} press ===")
parsed = ast.literal_eval(widget["press_command"])
pprint.pprint(parsed)
print(f"=== END: {{title}} press ===")
if "release_command" in widget and widget["release_command"]:
print(f"=== BEGIN: {{title}} release ===")
parsed = ast.literal_eval(widget["release_command"])
pprint.pprint(parsed)
print(f"=== END: {{title}} release ===")
verify_macros(data)
from pathlib import Path
pth = Path("{newname}")
pth.write_text(str(data))
readback = ast.literal_eval(pth.read_text())
""")
print(f"wrote {pyname}, edit and run it to create {newname}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment