c++ header files are .hh
This commit is contained in:
parent
d5b1addddc
commit
8622cfdef0
|
@ -2,14 +2,20 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <PluggableUSB.h>
|
#include <PluggableUSB.h>
|
||||||
|
|
||||||
#include "hid.h" // 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.h"
|
#include "instrument.hh"
|
||||||
|
|
||||||
//#include "blue.h" // Ginnie's blue guitar
|
//#include "blue.hh" // Ginnie's blue guitar
|
||||||
#include "standard.h" // Standard pins
|
#include "standard.hh" // Standard pins
|
||||||
|
|
||||||
|
// How often do you want to send an update?
|
||||||
|
// Bigger number: lower latency, but more bounces
|
||||||
|
// Smaller number: higher latency
|
||||||
|
// 50Hz feels pretty good to me
|
||||||
|
#define UPDATE_FREQ_HZ 50
|
||||||
|
#define UPDATE_INTERVAL_MS (1000 / UPDATE_FREQ_HZ)
|
||||||
|
|
||||||
InstrumentButtonState buttonState;
|
InstrumentButtonState buttonState;
|
||||||
InstrumentButtonState lastState;
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
pinMode(STRUM_DOWN, INPUT_PULLUP);
|
pinMode(STRUM_DOWN, INPUT_PULLUP);
|
||||||
|
@ -49,10 +55,12 @@ void setup() {
|
||||||
// and hope we don't miss anything while we're doing USB stuff.
|
// and hope we don't miss anything while we're doing USB stuff.
|
||||||
void loop() {
|
void loop() {
|
||||||
register uint16_t buttons = 0;
|
register uint16_t buttons = 0;
|
||||||
register uint16_t buttons_prior = 0;
|
unsigned long next = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
buttons = (0
|
unsigned long now = millis();
|
||||||
|
|
||||||
|
buttons |= ~(0
|
||||||
| (digitalRead(BUTTON_BLUE) << 0)
|
| (digitalRead(BUTTON_BLUE) << 0)
|
||||||
| (digitalRead(BUTTON_GREEN) << 1)
|
| (digitalRead(BUTTON_GREEN) << 1)
|
||||||
| (digitalRead(BUTTON_RED) << 2)
|
| (digitalRead(BUTTON_RED) << 2)
|
||||||
|
@ -70,30 +78,22 @@ void loop() {
|
||||||
| (digitalRead(SOLO_ORANGE) << 14) // Not in USB packet
|
| (digitalRead(SOLO_ORANGE) << 14) // Not in USB packet
|
||||||
);
|
);
|
||||||
|
|
||||||
if (buttons == buttons_prior) {
|
if (now < next) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
buttons_prior = buttons;
|
next = now + 20;
|
||||||
|
|
||||||
// Open pullup reads 1, so invert everything we've read
|
|
||||||
buttons = ~buttons;
|
|
||||||
|
|
||||||
buttonState.buttons = (buttons & 0b1100111111); // All directly-mappable bits
|
buttonState.buttons = (buttons & 0b1100111111); // All directly-mappable bits
|
||||||
buttonState.buttons |= ((buttons >> 10) & 0b11111); // Solo keys
|
buttonState.buttons |= ((buttons >> 10) & 0b11111); // Solo keys
|
||||||
bitWrite(buttonState.buttons, 6, (buttons >> 10) & 0b11111); // Solo bit
|
bitWrite(buttonState.buttons, 6, (buttons >> 10) & 0b11111); // Solo bit
|
||||||
|
|
||||||
// I don't understand why any rational engineer would have done this.
|
// I don't understand why any rational engineer would have done this.
|
||||||
if (bitRead(buttons, 6)) {
|
buttonState.hatAndConstant = (0x08
|
||||||
buttonState.hatAndConstant = 0x00; // up
|
^ (bitRead(buttons, 6) << 4) // up
|
||||||
} else if (false) {
|
// right << 3
|
||||||
buttonState.hatAndConstant = 0x02; // right
|
^ (bitRead(buttons, 7) << 2) // down
|
||||||
} else if (bitRead(buttons, 7)) {
|
// left << 1
|
||||||
buttonState.hatAndConstant = 0x04; // down
|
);
|
||||||
} else if (false) {
|
|
||||||
buttonState.hatAndConstant = 0x06; // left
|
|
||||||
} else {
|
|
||||||
buttonState.hatAndConstant = 0x08; // nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
buttonState.axis[2] = analogRead(ANALOG_WAMMY) / 4;
|
buttonState.axis[2] = analogRead(ANALOG_WAMMY) / 4;
|
||||||
|
|
30
README.md
30
README.md
|
@ -1,2 +1,28 @@
|
||||||
# WiiGuitarController
|
# Mock Band
|
||||||
Microcontroller Firmware to emulate guitar controllers from the Wii version of the Rock Band games
|
|
||||||
|
Microcontroller Firmware to emulate guitar and drum kit controllers from the
|
||||||
|
Wii version of the Rock Band games.
|
||||||
|
|
||||||
|
This is based on the foundational work done by Nicholas Angle on the
|
||||||
|
[Wii Guitar Controller](https://github.com/NianZo/WiiGuitarController)
|
||||||
|
([text article](https://www.niangames.com/articles/reverse-engineering-rockband-guitar-controllers)).
|
||||||
|
All I did was speed up the loop code to detect drum pad strikes,
|
||||||
|
which are very quick!
|
||||||
|
|
||||||
|
|
||||||
|
# Parts Needed
|
||||||
|
|
||||||
|
* A [Sparkfun Pro Micro](https://www.sparkfun.com/products/12640)
|
||||||
|
* A physical controller
|
||||||
|
|
||||||
|
|
||||||
|
## Sample controllers
|
||||||
|
|
||||||
|
I used the following:
|
||||||
|
|
||||||
|
* [MiniCaster](https://www.printables.com/model/479046-minicaster-mini-clone-heromidi-controller)
|
||||||
|
by Vlad the Inhaler:
|
||||||
|
it comes with full build instructions.
|
||||||
|
|
||||||
|
* [Cheap children's drum toy](https://www.amazon.com/Electronic-Sboet-Practice-Headphone-Christmas/dp/B0CHJMYCH9/),
|
||||||
|
each pad is a momentary switch.
|
||||||
|
|
Loading…
Reference in New Issue