فهرست منبع

Fix dropped lizard key/mouse reports; restore pad haptics in pure lizard (#314)

* Queue lizard HID reports through usbTxHid so key edges aren't dropped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Re-enable pad haptics layer on connect in pure lizard mode

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Jari 1 هفته پیش
والد
کامیت
9f67d7fa65
2فایلهای تغییر یافته به همراه19 افزوده شده و 16 حذف شده
  1. 7 3
      OpenPuck/haptics.cpp
  2. 12 13
      OpenPuck/mode_lizard.cpp

+ 7 - 3
OpenPuck/haptics.cpp

@@ -782,9 +782,13 @@ void hapticTask()
 		static const uint8_t DATA_LIZARD_ON[3] = { SETTING_LIZARD_MODE,
 							   0x01, 0x00 };
 
-		// In puck mode Steam owns haptics; skip id9 steering.
-		if (!modeIsPuck(g_usbMode)) {
-			bool wantAuto = (g_padHaptics != 0);
+		// In puck mode Steam owns haptics; skip id9 steering. Pure
+		// lizard is the exception: Steam never sees the controller, so
+		// nothing else would re-enable the pad layer after a session
+		// left id9=0, and the trackpad ticks stay silent.
+		const bool pureLizard = (g_usbMode == MODE_LIZARD);
+		if (!modeIsPuck(g_usbMode) || pureLizard) {
+			bool wantAuto = pureLizard || (g_padHaptics != 0);
 			for (int s = 0; s < NSLOT; s++) {
 				if (!g_slot[s].used || !hapticLinkUp(s)) {
 					// re-land id9 on the next (re)connect: a fresh controller defaults to

+ 12 - 13
OpenPuck/mode_lizard.cpp

@@ -2,6 +2,7 @@
 #include "lizard_map.h"
 #include "triton.h"
 #include "config.h"
+#include "usb_tx.h"
 #include <string.h>
 
 // Evaluate the binding table for ONE controller's button word, merging its keyboard/mouse-button/
@@ -210,6 +211,10 @@ void rfLizard(Adafruit_USBD_HID *mdev, Adafruit_USBD_HID *kdev, uint8_t mrid,
 	}
 
 	// ---- mouse report ----
+	// Mouse, consumer and keyboard share ONE endpoint (hid[0]) that stays busy
+	// until the host next polls. Sending directly under ready() dropped every
+	// report after the first in a cycle while the shadow state still advanced,
+	// losing key edges whenever the cursor moved; usbTxHid queues them in order.
 	if (dx || dy || dw || outMBtn != pmbtn) {
 		pmbtn = outMBtn;
 		hid_mouse_report_t m;
@@ -218,15 +223,13 @@ void rfLizard(Adafruit_USBD_HID *mdev, Adafruit_USBD_HID *kdev, uint8_t mrid,
 		m.y = (int8_t)dy;
 		m.wheel = (int8_t)dw;
 		m.pan = 0;
-		if (mdev->ready())
-			mdev->sendReport(mrid, &m, sizeof m);
+		usbTxHid(mdev, mrid, &m, sizeof m);
 	}
 
 	// ---- consumer control (edge-triggered) ----
 	if (g_usbMode == MODE_LIZARD) {
 		if (consumerBits != prevCC) {
-			if (mdev->ready())
-				mdev->sendReport(0x03, &consumerBits, 1);
+			usbTxHid(mdev, 0x03, &consumerBits, 1);
 			prevCC = consumerBits;
 		}
 	}
@@ -243,8 +246,7 @@ void rfLizard(Adafruit_USBD_HID *mdev, Adafruit_USBD_HID *kdev, uint8_t mrid,
 		uint8_t krep[8] = { outMod,	0,	    outKeys[0],
 				    outKeys[1], outKeys[2], outKeys[3],
 				    outKeys[4], outKeys[5] };
-		if (kdev->ready())
-			kdev->sendReport(krid, krep, 8);
+		usbTxHid(kdev, krid, krep, 8);
 	}
 }
 
@@ -254,20 +256,17 @@ void rfLizard(Adafruit_USBD_HID *mdev, Adafruit_USBD_HID *kdev, uint8_t mrid,
 // keyboard key / mouse button / consumer key that was DOWN at that instant would otherwise stay latched on
 // the desktop until a reconnect or power-cycle (the reported "stuck input after switching modes"). Sends the
 // neutral reports unconditionally (not change-gated) because the whole point is to override a stale held
-// state that the dedup would suppress. Same direct-sendReport path rfLizard uses.
+// state that the dedup would suppress. Same usbTxHid path rfLizard uses.
 void rfLizardRelease(Adafruit_USBD_HID *mdev, Adafruit_USBD_HID *kdev,
 		     uint8_t mrid, uint8_t krid)
 {
 	uint8_t krep[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; // all keys + modifiers up
-	if (kdev->ready())
-		kdev->sendReport(krid, krep, 8);
+	usbTxHid(kdev, krid, krep, 8);
 	hid_mouse_report_t m = { 0, 0, 0, 0, 0 }; // no buttons, no motion/wheel
-	if (mdev->ready())
-		mdev->sendReport(mrid, &m, sizeof m);
+	usbTxHid(mdev, mrid, &m, sizeof m);
 	if (g_usbMode == MODE_LIZARD) {
 		uint8_t cc = 0; // release any held consumer-control key
-		if (mdev->ready())
-			mdev->sendReport(0x03, &cc, 1);
+		usbTxHid(mdev, 0x03, &cc, 1);
 	}
 	// Zero the integrators + last-sent shadows so re-entry starts clean (no cursor fling from stale
 	// velocity, and held keys/buttons re-send correctly on the next rfLizard pass).