Skip to content

Commit

Permalink
Better README and help
Browse files Browse the repository at this point in the history
  • Loading branch information
pelrun committed Feb 4, 2024
1 parent fac73c3 commit 2f85e13
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 10 deletions.
45 changes: 41 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,44 @@
= Python version of GPD WinControls for GPD Win Mini
# Linux version of GPD WinControls for GPD Win Mini and GPD Win 4

HID commands have been largely reverse-engineered and the config read and write has been implemented.
A full replacement for WinControls, including features not exposed in the official app.

Requires pyHid 1.05
Shoulder buttons can be reassigned, and mouse clicks can be put anywhere.

Win 4 support coming.
Delay between macro keystrokes can be changed arbitrarily, and the fixed 300ms delay after the end of the macro can be changed.

Many more keys can be assigned to buttons, not just ones that are already available.

## Usage:

```
usage: gpdconfig [-h] [-s FILE] [-d FILE] [-r] [-v] [-c] [-f FIELD] [-k] [config ...]
Configures the mouse-mode controls on GPD Win devices. Replaces the official GPD WinControls app.
positional arguments:
config field=value, set a button or config field to the given value.
options:
-h, --help show this help message and exit
-s FILE, --set FILE Read config from FILE
-d FILE, --dump FILE Dump config to FILE
-r, --reset Reset to defaults
-v, --verbose Output current config to stdout
Informational options:
-c, --fields List available fields
-f FIELD, --field-help FIELD
Help for a specific field
-k, --keys List available keycodes
```

Some or all settings can be changed on the command line or from an input file.

The following fields take keycodes (use '-k' to get a list of all valid keycodes, including mouse buttons):
`'lu', 'ld', 'll', 'lr', 'du', 'dd', 'dl', 'dr', 'a', 'b', 'x', 'y', 'l1', 'r1', 'l2', 'r2', 'l3', 'r3', 'l41', 'l42', 'l43', 'l44', 'r41', 'r42', 'r43', 'r44'`

The following fields take numbers:
`'ldead', 'lcent', 'rdead', 'rcent', 'l4delay1', 'l4delay2', 'l4delay3', 'l4delay4', 'r4delay1', 'r4delay2', 'r4delay3', 'r4delay4'`

The following fields take other values:
`'rumble', 'ledmode', 'colour'`
8 changes: 5 additions & 3 deletions gpdconfig/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,24 @@ def main():
return

if options.field_help:
if options.field_help not in WinControls().field:
if options.field_help not in WinControls.field:
print(f"Unknown field '{options.field_help}'")
return
print(options.field_help, ':', WinControls().field[options.field_help].help())
print(f"'{options.field_help}': {WinControls.field[options.field_help].help()}")
return

#TODO: group types of field together and print them in a more readable way
if options.fields:
print("Available config fields:\n",list(WinControls().field.keys()))
for field in WinControls.field:
print(f"'{field}': {WinControls.field[field].help()}")

if options.keys:
print("Available keycodes:\n",list(KeyCodes.code.keys()))

if options.fields or options.keys:
return

# Read the current configuration from the device
wc = WinControls()

if wc.loaded and options.dump:
Expand Down
7 changes: 4 additions & 3 deletions gpdconfig/wincontrols/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class KeyCodes:
"LEFTSHIFT": 0xe1,
"LEFTALT": 0xe2,
"LEFTMETA": 0xe3,

"RIGHTCTRL": 0xe4,
"RIGHTSHIFT": 0xe5,
"RIGHTALT": 0xe6,
Expand Down Expand Up @@ -207,7 +208,7 @@ def help(self):
return f"{self.description} : {self.__doc__}"

class Key(Setting):
"""A button or control key. Must be a valid keycode."""
"""A button or trigger. Must be a valid keycode."""
_format = '<H'
kc = KeyCodes()

Expand All @@ -221,11 +222,11 @@ def get(self):
return Key.kc.key[super().get()]

class Signed(Setting):
"""Signed 8-bit value for the deadzone and centering offsets. Keep to the range -10 to 10."""
"""Signed offset for the deadzone and centering settings. Keep to the range -10 to 10."""
_format = '<b'

class Millis(Setting):
"""A macro delay in milliseconds."""
"""A delay in milliseconds."""
_format = '<H'

class Rumble(Setting):
Expand Down

0 comments on commit 2f85e13

Please sign in to comment.