Skip to content

Commit

Permalink
Merge pull request #18 from arntsonl/xb360_mergin
Browse files Browse the repository at this point in the history
Create merge from main
  • Loading branch information
arntsonl authored Sep 23, 2024
2 parents fdddfc2 + d7c71b5 commit 89c5f44
Show file tree
Hide file tree
Showing 84 changed files with 2,753 additions and 775 deletions.
41 changes: 21 additions & 20 deletions configs/FlatboxRev5/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,26 @@

// Main pin mapping Configuration
// Mapping between Flatbox Rev4 switch number (as silkscreened) and GPIO pin listed under "Flatbox Rev4 SW#"
// // Flatbox Rev5 SW# | GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
#define GPIO_PIN_10 GpioAction::BUTTON_PRESS_UP // UP | UP | UP | UP | UP | UP |
#define GPIO_PIN_12 GpioAction::BUTTON_PRESS_DOWN // DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
#define GPIO_PIN_11 GpioAction::BUTTON_PRESS_RIGHT // RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
#define GPIO_PIN_13 GpioAction::BUTTON_PRESS_LEFT // LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
#define GPIO_PIN_09 GpioAction::BUTTON_PRESS_B1 // B1 | A | B | Cross | 2 | K1 |
#define GPIO_PIN_07 GpioAction::BUTTON_PRESS_B2 // B2 | B | A | Circle | 3 | K2 |
#define GPIO_PIN_05 GpioAction::BUTTON_PRESS_R2 // R2 | RT | ZR | R2 | 8 | K3 |
#define GPIO_PIN_03 GpioAction::BUTTON_PRESS_L2 // L2 | LT | ZL | L2 | 7 | K4 |
#define GPIO_PIN_08 GpioAction::BUTTON_PRESS_B3 // B3 | X | Y | Square | 1 | P1 |
#define GPIO_PIN_06 GpioAction::BUTTON_PRESS_B4 // B4 | Y | X | Triangle | 4 | P2 |
#define GPIO_PIN_04 GpioAction::BUTTON_PRESS_R1 // R1 | RB | R | R1 | 6 | P3 |
#define GPIO_PIN_02 GpioAction::BUTTON_PRESS_L1 // L1 | LB | L | L1 | 5 | P4 |
#define GPIO_PIN_15 GpioAction::BUTTON_PRESS_S1 // S1 | Back | Minus | Select | 9 | Coin |
#define GPIO_PIN_14 GpioAction::BUTTON_PRESS_S2 // S2 | Start | Plus | Start | 10 | Start |
#define GPIO_PIN_28 GpioAction::BUTTON_PRESS_L3 // L3 | LS | LS | L3 | 11 | LS |
#define GPIO_PIN_29 GpioAction::BUTTON_PRESS_R3 // R3 | RS | RS | R3 | 12 | RS |
#define GPIO_PIN_26 GpioAction::BUTTON_PRESS_A1 // A1 | Guide | Home | PS | 13 | ~ |
#define GPIO_PIN_27 GpioAction::BUTTON_PRESS_A2 // A2 | ~ | Capture | ~ | 14 | ~ |
// // | Flatbox Rev5 SW# | GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
#define GPIO_PIN_14 GpioAction::BUTTON_PRESS_S2 // | S1 | S2 | Start | Plus | Start | 10 | Start |
#define GPIO_PIN_15 GpioAction::BUTTON_PRESS_S1 // | S2 | S1 | Back | Minus | Select | 9 | Coin |
#define GPIO_PIN_26 GpioAction::BUTTON_PRESS_A1 // | S3 | A1 | Guide | Home | PS | 13 | ~ |
#define GPIO_PIN_27 GpioAction::BUTTON_PRESS_A2 // | S4 | A2 | ~ | Capture | ~ | 14 | ~ |
#define GPIO_PIN_28 GpioAction::BUTTON_PRESS_L3 // | S5 | L3 | LS | LS | L3 | 11 | LS |
#define GPIO_PIN_29 GpioAction::BUTTON_PRESS_R3 // | S6 | R3 | RS | RS | R3 | 12 | RS |
#define GPIO_PIN_13 GpioAction::BUTTON_PRESS_LEFT // | S7 | LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
#define GPIO_PIN_12 GpioAction::BUTTON_PRESS_DOWN // | S8 | DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
#define GPIO_PIN_11 GpioAction::BUTTON_PRESS_RIGHT // | S9 | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
#define GPIO_PIN_08 GpioAction::BUTTON_PRESS_B3 // | S10 | B3 | X | Y | Square | 1 | P1 |
#define GPIO_PIN_06 GpioAction::BUTTON_PRESS_B4 // | S11 | B4 | Y | X | Triangle | 4 | P2 |
#define GPIO_PIN_04 GpioAction::BUTTON_PRESS_R1 // | S12 | R1 | RB | R | R1 | 6 | P3 |
#define GPIO_PIN_02 GpioAction::BUTTON_PRESS_L1 // | S13 | L1 | LB | L | L1 | 5 | P4 |
#define GPIO_PIN_09 GpioAction::BUTTON_PRESS_B1 // | S14 | B1 | A | B | Cross | 2 | K1 |
#define GPIO_PIN_07 GpioAction::BUTTON_PRESS_B2 // | S15 | B2 | B | A | Circle | 3 | K2 |
#define GPIO_PIN_05 GpioAction::BUTTON_PRESS_R2 // | S16 | R2 | RT | ZR | R2 | 8 | K3 |
#define GPIO_PIN_03 GpioAction::BUTTON_PRESS_L2 // | S17 | L2 | LT | ZL | L2 | 7 | K4 |
#define GPIO_PIN_10 GpioAction::BUTTON_PRESS_UP // | S18 | UP | UP | UP | UP | UP | UP |


// Keyboard Mapping Configuration
// // GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
Expand All @@ -55,4 +56,4 @@
#define KEY_BUTTON_A2 HID_KEY_F2 // A2 | ~ | Capture | ~ | 14 | ~ |
#define KEY_BUTTON_FN -1 // Hotkey Function |

#endif
#endif
41 changes: 21 additions & 20 deletions configs/FlatboxRev5/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ Configuration for the [Flatbox rev5](https://github.com/jfedor2/flatbox/tree/mas

## Main Pin Mapping Configuration

| RP2040 Pin | Action | GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
|------------|-------------------------------|--------|--------|--------|----------|--------|--------|
| GPIO_PIN_10| GpioAction::BUTTON_PRESS_UP | UP | UP | UP | UP | UP | UP |
| GPIO_PIN_12| GpioAction::BUTTON_PRESS_DOWN | DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
| GPIO_PIN_11| GpioAction::BUTTON_PRESS_RIGHT| RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
| GPIO_PIN_13| GpioAction::BUTTON_PRESS_LEFT | LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
| GPIO_PIN_09| GpioAction::BUTTON_PRESS_B1 | B1 | A | B | Cross | 2 | K1 |
| GPIO_PIN_07| GpioAction::BUTTON_PRESS_B2 | B2 | B | A | Circle | 3 | K2 |
| GPIO_PIN_05| GpioAction::BUTTON_PRESS_R2 | R2 | RT | ZR | R2 | 8 | K3 |
| GPIO_PIN_03| GpioAction::BUTTON_PRESS_L2 | L2 | LT | ZL | L2 | 7 | K4 |
| GPIO_PIN_08| GpioAction::BUTTON_PRESS_B3 | B3 | X | Y | Square | 1 | P1 |
| GPIO_PIN_06| GpioAction::BUTTON_PRESS_B4 | B4 | Y | X | Triangle | 4 | P2 |
| GPIO_PIN_04| GpioAction::BUTTON_PRESS_R1 | R1 | RB | R | R1 | 6 | P3 |
| GPIO_PIN_02| GpioAction::BUTTON_PRESS_L1 | L1 | LB | L | L1 | 5 | P4 |
| GPIO_PIN_15| GpioAction::BUTTON_PRESS_S1 | S1 | Back | Minus | Select | 9 | Coin |
| GPIO_PIN_14| GpioAction::BUTTON_PRESS_S2 | S2 | Start | Plus | Start | 10 | Start |
| GPIO_PIN_28| GpioAction::BUTTON_PRESS_L3 | L3 | LS | LS | L3 | 11 | LS |
| GPIO_PIN_29| GpioAction::BUTTON_PRESS_R3 | R3 | RS | RS | R3 | 12 | RS |
| GPIO_PIN_26| GpioAction::BUTTON_PRESS_A1 | A1 | Guide | Home | PS | 13 | ~ |
| GPIO_PIN_27| GpioAction::BUTTON_PRESS_A2 | A2 | ~ | Capture| ~ | 14 | ~ |
| RP2040 Pin | Action | Flatbox Rev5 SW# | GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
| ----------- | ------------------------------- | ---------------- | ------ | ------ | ------- | -------- | ------ | ------ |
| GPIO_PIN_14 | GpioAction::BUTTON_PRESS_S2 | S1 | S2 | Start | Plus | Start | 10 | Start |
| GPIO_PIN_15 | GpioAction::BUTTON_PRESS_S1 | S2 | S1 | Back | Minus | Select | 9 | Coin |
| GPIO_PIN_26 | GpioAction::BUTTON_PRESS_A1 | S3 | A1 | Guide | Home | PS | 13 | ~ |
| GPIO_PIN_27 | GpioAction::BUTTON_PRESS_A2 | S4 | A2 | ~ | Capture | ~ | 14 | ~ |
| GPIO_PIN_28 | GpioAction::BUTTON_PRESS_L3 | S5 | L3 | LS | LS | L3 | 11 | LS |
| GPIO_PIN_29 | GpioAction::BUTTON_PRESS_R3 | S6 | R3 | RS | RS | R3 | 12 | RS |
| GPIO_PIN_13 | GpioAction::BUTTON_PRESS_LEFT | S7 | LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
| GPIO_PIN_12 | GpioAction::BUTTON_PRESS_DOWN | S8 | DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
| GPIO_PIN_11 | GpioAction::BUTTON_PRESS_RIGHT | S9 | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
| GPIO_PIN_08 | GpioAction::BUTTON_PRESS_B3 | S10 | B3 | X | Y | Square | 1 | P1 |
| GPIO_PIN_06 | GpioAction::BUTTON_PRESS_B4 | S11 | B4 | Y | X | Triangle | 4 | P2 |
| GPIO_PIN_04 | GpioAction::BUTTON_PRESS_R1 | S12 | R1 | RB | R | R1 | 6 | P3 |
| GPIO_PIN_02 | GpioAction::BUTTON_PRESS_L1 | S13 | L1 | LB | L | L1 | 5 | P4 |
| GPIO_PIN_09 | GpioAction::BUTTON_PRESS_B1 | S14 | B1 | A | B | Cross | 2 | K1 |
| GPIO_PIN_07 | GpioAction::BUTTON_PRESS_B2 | S15 | B2 | B | A | Circle | 3 | K2 |
| GPIO_PIN_05 | GpioAction::BUTTON_PRESS_R2 | S16 | R2 | RT | ZR | R2 | 8 | K3 |
| GPIO_PIN_03 | GpioAction::BUTTON_PRESS_L2 | S17 | L2 | LT | ZL | L2 | 7 | K4 |
| GPIO_PIN_10 | GpioAction::BUTTON_PRESS_UP | S18 | UP | UP | UP | UP | UP | UP |

3 changes: 2 additions & 1 deletion headers/addons/drv8833_rumble.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string>
#include "gpaddon.h"
#include "gamepad/GamepadState.h"
#include "gamepad/GamepadAuxState.h"

#ifndef DRV8833_RUMBLE_ENABLED
#define DRV8833_RUMBLE_ENABLED 0
Expand Down Expand Up @@ -68,7 +69,7 @@ class DRV8833RumbleAddon : public GPAddon
float dutyMin;
float dutyMax;
uint32_t sysClock;
GamepadRumbleState currentRumbleState;
GamepadAuxHaptics currentRumbleState;
};

#endif
17 changes: 17 additions & 0 deletions headers/addons/keyboard_host_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class KeyboardHostListener : public USBListener {
GamepadState _keyboard_host_state;
bool _keyboard_host_enabled;
uint8_t getKeycodeFromModifier(uint8_t modifier);
void preprocess_report();
void process_kbd_report(uint8_t dev_addr, hid_keyboard_report_t const *report);
void process_mouse_report(uint8_t dev_addr, hid_mouse_report_t const *report);

KeyboardButtonMapping _keyboard_host_mapDpadUp;
KeyboardButtonMapping _keyboard_host_mapDpadDown;
Expand All @@ -58,9 +60,24 @@ class KeyboardHostListener : public USBListener {
KeyboardButtonMapping _keyboard_host_mapButtonR3;
KeyboardButtonMapping _keyboard_host_mapButtonA1;
KeyboardButtonMapping _keyboard_host_mapButtonA2;
KeyboardButtonMapping _keyboard_host_mapButtonA3;
KeyboardButtonMapping _keyboard_host_mapButtonA4;

uint8_t _keyboard_dev_addr;
uint8_t _keyboard_instance;

bool _mouse_host_enabled;
uint8_t _mouse_dev_addr;
uint8_t _mouse_instance;

uint16_t mouseLeftMapping;
uint16_t mouseMiddleMapping;
uint16_t mouseRightMapping;

int16_t mouseX = 0;
int16_t mouseY = 0;
int16_t mouseZ = 0;
bool mouseActive = false;
};

#endif // _KeyboardHost_H_
39 changes: 39 additions & 0 deletions headers/addons/wiiext.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,28 @@ class WiiExtensionInput : public GPAddon {
}
}
},
{
WiiExtensionController::WII_EXTENSION_DRAWSOME,
{
{
{WiiButtons::WII_BUTTON_A, GAMEPAD_MASK_B2},
{WiiButtons::WII_BUTTON_L, GAMEPAD_MASK_L2},
{WiiButtons::WII_BUTTON_R, GAMEPAD_MASK_R2},
},
{}
}
},
{
WiiExtensionController::WII_EXTENSION_UDRAW,
{
{
{WiiButtons::WII_BUTTON_A, GAMEPAD_MASK_B2},
{WiiButtons::WII_BUTTON_L, GAMEPAD_MASK_L2},
{WiiButtons::WII_BUTTON_R, GAMEPAD_MASK_R2},
},
{}
}
},
};
WiiExtensionConfig* currentConfig = NULL;

Expand All @@ -295,6 +317,9 @@ class WiiExtensionInput : public GPAddon {
bool dpadRight = false;

bool isAnalogTriggers = false;
bool isGyroscope = false;
bool isAccelerometer = false;
bool isTouch = false;

uint16_t triggerLeft = 0;
uint16_t triggerRight = 0;
Expand All @@ -314,6 +339,19 @@ class WiiExtensionInput : public GPAddon {
uint16_t rightY = 0;
uint16_t lastRightY = 0;

uint16_t accelerometerX = 0;
uint16_t accelerometerY = 0;
uint16_t accelerometerZ = 0;

uint16_t gyroscopeX = 0;
uint16_t gyroscopeY = 0;
uint16_t gyroscopeZ = 0;

uint16_t touchX = 0;
uint16_t touchY = 0;
uint16_t touchZ = 0;
bool touchPressed = false;

std::map<uint16_t, std::vector<WiiAnalogChange>> analogChanges = {
{WII_ANALOG_TYPE_LEFT_STICK_X,{}},
{WII_ANALOG_TYPE_LEFT_STICK_Y,{}},
Expand Down Expand Up @@ -344,6 +382,7 @@ class WiiExtensionInput : public GPAddon {
void setButtonState(bool buttonState, uint16_t buttonMask);
void queueAnalogChange(uint16_t analogInput, uint16_t analogValue, uint16_t lastAnalogValue);
void updateAnalogState();
void updateMotionState();
void reloadConfig();

uint16_t getAverage(std::vector<WiiAnalogChange> const& changes);
Expand Down
2 changes: 1 addition & 1 deletion headers/drivers/astro/AstroDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class AstroDriver : public GPDriver {
public:
virtual void initialize();
virtual void process(Gamepad * gamepad, uint8_t * outBuffer);
virtual void process(Gamepad * gamepad);
virtual void initializeAux() {}
virtual void processAux() {}
virtual uint16_t get_report(uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen);
Expand Down
2 changes: 1 addition & 1 deletion headers/drivers/egret/EgretDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class EgretDriver : public GPDriver {
public:
virtual void initialize();
virtual void process(Gamepad * gamepad, uint8_t * outBuffer);
virtual void process(Gamepad * gamepad);
virtual void initializeAux() {}
virtual void processAux() {}
virtual uint16_t get_report(uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen);
Expand Down
2 changes: 1 addition & 1 deletion headers/drivers/hid/HIDDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class HIDDriver : public GPDriver {
public:
virtual void initialize();
virtual void process(Gamepad * gamepad, uint8_t * outBuffer);
virtual void process(Gamepad * gamepad);
virtual void initializeAux() {}
virtual void processAux() {}
virtual uint16_t get_report(uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen);
Expand Down
2 changes: 1 addition & 1 deletion headers/drivers/keyboard/KeyboardDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class KeyboardDriver : public GPDriver {
public:
virtual void initialize();
virtual void process(Gamepad * gamepad, uint8_t * outBuffer);
virtual void process(Gamepad * gamepad);
virtual void initializeAux() {}
virtual void processAux() {}
virtual uint16_t get_report(uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen);
Expand Down
2 changes: 1 addition & 1 deletion headers/drivers/mdmini/MDMiniDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class MDMiniDriver : public GPDriver {
public:
virtual void initialize();
virtual void process(Gamepad * gamepad, uint8_t * outBuffer);
virtual void process(Gamepad * gamepad);
virtual void initializeAux() {}
virtual void processAux() {}
virtual uint16_t get_report(uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen);
Expand Down
2 changes: 1 addition & 1 deletion headers/drivers/neogeo/NeoGeoDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class NeoGeoDriver : public GPDriver {
public:
virtual void initialize();
virtual void process(Gamepad * gamepad, uint8_t * outBuffer);
virtual void process(Gamepad * gamepad);
virtual void initializeAux() {}
virtual void processAux() {}
virtual uint16_t get_report(uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen);
Expand Down
2 changes: 1 addition & 1 deletion headers/drivers/net/NetDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class NetDriver : public GPDriver {
public:
virtual void initialize();
virtual void process(Gamepad * gamepad, uint8_t * outBuffer);
virtual void process(Gamepad * gamepad);
virtual void initializeAux() {}
virtual void processAux() {}
virtual uint16_t get_report(uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen);
Expand Down
2 changes: 1 addition & 1 deletion headers/drivers/pcengine/PCEngineDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class PCEngineDriver : public GPDriver {
public:
virtual void initialize();
virtual void process(Gamepad * gamepad, uint8_t * outBuffer);
virtual void process(Gamepad * gamepad);
virtual void initializeAux() {}
virtual void processAux() {}
virtual uint16_t get_report(uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen);
Expand Down
Loading

0 comments on commit 89c5f44

Please sign in to comment.