Cymbal pads send up/down so RB3 is playable
This commit is contained in:
parent
c40e7ff970
commit
3e059d0fb1
32
MockBand.ino
32
MockBand.ino
|
@ -122,30 +122,40 @@ void loop() {
|
||||||
}
|
}
|
||||||
next = now + UPDATE_INTERVAL_MS;
|
next = now + UPDATE_INTERVAL_MS;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate and send an HID update
|
||||||
|
//
|
||||||
|
|
||||||
buttonState.buttons = (buttons & 0b1100111111); // +-..!OYRGB
|
buttonState.buttons = (buttons & 0b1100111111); // +-..!OYRGB
|
||||||
#ifdef GUITAR
|
#ifdef GUITAR
|
||||||
buttonState.buttons |= (buttons >> 10) & 0b11111; // Solo keys
|
buttonState.buttons |= (buttons >> 10) & 0b11111; // Solo keys
|
||||||
bitWrite(buttonState.buttons, 6, buttons & (0b11111 << 10)); // Solo modifier
|
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
|
#else // DRUMS
|
||||||
buttonState.buttons |= (buttons >> 10) & 0b01011; // Cymbals
|
buttonState.buttons |= (buttons >> 10) & 0b01011; // Cymbals
|
||||||
bitWrite(buttonState.buttons, 10, buttons & (0b01111 << 0)); // Drum pad modifier
|
bitWrite(buttonState.buttons, 10, buttons & (0b01111 << 0)); // Drum pad modifier
|
||||||
bitWrite(buttonState.buttons, 11, buttons & (0b01011 << 10)); // Cymbals modifier
|
bitWrite(buttonState.buttons, 11, buttons & (0b01011 << 10)); // Cymbals modifier
|
||||||
buttonState.axis[3] = bitRead(buttons, 12)?255:0; // High hat
|
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
|
#endif
|
||||||
|
|
||||||
// D-pad would go here if I ever implemented that:
|
// D-pad would go here if I ever implemented that:
|
||||||
// nothing seems to actualy need it.
|
// 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
|
#ifdef WAMMY
|
||||||
buttonState.axis[2] = analogRead(ANALOG_WAMMY) / 4; // Wammy bar
|
buttonState.axis[2] = analogRead(ANALOG_WAMMY) / 4; // Wammy bar
|
||||||
|
|
34
NOTES.md
34
NOTES.md
|
@ -37,3 +37,37 @@ in addition to the switch bouncing,
|
||||||
the stick was bouncing on the rubber pad.
|
the stick was bouncing on the rubber pad.
|
||||||
I settled on a 40ms silence window as feeling pretty good.
|
I settled on a 40ms silence window as feeling pretty good.
|
||||||
You can adjust this if you want to.
|
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
|
||||||
|
|
Loading…
Reference in New Issue