Просмотр исходного кода

Add BACK4+DPAD mode-switch chords for PS3/PS4/PS5/HORI

copilot-swe-agent[bot] 3 месяцев назад
Родитель
Сommit
80d61598f6
4 измененных файлов с 30 добавлено и 7 удалено
  1. 2 1
      OpenPuck/gamepad_util.cpp
  2. 3 2
      OpenPuck/mode_switch_hori.cpp
  3. 2 1
      OpenPuck/mode_switch_pro.cpp
  4. 23 3
      OpenPuck/rf_link.cpp

+ 2 - 1
OpenPuck/gamepad_util.cpp

@@ -176,7 +176,8 @@ uint32_t psButtonsFromSteam(uint32_t raw)
 		b |= tritonFromCode(g_qamMap);
 	}
 	if ((b & CHORD_BACK4) == CHORD_BACK4)
-		b &= ~(uint32_t)(TB_A | TB_B | TB_X | TB_Y);
+		b &= ~(uint32_t)(TB_A | TB_B | TB_X | TB_Y | TB_DUP | TB_DDN |
+				 TB_DLF | TB_DRT);
 	if (b & TB_L4)
 		psOrBackCode(&b, g_back[0]);
 	if (b & TB_R4)

+ 3 - 2
OpenPuck/mode_switch_hori.cpp

@@ -92,9 +92,10 @@ static void switchBuildHoripad(uint8_t slot, uint8_t out[8])
 	// QAM (3 dots) remap: the configured code is applied to the Switch output just like a back paddle below
 	// (so Capture(18) and every Switch target work). 0 = unmapped -> QAM does nothing on Switch.
 	bool qam = g_qamMap && (b & TB_QAM);
-	// Mode-switch chord (all 4 back + A/X/Y): don't pass the face press to the console while the back-4 are held.
+	// Mode-switch chord (all 4 back + face/dpad): don't pass the press to the console while the back-4 are held.
 	if ((b & CHORD_BACK4) == CHORD_BACK4)
-		b &= ~(uint32_t)(TB_A | TB_X | TB_Y);
+		b &= ~(uint32_t)(TB_A | TB_X | TB_Y | TB_DUP | TB_DDN | TB_DLF |
+				 TB_DRT);
 	// face buttons with optional A/B + X/Y swap (Nintendo physical-vs-label layout)
 	uint16_t fY = g_abSwap ? 0x08 : 0x01, fB = g_abSwap ? 0x04 : 0x02,
 		 fA = g_abSwap ? 0x02 : 0x04, fX = g_abSwap ? 0x01 : 0x08;

+ 2 - 1
OpenPuck/mode_switch_pro.cpp

@@ -437,7 +437,8 @@ static void jcInputPrefix(uint8_t slot, uint8_t *out)
 	// QAM (3 dots) remap -> applied via codeToJc below like a back paddle (so Capture(18)/any target work).
 	bool qam = g_qamMap && (b & TB_QAM);
 	if ((b & CHORD_BACK4) == CHORD_BACK4)
-		b &= ~(uint32_t)(TB_A | TB_B | TB_X | TB_Y);
+		b &= ~(uint32_t)(TB_A | TB_B | TB_X | TB_Y | TB_DUP | TB_DDN |
+				 TB_DLF | TB_DRT);
 	uint32_t fA = g_abSwap ? JC_BTN_B : JC_BTN_A,
 		 fB = g_abSwap ? JC_BTN_A : JC_BTN_B;
 	uint32_t fX = g_abSwap ? JC_BTN_Y : JC_BTN_X,

+ 23 - 3
OpenPuck/rf_link.cpp

@@ -610,15 +610,22 @@ uint8_t rfConnTx(uint8_t ch, uint8_t s1, const uint8_t *payload, uint8_t plen,
 									 .gy,
 								&g_in[g_curSlot]
 									 .gz);
-						// Mode-switch chord (all 4 back + face): don't leak the face press to the host. g_in[g_curSlot].buttons stays
+						// Mode-switch chord (all 4 back + face/dpad): don't leak the press to the host. g_in[g_curSlot].buttons stays
 						// intact so the chord detector still fires; per-mode builders mask the same bits while back-4 held.
 						if ((bb & CHORD_BACK4) ==
-						    CHORD_BACK4)
+						    CHORD_BACK4) {
 							((uint8_t *)rep)[2] &= ~(
 								uint8_t)(TB_A |
 									 TB_B |
 									 TB_X |
 									 TB_Y);
+							((uint8_t *)rep)[3] &= ~(
+								uint8_t)((TB_DDN |
+									  TB_DRT |
+									  TB_DLF |
+									  TB_DUP) >>
+									 8);
+						}
 						// Hand the report to the active controller. STREAM modes ignore it (they emit from task() reading
 						// g_in); PUSH modes (Xbox, puck/lizard) build + send their host report here.
 						if (g_active)
@@ -687,7 +694,8 @@ uint8_t rfConnTx(uint8_t ch, uint8_t s1, const uint8_t *payload, uint8_t plen,
 					}
 					idx += tlen + 2;
 				}
-				// mode-switch chord (back4 + face): A=always Steam; B/X/Y=configurable (g_chordBtn[]). Debounced.
+				// mode-switch chord (back4 + face/dpad): A=always Steam; B/X/Y=configurable (g_chordBtn[]);
+				// dpad left=PS3, up=DS4 game, right=PS5 game, down=Switch HORI. Debounced.
 				{
 					// Per-slot debounce: the chord input is per-slot (g_in[g_curSlot]), so the debounce counter
 					// must be too. The shared-static form worked with 1 controller because slot 0 polled
@@ -714,6 +722,18 @@ uint8_t rfConnTx(uint8_t ch, uint8_t s1, const uint8_t *payload, uint8_t plen,
 						else if (g_in[g_curSlot].buttons &
 							 TB_Y)
 							want = g_chordBtn[2];
+						else if (g_in[g_curSlot].buttons &
+							 TB_DLF)
+							want = MODE_PS3;
+						else if (g_in[g_curSlot].buttons &
+							 TB_DUP)
+							want = MODE_DS4_GAME;
+						else if (g_in[g_curSlot].buttons &
+							 TB_DRT)
+							want = MODE_PS5_GAME;
+						else if (g_in[g_curSlot].buttons &
+							 TB_DDN)
+							want = MODE_SW_HORI;
 					}
 					if (want != 0xFF &&
 					    want == chWant[g_curSlot]) {