mirror of
https://github.com/cathery/sys-con.git
synced 2025-02-04 21:39:56 +00:00
Change controller config options
Allow unmapping keys Allow mapping multiple keys to the same button Allow changing the deadzone for each trigger Remove dualshock4 global option from the config files Update config files for new changes
This commit is contained in:
parent
e1b3fcc3b0
commit
fb578f6987
@ -1,7 +1,8 @@
|
||||
; Config for the Dualshock 3 controller
|
||||
left_stick_deadzone = 10 ; from 0 to 100
|
||||
right_stick_deadzone = 10 ; from 0 to 100
|
||||
trigger_deadzone = 0 ; from 0 to 100
|
||||
left_trigger_deadzone = 0 ; from 0 to 100
|
||||
right_trigger_deadzone = 0 ; from 0 to 100
|
||||
|
||||
color_body = 48,71,105
|
||||
color_buttons = 22,22,22
|
||||
@ -13,4 +14,4 @@ color_rightGrip = 22,33,49
|
||||
swap_dpad_and_lstick = false ; set this to true to swap the d-pad and left stick
|
||||
|
||||
; For information on input mapping, see "example.ini"
|
||||
;key_SYNC = LSTICK_CLICK ; Remove the semicolon at the start to take effect
|
||||
;KEY_CAPTURE = LSTICK_CLICK ; Remove the semicolon at the start to take effect
|
@ -1,7 +1,8 @@
|
||||
; Config for the Dualshock 4 controller
|
||||
left_stick_deadzone = 10 ; from 0 to 100
|
||||
right_stick_deadzone = 10 ; from 0 to 100
|
||||
trigger_deadzone = 0 ; from 0 to 100
|
||||
left_trigger_deadzone = 0 ; from 0 to 100
|
||||
right_trigger_deadzone = 0 ; from 0 to 100
|
||||
|
||||
color_led = 0,0,64 ; from 0 to 255
|
||||
|
||||
@ -15,5 +16,5 @@ color_rightGrip = 33,33,33
|
||||
swap_dpad_and_lstick = false ; set this to true to swap the d-pad and left stick
|
||||
|
||||
; For information on input mapping, see "example.ini"
|
||||
;key_SYNC = LSTICK_CLICK ; Remove the semicolon at the start to take effect
|
||||
;KEY_CAPTURE = LSTICK_CLICK ; Remove the semicolon at the start to take effect
|
||||
|
||||
|
@ -1,2 +1 @@
|
||||
[global]
|
||||
use_dualshock_2nd_generation = false
|
@ -1,7 +1,8 @@
|
||||
; Config for the Xbox 360 and Xbox 360 Wireless type controllers
|
||||
left_stick_deadzone = 21 ; from 0 to 100
|
||||
right_stick_deadzone = 25 ; from 0 to 100
|
||||
trigger_deadzone = 0 ; from 0 to 100
|
||||
left_trigger_deadzone = 0 ; from 0 to 100
|
||||
right_trigger_deadzone = 0 ; from 0 to 100
|
||||
|
||||
color_body = 77,77,77
|
||||
color_buttons = 69,121,22
|
||||
@ -13,4 +14,4 @@ color_rightGrip = 100,100,100
|
||||
swap_dpad_and_lstick = false ; set this to true to swap the d-pad and left stick
|
||||
|
||||
; For information on input mapping, see "example.ini"
|
||||
;key_SYNC = LSTICK_CLICK ; Remove the semicolon at the start to take effect
|
||||
;KEY_CAPTURE = LSTICK_CLICK ; Remove the semicolon at the start to take effect
|
@ -1,7 +1,8 @@
|
||||
; Config for the Xbox One type controllers
|
||||
left_stick_deadzone = 10 ; from 0 to 100
|
||||
right_stick_deadzone = 17 ; from 0 to 100
|
||||
trigger_deadzone = 0 ; from 0 to 100
|
||||
left_trigger_deadzone = 0 ; from 0 to 100
|
||||
right_trigger_deadzone = 0 ; from 0 to 100
|
||||
|
||||
color_body = 107,107,107
|
||||
color_buttons = 0,0,0
|
||||
@ -14,5 +15,5 @@ swap_dpad_and_lstick = false ; set this to true to swap the d-pad and left stick
|
||||
|
||||
; For information on input mapping, see "example.ini"
|
||||
; Remove the semicolons below to take effect
|
||||
;key_FACE_DOWN = FACE_RIGHT
|
||||
;key_FACE_LEFT = FACE_UP
|
||||
;KEY_FACE_DOWN = FACE_RIGHT
|
||||
;KEY_FACE_LEFT = FACE_UP
|
@ -1,7 +1,8 @@
|
||||
; Config for the original XBOX type controllers
|
||||
left_stick_deadzone = 21 ; from 0 to 100
|
||||
right_stick_deadzone = 25 ; from 0 to 100
|
||||
trigger_deadzone = 0 ; from 0 to 100
|
||||
left_trigger_deadzone = 0 ; from 0 to 100
|
||||
right_trigger_deadzone = 0 ; from 0 to 100
|
||||
|
||||
color_body = 77,77,77
|
||||
color_buttons = 69,121,22
|
||||
@ -13,4 +14,4 @@ color_rightGrip = 100,100,100
|
||||
swap_dpad_and_lstick = false ; set this to true to swap the d-pad and left stick
|
||||
|
||||
; For information on input mapping, see "example.ini"
|
||||
;key_SYNC = GUIDE ; Remove the semicolon at the start to take effect
|
||||
;KEY_CAPTURE = HOME ; Remove the semicolon at the start to take effect
|
@ -5,39 +5,42 @@ right_stick_deadzone = 17 ; from 0 to 100
|
||||
|
||||
; trigger_deadzone is the percentage of how hard the trigger should be pressed before it is visible
|
||||
; 0 - always, 100 - not at all
|
||||
trigger_deadzone = 0 ; from 0 to 100
|
||||
left_trigger_deadzone = 0 ; from 0 to 100
|
||||
right_trigger_deadzone = 0 ; from 0 to 100
|
||||
|
||||
; Swap the button inputs for dpad and lstick, so that the dpad will be treated as analog input.
|
||||
swap_dpad_and_lstick = false ; set this to true to swap the d-pad and left stick
|
||||
|
||||
; to modify the key values, type "key_* = *"
|
||||
; to modify the key values, type "KEY_* = *"
|
||||
; where * is one of the values from this table
|
||||
; FACE_UP X on joycons
|
||||
; DEFAULT Use the default value (every key is mapped to this by default)
|
||||
; NONE Unmap the button
|
||||
; FACE_UP X on joycons
|
||||
; FACE_RIGHT A on joycons
|
||||
; FACE_DOWN B on joycons
|
||||
; FACE_LEFT Y on joycons
|
||||
; FACE_DOWN B on joycons
|
||||
; FACE_LEFT Y on joycons
|
||||
; LSTICK_CLICK Left stick press
|
||||
; RSTICK_CLICK Right stick press
|
||||
; LEFT_BUMPER Left bumper/ L
|
||||
; RIGHT_BUMPER Right bumper/ R
|
||||
; LEFT_TRIGGER Left trigger/ ZL
|
||||
; RIGHT_TRIGGER Right trigger/ ZR
|
||||
; BACK Minus on joycons
|
||||
; START Plus on joycons
|
||||
; DPAD_UP D-pad UP
|
||||
; BACK Minus on joycons
|
||||
; START Plus on joycons
|
||||
; DPAD_UP D-pad UP
|
||||
; DPAD_RIGHT D-pad RIGHT
|
||||
; DPAD_DOWN D-pad DOWN
|
||||
; DPAD_LEFT D-pad LEFT
|
||||
; SYNC Capture on joycons
|
||||
; GUIDE Home on joycons
|
||||
; TOUCHPAD Simulate at least one finger on the touch screen (doesn't work?)
|
||||
; DPAD_DOWN D-pad DOWN
|
||||
; DPAD_LEFT D-pad LEFT
|
||||
; CAPTURE Capture on joycons, sync on Xbox One, Touchpad press on DS4
|
||||
; HOME Home on joycons, Xbox button on Xbox, PS button on DS4
|
||||
; TOUCHPAD One finger on the DS4 touchpad (unused)
|
||||
|
||||
; example: this will swap the X and Y, A and B buttons to match the names on Xbox controllers
|
||||
key_FACE_DOWN = FACE_RIGHT
|
||||
key_FACE_LEFT = FACE_UP
|
||||
KEY_FACE_DOWN = FACE_RIGHT
|
||||
KEY_FACE_LEFT = FACE_UP
|
||||
|
||||
; example: this will press the Capture button on Left stick press
|
||||
key_LSTICK_CLICK = SYNC
|
||||
KEY_LSTICK_CLICK = CAPTURE
|
||||
|
||||
; these are RGB color values for the controller icon represented in the controller screens
|
||||
color_body = 107,107,107
|
||||
|
@ -1,8 +1,14 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
#define MAX_JOYSTICKS 2
|
||||
#define MAX_TRIGGERS 2
|
||||
#define MAX_CONTROLLER_BUTTONS 32
|
||||
|
||||
enum ControllerButton : uint8_t
|
||||
{
|
||||
NOT_SET = 0,
|
||||
DEFAULT = 0,
|
||||
NONE,
|
||||
FACE_UP,
|
||||
FACE_RIGHT,
|
||||
FACE_DOWN,
|
||||
@ -19,10 +25,10 @@ enum ControllerButton : uint8_t
|
||||
DPAD_RIGHT,
|
||||
DPAD_DOWN,
|
||||
DPAD_LEFT,
|
||||
CAPTURE,
|
||||
HOME,
|
||||
SYNC,
|
||||
GUIDE,
|
||||
TOUCHPAD,
|
||||
NUM_CONTROLLERBUTTONS = TOUCHPAD,
|
||||
};
|
||||
|
||||
struct NormalizedStick
|
||||
@ -45,14 +51,12 @@ union RGBAColor {
|
||||
|
||||
struct ControllerConfig
|
||||
{
|
||||
uint8_t leftStickDeadzonePercent{10};
|
||||
uint8_t rightStickDeadzonePercent{10};
|
||||
uint16_t leftStickRotationDegrees{};
|
||||
uint16_t rightStickRotationDegrees{};
|
||||
uint8_t triggerDeadzonePercent{};
|
||||
ControllerButton buttons[NUM_CONTROLLERBUTTONS]{};
|
||||
float triggers[2]{};
|
||||
NormalizedStick sticks[2]{};
|
||||
uint8_t stickDeadzonePercent[MAX_JOYSTICKS]{};
|
||||
uint16_t stickRotationDegrees[MAX_JOYSTICKS]{};
|
||||
uint8_t triggerDeadzonePercent[MAX_TRIGGERS]{};
|
||||
ControllerButton buttons[MAX_CONTROLLER_BUTTONS]{};
|
||||
float triggers[MAX_TRIGGERS]{};
|
||||
NormalizedStick sticks[MAX_JOYSTICKS]{};
|
||||
bool swapDPADandLSTICK{false};
|
||||
RGBAColor bodyColor{107, 107, 107, 255};
|
||||
RGBAColor buttonsColor{0, 0, 0, 255};
|
||||
|
@ -123,9 +123,9 @@ Result Dualshock3Controller::GetInput()
|
||||
return rc;
|
||||
}
|
||||
|
||||
float Dualshock3Controller::NormalizeTrigger(uint8_t value)
|
||||
float Dualshock3Controller::NormalizeTrigger(uint8_t deadzonePercent, uint8_t value)
|
||||
{
|
||||
uint8_t deadzone = (UINT8_MAX * _dualshock3ControllerConfig.triggerDeadzonePercent) / 100;
|
||||
uint8_t deadzone = (UINT8_MAX * deadzonePercent) / 100;
|
||||
//If the given value is below the trigger zone, save the calc and return 0, otherwise adjust the value to the deadzone
|
||||
return value < deadzone
|
||||
? 0
|
||||
@ -169,17 +169,17 @@ void Dualshock3Controller::NormalizeAxis(uint8_t x,
|
||||
//Pass by value should hopefully be optimized away by RVO
|
||||
NormalizedButtonData Dualshock3Controller::GetNormalizedButtonData()
|
||||
{
|
||||
NormalizedButtonData normalData;
|
||||
NormalizedButtonData normalData{};
|
||||
|
||||
normalData.triggers[0] = NormalizeTrigger(m_buttonData.trigger_left_pressure);
|
||||
normalData.triggers[1] = NormalizeTrigger(m_buttonData.trigger_right_pressure);
|
||||
normalData.triggers[0] = NormalizeTrigger(_dualshock3ControllerConfig.triggerDeadzonePercent[0], m_buttonData.trigger_left_pressure);
|
||||
normalData.triggers[1] = NormalizeTrigger(_dualshock3ControllerConfig.triggerDeadzonePercent[1], m_buttonData.trigger_right_pressure);
|
||||
|
||||
NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _dualshock3ControllerConfig.leftStickDeadzonePercent,
|
||||
NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _dualshock3ControllerConfig.stickDeadzonePercent[0],
|
||||
&normalData.sticks[0].axis_x, &normalData.sticks[0].axis_y);
|
||||
NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _dualshock3ControllerConfig.rightStickDeadzonePercent,
|
||||
NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _dualshock3ControllerConfig.stickDeadzonePercent[1],
|
||||
&normalData.sticks[1].axis_x, &normalData.sticks[1].axis_y);
|
||||
|
||||
bool buttons[NUM_CONTROLLERBUTTONS] = {
|
||||
bool buttons[MAX_CONTROLLER_BUTTONS] = {
|
||||
m_buttonData.triangle,
|
||||
m_buttonData.circle,
|
||||
m_buttonData.cross,
|
||||
@ -200,10 +200,13 @@ NormalizedButtonData Dualshock3Controller::GetNormalizedButtonData()
|
||||
m_buttonData.guide,
|
||||
};
|
||||
|
||||
for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i)
|
||||
for (int i = 0; i != MAX_CONTROLLER_BUTTONS; ++i)
|
||||
{
|
||||
ControllerButton button = _dualshock3ControllerConfig.buttons[i];
|
||||
normalData.buttons[(button != NOT_SET ? button : i)] = buttons[i];
|
||||
if (button == NONE)
|
||||
continue;
|
||||
|
||||
normalData.buttons[(button != DEFAULT ? button - 2 : i)] += buttons[i];
|
||||
}
|
||||
|
||||
return normalData;
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
|
||||
inline const Dualshock3ButtonData &GetButtonData() { return m_buttonData; };
|
||||
|
||||
float NormalizeTrigger(uint8_t value);
|
||||
float NormalizeTrigger(uint8_t deadzonePercent, uint8_t value);
|
||||
void NormalizeAxis(uint8_t x, uint8_t y, uint8_t deadzonePercent, float *x_out, float *y_out);
|
||||
|
||||
Result SendInitBytes();
|
||||
|
@ -129,9 +129,9 @@ Result Dualshock4Controller::GetInput()
|
||||
return rc;
|
||||
}
|
||||
|
||||
float Dualshock4Controller::NormalizeTrigger(uint8_t value)
|
||||
float Dualshock4Controller::NormalizeTrigger(uint8_t deadzonePercent, uint8_t value)
|
||||
{
|
||||
uint8_t deadzone = (UINT8_MAX * _dualshock4ControllerConfig.triggerDeadzonePercent) / 100;
|
||||
uint8_t deadzone = (UINT8_MAX * deadzonePercent) / 100;
|
||||
//If the given value is below the trigger zone, save the calc and return 0, otherwise adjust the value to the deadzone
|
||||
return value < deadzone
|
||||
? 0
|
||||
@ -175,17 +175,17 @@ void Dualshock4Controller::NormalizeAxis(uint8_t x,
|
||||
//Pass by value should hopefully be optimized away by RVO
|
||||
NormalizedButtonData Dualshock4Controller::GetNormalizedButtonData()
|
||||
{
|
||||
NormalizedButtonData normalData;
|
||||
NormalizedButtonData normalData{};
|
||||
|
||||
normalData.triggers[0] = NormalizeTrigger(m_buttonData.l2_pressure);
|
||||
normalData.triggers[1] = NormalizeTrigger(m_buttonData.r2_pressure);
|
||||
normalData.triggers[0] = NormalizeTrigger(_dualshock4ControllerConfig.triggerDeadzonePercent[0], m_buttonData.l2_pressure);
|
||||
normalData.triggers[1] = NormalizeTrigger(_dualshock4ControllerConfig.triggerDeadzonePercent[1], m_buttonData.r2_pressure);
|
||||
|
||||
NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _dualshock4ControllerConfig.leftStickDeadzonePercent,
|
||||
NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _dualshock4ControllerConfig.stickDeadzonePercent[0],
|
||||
&normalData.sticks[0].axis_x, &normalData.sticks[0].axis_y);
|
||||
NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _dualshock4ControllerConfig.rightStickDeadzonePercent,
|
||||
NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _dualshock4ControllerConfig.stickDeadzonePercent[1],
|
||||
&normalData.sticks[1].axis_x, &normalData.sticks[1].axis_y);
|
||||
|
||||
bool buttons[NUM_CONTROLLERBUTTONS] = {
|
||||
bool buttons[MAX_CONTROLLER_BUTTONS] = {
|
||||
m_buttonData.triangle,
|
||||
m_buttonData.circle,
|
||||
m_buttonData.cross,
|
||||
@ -204,13 +204,17 @@ NormalizedButtonData Dualshock4Controller::GetNormalizedButtonData()
|
||||
(m_buttonData.dpad == DS4_LEFT) || (m_buttonData.dpad == DS4_UPLEFT) || (m_buttonData.dpad == DS4_DOWNLEFT),
|
||||
m_buttonData.touchpad_press,
|
||||
m_buttonData.psbutton,
|
||||
false,
|
||||
m_buttonData.touchpad_finger1_unpressed == false,
|
||||
};
|
||||
|
||||
for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i)
|
||||
for (int i = 0; i != MAX_CONTROLLER_BUTTONS; ++i)
|
||||
{
|
||||
ControllerButton button = _dualshock4ControllerConfig.buttons[i];
|
||||
normalData.buttons[(button != NOT_SET ? button : i)] = buttons[i];
|
||||
if (button == NONE)
|
||||
continue;
|
||||
|
||||
normalData.buttons[(button != DEFAULT ? button - 2 : i)] += buttons[i];
|
||||
}
|
||||
|
||||
return normalData;
|
||||
|
@ -162,7 +162,7 @@ public:
|
||||
|
||||
virtual ControllerType GetType() override { return CONTROLLER_DUALSHOCK4; }
|
||||
|
||||
float NormalizeTrigger(uint8_t value);
|
||||
float NormalizeTrigger(uint8_t deadzonePercent, uint8_t value);
|
||||
void NormalizeAxis(uint8_t x, uint8_t y, uint8_t deadzonePercent, float *x_out, float *y_out);
|
||||
|
||||
Result SendInitBytes();
|
||||
|
@ -122,9 +122,9 @@ Result Xbox360Controller::SendInitBytes()
|
||||
return rc;
|
||||
}
|
||||
|
||||
float Xbox360Controller::NormalizeTrigger(uint8_t value)
|
||||
float Xbox360Controller::NormalizeTrigger(uint8_t deadzonePercent, uint8_t value)
|
||||
{
|
||||
uint16_t deadzone = (UINT8_MAX * _xbox360ControllerConfig.triggerDeadzonePercent) / 100;
|
||||
uint16_t deadzone = (UINT8_MAX * deadzonePercent) / 100;
|
||||
//If the given value is below the trigger zone, save the calc and return 0, otherwise adjust the value to the deadzone
|
||||
return value < deadzone
|
||||
? 0
|
||||
@ -169,17 +169,17 @@ void Xbox360Controller::NormalizeAxis(int16_t x,
|
||||
//Pass by value should hopefully be optimized away by RVO
|
||||
NormalizedButtonData Xbox360Controller::GetNormalizedButtonData()
|
||||
{
|
||||
NormalizedButtonData normalData;
|
||||
NormalizedButtonData normalData{};
|
||||
|
||||
normalData.triggers[0] = NormalizeTrigger(m_buttonData.trigger_left);
|
||||
normalData.triggers[1] = NormalizeTrigger(m_buttonData.trigger_right);
|
||||
normalData.triggers[0] = NormalizeTrigger(_xbox360ControllerConfig.triggerDeadzonePercent[0], m_buttonData.trigger_left);
|
||||
normalData.triggers[1] = NormalizeTrigger(_xbox360ControllerConfig.triggerDeadzonePercent[1], m_buttonData.trigger_right);
|
||||
|
||||
NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _xbox360ControllerConfig.leftStickDeadzonePercent,
|
||||
NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _xbox360ControllerConfig.stickDeadzonePercent[0],
|
||||
&normalData.sticks[0].axis_x, &normalData.sticks[0].axis_y);
|
||||
NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _xbox360ControllerConfig.rightStickDeadzonePercent,
|
||||
NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _xbox360ControllerConfig.stickDeadzonePercent[1],
|
||||
&normalData.sticks[1].axis_x, &normalData.sticks[1].axis_y);
|
||||
|
||||
bool buttons[NUM_CONTROLLERBUTTONS]{
|
||||
bool buttons[MAX_CONTROLLER_BUTTONS]{
|
||||
m_buttonData.y,
|
||||
m_buttonData.b,
|
||||
m_buttonData.a,
|
||||
@ -200,10 +200,13 @@ NormalizedButtonData Xbox360Controller::GetNormalizedButtonData()
|
||||
m_buttonData.guide,
|
||||
};
|
||||
|
||||
for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i)
|
||||
for (int i = 0; i != MAX_CONTROLLER_BUTTONS; ++i)
|
||||
{
|
||||
ControllerButton button = _xbox360ControllerConfig.buttons[i];
|
||||
normalData.buttons[(button != NOT_SET ? button : i)] = buttons[i];
|
||||
if (button == NONE)
|
||||
continue;
|
||||
|
||||
normalData.buttons[(button != DEFAULT ? button - 2 : i)] += buttons[i];
|
||||
}
|
||||
|
||||
return normalData;
|
||||
|
@ -106,7 +106,7 @@ public:
|
||||
|
||||
inline const Xbox360ButtonData &GetButtonData() { return m_buttonData; };
|
||||
|
||||
float NormalizeTrigger(uint8_t value);
|
||||
float NormalizeTrigger(uint8_t deadzonePercent, uint8_t value);
|
||||
void NormalizeAxis(int16_t x, int16_t y, uint8_t deadzonePercent, float *x_out, float *y_out);
|
||||
|
||||
Result SendInitBytes();
|
||||
|
@ -143,9 +143,9 @@ Result Xbox360WirelessController::GetInput()
|
||||
return rc;
|
||||
}
|
||||
|
||||
float Xbox360WirelessController::NormalizeTrigger(uint8_t value)
|
||||
float Xbox360WirelessController::NormalizeTrigger(uint8_t deadzonePercent, uint8_t value)
|
||||
{
|
||||
uint16_t deadzone = (UINT8_MAX * _xbox360WControllerConfig.triggerDeadzonePercent) / 100;
|
||||
uint16_t deadzone = (UINT8_MAX * deadzonePercent) / 100;
|
||||
//If the given value is below the trigger zone, save the calc and return 0, otherwise adjust the value to the deadzone
|
||||
return value < deadzone
|
||||
? 0
|
||||
@ -190,17 +190,17 @@ void Xbox360WirelessController::NormalizeAxis(int16_t x,
|
||||
//Pass by value should hopefully be optimized away by RVO
|
||||
NormalizedButtonData Xbox360WirelessController::GetNormalizedButtonData()
|
||||
{
|
||||
NormalizedButtonData normalData;
|
||||
NormalizedButtonData normalData{};
|
||||
|
||||
normalData.triggers[0] = NormalizeTrigger(m_buttonData.trigger_left);
|
||||
normalData.triggers[1] = NormalizeTrigger(m_buttonData.trigger_right);
|
||||
normalData.triggers[0] = NormalizeTrigger(_xbox360WControllerConfig.triggerDeadzonePercent[0], m_buttonData.trigger_left);
|
||||
normalData.triggers[1] = NormalizeTrigger(_xbox360WControllerConfig.triggerDeadzonePercent[1], m_buttonData.trigger_right);
|
||||
|
||||
NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _xbox360WControllerConfig.leftStickDeadzonePercent,
|
||||
NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _xbox360WControllerConfig.stickDeadzonePercent[0],
|
||||
&normalData.sticks[0].axis_x, &normalData.sticks[0].axis_y);
|
||||
NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _xbox360WControllerConfig.rightStickDeadzonePercent,
|
||||
NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _xbox360WControllerConfig.stickDeadzonePercent[1],
|
||||
&normalData.sticks[1].axis_x, &normalData.sticks[1].axis_y);
|
||||
|
||||
bool buttons[NUM_CONTROLLERBUTTONS]{
|
||||
bool buttons[MAX_CONTROLLER_BUTTONS]{
|
||||
m_buttonData.y,
|
||||
m_buttonData.b,
|
||||
m_buttonData.a,
|
||||
@ -221,10 +221,13 @@ NormalizedButtonData Xbox360WirelessController::GetNormalizedButtonData()
|
||||
m_buttonData.guide,
|
||||
};
|
||||
|
||||
for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i)
|
||||
for (int i = 0; i != MAX_CONTROLLER_BUTTONS; ++i)
|
||||
{
|
||||
ControllerButton button = _xbox360WControllerConfig.buttons[i];
|
||||
normalData.buttons[(button != NOT_SET ? button : i)] = buttons[i];
|
||||
if (button == NONE)
|
||||
continue;
|
||||
|
||||
normalData.buttons[(button != DEFAULT ? button - 2 : i)] += buttons[i];
|
||||
}
|
||||
|
||||
return normalData;
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
|
||||
inline const Xbox360ButtonData &GetButtonData() { return m_buttonData; };
|
||||
|
||||
float NormalizeTrigger(uint8_t value);
|
||||
float NormalizeTrigger(uint8_t deadzonePercent, uint8_t value);
|
||||
void NormalizeAxis(int16_t x, int16_t y, uint8_t deadzonePercent, float *x_out, float *y_out);
|
||||
|
||||
Result SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude);
|
||||
|
@ -109,9 +109,9 @@ Result XboxController::GetInput()
|
||||
return rc;
|
||||
}
|
||||
|
||||
float XboxController::NormalizeTrigger(uint8_t value)
|
||||
float XboxController::NormalizeTrigger(uint8_t deadzonePercent, uint8_t value)
|
||||
{
|
||||
uint8_t deadzone = (UINT8_MAX * _xboxControllerConfig.triggerDeadzonePercent) / 100;
|
||||
uint8_t deadzone = (UINT8_MAX * deadzonePercent) / 100;
|
||||
//If the given value is below the trigger zone, save the calc and return 0, otherwise adjust the value to the deadzone
|
||||
return value < deadzone
|
||||
? 0
|
||||
@ -156,17 +156,17 @@ void XboxController::NormalizeAxis(int16_t x,
|
||||
//Pass by value should hopefully be optimized away by RVO
|
||||
NormalizedButtonData XboxController::GetNormalizedButtonData()
|
||||
{
|
||||
NormalizedButtonData normalData;
|
||||
NormalizedButtonData normalData{};
|
||||
|
||||
normalData.triggers[0] = NormalizeTrigger(m_buttonData.trigger_left);
|
||||
normalData.triggers[1] = NormalizeTrigger(m_buttonData.trigger_right);
|
||||
normalData.triggers[0] = NormalizeTrigger(_xboxControllerConfig.triggerDeadzonePercent[0], m_buttonData.trigger_left);
|
||||
normalData.triggers[1] = NormalizeTrigger(_xboxControllerConfig.triggerDeadzonePercent[1], m_buttonData.trigger_right);
|
||||
|
||||
NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _xboxControllerConfig.leftStickDeadzonePercent,
|
||||
NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _xboxControllerConfig.stickDeadzonePercent[0],
|
||||
&normalData.sticks[0].axis_x, &normalData.sticks[0].axis_y);
|
||||
NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _xboxControllerConfig.rightStickDeadzonePercent,
|
||||
NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _xboxControllerConfig.stickDeadzonePercent[1],
|
||||
&normalData.sticks[1].axis_x, &normalData.sticks[1].axis_y);
|
||||
|
||||
bool buttons[NUM_CONTROLLERBUTTONS]{
|
||||
bool buttons[MAX_CONTROLLER_BUTTONS]{
|
||||
m_buttonData.y != 0,
|
||||
m_buttonData.b != 0,
|
||||
m_buttonData.a != 0,
|
||||
@ -187,10 +187,13 @@ NormalizedButtonData XboxController::GetNormalizedButtonData()
|
||||
m_buttonData.black_buttton != 0,
|
||||
};
|
||||
|
||||
for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i)
|
||||
for (int i = 0; i != MAX_CONTROLLER_BUTTONS; ++i)
|
||||
{
|
||||
ControllerButton button = _xboxControllerConfig.buttons[i];
|
||||
normalData.buttons[(button != NOT_SET ? button : i)] = buttons[i];
|
||||
if (button == NONE)
|
||||
continue;
|
||||
|
||||
normalData.buttons[(button != DEFAULT ? button - 2 : i)] += buttons[i];
|
||||
}
|
||||
|
||||
return normalData;
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
|
||||
inline const XboxButtonData &GetButtonData() { return m_buttonData; };
|
||||
|
||||
float NormalizeTrigger(uint8_t value);
|
||||
float NormalizeTrigger(uint8_t deadzonePercent, uint8_t value);
|
||||
void NormalizeAxis(int16_t x, int16_t y, uint8_t deadzonePercent, float *x_out, float *y_out);
|
||||
|
||||
Result SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude);
|
||||
|
@ -206,9 +206,9 @@ Result XboxOneController::SendInitBytes()
|
||||
return rc;
|
||||
}
|
||||
|
||||
float XboxOneController::NormalizeTrigger(uint16_t value)
|
||||
float XboxOneController::NormalizeTrigger(uint8_t deadzonePercent, uint16_t value)
|
||||
{
|
||||
uint16_t deadzone = (TRIGGER_MAXVALUE * _xboxoneControllerConfig.triggerDeadzonePercent) / 100;
|
||||
uint16_t deadzone = (TRIGGER_MAXVALUE * deadzonePercent) / 100;
|
||||
//If the given value is below the trigger zone, save the calc and return 0, otherwise adjust the value to the deadzone
|
||||
return value < deadzone
|
||||
? 0
|
||||
@ -253,17 +253,17 @@ void XboxOneController::NormalizeAxis(int16_t x,
|
||||
//Pass by value should hopefully be optimized away by RVO
|
||||
NormalizedButtonData XboxOneController::GetNormalizedButtonData()
|
||||
{
|
||||
NormalizedButtonData normalData;
|
||||
NormalizedButtonData normalData{};
|
||||
|
||||
normalData.triggers[0] = NormalizeTrigger(m_buttonData.trigger_left);
|
||||
normalData.triggers[1] = NormalizeTrigger(m_buttonData.trigger_right);
|
||||
normalData.triggers[0] = NormalizeTrigger(_xboxoneControllerConfig.triggerDeadzonePercent[0], m_buttonData.trigger_left);
|
||||
normalData.triggers[1] = NormalizeTrigger(_xboxoneControllerConfig.triggerDeadzonePercent[1], m_buttonData.trigger_right);
|
||||
|
||||
NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _xboxoneControllerConfig.leftStickDeadzonePercent,
|
||||
NormalizeAxis(m_buttonData.stick_left_x, m_buttonData.stick_left_y, _xboxoneControllerConfig.stickDeadzonePercent[0],
|
||||
&normalData.sticks[0].axis_x, &normalData.sticks[0].axis_y);
|
||||
NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _xboxoneControllerConfig.rightStickDeadzonePercent,
|
||||
NormalizeAxis(m_buttonData.stick_right_x, m_buttonData.stick_right_y, _xboxoneControllerConfig.stickDeadzonePercent[1],
|
||||
&normalData.sticks[1].axis_x, &normalData.sticks[1].axis_y);
|
||||
|
||||
bool buttons[NUM_CONTROLLERBUTTONS]{
|
||||
bool buttons[MAX_CONTROLLER_BUTTONS]{
|
||||
m_buttonData.y,
|
||||
m_buttonData.b,
|
||||
m_buttonData.a,
|
||||
@ -284,10 +284,13 @@ NormalizedButtonData XboxOneController::GetNormalizedButtonData()
|
||||
m_GuidePressed,
|
||||
};
|
||||
|
||||
for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i)
|
||||
for (int i = 0; i != MAX_CONTROLLER_BUTTONS; ++i)
|
||||
{
|
||||
ControllerButton button = _xboxoneControllerConfig.buttons[i];
|
||||
normalData.buttons[(button != NOT_SET ? button : i)] = buttons[i];
|
||||
if (button == NONE)
|
||||
continue;
|
||||
|
||||
normalData.buttons[(button != DEFAULT ? button - 2 : i)] += buttons[i];
|
||||
}
|
||||
|
||||
return normalData;
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
|
||||
inline const XboxOneButtonData &GetButtonData() { return m_buttonData; };
|
||||
|
||||
float NormalizeTrigger(uint16_t value);
|
||||
float NormalizeTrigger(uint8_t deadzonePercent, uint16_t value);
|
||||
void NormalizeAxis(int16_t x, int16_t y, uint8_t deadzonePercent, float *x_out, float *y_out);
|
||||
|
||||
Result SendInitBytes();
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
struct NormalizedButtonData
|
||||
{
|
||||
bool buttons[NUM_CONTROLLERBUTTONS];
|
||||
bool buttons[MAX_CONTROLLER_BUTTONS];
|
||||
float triggers[2];
|
||||
NormalizedStick sticks[2];
|
||||
};
|
||||
|
@ -162,7 +162,6 @@ void SwitchHDLHandler::FillHdlState(const NormalizedButtonData &data)
|
||||
|
||||
m_hdlState.buttons |= (data.buttons[16] ? KEY_CAPTURE : 0);
|
||||
m_hdlState.buttons |= (data.buttons[17] ? KEY_HOME : 0);
|
||||
m_hdlState.buttons |= (data.buttons[18] ? KEY_TOUCH : 0);
|
||||
}
|
||||
|
||||
void SwitchHDLHandler::UpdateInput()
|
||||
@ -189,7 +188,7 @@ void SwitchHDLHandler::UpdateInput()
|
||||
|
||||
void SwitchHDLHandler::UpdateOutput()
|
||||
{
|
||||
// Process a single output packet from a buffer
|
||||
// Process a single output packet from a buffer
|
||||
if (R_SUCCEEDED(GetController()->OutputBuffer()))
|
||||
return;
|
||||
|
||||
|
@ -26,8 +26,9 @@ namespace syscon::config
|
||||
|
||||
bool is_config_changed_check_thread_running = false;
|
||||
|
||||
constexpr const char *keyNames[NUM_CONTROLLERBUTTONS]
|
||||
{
|
||||
constexpr std::array keyNames{
|
||||
"DEFAULT",
|
||||
"NONE",
|
||||
"FACE_UP",
|
||||
"FACE_RIGHT",
|
||||
"FACE_DOWN",
|
||||
@ -44,21 +45,22 @@ namespace syscon::config
|
||||
"DPAD_RIGHT",
|
||||
"DPAD_DOWN",
|
||||
"DPAD_LEFT",
|
||||
"CAPTURE",
|
||||
"HOME",
|
||||
"SYNC",
|
||||
"GUIDE",
|
||||
"TOUCHPAD",
|
||||
};
|
||||
|
||||
ControllerButton StringToKey(const char *text)
|
||||
{
|
||||
for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i)
|
||||
for (int i = 0; i != keyNames.size(); ++i)
|
||||
{
|
||||
if (strcmp(keyNames[i], text) == 0)
|
||||
{
|
||||
return static_cast<ControllerButton>(i);
|
||||
}
|
||||
}
|
||||
return NOT_SET;
|
||||
return NONE;
|
||||
}
|
||||
|
||||
RGBAColor DecodeColorValue(const char *value)
|
||||
@ -82,37 +84,44 @@ namespace syscon::config
|
||||
|
||||
int ParseConfigLine(void *dummy, const char *section, const char *name, const char *value)
|
||||
{
|
||||
if (strncmp(name, "key_", 4) == 0)
|
||||
if (strncmp(name, "KEY_", 4) == 0)
|
||||
{
|
||||
ControllerButton button = StringToKey(name + 4);
|
||||
ControllerButton buttonValue = StringToKey(value);
|
||||
tempConfig.buttons[button] = buttonValue;
|
||||
tempConfig.buttons[buttonValue] = button;
|
||||
return 1;
|
||||
if (button >= 2)
|
||||
{
|
||||
tempConfig.buttons[button - 2] = buttonValue;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (strcmp(name, "left_stick_deadzone") == 0)
|
||||
{
|
||||
tempConfig.leftStickDeadzonePercent = atoi(value);
|
||||
tempConfig.stickDeadzonePercent[0] = atoi(value);
|
||||
return 1;
|
||||
}
|
||||
else if (strcmp(name, "right_stick_deadzone") == 0)
|
||||
{
|
||||
tempConfig.rightStickDeadzonePercent = atoi(value);
|
||||
tempConfig.stickDeadzonePercent[1] = atoi(value);
|
||||
return 1;
|
||||
}
|
||||
else if (strcmp(name, "left_stick_rotation") == 0)
|
||||
{
|
||||
tempConfig.leftStickRotationDegrees = atoi(value);
|
||||
tempConfig.stickRotationDegrees[0] = atoi(value);
|
||||
return 1;
|
||||
}
|
||||
else if (strcmp(name, "right_stick_rotation") == 0)
|
||||
{
|
||||
tempConfig.rightStickRotationDegrees = atoi(value);
|
||||
tempConfig.stickRotationDegrees[1] = atoi(value);
|
||||
return 1;
|
||||
}
|
||||
else if (strcmp(name, "trigger_deadzone") == 0)
|
||||
else if (strcmp(name, "left_trigger_deadzone") == 0)
|
||||
{
|
||||
tempConfig.triggerDeadzonePercent = atoi(value);
|
||||
tempConfig.triggerDeadzonePercent[0] = atoi(value);
|
||||
return 1;
|
||||
}
|
||||
else if (strcmp(name, "right_trigger_deadzone") == 0)
|
||||
{
|
||||
tempConfig.triggerDeadzonePercent[1] = atoi(value);
|
||||
return 1;
|
||||
}
|
||||
else if (strcmp(name, "swap_dpad_and_lstick") == 0)
|
||||
@ -160,10 +169,6 @@ namespace syscon::config
|
||||
Result ReadFromConfig(const char *path)
|
||||
{
|
||||
tempConfig = ControllerConfig{};
|
||||
for (int i = 0; i != NUM_CONTROLLERBUTTONS; ++i)
|
||||
{
|
||||
tempConfig.buttons[i] = NOT_SET;
|
||||
}
|
||||
return ini_parse(path, ParseConfigLine, NULL);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user