mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
Fix merge conflict
This commit is contained in:
parent
99dcc79674
commit
448e68155b
@ -63,36 +63,36 @@ std::list<BindingConnection> connections = std::list<BindingConnection>();
|
||||
|
||||
ControllerOutput output_array[] = {
|
||||
// Important: these have to be the first, or else they will update in the wrong order
|
||||
ControllerOutput(LEFTJOYSTICK_HALFMODE),
|
||||
ControllerOutput(RIGHTJOYSTICK_HALFMODE),
|
||||
ControllerOutput(KEY_TOGGLE),
|
||||
ControllerOutput((OrbisPadButtonDataOffset)LEFTJOYSTICK_HALFMODE),
|
||||
ControllerOutput((OrbisPadButtonDataOffset)RIGHTJOYSTICK_HALFMODE),
|
||||
ControllerOutput((OrbisPadButtonDataOffset)KEY_TOGGLE),
|
||||
|
||||
// Button mappings
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TRIANGLE),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CIRCLE),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CROSS),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_SQUARE),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L1),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L3),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R1),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R3),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_OPTIONS),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_UP),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_DOWN),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_LEFT),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_RIGHT),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::Triangle),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::Circle),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::Cross),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::Square),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::L1),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::L3),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::R1),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::R3),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::Options),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::TouchPad),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::Up),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::Down),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::Left),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::Right),
|
||||
|
||||
// Axis mappings
|
||||
ControllerOutput(0, Axis::LeftX),
|
||||
ControllerOutput(0, Axis::LeftY),
|
||||
ControllerOutput(0, Axis::RightX),
|
||||
ControllerOutput(0, Axis::RightY),
|
||||
ControllerOutput(0, Axis::TriggerLeft),
|
||||
ControllerOutput(0, Axis::TriggerRight),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::None, Axis::LeftX),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::None, Axis::LeftY),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::None, Axis::RightX),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::None, Axis::RightY),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::None, Axis::TriggerLeft),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::None, Axis::TriggerRight),
|
||||
|
||||
// the "sorry, you gave an incorrect value, now we bind it to nothing" output
|
||||
ControllerOutput(0, Axis::AxisMax),
|
||||
ControllerOutput(OrbisPadButtonDataOffset::None, Axis::AxisMax),
|
||||
};
|
||||
|
||||
// We had to go through 3 files of indirection just to update a flag
|
||||
@ -111,33 +111,33 @@ u32 GetAxisInputId(AxisMapping a) {
|
||||
return value;
|
||||
}
|
||||
|
||||
u32 GetOrbisToSdlButtonKeycode(u32 cbutton) {
|
||||
u32 GetOrbisToSdlButtonKeycode(OrbisPadButtonDataOffset cbutton) {
|
||||
switch (cbutton) {
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CIRCLE:
|
||||
case OrbisPadButtonDataOffset::Circle:
|
||||
return SDL_GAMEPAD_BUTTON_EAST;
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TRIANGLE:
|
||||
case OrbisPadButtonDataOffset::Triangle:
|
||||
return SDL_GAMEPAD_BUTTON_NORTH;
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_SQUARE:
|
||||
case OrbisPadButtonDataOffset::Square:
|
||||
return SDL_GAMEPAD_BUTTON_WEST;
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CROSS:
|
||||
case OrbisPadButtonDataOffset::Cross:
|
||||
return SDL_GAMEPAD_BUTTON_SOUTH;
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L1:
|
||||
case OrbisPadButtonDataOffset::L1:
|
||||
return SDL_GAMEPAD_BUTTON_LEFT_SHOULDER;
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R1:
|
||||
case OrbisPadButtonDataOffset::R1:
|
||||
return SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER;
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L3:
|
||||
case OrbisPadButtonDataOffset::L3:
|
||||
return SDL_GAMEPAD_BUTTON_LEFT_STICK;
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R3:
|
||||
case OrbisPadButtonDataOffset::R3:
|
||||
return SDL_GAMEPAD_BUTTON_RIGHT_STICK;
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_UP:
|
||||
case OrbisPadButtonDataOffset::Up:
|
||||
return SDL_GAMEPAD_BUTTON_DPAD_UP;
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_DOWN:
|
||||
case OrbisPadButtonDataOffset::Down:
|
||||
return SDL_GAMEPAD_BUTTON_DPAD_DOWN;
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_LEFT:
|
||||
case OrbisPadButtonDataOffset::Left:
|
||||
return SDL_GAMEPAD_BUTTON_DPAD_LEFT;
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_RIGHT:
|
||||
case OrbisPadButtonDataOffset::Right:
|
||||
return SDL_GAMEPAD_BUTTON_DPAD_RIGHT;
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_OPTIONS:
|
||||
case OrbisPadButtonDataOffset::Options:
|
||||
return SDL_GAMEPAD_BUTTON_START;
|
||||
|
||||
default:
|
||||
@ -145,11 +145,11 @@ u32 GetOrbisToSdlButtonKeycode(u32 cbutton) {
|
||||
}
|
||||
}
|
||||
u32 GetControllerButtonInputId(u32 cbutton) {
|
||||
if ((cbutton & (OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD | LEFTJOYSTICK_HALFMODE |
|
||||
if ((cbutton & ((u32)OrbisPadButtonDataOffset::TouchPad | LEFTJOYSTICK_HALFMODE |
|
||||
RIGHTJOYSTICK_HALFMODE)) != 0) {
|
||||
return (u32)-1;
|
||||
}
|
||||
return GetOrbisToSdlButtonKeycode(cbutton) + 0x10000000;
|
||||
return GetOrbisToSdlButtonKeycode((OrbisPadButtonDataOffset)cbutton) + 0x10000000;
|
||||
}
|
||||
|
||||
// syntax: 'name, name,name' or 'name,name' or 'name'
|
||||
@ -190,7 +190,7 @@ InputBinding GetBindingFromString(std::string& line) {
|
||||
key3 = axis_id;
|
||||
} else if (string_to_cbutton_map.find(t) != string_to_cbutton_map.end()) {
|
||||
// Map to controller button input ID
|
||||
u32 cbutton_id = GetControllerButtonInputId(string_to_cbutton_map.at(t));
|
||||
u32 cbutton_id = GetControllerButtonInputId((u32)string_to_cbutton_map.at(t));
|
||||
if (cbutton_id == (u32)-1) {
|
||||
return InputBinding(0, 0, 0);
|
||||
}
|
||||
@ -213,7 +213,7 @@ InputBinding GetBindingFromString(std::string& line) {
|
||||
ControllerOutput* GetOutputPointer(const ControllerOutput& parsed) {
|
||||
// i wonder how long until someone notices this or I get rid of it
|
||||
int i = 0;
|
||||
for (; i[output_array] != ControllerOutput(0, Axis::AxisMax); i++) {
|
||||
for (; i[output_array] != ControllerOutput(OrbisPadButtonDataOffset::None, Axis::AxisMax); i++) {
|
||||
if (i[output_array] == parsed) {
|
||||
return &output_array[i];
|
||||
}
|
||||
@ -284,7 +284,7 @@ void ParseInputConfig(const std::string game_id = "") {
|
||||
line);
|
||||
continue;
|
||||
}
|
||||
ControllerOutput* toggle_out = GetOutputPointer(ControllerOutput(KEY_TOGGLE));
|
||||
ControllerOutput* toggle_out = GetOutputPointer(ControllerOutput((OrbisPadButtonDataOffset)KEY_TOGGLE));
|
||||
BindingConnection toggle_connection =
|
||||
BindingConnection(InputBinding(toggle_keys.key2), toggle_out, toggle_keys.key3);
|
||||
connections.insert(connections.end(), toggle_connection);
|
||||
@ -329,7 +329,7 @@ void ParseInputConfig(const std::string game_id = "") {
|
||||
? 127
|
||||
: axis_it->second.value;
|
||||
connection = BindingConnection(
|
||||
binding, GetOutputPointer(ControllerOutput(0, axis_it->second.axis)), value_to_set);
|
||||
binding, GetOutputPointer(ControllerOutput(OrbisPadButtonDataOffset::None, axis_it->second.axis)), value_to_set);
|
||||
connections.insert(connections.end(), connection);
|
||||
} else {
|
||||
LOG_WARNING(Input, "Invalid format at line: {}, data: \"{}\", skipping line.",
|
||||
@ -415,7 +415,7 @@ void ControllerOutput::ResetUpdate() {
|
||||
}
|
||||
void ControllerOutput::AddUpdate(bool pressed, bool analog, u32 param) {
|
||||
state_changed = true;
|
||||
if (button != 0) {
|
||||
if (button != OrbisPadButtonDataOffset::None) {
|
||||
if (analog) {
|
||||
new_button_state |= abs((s32)param) > 0x40;
|
||||
} else {
|
||||
@ -443,9 +443,9 @@ void ControllerOutput::FinalizeUpdate() {
|
||||
old_button_state = new_button_state;
|
||||
old_param = new_param;
|
||||
float touchpad_x = 0;
|
||||
if (button != 0) {
|
||||
switch (button) {
|
||||
case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD:
|
||||
if (button != OrbisPadButtonDataOffset::None) {
|
||||
switch ((u32)button) {
|
||||
case (u32)OrbisPadButtonDataOffset::TouchPad:
|
||||
touchpad_x = Config::getBackButtonBehavior() == "left" ? 0.25f
|
||||
: Config::getBackButtonBehavior() == "right" ? 0.75f
|
||||
: 0.5f;
|
||||
@ -465,7 +465,7 @@ void ControllerOutput::FinalizeUpdate() {
|
||||
}
|
||||
break;
|
||||
default: // is a normal key (hopefully)
|
||||
controller->CheckButton(0, button, new_button_state);
|
||||
controller->CheckButton(0, (OrbisPadButtonDataOffset)button, new_button_state);
|
||||
break;
|
||||
}
|
||||
} else if (axis != Axis::AxisMax) {
|
||||
@ -485,8 +485,8 @@ void ControllerOutput::FinalizeUpdate() {
|
||||
// Also handle button counterpart for TriggerLeft and TriggerRight
|
||||
controller->CheckButton(0,
|
||||
axis == Axis::TriggerLeft
|
||||
? OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L2
|
||||
: OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2,
|
||||
? OrbisPadButtonDataOffset::L2
|
||||
: OrbisPadButtonDataOffset::R2,
|
||||
new_param > 0x20);
|
||||
return;
|
||||
default:
|
||||
|
@ -40,25 +40,25 @@ struct AxisMapping {
|
||||
};
|
||||
|
||||
// i strongly suggest you collapse these maps
|
||||
const std::map<std::string, u32> string_to_cbutton_map = {
|
||||
{"triangle", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TRIANGLE},
|
||||
{"circle", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CIRCLE},
|
||||
{"cross", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_CROSS},
|
||||
{"square", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_SQUARE},
|
||||
{"l1", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L1},
|
||||
{"r1", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R1},
|
||||
{"l3", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_L3},
|
||||
{"r3", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R3},
|
||||
{"pad_up", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_UP},
|
||||
{"pad_down", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_DOWN},
|
||||
{"pad_left", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_LEFT},
|
||||
{"pad_right", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_RIGHT},
|
||||
{"options", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_OPTIONS},
|
||||
const std::map<std::string, OrbisPadButtonDataOffset> string_to_cbutton_map = {
|
||||
{"triangle", OrbisPadButtonDataOffset::Triangle},
|
||||
{"circle", OrbisPadButtonDataOffset::Circle},
|
||||
{"cross", OrbisPadButtonDataOffset::Cross},
|
||||
{"square", OrbisPadButtonDataOffset::Square},
|
||||
{"l1", OrbisPadButtonDataOffset::L1},
|
||||
{"r1", OrbisPadButtonDataOffset::R1},
|
||||
{"l3", OrbisPadButtonDataOffset::L3},
|
||||
{"r3", OrbisPadButtonDataOffset::R3},
|
||||
{"pad_up", OrbisPadButtonDataOffset::Up},
|
||||
{"pad_down", OrbisPadButtonDataOffset::Down},
|
||||
{"pad_left", OrbisPadButtonDataOffset::Left},
|
||||
{"pad_right", OrbisPadButtonDataOffset::Right},
|
||||
{"options", OrbisPadButtonDataOffset::Options},
|
||||
|
||||
// these are outputs only (touchpad can only be bound to itself)
|
||||
{"touchpad", OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD},
|
||||
{"leftjoystick_halfmode", LEFTJOYSTICK_HALFMODE},
|
||||
{"rightjoystick_halfmode", RIGHTJOYSTICK_HALFMODE},
|
||||
{"touchpad", OrbisPadButtonDataOffset::TouchPad},
|
||||
{"leftjoystick_halfmode", (OrbisPadButtonDataOffset)LEFTJOYSTICK_HALFMODE},
|
||||
{"rightjoystick_halfmode", (OrbisPadButtonDataOffset)RIGHTJOYSTICK_HALFMODE},
|
||||
};
|
||||
const std::map<std::string, AxisMapping> string_to_axis_map = {
|
||||
{"axis_left_x_plus", {Input::Axis::LeftX, 127}},
|
||||
@ -270,12 +270,12 @@ class ControllerOutput {
|
||||
public:
|
||||
static void SetControllerOutputController(GameController* c);
|
||||
|
||||
u32 button;
|
||||
OrbisPadButtonDataOffset button;
|
||||
Axis axis;
|
||||
s32 old_param, new_param;
|
||||
bool old_button_state, new_button_state, state_changed;
|
||||
|
||||
ControllerOutput(const u32 b, Axis a = Axis::AxisMax) {
|
||||
ControllerOutput(const OrbisPadButtonDataOffset b, Axis a = Axis::AxisMax) {
|
||||
button = b;
|
||||
axis = a;
|
||||
old_param = 0;
|
||||
@ -288,13 +288,13 @@ public:
|
||||
return button != o.button || axis != o.axis;
|
||||
}
|
||||
std::string ToString() const {
|
||||
return fmt::format("({}, {}, {})", button, (int)axis, old_param);
|
||||
return fmt::format("({}, {}, {})", (u32)button, (int)axis, old_param);
|
||||
}
|
||||
inline bool IsButton() const {
|
||||
return axis == Axis::AxisMax && button != 0;
|
||||
return axis == Axis::AxisMax && button != OrbisPadButtonDataOffset::None;
|
||||
}
|
||||
inline bool IsAxis() const {
|
||||
return axis != Axis::AxisMax && button == 0;
|
||||
return axis != Axis::AxisMax && button == OrbisPadButtonDataOffset::None;
|
||||
}
|
||||
|
||||
void ResetUpdate();
|
||||
|
@ -1,7 +1,6 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
<<<<<<< HEAD
|
||||
#include "SDL3/SDL_events.h"
|
||||
#include "SDL3/SDL_init.h"
|
||||
#include "SDL3/SDL_properties.h"
|
||||
@ -11,16 +10,6 @@
|
||||
#include "common/config.h"
|
||||
#include "common/elf_info.h"
|
||||
#include "common/version.h"
|
||||
=======
|
||||
#include <SDL3/SDL_events.h>
|
||||
#include <SDL3/SDL_init.h>
|
||||
#include <SDL3/SDL_properties.h>
|
||||
#include <SDL3/SDL_timer.h>
|
||||
#include <SDL3/SDL_video.h>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/config.h"
|
||||
>>>>>>> origin/main
|
||||
#include "core/libraries/pad/pad.h"
|
||||
#include "imgui/renderer/imgui_core.h"
|
||||
#include "input/controller.h"
|
||||
@ -36,43 +25,6 @@ namespace Frontend {
|
||||
|
||||
using namespace Libraries::Pad;
|
||||
|
||||
static OrbisPadButtonDataOffset SDLGamepadToOrbisButton(u8 button) {
|
||||
switch (button) {
|
||||
case SDL_GAMEPAD_BUTTON_DPAD_DOWN:
|
||||
return OrbisPadButtonDataOffset::Down;
|
||||
case SDL_GAMEPAD_BUTTON_DPAD_UP:
|
||||
return OrbisPadButtonDataOffset::Up;
|
||||
case SDL_GAMEPAD_BUTTON_DPAD_LEFT:
|
||||
return OrbisPadButtonDataOffset::Left;
|
||||
case SDL_GAMEPAD_BUTTON_DPAD_RIGHT:
|
||||
return OrbisPadButtonDataOffset::Right;
|
||||
case SDL_GAMEPAD_BUTTON_SOUTH:
|
||||
return OrbisPadButtonDataOffset::Cross;
|
||||
case SDL_GAMEPAD_BUTTON_NORTH:
|
||||
return OrbisPadButtonDataOffset::Triangle;
|
||||
case SDL_GAMEPAD_BUTTON_WEST:
|
||||
return OrbisPadButtonDataOffset::Square;
|
||||
case SDL_GAMEPAD_BUTTON_EAST:
|
||||
return OrbisPadButtonDataOffset::Circle;
|
||||
case SDL_GAMEPAD_BUTTON_START:
|
||||
return OrbisPadButtonDataOffset::Options;
|
||||
case SDL_GAMEPAD_BUTTON_TOUCHPAD:
|
||||
return OrbisPadButtonDataOffset::TouchPad;
|
||||
case SDL_GAMEPAD_BUTTON_BACK:
|
||||
return OrbisPadButtonDataOffset::TouchPad;
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_SHOULDER:
|
||||
return OrbisPadButtonDataOffset::L1;
|
||||
case SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER:
|
||||
return OrbisPadButtonDataOffset::R1;
|
||||
case SDL_GAMEPAD_BUTTON_LEFT_STICK:
|
||||
return OrbisPadButtonDataOffset::L3;
|
||||
case SDL_GAMEPAD_BUTTON_RIGHT_STICK:
|
||||
return OrbisPadButtonDataOffset::R3;
|
||||
default:
|
||||
return OrbisPadButtonDataOffset::None;
|
||||
}
|
||||
}
|
||||
|
||||
static Uint32 SDLCALL PollController(void* userdata, SDL_TimerID timer_id, Uint32 interval) {
|
||||
auto* controller = reinterpret_cast<Input::GameController*>(userdata);
|
||||
return controller->Poll();
|
||||
@ -164,7 +116,6 @@ void WindowSDL::WaitEvent() {
|
||||
case SDL_EVENT_MOUSE_WHEEL_OFF:
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
<<<<<<< HEAD
|
||||
OnKeyboardMouseInput(&event);
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_ADDED:
|
||||
@ -177,21 +128,10 @@ void WindowSDL::WaitEvent() {
|
||||
controller->SetTouchpadState(event.gtouchpad.finger,
|
||||
event.type != SDL_EVENT_GAMEPAD_TOUCHPAD_UP, event.gtouchpad.x,
|
||||
event.gtouchpad.y);
|
||||
=======
|
||||
OnKeyPress(&event);
|
||||
>>>>>>> origin/main
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
case SDL_EVENT_GAMEPAD_ADDED:
|
||||
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_UP:
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
|
||||
>>>>>>> origin/main
|
||||
OnGamepadEvent(&event);
|
||||
break;
|
||||
case SDL_EVENT_QUIT:
|
||||
@ -212,7 +152,6 @@ void WindowSDL::OnResize() {
|
||||
ImGui::Core::OnResize();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
Uint32 wheelOffCallback(void* og_event, Uint32 timer_id, Uint32 interval) {
|
||||
SDL_Event off_event = *(SDL_Event*)og_event;
|
||||
off_event.type = SDL_EVENT_MOUSE_WHEEL_OFF;
|
||||
@ -236,68 +175,12 @@ void WindowSDL::OnKeyboardMouseInput(const SDL_Event* event) {
|
||||
if (input_id == SDLK_F8) {
|
||||
Input::ParseInputConfig(std::string(Common::ElfInfo::Instance().GameSerial()));
|
||||
return;
|
||||
=======
|
||||
void WindowSDL::OnKeyPress(const SDL_Event* event) {
|
||||
#ifdef __APPLE__
|
||||
// Use keys that are more friendly for keyboards without a keypad.
|
||||
// Once there are key binding options this won't be necessary.
|
||||
constexpr SDL_Keycode CrossKey = SDLK_N;
|
||||
constexpr SDL_Keycode CircleKey = SDLK_B;
|
||||
constexpr SDL_Keycode SquareKey = SDLK_V;
|
||||
constexpr SDL_Keycode TriangleKey = SDLK_C;
|
||||
#else
|
||||
constexpr SDL_Keycode CrossKey = SDLK_KP_2;
|
||||
constexpr SDL_Keycode CircleKey = SDLK_KP_6;
|
||||
constexpr SDL_Keycode SquareKey = SDLK_KP_4;
|
||||
constexpr SDL_Keycode TriangleKey = SDLK_KP_8;
|
||||
#endif
|
||||
|
||||
auto button = OrbisPadButtonDataOffset::None;
|
||||
Input::Axis axis = Input::Axis::AxisMax;
|
||||
int axisvalue = 0;
|
||||
int ax = 0;
|
||||
std::string backButtonBehavior = Config::getBackButtonBehavior();
|
||||
switch (event->key.key) {
|
||||
case SDLK_UP:
|
||||
button = OrbisPadButtonDataOffset::Up;
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
button = OrbisPadButtonDataOffset::Down;
|
||||
break;
|
||||
case SDLK_LEFT:
|
||||
button = OrbisPadButtonDataOffset::Left;
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
button = OrbisPadButtonDataOffset::Right;
|
||||
break;
|
||||
case TriangleKey:
|
||||
button = OrbisPadButtonDataOffset::Triangle;
|
||||
break;
|
||||
case CircleKey:
|
||||
button = OrbisPadButtonDataOffset::Circle;
|
||||
break;
|
||||
case CrossKey:
|
||||
button = OrbisPadButtonDataOffset::Cross;
|
||||
break;
|
||||
case SquareKey:
|
||||
button = OrbisPadButtonDataOffset::Square;
|
||||
break;
|
||||
case SDLK_RETURN:
|
||||
button = OrbisPadButtonDataOffset::Options;
|
||||
break;
|
||||
case SDLK_A:
|
||||
axis = Input::Axis::LeftX;
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
axisvalue += -127;
|
||||
} else {
|
||||
axisvalue = 0;
|
||||
>>>>>>> origin/main
|
||||
}
|
||||
// Toggle mouse capture and movement input
|
||||
else if (input_id == SDLK_F7) {
|
||||
Input::ToggleMouseEnabled();
|
||||
SDL_SetWindowRelativeMouseMode(this->GetSdlWindow(),
|
||||
!SDL_GetWindowRelativeMouseMode(this->GetSdlWindow()));
|
||||
SDL_SetWindowRelativeMouseMode(this->GetSDLWindow(),
|
||||
!SDL_GetWindowRelativeMouseMode(this->GetSDLWindow()));
|
||||
return;
|
||||
}
|
||||
// Toggle fullscreen
|
||||
@ -307,127 +190,17 @@ void WindowSDL::OnKeyPress(const SDL_Event* event) {
|
||||
SDL_SetWindowFullscreen(window, !is_fullscreen);
|
||||
return;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
// Trigger rdoc capture
|
||||
else if (input_id == SDLK_F12) {
|
||||
=======
|
||||
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
|
||||
break;
|
||||
case SDLK_S:
|
||||
axis = Input::Axis::LeftY;
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
axisvalue += 127;
|
||||
} else {
|
||||
axisvalue = 0;
|
||||
}
|
||||
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
|
||||
break;
|
||||
case SDLK_J:
|
||||
axis = Input::Axis::RightX;
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
axisvalue += -127;
|
||||
} else {
|
||||
axisvalue = 0;
|
||||
}
|
||||
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
|
||||
break;
|
||||
case SDLK_L:
|
||||
axis = Input::Axis::RightX;
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
axisvalue += 127;
|
||||
} else {
|
||||
axisvalue = 0;
|
||||
}
|
||||
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
|
||||
break;
|
||||
case SDLK_I:
|
||||
axis = Input::Axis::RightY;
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
axisvalue += -127;
|
||||
} else {
|
||||
axisvalue = 0;
|
||||
}
|
||||
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
|
||||
break;
|
||||
case SDLK_K:
|
||||
axis = Input::Axis::RightY;
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
axisvalue += 127;
|
||||
} else {
|
||||
axisvalue = 0;
|
||||
}
|
||||
ax = Input::GetAxis(-0x80, 0x80, axisvalue);
|
||||
break;
|
||||
case SDLK_X:
|
||||
button = OrbisPadButtonDataOffset::L3;
|
||||
break;
|
||||
case SDLK_M:
|
||||
button = OrbisPadButtonDataOffset::R3;
|
||||
break;
|
||||
case SDLK_Q:
|
||||
button = OrbisPadButtonDataOffset::L1;
|
||||
break;
|
||||
case SDLK_U:
|
||||
button = OrbisPadButtonDataOffset::R1;
|
||||
break;
|
||||
case SDLK_E:
|
||||
button = OrbisPadButtonDataOffset::L2;
|
||||
axis = Input::Axis::TriggerLeft;
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
axisvalue += 255;
|
||||
} else {
|
||||
axisvalue = 0;
|
||||
}
|
||||
ax = Input::GetAxis(0, 0x80, axisvalue);
|
||||
break;
|
||||
case SDLK_O:
|
||||
button = OrbisPadButtonDataOffset::R2;
|
||||
axis = Input::Axis::TriggerRight;
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
axisvalue += 255;
|
||||
} else {
|
||||
axisvalue = 0;
|
||||
}
|
||||
ax = Input::GetAxis(0, 0x80, axisvalue);
|
||||
break;
|
||||
case SDLK_SPACE:
|
||||
if (backButtonBehavior != "none") {
|
||||
float x = backButtonBehavior == "left" ? 0.25f
|
||||
: (backButtonBehavior == "right" ? 0.75f : 0.5f);
|
||||
// trigger a touchpad event so that the touchpad emulation for back button works
|
||||
controller->SetTouchpadState(0, true, x, 0.5f);
|
||||
button = OrbisPadButtonDataOffset::TouchPad;
|
||||
} else {
|
||||
button = {};
|
||||
}
|
||||
break;
|
||||
case SDLK_F11:
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
{
|
||||
SDL_WindowFlags flag = SDL_GetWindowFlags(window);
|
||||
bool is_fullscreen = flag & SDL_WINDOW_FULLSCREEN;
|
||||
SDL_SetWindowFullscreen(window, !is_fullscreen);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDLK_F12:
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
// Trigger rdoc capture
|
||||
>>>>>>> origin/main
|
||||
VideoCore::TriggerCapture();
|
||||
return;
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
// if it's a wheel event, make a timer that turns it off after a set time
|
||||
if (event->type == SDL_EVENT_MOUSE_WHEEL) {
|
||||
const SDL_Event* copy = new SDL_Event(*event);
|
||||
SDL_AddTimer(33, wheelOffCallback, (void*)copy);
|
||||
=======
|
||||
if (button != OrbisPadButtonDataOffset::None) {
|
||||
controller->CheckButton(0, button, event->type == SDL_EVENT_KEY_DOWN);
|
||||
>>>>>>> origin/main
|
||||
}
|
||||
|
||||
// add/remove it from the list
|
||||
@ -440,70 +213,18 @@ void WindowSDL::OnKeyPress(const SDL_Event* event) {
|
||||
}
|
||||
|
||||
void WindowSDL::OnGamepadEvent(const SDL_Event* event) {
|
||||
<<<<<<< HEAD
|
||||
|
||||
bool input_down = event->type == SDL_EVENT_GAMEPAD_AXIS_MOTION ||
|
||||
event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN ||
|
||||
event->type == SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN ||
|
||||
event->type == SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION;
|
||||
u32 input_id = Input::InputBinding::GetInputIDFromEvent(*event);
|
||||
=======
|
||||
auto button = OrbisPadButtonDataOffset::None;
|
||||
Input::Axis axis = Input::Axis::AxisMax;
|
||||
switch (event->type) {
|
||||
case SDL_EVENT_GAMEPAD_ADDED:
|
||||
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||
controller->TryOpenSDLController();
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_UP:
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
|
||||
controller->SetTouchpadState(event->gtouchpad.finger,
|
||||
event->type != SDL_EVENT_GAMEPAD_TOUCHPAD_UP,
|
||||
event->gtouchpad.x, event->gtouchpad.y);
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_UP: {
|
||||
button = SDLGamepadToOrbisButton(event->gbutton.button);
|
||||
if (button == OrbisPadButtonDataOffset::None) {
|
||||
break;
|
||||
}
|
||||
if (event->gbutton.button != SDL_GAMEPAD_BUTTON_BACK) {
|
||||
controller->CheckButton(0, button, event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN);
|
||||
break;
|
||||
}
|
||||
const auto backButtonBehavior = Config::getBackButtonBehavior();
|
||||
if (backButtonBehavior != "none") {
|
||||
float x = backButtonBehavior == "left" ? 0.25f
|
||||
: (backButtonBehavior == "right" ? 0.75f : 0.5f);
|
||||
// trigger a touchpad event so that the touchpad emulation for back button works
|
||||
controller->SetTouchpadState(0, true, x, 0.5f);
|
||||
controller->CheckButton(0, button, event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||
axis = event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFTX ? Input::Axis::LeftX
|
||||
: event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFTY ? Input::Axis::LeftY
|
||||
: event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHTX ? Input::Axis::RightX
|
||||
: event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHTY ? Input::Axis::RightY
|
||||
: event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFT_TRIGGER ? Input::Axis::TriggerLeft
|
||||
: event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER ? Input::Axis::TriggerRight
|
||||
: Input::Axis::AxisMax;
|
||||
if (axis != Input::Axis::AxisMax) {
|
||||
if (event->gaxis.axis == SDL_GAMEPAD_AXIS_LEFT_TRIGGER ||
|
||||
event->gaxis.axis == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER) {
|
||||
controller->Axis(0, axis, Input::GetAxis(0, 0x8000, event->gaxis.value));
|
||||
>>>>>>> origin/main
|
||||
|
||||
bool inputs_changed = Input::UpdatePressedKeys(input_id, input_down);
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (inputs_changed) {
|
||||
Input::ActivateOutputsFromInputs();
|
||||
}
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> origin/main
|
||||
} // namespace Frontend
|
||||
|
@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/types.h"
|
||||
#include "core/libraries/pad/pad.h"
|
||||
#include "string"
|
||||
|
||||
struct SDL_Window;
|
||||
@ -74,8 +75,6 @@ private:
|
||||
void OnKeyboardMouseInput(const SDL_Event* event);
|
||||
void OnGamepadEvent(const SDL_Event* event);
|
||||
|
||||
static OrbisPadButtonDataOffset SDLGamepadToOrbisButton(u8 button);
|
||||
|
||||
private:
|
||||
s32 width;
|
||||
s32 height;
|
||||
|
Loading…
Reference in New Issue
Block a user