Send CH-friendly dpad on cymbals; +XBox drum PID

This commit is contained in:
Neale Pickett 2024-01-07 14:54:34 -07:00
parent edaf38c598
commit f35e123474
1 changed files with 18 additions and 11 deletions

View File

@ -2,8 +2,6 @@
#include <Arduino.h>
#include <PluggableUSB.h>
//#define DEBUG
#include "hid.hh" // Modified HID library: doesn't prefix each packet with ID
#include "instrument.hh"
#include "standard.hh" // Standard pins
@ -28,7 +26,9 @@
#error USB_VID must be set to 0x1bad: see INSTALL.md
#endif
#if USB_PID == 0x0004
#if USB_PID == 0x0003
#define DRUM // XBox
#elif USB_PID == 0x0004
#define GUITAR
#elif USB_PID == 0x0005
#define DRUM // Wii RB1
@ -144,26 +144,33 @@ void loop() {
buttonState.buttons |= (buttons >> 10) & 0b01011; // Cymbals
bitWrite(buttonState.buttons, 10, (buttons >> 0) & 0b01111); // Drum pad modifier
bitWrite(buttonState.buttons, 11, (buttons >> 10) & 0b01011); // Cymbals modifier
buttonState.axis[3] = bitRead(buttons, 12)?255:0; // High hat
//buttonState.axis[3] = bitRead(buttons, 12)?255:0; // High hat
buttonState.axis[2] = 127;
// rbdrum2midi wants these set
// rbdrum2midi wants these set: it ignores the button states.
buttonState.velocity[0] = bitRead(buttonState.buttons, 3)?127:0; // Y
buttonState.velocity[1] = bitRead(buttonState.buttons, 2)?127:0; // R
buttonState.velocity[2] = bitRead(buttonState.buttons, 1)?127:0; // G
buttonState.velocity[3] = bitRead(buttonState.buttons, 0)?127:0; // B
// Say the D-pad is centered
buttonState.hatAndConstant = 8;
// Clone Hero 1.0.0.4080-final needs blue and yellow cymbals to send up and down on d-pad.
// This is what the mysterous CymExt1 and CymExt2 mappings mean.
// If these aren't set, all pads (except red) register as simultaneous drum and cymbal hits.
if (bitRead(buttons, 10)) {
buttonState.hatAndConstant = 0; // up
} else if bitRead(buttons, 13) { //
buttonState.hatAndConstant = 4; // down
} else {
buttonState.hatAndConstant = 8; // nothing
}
#endif
#ifdef DPAD
#error DPAD isn't implemented yet
#endif
#ifdef DEBUG
// Log sample rate to the first X axis
buttonState.axis[0] = samples & 0xff;
#endif
// Log sample rate to the second Y axis
buttonState.axis[3] = samples & 0xff;
// Send an update
HID().SendReport(0, (uint8_t *)&buttonState, 27);