mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-26 12:26:18 +00:00
Fixing my pull request branch
This commit is contained in:
parent
ed78407127
commit
eb75efc903
2 changed files with 91 additions and 55 deletions
|
@ -176,7 +176,7 @@ InputBinding GetBindingFromString(std::string& line) {
|
||||||
if (string_to_keyboard_key_map.find(t) != string_to_keyboard_key_map.end()) {
|
if (string_to_keyboard_key_map.find(t) != string_to_keyboard_key_map.end()) {
|
||||||
input = InputID(InputType::KeyboardMouse, string_to_keyboard_key_map.at(t));
|
input = InputID(InputType::KeyboardMouse, string_to_keyboard_key_map.at(t));
|
||||||
} else if (string_to_axis_map.find(t) != string_to_axis_map.end()) {
|
} else if (string_to_axis_map.find(t) != string_to_axis_map.end()) {
|
||||||
input = InputID(InputType::Axis, (u32)string_to_axis_map.at(t).axis);
|
input = InputID(InputType::Axis, string_to_axis_map.at(t).axis);
|
||||||
} else if (string_to_cbutton_map.find(t) != string_to_cbutton_map.end()) {
|
} else if (string_to_cbutton_map.find(t) != string_to_cbutton_map.end()) {
|
||||||
input = InputID(InputType::Controller, string_to_cbutton_map.at(t));
|
input = InputID(InputType::Controller, string_to_cbutton_map.at(t));
|
||||||
} else {
|
} else {
|
||||||
|
@ -411,7 +411,7 @@ void ParseInputConfig(const std::string game_id = "") {
|
||||||
u32 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_WARNING(Input, "Something went wrong with wheel input parsing!");
|
LOG_WARNING(Input, "Something went wrong with wheel input parsing!");
|
||||||
return (u32)-1;
|
return UINT32_MAX;
|
||||||
}
|
}
|
||||||
if (event.wheel.y > 0) {
|
if (event.wheel.y > 0) {
|
||||||
return SDL_MOUSE_WHEEL_UP;
|
return SDL_MOUSE_WHEEL_UP;
|
||||||
|
@ -422,7 +422,7 @@ u32 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 (u32)-1;
|
return UINT32_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputEvent InputBinding::GetInputEventFromSDLEvent(const SDL_Event& e) {
|
InputEvent InputBinding::GetInputEventFromSDLEvent(const SDL_Event& e) {
|
||||||
|
@ -432,16 +432,19 @@ InputEvent InputBinding::GetInputEventFromSDLEvent(const SDL_Event& e) {
|
||||||
return InputEvent(InputType::KeyboardMouse, e.key.key, e.key.down, 0);
|
return InputEvent(InputType::KeyboardMouse, e.key.key, e.key.down, 0);
|
||||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||||
return InputEvent(InputType::KeyboardMouse, (u32)e.button.button, e.button.down, 0);
|
return InputEvent(InputType::KeyboardMouse, static_cast<u32>(e.button.button),
|
||||||
|
e.button.down, 0);
|
||||||
case SDL_EVENT_MOUSE_WHEEL:
|
case SDL_EVENT_MOUSE_WHEEL:
|
||||||
case SDL_EVENT_MOUSE_WHEEL_OFF:
|
case SDL_EVENT_MOUSE_WHEEL_OFF:
|
||||||
return InputEvent(InputType::KeyboardMouse, GetMouseWheelEvent(e),
|
return InputEvent(InputType::KeyboardMouse, GetMouseWheelEvent(e),
|
||||||
e.type == SDL_EVENT_MOUSE_WHEEL, 0);
|
e.type == SDL_EVENT_MOUSE_WHEEL, 0);
|
||||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||||
return InputEvent(InputType::Controller, (u32)e.gbutton.button, e.gbutton.down, 0);
|
return InputEvent(InputType::Controller, static_cast<u32>(e.gbutton.button),
|
||||||
|
e.gbutton.down, 0);
|
||||||
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||||
return InputEvent(InputType::Axis, (u32)e.gaxis.axis, true, e.gaxis.value / 256);
|
return InputEvent(InputType::Axis, static_cast<u32>(e.gaxis.axis),
|
||||||
|
true, e.gaxis.value / 256);
|
||||||
default:
|
default:
|
||||||
return InputEvent();
|
return InputEvent();
|
||||||
}
|
}
|
||||||
|
@ -570,7 +573,7 @@ void ControllerOutput::FinalizeUpdate() {
|
||||||
bool UpdatePressedKeys(InputEvent event) {
|
bool UpdatePressedKeys(InputEvent event) {
|
||||||
// Skip invalid inputs
|
// Skip invalid inputs
|
||||||
InputID input = event.input;
|
InputID input = event.input;
|
||||||
if (input.sdl_id == (u32)-1) {
|
if (input.sdl_id == UINT32_MAX) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (input.type == InputType::Axis) {
|
if (input.type == InputType::Axis) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ class InputID {
|
||||||
public:
|
public:
|
||||||
InputType type;
|
InputType type;
|
||||||
u32 sdl_id;
|
u32 sdl_id;
|
||||||
InputID(InputType d = InputType::Count, u32 i = (u32)-1) : type(d), sdl_id(i) {}
|
InputID(InputType d = InputType::Count, u32 i = UINT32_MAX) : type(d), sdl_id(i) {}
|
||||||
bool operator==(const InputID& o) const {
|
bool operator==(const InputID& o) const {
|
||||||
return type == o.type && sdl_id == o.sdl_id;
|
return type == o.type && sdl_id == o.sdl_id;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public:
|
||||||
return *this != InputID();
|
return *this != InputID();
|
||||||
}
|
}
|
||||||
std::string ToString() {
|
std::string ToString() {
|
||||||
return fmt::format("({}: {:x})", input_type_names[(u8)type], sdl_id);
|
return fmt::format("({}: {:x})", input_type_names[static_cast<u8>(type)], sdl_id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,6 +124,7 @@ const std::map<std::string, AxisMapping> string_to_axis_map = {
|
||||||
{"axis_right_y", {SDL_GAMEPAD_AXIS_RIGHTY, 127}},
|
{"axis_right_y", {SDL_GAMEPAD_AXIS_RIGHTY, 127}},
|
||||||
};
|
};
|
||||||
const std::map<std::string, u32> string_to_keyboard_key_map = {
|
const std::map<std::string, u32> string_to_keyboard_key_map = {
|
||||||
|
// alphanumeric
|
||||||
{"a", SDLK_A},
|
{"a", SDLK_A},
|
||||||
{"b", SDLK_B},
|
{"b", SDLK_B},
|
||||||
{"c", SDLK_C},
|
{"c", SDLK_C},
|
||||||
|
@ -160,6 +161,73 @@ const std::map<std::string, u32> string_to_keyboard_key_map = {
|
||||||
{"7", SDLK_7},
|
{"7", SDLK_7},
|
||||||
{"8", SDLK_8},
|
{"8", SDLK_8},
|
||||||
{"9", SDLK_9},
|
{"9", SDLK_9},
|
||||||
|
|
||||||
|
// symbols
|
||||||
|
{"`", SDLK_GRAVE},
|
||||||
|
{"~", SDLK_TILDE},
|
||||||
|
{"!", SDLK_EXCLAIM},
|
||||||
|
{"@", SDLK_AT},
|
||||||
|
{"#", SDLK_HASH},
|
||||||
|
{"$", SDLK_DOLLAR},
|
||||||
|
{"%", SDLK_PERCENT},
|
||||||
|
{"^", SDLK_CARET},
|
||||||
|
{"&", SDLK_AMPERSAND},
|
||||||
|
{"*", SDLK_ASTERISK},
|
||||||
|
{"(", SDLK_LEFTPAREN},
|
||||||
|
{")", SDLK_RIGHTPAREN},
|
||||||
|
{"-", SDLK_MINUS},
|
||||||
|
{"_", SDLK_UNDERSCORE},
|
||||||
|
{"=", SDLK_EQUALS},
|
||||||
|
{"+", SDLK_PLUS},
|
||||||
|
{"[", SDLK_LEFTBRACKET},
|
||||||
|
{"]", SDLK_RIGHTBRACKET},
|
||||||
|
{"{", SDLK_LEFTBRACE},
|
||||||
|
{"}", SDLK_RIGHTBRACE},
|
||||||
|
{"\\", SDLK_BACKSLASH},
|
||||||
|
{"|", SDLK_PIPE},
|
||||||
|
{";", SDLK_SEMICOLON},
|
||||||
|
{":", SDLK_COLON},
|
||||||
|
{"'", SDLK_APOSTROPHE},
|
||||||
|
{"\"", SDLK_DBLAPOSTROPHE},
|
||||||
|
{",", SDLK_COMMA},
|
||||||
|
{"<", SDLK_LESS},
|
||||||
|
{".", SDLK_PERIOD},
|
||||||
|
{">", SDLK_GREATER},
|
||||||
|
{"/", SDLK_SLASH},
|
||||||
|
{"?", SDLK_QUESTION},
|
||||||
|
|
||||||
|
// special keys
|
||||||
|
{"escape", SDLK_ESCAPE},
|
||||||
|
{"printscreen", SDLK_PRINTSCREEN},
|
||||||
|
{"scrolllock", SDLK_SCROLLLOCK},
|
||||||
|
{"pausebreak", SDLK_PAUSE},
|
||||||
|
{"backspace", SDLK_BACKSPACE},
|
||||||
|
{"delete", SDLK_DELETE},
|
||||||
|
{"insert", SDLK_INSERT},
|
||||||
|
{"home", SDLK_HOME},
|
||||||
|
{"end", SDLK_END},
|
||||||
|
{"pgup", SDLK_PAGEUP},
|
||||||
|
{"pgdown", SDLK_PAGEDOWN},
|
||||||
|
{"tab", SDLK_TAB},
|
||||||
|
{"capslock", SDLK_CAPSLOCK},
|
||||||
|
{"enter", SDLK_RETURN},
|
||||||
|
{"lshift", SDLK_LSHIFT},
|
||||||
|
{"rshift", SDLK_RSHIFT},
|
||||||
|
{"lctrl", SDLK_LCTRL},
|
||||||
|
{"rctrl", SDLK_RCTRL},
|
||||||
|
{"lalt", SDLK_LALT},
|
||||||
|
{"ralt", SDLK_RALT},
|
||||||
|
{"lmeta", SDLK_LGUI},
|
||||||
|
{"rmeta", SDLK_RGUI},
|
||||||
|
{"lwin", SDLK_LGUI},
|
||||||
|
{"rwin", SDLK_RGUI},
|
||||||
|
{"space", SDLK_SPACE},
|
||||||
|
{"up", SDLK_UP},
|
||||||
|
{"down", SDLK_DOWN},
|
||||||
|
{"left", SDLK_LEFT},
|
||||||
|
{"right", SDLK_RIGHT},
|
||||||
|
|
||||||
|
// keypad
|
||||||
{"kp0", SDLK_KP_0},
|
{"kp0", SDLK_KP_0},
|
||||||
{"kp1", SDLK_KP_1},
|
{"kp1", SDLK_KP_1},
|
||||||
{"kp2", SDLK_KP_2},
|
{"kp2", SDLK_KP_2},
|
||||||
|
@ -170,43 +238,16 @@ const std::map<std::string, u32> string_to_keyboard_key_map = {
|
||||||
{"kp7", SDLK_KP_7},
|
{"kp7", SDLK_KP_7},
|
||||||
{"kp8", SDLK_KP_8},
|
{"kp8", SDLK_KP_8},
|
||||||
{"kp9", SDLK_KP_9},
|
{"kp9", SDLK_KP_9},
|
||||||
{"comma", SDLK_COMMA},
|
{"kp .", SDLK_KP_PERIOD},
|
||||||
{"period", SDLK_PERIOD},
|
{"kp ,", SDLK_KP_COMMA},
|
||||||
{"question", SDLK_QUESTION},
|
{"kp /", SDLK_KP_DIVIDE},
|
||||||
{"semicolon", SDLK_SEMICOLON},
|
{"kp *", SDLK_KP_MULTIPLY},
|
||||||
{"minus", SDLK_MINUS},
|
{"kp -", SDLK_KP_MINUS},
|
||||||
{"underscore", SDLK_UNDERSCORE},
|
{"kp +", SDLK_KP_PLUS},
|
||||||
{"lparenthesis", SDLK_LEFTPAREN},
|
{"kp =", SDLK_KP_EQUALS},
|
||||||
{"rparenthesis", SDLK_RIGHTPAREN},
|
{"kp enter", SDLK_KP_ENTER},
|
||||||
{"lbracket", SDLK_LEFTBRACKET},
|
|
||||||
{"rbracket", SDLK_RIGHTBRACKET},
|
// mouse
|
||||||
{"lbrace", SDLK_LEFTBRACE},
|
|
||||||
{"rbrace", SDLK_RIGHTBRACE},
|
|
||||||
{"backslash", SDLK_BACKSLASH},
|
|
||||||
{"dash", SDLK_SLASH},
|
|
||||||
{"enter", SDLK_RETURN},
|
|
||||||
{"space", SDLK_SPACE},
|
|
||||||
{"tab", SDLK_TAB},
|
|
||||||
{"backspace", SDLK_BACKSPACE},
|
|
||||||
{"escape", SDLK_ESCAPE},
|
|
||||||
{"left", SDLK_LEFT},
|
|
||||||
{"right", SDLK_RIGHT},
|
|
||||||
{"up", SDLK_UP},
|
|
||||||
{"down", SDLK_DOWN},
|
|
||||||
{"lctrl", SDLK_LCTRL},
|
|
||||||
{"rctrl", SDLK_RCTRL},
|
|
||||||
{"lshift", SDLK_LSHIFT},
|
|
||||||
{"rshift", SDLK_RSHIFT},
|
|
||||||
{"lalt", SDLK_LALT},
|
|
||||||
{"ralt", SDLK_RALT},
|
|
||||||
{"lmeta", SDLK_LGUI},
|
|
||||||
{"rmeta", SDLK_RGUI},
|
|
||||||
{"lwin", SDLK_LGUI},
|
|
||||||
{"rwin", SDLK_RGUI},
|
|
||||||
{"home", SDLK_HOME},
|
|
||||||
{"end", SDLK_END},
|
|
||||||
{"pgup", SDLK_PAGEUP},
|
|
||||||
{"pgdown", SDLK_PAGEDOWN},
|
|
||||||
{"leftbutton", SDL_BUTTON_LEFT},
|
{"leftbutton", SDL_BUTTON_LEFT},
|
||||||
{"rightbutton", SDL_BUTTON_RIGHT},
|
{"rightbutton", SDL_BUTTON_RIGHT},
|
||||||
{"middlebutton", SDL_BUTTON_MIDDLE},
|
{"middlebutton", SDL_BUTTON_MIDDLE},
|
||||||
|
@ -216,15 +257,6 @@ const std::map<std::string, u32> string_to_keyboard_key_map = {
|
||||||
{"mousewheeldown", SDL_MOUSE_WHEEL_DOWN},
|
{"mousewheeldown", SDL_MOUSE_WHEEL_DOWN},
|
||||||
{"mousewheelleft", SDL_MOUSE_WHEEL_LEFT},
|
{"mousewheelleft", SDL_MOUSE_WHEEL_LEFT},
|
||||||
{"mousewheelright", SDL_MOUSE_WHEEL_RIGHT},
|
{"mousewheelright", SDL_MOUSE_WHEEL_RIGHT},
|
||||||
{"kpperiod", SDLK_KP_PERIOD},
|
|
||||||
{"kpcomma", SDLK_KP_COMMA},
|
|
||||||
{"kpdivide", SDLK_KP_DIVIDE},
|
|
||||||
{"kpmultiply", SDLK_KP_MULTIPLY},
|
|
||||||
{"kpminus", SDLK_KP_MINUS},
|
|
||||||
{"kpplus", SDLK_KP_PLUS},
|
|
||||||
{"kpenter", SDLK_KP_ENTER},
|
|
||||||
{"kpequals", SDLK_KP_EQUALS},
|
|
||||||
{"capslock", SDLK_CAPSLOCK},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void ParseInputConfig(const std::string game_id);
|
void ParseInputConfig(const std::string game_id);
|
||||||
|
@ -320,6 +352,7 @@ public:
|
||||||
// returns an InputEvent based on the event type (keyboard, mouse buttons/wheel, or controller)
|
// returns an InputEvent based on the event type (keyboard, mouse buttons/wheel, or controller)
|
||||||
static InputEvent GetInputEventFromSDLEvent(const SDL_Event& e);
|
static InputEvent GetInputEventFromSDLEvent(const SDL_Event& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ControllerOutput {
|
class ControllerOutput {
|
||||||
static GameController* controller;
|
static GameController* controller;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue