Skip to content

Commit

Permalink
PS4 Passthrough Add-on w/ PS5 Compatibility (#457)
Browse files Browse the repository at this point in the history
PS4 Passthrough Add-on w/ PS5 Compatibility, including web config settings, new USB host manager code, TinyUSB HID host extension code, and many other changes.
  • Loading branch information
arntsonl authored Aug 16, 2023
1 parent 0cf92a0 commit 62fb8fb
Show file tree
Hide file tree
Showing 47 changed files with 830 additions and 128 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ src/addonmanager.cpp
src/configmanager.cpp
src/storagemanager.cpp
src/system.cpp
src/usbhostmanager.cpp
src/config_legacy.cpp
src/config_utils.cpp
src/configs/webconfig.cpp
Expand All @@ -143,6 +144,7 @@ src/addons/neopicoleds.cpp
src/addons/playernum.cpp
src/addons/playerleds.cpp
src/addons/ps4mode.cpp
src/addons/pspassthrough.cpp
src/addons/reverse.cpp
src/addons/turbo.cpp
src/addons/slider_socd.cpp
Expand Down
2 changes: 2 additions & 0 deletions configs/AlpacaOwO/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
#define DEFAULT_INPUT_MODE INPUT_MODE_XINPUT //INPUT_MODE_XINPUT (XInput), INPUT_MODE_SWITCH (Nintendo Switch), INPUT_MODE_HID (D-Input), INPUT_MODE_KEYBOARD (Keyboard)
#define DEFAULT_DPAD_MODE DPAD_MODE_DIGITAL //DPAD_MODE_DIGITAL, DPAD_MODE_LEFT_ANALOG, DPAD_MODE_RIGHT_ANALOG,

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/BentoBox/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/DURAL/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/FightboardV3/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/FightboardV3Mirrored/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/FlatboxRev4/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/FlatboxRev5/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/FlatboxRev5RGB/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/KB2040/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#define DEFAULT_INPUT_MODE INPUT_MODE_XINPUT //INPUT_MODE_XINPUT (XInput), INPUT_MODE_SWITCH (Nintendo Switch), INPUT_MODE_HID (D-Input), INPUT_MODE_KEYBOARD (Keyboard)
#define DEFAULT_DPAD_MODE DPAD_MODE_DIGITAL //DPAD_MODE_DIGITAL, DPAD_MODE_LEFT_ANALOG, DPAD_MODE_RIGHT_ANALOG,

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF
#define DEFAULT_LOCK_HOTKEYS false// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
Expand Down
2 changes: 2 additions & 0 deletions configs/KeyboardConverter/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/MavercadeKeebfighter/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
7 changes: 7 additions & 0 deletions configs/Pico/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
#define DEFAULT_INPUT_MODE INPUT_MODE_XINPUT //INPUT_MODE_XINPUT (XInput), INPUT_MODE_SWITCH (Nintendo Switch), INPUT_MODE_HID (D-Input), INPUT_MODE_KEYBOARD (Keyboard)
#define DEFAULT_DPAD_MODE DPAD_MODE_DIGITAL //DPAD_MODE_DIGITAL, DPAD_MODE_LEFT_ANALOG, DPAD_MODE_RIGHT_ANALOG,

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down Expand Up @@ -296,6 +298,11 @@
#define KEYBOARD_HOST_PIN_DPLUS -1
#define KEYBOARD_HOST_PIN_5V -1

// PS Passthrough Host Addon defaults
#define PSPASSTHROUGH_HOST_ENABLED 0
#define PSPASSTHROUGH_HOST_PIN_DPLUS -1
#define PSPASSTHROUGH_HOST_PIN_5V -1

// For details on this, see: https://gp2040-ce.info/#/development?id=i2c-display-splash
#define DEFAULT_SPLASH \
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, \
Expand Down
2 changes: 2 additions & 0 deletions configs/PicoAnn/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/PicoFightingBoard/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/RP2040AdvancedBreakoutBoard/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/RP2040MiniBreakoutBoard/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/ReflexEncoder/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
1 change: 1 addition & 0 deletions configs/SGFDevices/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
Expand Down
3 changes: 3 additions & 0 deletions configs/SparkFunProMicro/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@

#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/Stress/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
2 changes: 2 additions & 0 deletions configs/WaveshareZero/BoardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#define DEFAULT_FORCED_SETUP_MODE FORCED_SETUP_MODE_OFF // FORCED_SETUP_MODE_OFF, FORCED_SETUP_MODE_LOCK_MODE_SWITCH, FORCED_SETUP_MODE_LOCK_WEB_CONFIG, FORCED_SETUP_MODE_LOCK_BOTH
#define DEFAULT_LOCK_HOTKEYS false // or true

#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER

// This is the LEDs section.
// The default `TURBO_LED_PIN` pin is set to `15` ( it is recommended to run through 3V3(OUT) with a resistor)
// The Turbo LED will flash at a speed consistant with the set speed of the Turbo when a Turbo button is active.
Expand Down
3 changes: 3 additions & 0 deletions headers/addonmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
#define _ADDONMANAGER_H_

#include "gpaddon.h"
#include "usbaddon.h"

#include <vector>
#include <pico/mutex.h>

enum ADDON_PROCESS {
CORE0_INPUT,
CORE0_USBREPORT,
CORE1_ALWAYS,
CORE1_LOOP
};

Expand All @@ -22,6 +24,7 @@ class AddonManager {
AddonManager() {}
~AddonManager() {}
void LoadAddon(GPAddon*, ADDON_PROCESS);
void LoadUSBAddon(USBAddon*, ADDON_PROCESS);
void PreprocessAddons(ADDON_PROCESS);
void ProcessAddons(ADDON_PROCESS);
GPAddon * GetAddon(std::string); // hack for NeoPicoLED
Expand Down
46 changes: 37 additions & 9 deletions headers/addons/keyboard_host.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _KeyboardHost_H
#define _KeyboardHost_H

#include "gpaddon.h"
#include "usbaddon.h"
#include "gamepad.h"

#ifndef KEYBOARD_HOST_ENABLED
Expand All @@ -21,12 +21,12 @@

struct KeyboardButtonMapping
{
KeyboardButtonMapping(uint16_t bm) :
buttonMask(bm)
{}

uint8_t key;
const uint16_t buttonMask;
uint16_t buttonMask;

inline void setMask(uint16_t m) {
buttonMask = m;
}

inline void setKey(uint8_t p)
{
Expand All @@ -36,14 +36,42 @@ struct KeyboardButtonMapping
bool isAssigned() const { return key != 0xff; }
};

class KeyboardHostAddon : public GPAddon {
class KeyboardHostAddon : public USBAddon {
public:
virtual bool available();
virtual void setup(); // KeyboardHost Setup
virtual void process() {} // KeyboardHost Process
virtual void process() {} // KeyboardHost Process
virtual void preprocess();
virtual std::string name() { return KeyboardHostName; }
private:
// USB Add-on Features
virtual void mount(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len);
virtual void unmount(uint8_t dev_addr);
virtual void report_received(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len);
virtual void set_report_complete(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t report_type, uint16_t len) {}
virtual void get_report_complete(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t report_type, uint16_t len) {}
private:
bool _keyboard_host_enabled;
uint8_t getKeycodeFromModifier(uint8_t modifier);
void process_kbd_report(uint8_t dev_addr, hid_keyboard_report_t const *report);
GamepadState _keyboard_host_state;
KeyboardButtonMapping _keyboard_host_mapDpadUp;
KeyboardButtonMapping _keyboard_host_mapDpadDown;
KeyboardButtonMapping _keyboard_host_mapDpadLeft;
KeyboardButtonMapping _keyboard_host_mapDpadRight;
KeyboardButtonMapping _keyboard_host_mapButtonB1;
KeyboardButtonMapping _keyboard_host_mapButtonB2;
KeyboardButtonMapping _keyboard_host_mapButtonB3;
KeyboardButtonMapping _keyboard_host_mapButtonB4;
KeyboardButtonMapping _keyboard_host_mapButtonL1;
KeyboardButtonMapping _keyboard_host_mapButtonR1;
KeyboardButtonMapping _keyboard_host_mapButtonL2;
KeyboardButtonMapping _keyboard_host_mapButtonR2;
KeyboardButtonMapping _keyboard_host_mapButtonS1;
KeyboardButtonMapping _keyboard_host_mapButtonS2;
KeyboardButtonMapping _keyboard_host_mapButtonL3;
KeyboardButtonMapping _keyboard_host_mapButtonR3;
KeyboardButtonMapping _keyboard_host_mapButtonA1;
KeyboardButtonMapping _keyboard_host_mapButtonA2;
};

#endif // _KeyboardHost_H_
46 changes: 46 additions & 0 deletions headers/addons/pspassthrough.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef _PSPassthrough_H
#define _PSPassthrough_H

#include "usbaddon.h"

#include "ps4_driver.h"

#ifndef PSPASSTHROUGH_ENABLED
#define PSPASSTHROUGH_ENABLED 0
#endif

#ifndef PPSPASSTHROUGH_PIN_DPLUS
#define PSPASSTHROUGH_PIN_DPLUS -1
#endif

#ifndef PSPASSTHROUGH_PIN_5V
#define PSPASSTHROUGH_PIN_5V -1
#endif

// KeyboardHost Module Name
#define PSPassthroughName "PSPassthrough"

class PSPassthroughAddon : public USBAddon {
public:
virtual bool available();
virtual void setup(); // PSPassthrough Setup
virtual void process(); // PSPassthrough Process
virtual void preprocess() {}
virtual std::string name() { return PSPassthroughName; }
// USB Add-on Features
virtual void mount(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len);
virtual void unmount(uint8_t dev_addr);
virtual void set_report_complete(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t report_type, uint16_t len);
virtual void get_report_complete(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t report_type, uint16_t len);
virtual void report_received(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len) {}
private:
uint8_t ps_dev_addr;
uint8_t ps_instance;
int8_t nonce_page;
PS4State passthrough_state;
int8_t send_nonce_part;
uint8_t report_buffer[64];
bool awaiting_cb;
};

#endif // _PSPassthrough_H_
4 changes: 4 additions & 0 deletions headers/gamepad/GamepadConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#define DEFAULT_INPUT_MODE INPUT_MODE_XINPUT
#endif

#ifndef DEFAULT_PS4CONTROLLER_TYPE
#define DEFAULT_PS4CONTROLLER_TYPE PS4_CONTROLLER
#endif

/* hotkeys */
#ifndef HOTKEY_01_AUX_MASK
#define HOTKEY_01_AUX_MASK 0
Expand Down
23 changes: 23 additions & 0 deletions headers/usbaddon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef _USBAddon_H_
#define _USBAddon_H_

#include "gpaddon.h"

#include <string>

class USBAddon : public GPAddon
{
public:
virtual bool available() = 0;
virtual void setup() = 0;
virtual void process() = 0;
virtual void preprocess() = 0;
virtual std::string name() = 0;
virtual void mount(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_report, uint16_t desc_len) = 0;
virtual void unmount(uint8_t dev_addr) = 0;
virtual void report_received(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len) = 0;
virtual void set_report_complete(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t report_type, uint16_t len) = 0;
virtual void get_report_complete(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t report_type, uint16_t len) = 0;
};

#endif
Loading

0 comments on commit 62fb8fb

Please sign in to comment.