From f35e1234745365bca7a1e2f814054298c6dd7883 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Sun, 7 Jan 2024 14:54:34 -0700 Subject: [PATCH] Send CH-friendly dpad on cymbals; +XBox drum PID --- MockBand.ino | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/MockBand.ino b/MockBand.ino index 8794bd6..7bb3da2 100644 --- a/MockBand.ino +++ b/MockBand.ino @@ -2,8 +2,6 @@ #include #include -//#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);