MORE DRUMS

This attempts to address
#1, #2, and #3
This commit is contained in:
Neale Pickett 2024-01-01 14:23:56 -07:00
parent 07685051d9
commit fb077ba140
2 changed files with 37 additions and 27 deletions

View File

@ -2,12 +2,17 @@
#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 "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);

View File

@ -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.
I'm tracking things I need to do in the
[forgejo issues](https://git.woozle.org/neale/mockband/issues).