Explorar o código

Drop formatting requirement for trailing comments

Jari hai 4 meses
pai
achega
be0d648579

+ 2 - 4
.github/workflows/format.yml

@@ -20,9 +20,7 @@ jobs:
           sudo apt-get update
           sudo apt-get install -y clang-format-18
 
-      - name: Check formatting and style
+      - name: Check formatting
         # Fails the job (and blocks the PR) the moment any file differs from
-        # the Linux kernel .clang-format style, or a long trailing // comment
-        # is found. Run `make format` to fix formatting; move long trailing
-        # comments above their statement to satisfy the lint.
+        # the Linux kernel .clang-format style. Run `make format` to fix.
         run: make check

+ 2 - 8
Makefile

@@ -16,7 +16,7 @@ FORMAT_FILES := $(shell find OpenPuck ReversePuckFirmware puck_sniffer pairtui \
 	\( -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' -o -name '*.ino' \) \
 	-not -name 'git_version.h')
 
-.PHONY: format format-check lint check
+.PHONY: format format-check check
 
 ## Reformat all C/C++ sources in place using the Linux kernel style.
 format:
@@ -27,11 +27,5 @@ format:
 format-check:
 	$(CLANG_FORMAT) --dry-run --Werror $(FORMAT_FILES)
 
-## Style rules clang-format can't enforce. Currently: a long trailing //
-## comment must be moved onto its own line above the statement (clang-format
-## won't relocate it, so it would otherwise split the code or run past 80).
-lint:
-	python3 tools/check-trailing-comments.py $(FORMAT_FILES)
-
 ## Everything CI gates on.
-check: format-check lint
+check: format-check

+ 9 - 6
OpenPuck/OpenPuck.ino

@@ -62,14 +62,16 @@ void usbReenumerate(uint8_t k)
 	USBDevice.setConfigurationBuffer(g_usbCfgDesc, sizeof g_usbCfgDesc);
 	g_active->usbIdentity(); // clearConfiguration reset VID/PID/strings -- restore them
 	// serial carries the mounted count so the host invalidates its cached config descriptor on a change
-	snprintf(g_usbSerial, sizeof g_usbSerial, "%s%c%u", g_unit,
-		 MODE_SUFFIX[(g_usbMode >= 1 && g_usbMode <= 8) ? g_usbMode - 1 :
-							         0],
-		 (unsigned)k);
+	snprintf(
+		g_usbSerial, sizeof g_usbSerial, "%s%c%u", g_unit,
+		MODE_SUFFIX[(g_usbMode >= 1 && g_usbMode <= 8) ? g_usbMode - 1 :
+								 0],
+		(unsigned)k);
 	USBDevice.setSerialDescriptor(g_usbSerial);
 	if (s_dynWantWakeMouse)
 		wakeHidAddInterface(); // HID instance 0
-	g_active->mountSlots(k); // mode's fixed HIDs (if any) + k slot interfaces
+	g_active->mountSlots(
+		k); // mode's fixed HIDs (if any) + k slot interfaces
 	if (s_dynWantWebusb)
 		USBDevice.addInterface(usb_web);
 	USBDevice.setConfigurationAttribute(0x80 | 0x20);
@@ -135,7 +137,8 @@ void setup()
 			usb_web.begin();
 		usbMountEnable(true, g_active->maxSlots());
 		usbMountRebuildMap(); // initial connected set (usually empty at cold boot)
-		usbReenumerate(g_usbMountCount); // build the live descriptor + attach
+		usbReenumerate(
+			g_usbMountCount); // build the live descriptor + attach
 	} else {
 		USBDevice.detach();
 		delay(30);

+ 4 - 3
OpenPuck/config.cpp

@@ -39,7 +39,8 @@ uint8_t g_padHaptics = 1;
 void applyActiveType()
 {
 	g_etype = etypeForMode(g_usbMode);
-	if (g_etype >= ET_COUNT) { // puck mode (Steam/Lizard): no remap, haptics on
+	if (g_etype >=
+	    ET_COUNT) { // puck mode (Steam/Lizard): no remap, haptics on
 		g_back[0] = 5;
 		g_back[1] = 6;
 		g_back[2] = 7;
@@ -67,8 +68,8 @@ const uint32_t g_pollUs = POLL_US_DEFAULT;
 // bumped (per-type TypeCfg blob replaces scalar abSwap/back/qamMap): old cfg ignored -> clean defaults on first boot
 #define CFG_MAGIC 0xCA
 struct Cfg {
-	uint8_t magic, mode, mDiv, mFric, rsvd0, pollU100, persistMode, bootMode,
-		chordBtn[3], rumbleScale;
+	uint8_t magic, mode, mDiv, mFric, rsvd0, pollU100, persistMode,
+		bootMode, chordBtn[3], rumbleScale;
 	TypeCfg type[ET_COUNT]; // per-emulated-type back/qam/abSwap/padHaptics
 }; // rsvd0 = ex-padSmooth, now the one-shot debug-CDC arm
 

+ 4 - 2
OpenPuck/config.h

@@ -120,14 +120,16 @@ struct TypeCfg {
 	uint8_t padHaptics;
 };
 extern TypeCfg g_type[ET_COUNT];
-extern uint8_t g_etype; // etypeForMode(g_usbMode), resolved at boot (ET_NONE for puck modes)
+extern uint8_t
+	g_etype; // etypeForMode(g_usbMode), resolved at boot (ET_NONE for puck modes)
 
 // Live, resolved-active-type mirrors of g_type[g_etype], read by the hot-path mode builders. Refreshed by
 // applyActiveType() at boot and after any edit to the active type.
 extern uint8_t g_abSwap; // 1 = swap A/B and X/Y (Nintendo face-button layout)
 extern uint8_t g_back[4];
 extern uint8_t g_qamMap;
-extern uint8_t g_padHaptics; // 1 = trackpad haptics on (default), 0 = disabled for the active type
+extern uint8_t
+	g_padHaptics; // 1 = trackpad haptics on (default), 0 = disabled for the active type
 
 // Copy g_type[g_etype] into the live mirrors above (safe defaults when g_etype == ET_NONE).
 void applyActiveType();

+ 6 - 3
OpenPuck/mode_switch_pro.cpp

@@ -205,7 +205,8 @@ static void jcRumble(uint8_t slot, const uint8_t *p, uint16_t pn)
 		return;
 	g_jcLastLo[slot] = lo;
 	g_jcLastHi[slot] = hi;
-	hapticSteamRumble(lo, hi, jcBondOf(slot)); // route to the mapped controller
+	hapticSteamRumble(lo, hi,
+			  jcBondOf(slot)); // route to the mapped controller
 }
 static int jcStick12(int16_t v, bool inv)
 { // steam int16 (center 0) -> 12-bit (center 0x800), clamped
@@ -224,7 +225,8 @@ static void jcPackStick(uint8_t s[3], int16_t x, int16_t y)
 // shared by the streamed 0x30 report and the 0x21 subcommand-reply reports the host reads during init.
 static void jcInputPrefix(uint8_t slot, uint8_t *out)
 {
-	uint8_t bond = jcBondOf(slot); // input data comes from the mapped controller; timer/state stay per USB slot
+	uint8_t bond = jcBondOf(
+		slot); // input data comes from the mapped controller; timer/state stay per USB slot
 	uint32_t b = g_in[bond].buttons;
 	// 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);
@@ -298,7 +300,8 @@ static void jcInputPrefix(uint8_t slot, uint8_t *out)
 }
 static void switchProBuild(uint8_t slot, uint8_t out[63])
 {
-	uint8_t bond = jcBondOf(slot); // IMU data comes from the mapped controller
+	uint8_t bond =
+		jcBondOf(slot); // IMU data comes from the mapped controller
 	memset(out, 0, 63);
 	jcInputPrefix(slot, out);
 	// Gyro slot order follows hid-nintendo: raw+6 = ROLL, raw+8 = PITCH, raw+10 = YAW. Source routing (a proper

+ 2 - 1
OpenPuck/mode_xinput.cpp

@@ -82,7 +82,8 @@ static bool xi_deinit(void)
 static void xi_reset(uint8_t rhport)
 {
 	(void)rhport;
-	g_xiOpenU = 0; // restart per-interface claim ordering for this enumeration
+	g_xiOpenU =
+		0; // restart per-interface claim ordering for this enumeration
 	for (int s = 0; s < NSLOT; s++) {
 		g_xiSlot[s].itf = 0;
 		g_xiSlot[s].epIn = g_xiSlot[s].epOut = 0;

+ 8 - 4
OpenPuck/puck_hid.cpp

@@ -516,8 +516,10 @@ static void wakeNudgeTask()
 		if (millis() - stepMs < 15)
 			return; // pace the edges
 		stepMs = millis();
-		wakeHidMove((step == 1) ? NUDGE_JIGGLE_PX : -NUDGE_JIGGLE_PX, 0);
-		if (step >= 2) { // jiggle (right, then back) delivered -> disarm every slot
+		wakeHidMove((step == 1) ? NUDGE_JIGGLE_PX : -NUDGE_JIGGLE_PX,
+			    0);
+		if (step >=
+		    2) { // jiggle (right, then back) delivered -> disarm every slot
 			step = 1;
 			for (int s = 0; s < NSLOT; s++)
 				g_nudgeStep[s] = 0;
@@ -537,11 +539,13 @@ static void wakeNudgeTask()
 		stepMs[s] = millis();
 		hid_mouse_report_t m;
 		m.buttons = 0;
-		m.x = (g_nudgeStep[s] == 1) ? NUDGE_JIGGLE_PX : -NUDGE_JIGGLE_PX;
+		m.x = (g_nudgeStep[s] == 1) ? NUDGE_JIGGLE_PX :
+					      -NUDGE_JIGGLE_PX;
 		m.y = 0;
 		m.wheel = 0;
 		m.pan = 0;
-		hid[s].sendReport(0x40, &m, sizeof m); // jiggle right, then back
+		hid[s].sendReport(0x40, &m,
+				  sizeof m); // jiggle right, then back
 		g_nudgeStep[s] = (g_nudgeStep[s] >= 2) ?
 					 0 :
 					 (uint8_t)(g_nudgeStep[s] + 1);

+ 7 - 5
OpenPuck/radio.cpp

@@ -43,15 +43,17 @@ void rfGenSessionAddr(int slot)
 		}
 	uint32_t h, h2;
 	if (uuidLive) {
-		h = (uint32_t)uuid[0] * 0x9E3779B1u ^ (uint32_t)uuid[2] * 0x85EBCA6Bu ^
+		h = (uint32_t)uuid[0] * 0x9E3779B1u ^
+		    (uint32_t)uuid[2] * 0x85EBCA6Bu ^
 		    (uint32_t)uuid[4] * 0xC2B2AE35u ^ (uint32_t)uuid[6] ^
 		    NRF_FICR->DEVICEID[0];
-		h2 = (uint32_t)uuid[1] * 0x27D4EB2Fu ^ (uint32_t)uuid[3] * 0x165667B1u ^
-		     (uint32_t)uuid[5] ^ (uint32_t)uuid[7] * 0x9E3779B1u ^
-		     NRF_FICR->DEVICEID[1];
+		h2 = (uint32_t)uuid[1] * 0x27D4EB2Fu ^
+		     (uint32_t)uuid[3] * 0x165667B1u ^ (uint32_t)uuid[5] ^
+		     (uint32_t)uuid[7] * 0x9E3779B1u ^ NRF_FICR->DEVICEID[1];
 	} else {
 		h = NRF_FICR->DEVICEID[0] * 0x9E3779B1u ^ NRF_FICR->DEVICEID[1];
-		h2 = NRF_FICR->DEVICEID[1] * 0x85EBCA6Bu ^ NRF_FICR->DEVICEID[0];
+		h2 = NRF_FICR->DEVICEID[1] * 0x85EBCA6Bu ^
+		     NRF_FICR->DEVICEID[0];
 	}
 	// Scrub degenerate bytes (0x00/0xFF) for clean preamble correlation.
 	for (int i = 0; i < 4; i++) {

+ 2 - 1
OpenPuck/rf_link.h

@@ -51,7 +51,8 @@ extern unsigned long g_connCooldown;
 // connected-mode state (reset by the 'k' console toggle)
 extern uint8_t g_connSt, g_connStep;
 extern uint16_t g_connPoll;
-extern uint32_t g_connF1; // count of 0xF1 input reports seen (aggregate across all slots)
+extern uint32_t
+	g_connF1; // count of 0xF1 input reports seen (aggregate across all slots)
 
 // last protocol version the controller reported in an F3 reply (0xFF=none) -- aggregate (last writer wins)
 extern uint8_t g_connF3v;

+ 2 - 1
OpenPuck/serial_console.cpp

@@ -223,7 +223,8 @@ void serialConsolePoll()
 					saveCfg();
 					Serial.printf(
 						"# A/B + X/Y swap %s (Nintendo layout) [type %u]\n",
-						g_abSwap ? "ON" : "off", g_etype);
+						g_abSwap ? "ON" : "off",
+						g_etype);
 				} else
 					Serial.println(
 						"# A/B swap N/A in this mode (Steam/Lizard are not emulated types)");

+ 4 - 2
OpenPuck/webusb_config.cpp

@@ -265,7 +265,8 @@ void webusbPoll()
 						else if (k == 4)
 							g_type[et].qamMap = v;
 						else if (k == 5)
-							g_type[et].abSwap = v ? 1 : 0;
+							g_type[et].abSwap =
+								v ? 1 : 0;
 						else if (k == 6)
 							g_type[et].padHaptics =
 								v ? 1 : 0;
@@ -289,7 +290,8 @@ void webusbPoll()
 				// Legacy single-value fields (4 abSwap, 5-8 back, 21 qam) edit the ACTIVE emulated type.
 				case 4:
 					if (g_etype < ET_COUNT) {
-						g_type[g_etype].abSwap = v ? 1 : 0;
+						g_type[g_etype].abSwap = v ? 1 :
+									     0;
 						applyActiveType();
 					}
 					break;