Created
October 15, 2025 18:54
-
-
Save loopj/7f107a520776b7136a5b5e169e4c42af to your computer and use it in GitHub Desktop.
Quick and dirty python script to read/write to Nintendo GameCube Controller Adapters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pip install hidapi | |
| import hid | |
| import argparse | |
| VID = 0x057E | |
| PID = 0x0337 | |
| def open_dev(): | |
| h = hid.device() | |
| h.open(VID, PID) | |
| h.set_nonblocking(True) | |
| return h | |
| def send_hid_report(tx): | |
| h = open_dev() | |
| try: | |
| h.write(bytes(tx)) | |
| finally: | |
| h.close() | |
| def read_hid_reports(args): | |
| h = open_dev() | |
| try: | |
| while True: | |
| rx = h.read(64) | |
| if rx: | |
| print(" ".join(f"{b:02x}" for b in rx)) | |
| except KeyboardInterrupt: | |
| pass | |
| finally: | |
| h.close() | |
| def main(): | |
| parser = argparse.ArgumentParser(description="GameCube adapter HID tool") | |
| sub = parser.add_subparsers(dest="command", required=True) | |
| # set_motor (0x11) | |
| set_motor = sub.add_parser("set_motor", help="Send a 'set motor' HID report (0x11)") | |
| set_motor.add_argument("channels", nargs=4, type=int, help="ch0 ch1 ch2 ch3") | |
| set_motor.set_defaults(func=lambda args: send_hid_report([0x11] + args.channels)) | |
| # read_origin (0x12) | |
| read_origin = sub.add_parser( | |
| "read_origin", help="Send a 'read origin' HID report (0x12)" | |
| ) | |
| read_origin.set_defaults(func=lambda args: send_hid_report([0x12])) | |
| # start_polling (0x13) | |
| start_polling = sub.add_parser( | |
| "start_polling", help="Send a 'start polling' HID report (0x13)" | |
| ) | |
| start_polling.set_defaults(func=lambda args: send_hid_report([0x13])) | |
| # stop_polling (0x14) | |
| stop_polling = sub.add_parser( | |
| "stop_polling", help="Send a 'stop polling' HID report (0x14)" | |
| ) | |
| stop_polling.set_defaults(func=lambda args: send_hid_report([0x14])) | |
| # reset (0x15) | |
| reset = sub.add_parser("reset", help="Send a 'reset' HID report (0x15)") | |
| reset.set_defaults(func=lambda args: send_hid_report([0x15])) | |
| # listen | |
| listen = sub.add_parser("listen", help="Continuously read and print HID reports") | |
| listen.set_defaults(func=read_hid_reports) | |
| args = parser.parse_args() | |
| args.func(args) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment