Fix strum buttons, isolate guitar & drum buttons.
This commit is contained in:
parent
84652514ee
commit
c40e7ff970
26
MockBand.ino
26
MockBand.ino
|
@ -2,16 +2,15 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <PluggableUSB.h>
|
#include <PluggableUSB.h>
|
||||||
|
|
||||||
#define DEBUG
|
//#define DEBUG
|
||||||
|
|
||||||
#include "hid.hh" // Modified HID library: doesn't prefix each packet with ID
|
#include "hid.hh" // Modified HID library: doesn't prefix each packet with ID
|
||||||
#include "instrument.hh"
|
#include "instrument.hh"
|
||||||
|
|
||||||
//#include "blue.hh" // Ginnie's blue guitar
|
//#include "blue.hh" // Ginnie's blue guitar
|
||||||
#include "standard.hh" // Standard pins
|
#include "standard.hh" // Standard pins
|
||||||
|
|
||||||
// If defined, we will check the wammy bar input
|
// If defined, we will check the wammy bar input
|
||||||
#define WAMMY
|
//#define WAMMY
|
||||||
|
|
||||||
// Maximum time between wammy bar updates.
|
// Maximum time between wammy bar updates.
|
||||||
#define UPDATE_INTERVAL_MS 20
|
#define UPDATE_INTERVAL_MS 20
|
||||||
|
@ -126,28 +125,31 @@ void loop() {
|
||||||
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
|
||||||
#else // DRUMS
|
#else // DRUMS
|
||||||
buttonState.buttons |= (buttons >> 10) & 0b01011; // Cymbals
|
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, 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
|
||||||
|
#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.
|
// I don't understand why any rational engineer would have specified this algorithm.
|
||||||
buttonState.hatAndConstant = (0x08
|
if (bitRead(buttons, 6)) {
|
||||||
^ (bitRead(buttons, 6) << 4) // strum up
|
buttonState.hatAndConstant = 0x00; // up
|
||||||
// right << 3
|
} else if bitRead(buttons, 7) { //
|
||||||
^ (bitRead(buttons, 7) << 2) // strum down
|
buttonState.hatAndConstant = 0x04; // down
|
||||||
// left << 1
|
} 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
|
||||||
#endif
|
#endif
|
||||||
buttonState.axis[3] = bitRead(buttons, 12)?255:0; // High hat
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
Loading…
Reference in New Issue