Skip to content

Commit 0410a6a

Browse files
committed
add init mode for back buttons
1 parent cabbf26 commit 0410a6a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/hhd/device/claw/base.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@
2929

3030
logger = logging.getLogger(__name__)
3131

32-
CLAW_SET_DINPUT = bytes([0x0F, 0x00, 0x00, 0x3C, 0x24, 0x02])
32+
CLAW_SET_M1 = bytes(
33+
[0x0F, 0x00, 0x00, 0x3C, 0x21, 0x01, 0x00, 0x7A, 0x05, 0x01, 0x00, 0x00, 0x11, 0x00]
34+
)
35+
CLAW_SET_M2 = bytes(
36+
[0x0F, 0x00, 0x00, 0x3C, 0x21, 0x01, 0x01, 0x1F, 0x05, 0x01, 0x00, 0x00, 0x12, 0x00]
37+
)
38+
CLAW_SYNC_ROM = bytes([0x0F, 0x00, 0x00, 0x3C, 0x22])
39+
CLAW_SET_DINPUT = bytes([0x0F, 0x00, 0x00, 0x3C, 0x24, 0x02, 0x00])
40+
CLAW_SET_MSI = bytes([0x0F, 0x00, 0x00, 0x3C, 0x24, 0x03, 0x00])
3341

3442
MSI_CLAW_VID = 0x0DB0
3543
MSI_CLAW_XINPUT_PID = 0x1901
@@ -110,10 +118,17 @@ def consume(self, events: Sequence[Event]) -> None:
110118
)
111119
self.dev.write(cmd)
112120

113-
def set_dinput_mode(self):
121+
def set_dinput_mode(self, init: bool = False) -> None:
114122
if not self.dev:
115123
return
116124

125+
# Make sure M1/M2 are recognizable
126+
if init:
127+
self.dev.write(CLAW_SET_M1)
128+
self.dev.write(CLAW_SET_M2)
129+
self.dev.write(CLAW_SYNC_ROM)
130+
self.dev.write(CLAW_SET_MSI)
131+
117132
# Set the device to dinput mode
118133
self.dev.write(CLAW_SET_DINPUT)
119134

@@ -203,7 +218,7 @@ def plugin_run(
203218
)
204219
try:
205220
d_vend.open()
206-
d_vend.set_dinput_mode()
221+
d_vend.set_dinput_mode(init=True)
207222
d_vend.close(True)
208223
time.sleep(2)
209224
except Exception as e:

0 commit comments

Comments
 (0)