VRInput: fix left controller haptics never firing

INVR_Vibrate()'s channel selection was `i & chan` (bitwise AND) inside
a loop over i in [0,2), instead of just using chan directly as the
index. For chan=0 (left controller, per the only call site iterating
j in [0,2)), i & 0 is always 0, so the "if (channel)" check was never
true and vibration_channel_duration/intensity were never set - the
left controller silently never vibrated. chan=1 (right) happened to
work by coincidence (i=1 gives 1 & 1 == 1). chan is now used directly
as the array index, with no loop needed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L4QAoxV2KY7ek4PcZw3WvY
This commit is contained in:
Henrik RydgårdandClaude Sonnet 5 committed 2026-08-09 21:41:54 +02:00
1 parent 7ff9fbdb47
commit 4706a4509d
1 file changed
+8 -11
+8 -11
View File
@@ -78,19 +78,16 @@ XrTime ToXrTime(const double timeInSeconds) {
}
void INVR_Vibrate( int duration, int chan, float intensity ) {
for (int i = 0; i < 2; ++i) {
int channel = i & chan;
if (channel) {
if (vibration_channel_duration[channel] > 0.0f)
return;
// chan selects the controller directly (0 = left, 1 = right) - it's an index into
// vibration_channel_duration/intensity, not a bitmask.
if (vibration_channel_duration[chan] > 0.0f)
return;
if (vibration_channel_duration[channel] == -1.0f && duration != 0.0f)
return;
if (vibration_channel_duration[chan] == -1.0f && duration != 0.0f)
return;
vibration_channel_duration[channel] = (float)duration;
vibration_channel_intensity[channel] = intensity;
}
}
vibration_channel_duration[chan] = (float)duration;
vibration_channel_intensity[chan] = intensity;
}
void VR_processHaptics() {