mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
Wheel works now (for me), l2/r2 handling improvements, and misc bugfixes
This commit is contained in:
parent
df738c6dc1
commit
0d87d0d730
@ -185,14 +185,14 @@ void parseInputConfig(const std::string game_id = "") {
|
|||||||
if (before_equals == "modkey_toggle") {
|
if (before_equals == "modkey_toggle") {
|
||||||
if (comma_pos != std::string::npos) {
|
if (comma_pos != std::string::npos) {
|
||||||
// handle key-to-key toggling (separate list?)
|
// handle key-to-key toggling (separate list?)
|
||||||
LOG_ERROR(Input, "todo");
|
LOG_ERROR(Input, "todo: {}", line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LOG_ERROR(Input, "Invalid format at line: {}, data: \"{}\", skipping line.", lineCount, line);
|
LOG_ERROR(Input, "Invalid format at line: {}, data: \"{}\", skipping line.", lineCount, line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (before_equals == "mouse_movement_params") {
|
if (before_equals == "mouse_movement_params") {
|
||||||
LOG_ERROR(Input, "todo");
|
LOG_ERROR(Input, "todo: {}", line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +209,7 @@ void parseInputConfig(const std::string game_id = "") {
|
|||||||
if (button_it != string_to_cbutton_map.end()) {
|
if (button_it != string_to_cbutton_map.end()) {
|
||||||
connection = BindingConnection(binding, getOutputPointer(ControllerOutput(button_it->second)));
|
connection = BindingConnection(binding, getOutputPointer(ControllerOutput(button_it->second)));
|
||||||
connections.insert(connections.end(), connection);
|
connections.insert(connections.end(), connection);
|
||||||
|
|
||||||
} else if (axis_it != string_to_axis_map.end()) {
|
} else if (axis_it != string_to_axis_map.end()) {
|
||||||
connection = BindingConnection(binding, getOutputPointer(ControllerOutput(0, axis_it->second.axis)), axis_it->second.value);
|
connection = BindingConnection(binding, getOutputPointer(ControllerOutput(0, axis_it->second.axis)), axis_it->second.value);
|
||||||
connections.insert(connections.end(), connection);
|
connections.insert(connections.end(), connection);
|
||||||
@ -219,11 +220,14 @@ void parseInputConfig(const std::string game_id = "") {
|
|||||||
//LOG_INFO(Input, "Succesfully parsed line {}", lineCount);
|
//LOG_INFO(Input, "Succesfully parsed line {}", lineCount);
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
|
LOG_INFO(Input, "Done parsing the input config!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32 getMouseWheelEvent(const SDL_Event& event) {
|
u32 getMouseWheelEvent(const SDL_Event& event) {
|
||||||
if (event.type != SDL_EVENT_MOUSE_WHEEL || event.type != SDL_EVENT_MOUSE_WHEEL_OFF)
|
if (event.type != SDL_EVENT_MOUSE_WHEEL && event.type != SDL_EVENT_MOUSE_WHEEL_OFF) {
|
||||||
|
LOG_ERROR(Input, "Something went wrong with wheel input parsing!");
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
if (event.wheel.y > 0) {
|
if (event.wheel.y > 0) {
|
||||||
return SDL_MOUSE_WHEEL_UP;
|
return SDL_MOUSE_WHEEL_UP;
|
||||||
} else if (event.wheel.y < 0) {
|
} else if (event.wheel.y < 0) {
|
||||||
@ -233,7 +237,7 @@ Uint32 getMouseWheelEvent(const SDL_Event& event) {
|
|||||||
} else if (event.wheel.x < 0) {
|
} else if (event.wheel.x < 0) {
|
||||||
return SDL_MOUSE_WHEEL_LEFT;
|
return SDL_MOUSE_WHEEL_LEFT;
|
||||||
}
|
}
|
||||||
return 0;
|
return (u32)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 InputBinding::getInputIDFromEvent(const SDL_Event& e) {
|
u32 InputBinding::getInputIDFromEvent(const SDL_Event& e) {
|
||||||
@ -261,13 +265,6 @@ void ControllerOutput::update(bool pressed, int a_value) {
|
|||||||
float touchpad_x = 0;
|
float touchpad_x = 0;
|
||||||
if(button != 0){
|
if(button != 0){
|
||||||
switch (button) {
|
switch (button) {
|
||||||
// todo: check if l2 and r2 can be moved to the axis section
|
|
||||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2:
|
|
||||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2:
|
|
||||||
axis = (button == OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2) ? Axis::TriggerRight
|
|
||||||
: Axis::TriggerLeft;
|
|
||||||
controller->Axis(0, axis, GetAxis(0, 0x80, pressed ? 128 : 0));
|
|
||||||
break;
|
|
||||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD:
|
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD:
|
||||||
touchpad_x = Config::getBackButtonBehavior() == "left" ? 0.25f
|
touchpad_x = Config::getBackButtonBehavior() == "left" ? 0.25f
|
||||||
: Config::getBackButtonBehavior() == "right" ? 0.75f
|
: Config::getBackButtonBehavior() == "right" ? 0.75f
|
||||||
@ -298,9 +295,11 @@ void ControllerOutput::update(bool pressed, int a_value) {
|
|||||||
break;
|
break;
|
||||||
case Axis::TriggerLeft:
|
case Axis::TriggerLeft:
|
||||||
case Axis::TriggerRight:
|
case Axis::TriggerRight:
|
||||||
// todo: verify this works
|
// todo: verify this works (This probably works from testing,
|
||||||
//controller->Axis(0, axis, GetAxis(0, 0x80, pressed ? 128 : 0));
|
// but needs extra info (multiple input to the same trigger?))
|
||||||
break;
|
axis_value = SDL_clamp((pressed ? a_value : 0) * multiplier, 0, 127);
|
||||||
|
controller->Axis(0, axis, GetAxis(0, 0x80, axis_value));
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -319,13 +318,6 @@ void ControllerOutput::addUpdate(bool pressed, int a_value) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (button) {
|
switch (button) {
|
||||||
// todo: check if l2 and r2 can be moved to the axis section
|
|
||||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2:
|
|
||||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2:
|
|
||||||
axis = (button == OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2) ? Axis::TriggerRight
|
|
||||||
: Axis::TriggerLeft;
|
|
||||||
controller->Axis(0, axis, GetAxis(0, 0x80, pressed ? 128 : 0));
|
|
||||||
break;
|
|
||||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD:
|
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD:
|
||||||
touchpad_x = Config::getBackButtonBehavior() == "left" ? 0.25f
|
touchpad_x = Config::getBackButtonBehavior() == "left" ? 0.25f
|
||||||
: Config::getBackButtonBehavior() == "right" ? 0.75f
|
: Config::getBackButtonBehavior() == "right" ? 0.75f
|
||||||
@ -334,10 +326,10 @@ void ControllerOutput::addUpdate(bool pressed, int a_value) {
|
|||||||
controller->CheckButton(0, button, pressed);
|
controller->CheckButton(0, button, pressed);
|
||||||
break;
|
break;
|
||||||
case LEFTJOYSTICK_HALFMODE:
|
case LEFTJOYSTICK_HALFMODE:
|
||||||
leftjoystick_halfmode ^= pressed; // toggle if pressed, don't change otherwise
|
leftjoystick_halfmode = pressed;
|
||||||
break;
|
break;
|
||||||
case RIGHTJOYSTICK_HALFMODE:
|
case RIGHTJOYSTICK_HALFMODE:
|
||||||
rightjoystick_halfmode ^= pressed;
|
rightjoystick_halfmode = pressed;
|
||||||
break;
|
break;
|
||||||
default: // is a normal key (hopefully)
|
default: // is a normal key (hopefully)
|
||||||
controller->CheckButton(0, button, pressed);
|
controller->CheckButton(0, button, pressed);
|
||||||
@ -357,15 +349,15 @@ void ControllerOutput::addUpdate(bool pressed, int a_value) {
|
|||||||
case Axis::TriggerLeft:
|
case Axis::TriggerLeft:
|
||||||
case Axis::TriggerRight:
|
case Axis::TriggerRight:
|
||||||
// todo: verify this works
|
// todo: verify this works
|
||||||
//controller->Axis(0, axis, GetAxis(0, 0x80, pressed ? 128 : 0));
|
axis_value = SDL_clamp((pressed ? a_value : 0) * multiplier + axis_value, 0, 127);
|
||||||
break;
|
controller->Axis(0, axis, GetAxis(0, 0x80, axis_value));
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
axis_value = SDL_clamp((pressed ? a_value : 0) * multiplier + axis_value, -127, 127);
|
axis_value = SDL_clamp((pressed ? a_value : 0) * multiplier + axis_value, -127, 127);
|
||||||
int ax = GetAxis(-0x80, 0x80, axis_value);
|
controller->Axis(0, axis, GetAxis(-0x80, 0x80, axis_value));
|
||||||
controller->Axis(0, axis, ax);
|
//LOG_INFO(Input, "Axis value delta: {} final value: {}", (pressed ? a_value : 0), axis_value);
|
||||||
LOG_INFO(Input, "Axis value delta: {} final value: {}", a_value, axis_value);
|
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(Input, "Controller output with no values detected!");
|
LOG_ERROR(Input, "Controller output with no values detected!");
|
||||||
}
|
}
|
||||||
@ -398,21 +390,18 @@ bool isInputActive(const InputBinding& i) {
|
|||||||
*/
|
*/
|
||||||
auto it = pressed_keys.begin();
|
auto it = pressed_keys.begin();
|
||||||
|
|
||||||
// Check for key1 if it's set
|
|
||||||
if (i.key1 != 0) {
|
if (i.key1 != 0) {
|
||||||
it = std::find(it, pressed_keys.end(), i.key1);
|
it = std::find(it, pressed_keys.end(), i.key1);
|
||||||
if (it == pressed_keys.end()) return false;
|
if (it == pressed_keys.end()) return false;
|
||||||
++it; // Move to the next element for subsequent checks
|
++it; // Move to the next element for subsequent checks
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for key2 if it's set
|
|
||||||
if (i.key2 != 0) {
|
if (i.key2 != 0) {
|
||||||
it = std::find(it, pressed_keys.end(), i.key2);
|
it = std::find(it, pressed_keys.end(), i.key2);
|
||||||
if (it == pressed_keys.end()) return false;
|
if (it == pressed_keys.end()) return false;
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for key3 if it's set
|
|
||||||
if (i.key3 != 0) {
|
if (i.key3 != 0) {
|
||||||
it = std::find(it, pressed_keys.end(), i.key3);
|
it = std::find(it, pressed_keys.end(), i.key3);
|
||||||
if (it == pressed_keys.end()) return false;
|
if (it == pressed_keys.end()) return false;
|
||||||
@ -429,6 +418,9 @@ void activateOutputsFromInputs() {
|
|||||||
if (it->output) {
|
if (it->output) {
|
||||||
it->output->update(false, 0);
|
it->output->update(false, 0);
|
||||||
} else {
|
} else {
|
||||||
|
// LOG_ERROR(Input, "Null output in BindingConnection at position {}\n data: {}: {}",
|
||||||
|
// std::distance(connections.begin(), it),
|
||||||
|
// it->binding.toString(), it->output->toString());
|
||||||
LOG_ERROR(Input, "Null output in BindingConnection at position {}", std::distance(connections.begin(), it));
|
LOG_ERROR(Input, "Null output in BindingConnection at position {}", std::distance(connections.begin(), it));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/libraries/pad/pad.h"
|
#include "core/libraries/pad/pad.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
#include "input/controller.h"
|
#include "input/controller.h"
|
||||||
|
|
||||||
#include "SDL3/SDL_events.h"
|
#include "SDL3/SDL_events.h"
|
||||||
@ -43,9 +44,7 @@ const std::map<std::string, u32> string_to_cbutton_map = {
|
|||||||
{"cross", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CROSS},
|
{"cross", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CROSS},
|
||||||
{"square", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_SQUARE},
|
{"square", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_SQUARE},
|
||||||
{"l1", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L1},
|
{"l1", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L1},
|
||||||
{"l2", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2},
|
|
||||||
{"r1", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R1},
|
{"r1", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R1},
|
||||||
{"r2", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2},
|
|
||||||
{"l3", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L3},
|
{"l3", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L3},
|
||||||
{"r3", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R3},
|
{"r3", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R3},
|
||||||
{"options", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_OPTIONS},
|
{"options", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_OPTIONS},
|
||||||
@ -66,6 +65,8 @@ const std::map<std::string, AxisMapping> string_to_axis_map = {
|
|||||||
{"axis_right_x_minus", {Input::Axis::RightX, -127}},
|
{"axis_right_x_minus", {Input::Axis::RightX, -127}},
|
||||||
{"axis_right_y_plus", {Input::Axis::RightY, 127}},
|
{"axis_right_y_plus", {Input::Axis::RightY, 127}},
|
||||||
{"axis_right_y_minus", {Input::Axis::RightY, -127}},
|
{"axis_right_y_minus", {Input::Axis::RightY, -127}},
|
||||||
|
{"l2", {Axis::TriggerLeft, 127}},
|
||||||
|
{"r2", {Axis::TriggerRight, 127}},
|
||||||
};
|
};
|
||||||
const std::map<std::string, u32> string_to_keyboard_key_map = {
|
const std::map<std::string, u32> string_to_keyboard_key_map = {
|
||||||
{"a", SDLK_A},
|
{"a", SDLK_A},
|
||||||
@ -220,6 +221,9 @@ public:
|
|||||||
inline bool isEmpty() {
|
inline bool isEmpty() {
|
||||||
return key1 == 0 && key2 == 0 && key3 == 0;
|
return key1 == 0 && key2 == 0 && key3 == 0;
|
||||||
}
|
}
|
||||||
|
std::string toString() {
|
||||||
|
return fmt::format("({}, {}, {})", key1, key2, key3);
|
||||||
|
}
|
||||||
|
|
||||||
// returns a u32 based on the event type (keyboard, mouse buttons, or wheel)
|
// returns a u32 based on the event type (keyboard, mouse buttons, or wheel)
|
||||||
static u32 getInputIDFromEvent(const SDL_Event& e);
|
static u32 getInputIDFromEvent(const SDL_Event& e);
|
||||||
@ -246,6 +250,9 @@ public:
|
|||||||
inline bool operator!=(const ControllerOutput& o) const {
|
inline bool operator!=(const ControllerOutput& o) const {
|
||||||
return button != o.button || axis != o.axis;
|
return button != o.button || axis != o.axis;
|
||||||
}
|
}
|
||||||
|
std::string toString() const {
|
||||||
|
return fmt::format("({}, {}, {})", button, (int)axis, axis_value);
|
||||||
|
}
|
||||||
void update(bool pressed, int axis_direction = 0);
|
void update(bool pressed, int axis_direction = 0);
|
||||||
// Off events are not counted
|
// Off events are not counted
|
||||||
void addUpdate(bool pressed, int axis_direction = 0);
|
void addUpdate(bool pressed, int axis_direction = 0);
|
||||||
|
@ -167,22 +167,26 @@ void WindowSDL::onKeyboardMouseInput(const SDL_Event* event) {
|
|||||||
// Reparse kbm inputs
|
// Reparse kbm inputs
|
||||||
if (input_id == SDLK_F8) {
|
if (input_id == SDLK_F8) {
|
||||||
Input::parseInputConfig(std::string(Common::ElfInfo::Instance().GameSerial()));
|
Input::parseInputConfig(std::string(Common::ElfInfo::Instance().GameSerial()));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// Toggle mouse capture and movement input
|
// Toggle mouse capture and movement input
|
||||||
else if (input_id == SDLK_F7) {
|
else if (input_id == SDLK_F7) {
|
||||||
Input::toggleMouseEnabled();
|
Input::toggleMouseEnabled();
|
||||||
SDL_SetWindowRelativeMouseMode(this->GetSdlWindow(),
|
SDL_SetWindowRelativeMouseMode(this->GetSdlWindow(),
|
||||||
!SDL_GetWindowRelativeMouseMode(this->GetSdlWindow()));
|
!SDL_GetWindowRelativeMouseMode(this->GetSdlWindow()));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// Toggle fullscreen
|
// Toggle fullscreen
|
||||||
else if (input_id == SDLK_F11) {
|
else if (input_id == SDLK_F11) {
|
||||||
SDL_WindowFlags flag = SDL_GetWindowFlags(window);
|
SDL_WindowFlags flag = SDL_GetWindowFlags(window);
|
||||||
bool is_fullscreen = flag & SDL_WINDOW_FULLSCREEN;
|
bool is_fullscreen = flag & SDL_WINDOW_FULLSCREEN;
|
||||||
SDL_SetWindowFullscreen(window, !is_fullscreen);
|
SDL_SetWindowFullscreen(window, !is_fullscreen);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// Trigger rdoc capture
|
// Trigger rdoc capture
|
||||||
else if (input_id == SDLK_F12) {
|
else if (input_id == SDLK_F12) {
|
||||||
VideoCore::TriggerCapture();
|
VideoCore::TriggerCapture();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user