Skip to content

Commit 14a22be

Browse files
committed
add deadzone support
1 parent c7ea7be commit 14a22be

File tree

3 files changed

+64
-12
lines changed

3 files changed

+64
-12
lines changed

src/hhd/device/gpd/win/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def update(self, conf: Config):
206206

207207
buttons = {}
208208
delays = {}
209+
deadzones = {}
209210

210211
match c.get("mouse_mode", "unchanged"):
211212
case "mouse":
@@ -226,6 +227,9 @@ def update(self, conf: Config):
226227
case "default":
227228
buttons.update(BACKBUTTONS_DEFAULT["buttons"])
228229
delays.update(BACKBUTTONS_DEFAULT["delays"])
230+
231+
if c.get("deadzones.mode", "unchanged") == "custom":
232+
deadzones.update(c.get("deadzones.custom", {}))
229233

230234
rgb_mode = "off"
231235
rgb_color = (0, 0, 0)
@@ -250,6 +254,7 @@ def update(self, conf: Config):
250254
rumble=vibration,
251255
rgb_mode=rgb_mode,
252256
rgb_color=rgb_color, # type: ignore
257+
deadzones=deadzones
253258
)
254259
except Exception as e:
255260
conf["wincontrols.wincontrols.status"] = f"{e}"

src/hhd/device/gpd/win/wincontrols.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@
230230
}
231231

232232
DEADZONE_MAP = {
233-
"ls_deadzone": 72,
233+
"ls_boundary": 72,
234234
"ls_center": 73,
235-
"rs_deadzone": 74,
235+
"rs_boundary": 74,
236236
"rs_center": 75,
237237
}
238238

@@ -370,16 +370,8 @@ def get_command(cid: int, ofs: int = 0, payload: bytes = b"") -> bytes:
370370

371371
PAUSE = 0.05
372372

373-
GM_SUPPROTED_VERSIONS = {
374-
3: 0x14, # Win Max 2
375-
4: 0x09, # Win 4
376-
5: 0x10 # Win Mini
377-
}
378-
EXT_SUPPORTED_VERSIONS = {
379-
1: 0x23,
380-
4: 0x07,
381-
5: 0x04
382-
}
373+
GM_SUPPROTED_VERSIONS = {3: 0x14, 4: 0x09, 5: 0x10} # Win Max 2 # Win 4 # Win Mini
374+
EXT_SUPPORTED_VERSIONS = {1: 0x23, 4: 0x07, 5: 0x04}
383375

384376

385377
def check_fwver(res: bytes):
@@ -537,6 +529,13 @@ def update_config(
537529
assert rumble in RUMBLE_MODES, f"Unknown rumble mode {rumble}"
538530
cfg[66 : 66 + 2] = RUMBLE_MODES[rumble].to_bytes(2, "little")
539531

532+
deadzones = {k: min(max(v, -10), 10) for k, v in deadzones.items()}
533+
for k, v in deadzones.items():
534+
assert k in DEADZONE_MAP, f"Unknown deadzone {k}"
535+
cfg[DEADZONE_MAP[k] : DEADZONE_MAP[k] + 1] = v.to_bytes(
536+
1, "little", signed=True
537+
)
538+
540539
if "K4" in fwver:
541540
# Limit RGB changes to Win 4 with firmware 40X
542541
if rgb_mode is not None:

src/hhd/device/gpd/win/wincontrols.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,54 @@ children:
9494
default: "Default (Pause/PrntScr)"
9595
default: hhd
9696

97+
deadzones:
98+
type: mode
99+
title: Deadzones
100+
default: unchanged
101+
102+
modes:
103+
unchanged:
104+
type: container
105+
title: "Do not change"
106+
tags: [ non-essential, deadzone, unchanged ]
107+
hint: >-
108+
Do not change the deadzones.
109+
110+
custom:
111+
type: container
112+
title: "Set Deadzones"
113+
tags: [ non-essential, deadzone, custom ]
114+
hint: >-
115+
Use custom deadzones.
116+
children:
117+
ls_center:
118+
type: int
119+
title: Left Stick Deadzone
120+
min: -10
121+
max: 10
122+
default: 0
123+
124+
ls_boundary:
125+
type: int
126+
title: Left Stick Endstop
127+
min: -10
128+
max: 10
129+
default: 0
130+
131+
rs_center:
132+
type: int
133+
title: Right Stick Deadzone
134+
min: -10
135+
max: 10
136+
default: 0
137+
138+
rs_boundary:
139+
type: int
140+
title: Right Stick Endstop
141+
min: -10
142+
max: 10
143+
default: 0
144+
97145
vibration:
98146
type: multiple
99147
title: Vibration Strength

0 commit comments

Comments
 (0)