Skip to content

Commit

Permalink
Merge branch 'main' into togglejoystick
Browse files Browse the repository at this point in the history
  • Loading branch information
tupleu authored Sep 17, 2024
2 parents 0d5095f + ca3bac9 commit d5f7fde
Show file tree
Hide file tree
Showing 81 changed files with 2,711 additions and 733 deletions.
9 changes: 9 additions & 0 deletions headers/addons/analog.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
#define AUTO_CALIBRATE_ENABLED 0
#endif

#ifndef ANALOG_SMOOTHING_ENABLED
#define ANALOG_SMOOTHING_ENABLED 0
#endif

#ifndef SMOOTHING_FACTOR
#define SMOOTHING_FACTOR 5
#endif

// Analog Module Name
#define AnalogName "Analog"

Expand All @@ -78,6 +86,7 @@ class AnalogInput : public GPAddon {
uint16_t adc_2_y_center = 0;

static float readPin(int pin, uint16_t center, bool autoCalibrate);
static float emaCalculation(float ema_value, float smoothing_factor, float ema_previous);
static uint16_t map(uint16_t x, uint16_t in_min, uint16_t in_max, uint16_t out_min, uint16_t out_max);
static float magnitudeCalculation(float x, float y, float& x_magnitude, float& y_magnitude);
static void radialDeadzone(float& x, float& y, float in_deadzone, float out_deadzone, float x_magnitude, float y_magnitude, float magnitude, bool circularity);
Expand Down
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 d5f7fde

Please sign in to comment.