Cymbal pads send up/down so RB3 is playable

This commit is contained in:
Neale Pickett 2024-01-03 19:10:58 -07:00
parent c40e7ff970
commit 3e059d0fb1
2 changed files with 55 additions and 11 deletions

View File

@ -121,31 +121,41 @@ void loop() {
continue;
}
next = now + UPDATE_INTERVAL_MS;
//
// Calculate and send an HID update
//
buttonState.buttons = (buttons & 0b1100111111); // +-..!OYRGB
#ifdef GUITAR
buttonState.buttons |= (buttons >> 10) & 0b11111; // Solo keys
bitWrite(buttonState.buttons, 6, buttons & (0b11111 << 10)); // Solo modifier
if (bitRead(buttons, 6)) {
buttonState.hatAndConstant = 0; // up
} else if bitRead(buttons, 7) { //
buttonState.hatAndConstant = 4; // down
} else {
buttonState.hatAndConstant = 8; // nothing
}
#else // DRUMS
buttonState.buttons |= (buttons >> 10) & 0b01011; // Cymbals
bitWrite(buttonState.buttons, 10, buttons & (0b01111 << 0)); // Drum pad modifier
bitWrite(buttonState.buttons, 11, buttons & (0b01011 << 10)); // Cymbals modifier
buttonState.axis[3] = bitRead(buttons, 12)?255:0; // High hat
// Use the cymbals for up and down, since I don't have a D-pad
if bitRead(buttons, 13) {
buttonState.hatAndConstant = 0; // up
} else if bitRead(buttons, 10) {
buttonState.hatAndConstant = 4; // down
} else {
buttonState.hatAndConstant = 8; // nothing
}
#endif
// D-pad would go here if I ever implemented that:
// nothing seems to actualy need it.
//
// I don't understand why any rational engineer would have specified this algorithm.
if (bitRead(buttons, 6)) {
buttonState.hatAndConstant = 0x00; // up
} else if bitRead(buttons, 7) { //
buttonState.hatAndConstant = 0x04; // down
} else {
buttonState.hatAndConstant = 0x08; // nothing
}
// left: 0x06
// right: 0x02
#ifdef WAMMY
buttonState.axis[2] = analogRead(ANALOG_WAMMY) / 4; // Wammy bar

View File

@ -37,3 +37,37 @@ in addition to the switch bouncing,
the stick was bouncing on the rubber pad.
I settled on a 40ms silence window as feeling pretty good.
You can adjust this if you want to.
Gamepad Buttons
---------------
The `buttons` struct member is a bitmap,
each bit mapping to one of the 12 buttons reported through HID.
Here's what each bit means:
* 0: Blue
* 1: Green
* 2: Red
* 3: Yellow
* 4: Orange
* 5: Tilt Switch / 2x kick
* 6: Solo modifier (second row of buttons on guitar)
* 7: ?
* 8: Minus
* 9: Plus
* 10: Drum pad modifier?
* 11: Cymbal modifier?
* 12: ?
hatAndConstant
--------------
I don't get this, but here's what the values mean:
* 2: right
* 6: left
* 0: up
* 4: down
* 8: nothing