Ver Fonte

Fix scale

Jari há 3 meses atrás
pai
commit
67346300f4
4 ficheiros alterados com 28 adições e 26 exclusões
  1. 10 10
      OpenPuck/config.cpp
  2. 4 4
      OpenPuck/config.h
  3. 7 5
      OpenPuck/webusb_config.cpp
  4. 7 7
      docs/index.html

+ 10 - 10
OpenPuck/config.cpp

@@ -24,13 +24,13 @@ int g_mDiv = 64, g_mFric = 94;
 // Per-type button config. back default {5,6,7,8} = L4->LB R4->RB L5->L3 R5->R3 (0..11 buttons, 12..15 D-pad,
 // 16/17 PS touch/mute, 18 Switch Capture). Switch differs: QAM defaults to Capture(18), A/B swap on, and
 // trackpad haptics off. qamMap 0 = unmapped (hardcoded per-mode behavior). ledBright 0 = no override.
-// rumble 1 = enabled (default), 0 = host rumble silenced for that type. rumbleScale 200 = double strength
-// (default), 100 = native, 0 = off -- per emulated type.
+// rumble 1 = enabled (default), 0 = host rumble silenced for that type. rumbleScale 100 = native strength
+// (default), 200 = double (max), 0 = off -- per emulated type.
 TypeCfg g_type[ET_COUNT] = {
-	/* ET_XBOX   */ { { 5, 6, 7, 8 }, 0, 0, 1, 0, 1, 200 },
-	/* ET_SWITCH */ { { 5, 6, 7, 8 }, 18, 1, 0, 0, 1, 200 },
-	/* ET_DS4    */ { { 5, 6, 7, 8 }, 0, 0, 1, 0, 1, 200 },
-	/* ET_DS5    */ { { 5, 6, 7, 8 }, 0, 0, 1, 0, 1, 200 },
+	/* ET_XBOX   */ { { 5, 6, 7, 8 }, 0, 0, 1, 0, 1, 100 },
+	/* ET_SWITCH */ { { 5, 6, 7, 8 }, 18, 1, 0, 0, 1, 100 },
+	/* ET_DS4    */ { { 5, 6, 7, 8 }, 0, 0, 1, 0, 1, 100 },
+	/* ET_DS5    */ { { 5, 6, 7, 8 }, 0, 0, 1, 0, 1, 100 },
 };
 uint8_t g_etype = ET_NONE;
 
@@ -57,7 +57,7 @@ void applyActiveType()
 		g_rumble = 1;
 		g_ledBright = 0;
 		g_rumbleScale =
-			200; // puck modes forward rumble verbatim; scale unused
+			100; // puck modes forward rumble verbatim; scale unused
 		return;
 	}
 	const TypeCfg &t = g_type[g_etype];
@@ -70,9 +70,9 @@ void applyActiveType()
 	g_ledBright = t.ledBright;
 	g_rumbleScale = t.rumbleScale;
 }
-// Live mirror of the active type's rumble strength % (200 = double). Set by applyActiveType(); the
-// per-type source of truth is g_type[et].rumbleScale, edited from the WebUSB panel / CDC console.
-uint8_t g_rumbleScale = 200;
+// Live mirror of the active type's rumble strength % (100 = native default, 200 = double max). Set by
+// applyActiveType(); the per-type source of truth is g_type[et].rumbleScale, edited from the WebUSB panel.
+uint8_t g_rumbleScale = 100;
 
 // poll rate defaults to POLL_US_DEFAULT (250 Hz), matching the real Valve puck (see config.h). The
 // delivered report rate equals the poll rate (fresh IMU in every reply). Live-adjustable via console

+ 4 - 4
OpenPuck/config.h

@@ -122,8 +122,8 @@ extern int g_mDiv, g_mFric; // xbox/lizard mouse sensitivity divisor / friction%
 // ledBright = LED brightness sent to the controller on connect: 0 = no override (controller default),
 // 1-100 = brightness %. Steam sets brightness each session; emulated modes never do, so the controller
 // comes up at full brightness. Setting a value here preserves the preferred brightness across mode switches.
-// rumbleScale = host-rumble strength for this type, percent of decoded amplitude (0 = off, 100 = 1x native,
-// 200 = double, default). Applied in hapticSteamRumble() -- the choke point every emulated mode's rumble
+// rumbleScale = host-rumble strength for this type, percent of decoded amplitude (0 = off, 100 = 1x native
+// default, 200 = double max). Applied in hapticSteamRumble() -- the choke point every emulated mode's rumble
 // passes through -- so each emulated controller can be tuned independently.
 struct TypeCfg {
 	uint8_t back[4];
@@ -152,8 +152,8 @@ extern uint8_t g_ledBright;
 
 // Copy g_type[g_etype] into the live mirrors above (safe defaults when g_etype == ET_NONE).
 void applyActiveType();
-// Live mirror of the active emulated type's rumble strength (percent of decoded amplitude; 100 = 1x,
-// 200 = 2x default). Read by hapticSteamRumble(); refreshed by applyActiveType() (200 for puck modes,
+// Live mirror of the active emulated type's rumble strength (percent of decoded amplitude; 100 = 1x
+// default, 200 = 2x max). Read by hapticSteamRumble(); refreshed by applyActiveType() (100 for puck modes,
 // which forward rumble verbatim and never scale). Edit the per-type value in g_type[et].rumbleScale.
 extern uint8_t g_rumbleScale;
 // Switch Pro motion settings. Persisted in their OWN flash file (mode_switch_pro.cpp), NOT in Cfg -- so changing

+ 7 - 5
OpenPuck/webusb_config.cpp

@@ -934,22 +934,24 @@ void webusbPoll()
 					}
 					break;
 
-				// LEGACY rumble strength % (0=off, 100=1x, 200=double): edits the ACTIVE emulated
-				// type (rumble strength is now per-type; kept so old panels / backups still apply).
+				// LEGACY rumble strength % (0=off, 100=1x native, 200=double max): edits the ACTIVE
+				// emulated type (rumble strength is now per-type; kept so old panels/backups still apply).
 				case 22:
 					if (g_etype < ET_COUNT) {
-						g_type[g_etype].rumbleScale = v;
+						g_type[g_etype].rumbleScale =
+							v > 200 ? 200 : v;
 						applyActiveType();
 					}
 					break;
 
-				// per-emulated-type rumble strength % (v18): fields 30..33 = ET_XBOX/SWITCH/DS4/DS5.
+				// per-emulated-type rumble strength % (v18): fields 30..33 = ET_XBOX/SWITCH/DS4/DS5
+				// (0=off, 100=native default, 200=double max).
 				case 30:
 				case 31:
 				case 32:
 				case 33: {
 					uint8_t et = (uint8_t)(f - 30);
-					g_type[et].rumbleScale = v;
+					g_type[et].rumbleScale = v > 200 ? 200 : v;
 					if (et == g_etype)
 						applyActiveType();
 					break;

+ 7 - 7
docs/index.html

@@ -544,13 +544,13 @@ function setTab(et){
     // Rumble strength (per-type; write fields 30..33, blob v18 at JS p[180+et]). 0=off, 100=native, 200=double.
     { const row=document.createElement("div"); row.className="row";
       const lab=document.createElement("label"); lab.textContent="Rumble strength"; row.appendChild(lab);
-      const sl=document.createElement("input"); sl.type="range"; sl.min=0; sl.max=255; sl.step=5; row.appendChild(sl);
+      const sl=document.createElement("input"); sl.type="range"; sl.min=0; sl.max=200; sl.step=5; row.appendChild(sl);
       const vspan=document.createElement("span"); vspan.className="val"; row.appendChild(vspan);
       sl.addEventListener("input",()=>{ vspan.textContent=sl.value+"%"; });
       sl.addEventListener("change",()=>setField(30+et, +sl.value));
       sec.appendChild(row);
       const note=document.createElement("p"); note.className="note";
-      note.textContent="Scales host rumble for this controller type (100% = native, 200% = double, 0% = off). Use the toggle above to disable rumble entirely.";
+      note.textContent="Scales host rumble for this controller type (100% = native default, 200% = double max, 0% = off). Use the toggle above to disable rumble entirely.";
       sec.appendChild(note);
       rec.rumbleScale=sl; rec.rumbleScaleV=vspan; }
     host.appendChild(sec); typeEls.push(rec);
@@ -948,8 +948,8 @@ function applyBlob(p){
       rec.pad.textContent=pad?"on":"off"; rec.pad.classList.toggle("active",!!pad);
       rec.rumble.textContent=rum?"on":"off"; rec.rumble.classList.toggle("active",!!rum);
       if(document.activeElement!==rec.led){ rec.led.value=led; rec.ledV.textContent=(led===0)?"Auto":led+"%"; }
-      // per-type rumble strength (blob v18, firmware p[182+et] -> JS p[180+et]; defaults 200 for older fw)
-      { const rs=(p.length>180+et)?p[180+et]:200;
+      // per-type rumble strength (blob v18, firmware p[182+et] -> JS p[180+et]; defaults 100 for older fw)
+      { const rs=(p.length>180+et)?p[180+et]:100;
         if(document.activeElement!==rec.rumbleScale){ rec.rumbleScale.value=rs; rec.rumbleScaleV.textContent=rec.rumbleScale.value+"%"; } }
       // dot marks the type matching the current puck mode
       rec.activeDot.style.display = (et===activeEt) ? "" : "none";
@@ -992,7 +992,7 @@ function buildBackup(p, bp){
   const types=[];
   for(let et=0; et<TYPE_DEFS.length; et++){ const q=73+et*9;
     types.push({back:[p[q],p[q+1],p[q+2],p[q+3]], qam:p[q+4], abSwap:p[q+5], pad:p[q+6], led:p[q+7], rumble:p[q+8],
-                rumbleScale:(p.length>180+et?p[180+et]:200)}); }
+                rumbleScale:(p.length>180+et?p[180+et]:100)}); }
   const cfg={ mode:p[1], mDiv:p[2], mFric:p[3], persistMode:p[22], chord:[p[23],p[24],p[25]],
               swProRate:p[52], swGyro10:p[53], types };
   // version 2: include the lizard map so it survives a backup/restore cycle.
@@ -1083,8 +1083,8 @@ async function importBackup(file){
         await sf(40+et*9+4, t.qam); await sf(40+et*9+5, t.abSwap?1:0);
         await sf(40+et*9+6, t.pad?1:0); await sf(40+et*9+7, t.led);
         await sf(40+et*9+8, t.rumble!==undefined?t.rumble:1);
-        // per-type rumble strength (field 30..33); default 200 (2x) for pre-v18 backups
-        await sf(30+et, t.rumbleScale!==undefined?t.rumbleScale:200); }
+        // per-type rumble strength (field 30..33); default 100 (native) for pre-v18 backups
+        await sf(30+et, t.rumbleScale!==undefined?t.rumbleScale:100); }
       log("settings replayed ("+(8+legacyRumbleN+typeN*10)+" fields)");
     } else { log("settings replayed ("+(8+legacyRumbleN)+" fields — no per-type config in this backup)"); }
     // restore the lizard map if the backup includes it (version 2+) and the puck speaks v16+.