From fb077ba140837f169972ddcdc0408b70536407e0 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Mon, 1 Jan 2024 14:23:56 -0700 Subject: [PATCH] MORE DRUMS This attempts to address #1, #2, and #3 --- MockBand.ino | 38 +++++++++++++++++++++++++++++--------- README.md | 26 ++++++++------------------ 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/MockBand.ino b/MockBand.ino index e3d6997..74125a1 100644 --- a/MockBand.ino +++ b/MockBand.ino @@ -2,12 +2,17 @@ #include #include +#define DEBUG + #include "hid.hh" // Modified HID library: doesn't prefix each packet with ID #include "instrument.hh" //#include "blue.hh" // Ginnie's blue guitar #include "standard.hh" // Standard pins +// If defined, we will check the wammy bar input +#define WAMMY + // Maximum time between wammy bar updates. #define UPDATE_INTERVAL_MS 20 @@ -118,22 +123,37 @@ void loop() { } next = now + UPDATE_INTERVAL_MS; - buttonState.buttons = (buttons & 0b1100111111); // All directly-mappable bits - buttonState.buttons |= ((buttons >> 10) & 0b11111); // Solo keys - bitWrite(buttonState.buttons, 6, (buttons >> 10) & 0b11111); // Solo bit + buttonState.buttons = (buttons & 0b1100111111); // +-..!OYRGB +#ifdef GUITAR + buttonState.buttons |= (buttons >> 10) & 0b11111; // Solo keys +#else // DRUMS + buttonState.buttons |= (buttons >> 10) & 0b01011; // Cymbals +#endif + bitWrite(buttonState.buttons, 6, buttons & (0b11111 << 10)); // Solo modifier + bitWrite(buttonState.buttons, 10, buttons & (0b01111 << 0)); // Drum pad modifier + bitWrite(buttonState.buttons, 11, buttons & (0b01011 << 10)); // Cymbals modifier - // I don't understand why any rational engineer would have done this. + // 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. buttonState.hatAndConstant = (0x08 - ^ (bitRead(buttons, 6) << 4) // up + ^ (bitRead(buttons, 6) << 4) // strum up // right << 3 - ^ (bitRead(buttons, 7) << 2) // down + ^ (bitRead(buttons, 7) << 2) // strum down // left << 1 ); - buttonState.axis[2] = analogRead(ANALOG_WAMMY) / 4; +#ifdef WAMMY + buttonState.axis[2] = analogRead(ANALOG_WAMMY) / 4; // Wammy bar +#endif + buttonState.axis[3] = bitRead(buttons, 12)?255:0; // High hat - // The second Y axis doesn't appear to be used, so I'm logging sample rate with it - buttonState.axis[3] = samples & 0xff; // most things map this to [-1,1] + +#ifdef DEBUG + // Log sample rate to the first X axis + buttonState.axis[0] = samples & 0xff; +#endif // Send an update HID().SendReport(0, (uint8_t *)&buttonState, 27); diff --git a/README.md b/README.md index a061525..da32bce 100644 --- a/README.md +++ b/README.md @@ -39,28 +39,18 @@ On the drum kit, * Orange: kick pedal * Solo Buttons: cymbals +* Red Solo: high hat +* Tilt: 2x kick I think. I haven't been able to test this yet, but the Clone Hero wiki leads me to believe this is how it works. +You can hook up a wammy bar for the drum kit, +and it will be sent the same way as the guitar. +I don't know why anyone would want this +but I'm not going to tell you how to live your life. # Still To Do - -* 2x kick: needs its own input pin. Maps to button 5. -* Drum pad modifier: looks like button 10 needs to be pressed when a drum pad is hit. -* Drum cymbal modifier: I don't see a problem with using the solo pins for this, but I may need to also send button 11. -* Hi Hat pedal: needs to be its own input pin. Looks like it maps to the second Y axis: the one I'm currently using to send frame rate. - -If I set this up correctly, it will use every input pin on the pro micro. - -Perhaps a smarter thing to do would be use the value of USB_PID -to re-use the orange solo pin as the hi hat pedal, -and the red solo pin as the 2x kick. - -The -[Clone Hero Drum Mapping Guide](https://wiki.clonehero.net/books/guitars-drums-controllers/page/drum-mapping-guide) -is super helpful. -I'll need to hunt down a copy of Wii Rock Band 3 -(or maybe The Beatles?) -in order to test this on an actual Wii. \ No newline at end of file +I'm tracking things I need to do in the +[forgejo issues](https://git.woozle.org/neale/mockband/issues).