JonnyHaystack / HayBox

Modular cross-platform firmware for digital or mixed analog/digital game controllers
GNU General Public License v3.0
170 stars 176 forks source link

Getting compilation errors when targeting Smash Box #4

Closed ribbanya closed 3 years ago

ribbanya commented 3 years ago

Errors

In file included from X:\HayB0XX\HayB0XX\DInputBackend.cpp:1:0:
X:\HayB0XX\HayB0XX\src\ArduinoJoystickLibrary\src\Joystick.h:32:2: error: #error The Joystick library can only be used with a USB MCU (e.g. Arduino Leonardo, Arduino Micro, etc.).
 #error The Joystick library can only be used with a USB MCU (e.g. Arduino Leonardo, Arduino Micro, etc.).
  ^~~~~
In file included from X:\HayB0XX\HayB0XX\DInputBackend.cpp:4:0:
DInputBackend.h:16:3: error: 'Joystick_' does not name a type
   Joystick_ *mpJoystick;
   ^~~~~~~~~
X:\HayB0XX\HayB0XX\DInputBackend.cpp: In constructor 'DInputBackend::DInputBackend()':
DInputBackend.cpp:8:3: error: 'mpJoystick' was not declared in this scope
   mpJoystick = new Joystick_(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_GAMEPAD,
   ^~~~~~~~~~
DInputBackend.cpp:8:20: error: expected type-specifier before 'Joystick_'
   mpJoystick = new Joystick_(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_GAMEPAD,
                    ^~~~~~~~~
X:\HayB0XX\HayB0XX\DInputBackend.cpp: In destructor 'virtual DInputBackend::~DInputBackend()':
DInputBackend.cpp:26:3: error: 'mpJoystick' was not declared in this scope
   mpJoystick->end();
   ^~~~~~~~~~
X:\HayB0XX\HayB0XX\KeyboardMode.cpp: In constructor 'KeyboardMode::KeyboardMode(socd::SocdType, state::InputState&)':
KeyboardMode.cpp:9:3: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
   Keyboard.begin();
   ^~~~~~~~
X:\HayB0XX\HayB0XX\KeyboardMode.cpp:9:3: note: suggested alternative: 'KeyboardMode'
   Keyboard.begin();
   ^~~~~~~~
   KeyboardMode
X:\HayB0XX\HayB0XX\KeyboardMode.cpp: In destructor 'virtual KeyboardMode::~KeyboardMode()':
KeyboardMode.cpp:13:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
     Keyboard.releaseAll();
     ^~~~~~~~
DInputBackend.cpp:27:10: error: type '<type error>' argument given to 'delete', expected pointer
   delete mpJoystick;
          ^~~~~~~~~~
X:\HayB0XX\HayB0XX\DInputBackend.cpp: In member function 'virtual void DInputBackend::SendOutputs(state::OutputState)':
DInputBackend.cpp:32:3: error: 'mpJoystick' was not declared in this scope
   mpJoystick->setButton(0, outputState.b);
   ^~~~~~~~~~
X:\HayB0XX\HayB0XX\KeyboardMode.cpp:13:5: note: suggested alternative: 'KeyboardMode'
     Keyboard.releaseAll();
     ^~~~~~~~
     KeyboardMode
X:\HayB0XX\HayB0XX\KeyboardMode.cpp: In member function 'void KeyboardMode::Press(char, bool)':
KeyboardMode.cpp:24:9: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
         Keyboard.press(key);
         ^~~~~~~~
X:\HayB0XX\HayB0XX\KeyboardMode.cpp:24:9: note: suggested alternative: 'KeyboardMode'
         Keyboard.press(key);
         ^~~~~~~~
         KeyboardMode
KeyboardMode.cpp:26:9: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
         Keyboard.release(key);
         ^~~~~~~~
X:\HayB0XX\HayB0XX\KeyboardMode.cpp:26:9: note: suggested alternative: 'KeyboardMode'
         Keyboard.release(key);
         ^~~~~~~~
         KeyboardMode
exit status 1
'Joystick_' does not name a type

Differences from master (76202489bfa5745beecb8b111fd0451be498d13d)

diff --git a/HayB0XX/HayB0XX.ino b/HayB0XX/HayB0XX.ino
index d5be178..2e03ae1 100644
--- a/HayB0XX/HayB0XX.ino
+++ b/HayB0XX/HayB0XX.ino
@@ -10,7 +10,7 @@
     Zac Staples' Arduino_Vector library
 */

-#include "setup_gccpcb2.h"
+#include "setup_smashbox.h"

 #include "DefaultKeyboardMode.h"
 #include "FgcMode.h"
@@ -75,8 +75,8 @@ void readInputs() {
   gInputState.mod_x = (digitalRead(pinout::MODX) == LOW);
   gInputState.mod_y = (digitalRead(pinout::MODY) == LOW);
   gInputState.start = (digitalRead(pinout::START) == LOW);
-  gInputState.select = (digitalRead(pinout::SELECT) == LOW);
-  gInputState.home = (digitalRead(pinout::HOME) == LOW);
+  // gInputState.select = (digitalRead(pinout::SELECT) == LOW);
+  // gInputState.home = (digitalRead(pinout::HOME) == LOW);
   gInputState.b = (digitalRead(pinout::B) == LOW);
   gInputState.x = (digitalRead(pinout::X) == LOW);
   gInputState.z = (digitalRead(pinout::Z) == LOW);
@@ -114,8 +114,8 @@ void setup() {
   pinMode(pinout::MODX, INPUT_PULLUP);
   pinMode(pinout::MODY, INPUT_PULLUP);
   pinMode(pinout::START, INPUT_PULLUP);
-  pinMode(pinout::SELECT, INPUT_PULLUP);
-  pinMode(pinout::HOME, INPUT_PULLUP);
+  // pinMode(pinout::SELECT, INPUT_PULLUP);
+  // pinMode(pinout::HOME, INPUT_PULLUP);
   pinMode(pinout::B, INPUT_PULLUP);
   pinMode(pinout::X, INPUT_PULLUP);
   pinMode(pinout::Z, INPUT_PULLUP);

Arduino settings

image

Other notes

I'm on Windows 10 and using the git clone --recursive method.

JonnyHaystack commented 3 years ago

From the README:

image

This also applies to smashbox if it uses an ATMega2560 because that MCU does not support native USB

ribbanya commented 3 years ago

Ah, I missed that. Thank you.

JonnyHaystack commented 3 years ago

Well, it wasn't written as a step for smash box until now. I just added it in because you brought it to my attention, so thanks for that :smile:

ribbanya commented 3 years ago

Is there a way to utilize the Gen 2's USB joystick capabilities? Is the way Smash Box does it significantly different from how the B0XX does it?

JonnyHaystack commented 3 years ago

Umm I don't really know much about smashbox hardware tbh. Do the different generations have different MCUs? Maybe newer ones use the 32U4?

ribbanya commented 3 years ago

No, it's still the Arduino Mega 2560, but it has a custom bootloader and a separate processor for USB mode.

I asked in Discord but they seem unwilling to explain how it works on the firmware end.

Gen2 boards have an extra processor specifically for USB Host functions.

It's an Arduino Mega with custom firmware. If you got a gen2 board in your smash box gen2, the gen2 upgrade or a smash box experience kit, you have a board with USB game pad capabilities.

I can't do much if someone else's custom firmware lacks those features.

This was the only documentation I could find, but it's not particularly helpful for this.

JonnyHaystack commented 3 years ago

Hmm I don't really know enough about the hardware and I don't own a SmashBox so it would be hard for me to add support for this. Maybe if you can find out more about the USB host board and whether it can be driven using some open source library, then it could be possible. I think it would require new communication backends as well (which isn't hard, if you have a library doing the heavy lifting).