소스 검색

Drop bits that can activate from the grip in lizard mode (#140)

* Drop bits that can activate from the grip

* fmt
Jari 3 달 전
부모
커밋
cab2f7e892
2개의 변경된 파일과 9개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 2
      OpenPuck/lizard_map.h
  2. 5 1
      OpenPuck/mode_lizard.cpp

+ 4 - 2
OpenPuck/lizard_map.h

@@ -39,8 +39,10 @@
 #define LZ_GYRO_BTN 3u
 
 // ---- virtual stick-deflection trigger bits (usable in trigMask / holdMask) ----
-// The SC2 controller never sets bits 28..31 in its 0x45 report; rfLizard ORs these in after
-// reading the physical button word so bindings can fire on stick deflection.
+// These reuse bits 28..31 of the button word, which the SC2 *does* use in its 0x45 report (bit 28 =
+// right grip touch, bit 29 = left grip touch; PROTOCOL.md §8). To avoid grip-touch firing these,
+// lizardButtons() masks the controller's top 4 bits off before OR-ing in the deflection flags below,
+// so in MODE_LIZARD these bits mean ONLY stick deflection (grips are not a bindable lizard input).
 #define LZ_BTN_LSTICK_RT 0x10000000u // lx >  12000
 #define LZ_BTN_LSTICK_LF 0x20000000u // lx < -12000
 #define LZ_BTN_LSTICK_DN 0x40000000u // ly < -12000

+ 5 - 1
OpenPuck/mode_lizard.cpp

@@ -71,9 +71,13 @@ static void lizardEvalSlot(uint32_t buttons, uint8_t &outMod,
 }
 
 // Add the virtual stick-deflection bits so bindings can trigger on left-stick direction.
+// The LZ_BTN_LSTICK_* flags live on bits 28..31, which OVERLAP real controller inputs: bit 28 = right
+// grip touch, bit 29 = left grip touch (PROTOCOL.md §8). Merely holding the controller sets the grip
+// bits, which would masquerade as an L-stick deflection and fire the bound key. Clear the top 4 bits of
+// the physical word (grips are not a bindable lizard input) so these flags reflect ONLY stick deflection.
 static uint32_t lizardButtons(const PuckInput &in)
 {
-	uint32_t buttons = in.buttons;
+	uint32_t buttons = in.buttons & 0x0FFFFFFFu;
 	if (in.lx > 12000)
 		buttons |= LZ_BTN_LSTICK_RT;
 	if (in.lx < -12000)