diff options
Diffstat (limited to 'src/input_common/drivers')
| -rw-r--r-- | src/input_common/drivers/mouse.cpp | 35 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.h | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 10 |
3 files changed, 43 insertions, 4 deletions
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index aa69216c8..d8ae7f0c1 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -16,6 +16,7 @@ constexpr int mouse_axis_x = 0; | |||
| 16 | constexpr int mouse_axis_y = 1; | 16 | constexpr int mouse_axis_y = 1; |
| 17 | constexpr int wheel_axis_x = 2; | 17 | constexpr int wheel_axis_x = 2; |
| 18 | constexpr int wheel_axis_y = 3; | 18 | constexpr int wheel_axis_y = 3; |
| 19 | constexpr int motion_wheel_y = 4; | ||
| 19 | constexpr int touch_axis_x = 10; | 20 | constexpr int touch_axis_x = 10; |
| 20 | constexpr int touch_axis_y = 11; | 21 | constexpr int touch_axis_y = 11; |
| 21 | constexpr PadIdentifier identifier = { | 22 | constexpr PadIdentifier identifier = { |
| @@ -30,8 +31,9 @@ Mouse::Mouse(std::string input_engine_) : InputEngine(std::move(input_engine_)) | |||
| 30 | PreSetAxis(identifier, mouse_axis_y); | 31 | PreSetAxis(identifier, mouse_axis_y); |
| 31 | PreSetAxis(identifier, wheel_axis_x); | 32 | PreSetAxis(identifier, wheel_axis_x); |
| 32 | PreSetAxis(identifier, wheel_axis_y); | 33 | PreSetAxis(identifier, wheel_axis_y); |
| 34 | PreSetAxis(identifier, motion_wheel_y); | ||
| 33 | PreSetAxis(identifier, touch_axis_x); | 35 | PreSetAxis(identifier, touch_axis_x); |
| 34 | PreSetAxis(identifier, touch_axis_x); | 36 | PreSetAxis(identifier, touch_axis_y); |
| 35 | update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); }); | 37 | update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); }); |
| 36 | } | 38 | } |
| 37 | 39 | ||
| @@ -48,6 +50,8 @@ void Mouse::UpdateThread(std::stop_token stop_token) { | |||
| 48 | SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity); | 50 | SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity); |
| 49 | } | 51 | } |
| 50 | 52 | ||
| 53 | SetAxis(identifier, motion_wheel_y, 0.0f); | ||
| 54 | |||
| 51 | if (mouse_panning_timout++ > 20) { | 55 | if (mouse_panning_timout++ > 20) { |
| 52 | StopPanning(); | 56 | StopPanning(); |
| 53 | } | 57 | } |
| @@ -136,6 +140,7 @@ void Mouse::MouseWheelChange(int x, int y) { | |||
| 136 | wheel_position.y += y; | 140 | wheel_position.y += y; |
| 137 | SetAxis(identifier, wheel_axis_x, static_cast<f32>(wheel_position.x)); | 141 | SetAxis(identifier, wheel_axis_x, static_cast<f32>(wheel_position.x)); |
| 138 | SetAxis(identifier, wheel_axis_y, static_cast<f32>(wheel_position.y)); | 142 | SetAxis(identifier, wheel_axis_y, static_cast<f32>(wheel_position.y)); |
| 143 | SetAxis(identifier, motion_wheel_y, static_cast<f32>(y) / 100.0f); | ||
| 139 | } | 144 | } |
| 140 | 145 | ||
| 141 | void Mouse::ReleaseAllButtons() { | 146 | void Mouse::ReleaseAllButtons() { |
| @@ -171,13 +176,39 @@ AnalogMapping Mouse::GetAnalogMappingForDevice( | |||
| 171 | return mapping; | 176 | return mapping; |
| 172 | } | 177 | } |
| 173 | 178 | ||
| 179 | Common::Input::ButtonNames Mouse::GetUIButtonName(const Common::ParamPackage& params) const { | ||
| 180 | const auto button = static_cast<MouseButton>(params.Get("button", 0)); | ||
| 181 | switch (button) { | ||
| 182 | case MouseButton::Left: | ||
| 183 | return Common::Input::ButtonNames::ButtonLeft; | ||
| 184 | case MouseButton::Right: | ||
| 185 | return Common::Input::ButtonNames::ButtonRight; | ||
| 186 | case MouseButton::Wheel: | ||
| 187 | return Common::Input::ButtonNames::ButtonMouseWheel; | ||
| 188 | case MouseButton::Backward: | ||
| 189 | return Common::Input::ButtonNames::ButtonBackward; | ||
| 190 | case MouseButton::Forward: | ||
| 191 | return Common::Input::ButtonNames::ButtonForward; | ||
| 192 | case MouseButton::Task: | ||
| 193 | return Common::Input::ButtonNames::ButtonTask; | ||
| 194 | case MouseButton::Extra: | ||
| 195 | return Common::Input::ButtonNames::ButtonExtra; | ||
| 196 | case MouseButton::Undefined: | ||
| 197 | default: | ||
| 198 | return Common::Input::ButtonNames::Undefined; | ||
| 199 | } | ||
| 200 | } | ||
| 201 | |||
| 174 | Common::Input::ButtonNames Mouse::GetUIName(const Common::ParamPackage& params) const { | 202 | Common::Input::ButtonNames Mouse::GetUIName(const Common::ParamPackage& params) const { |
| 175 | if (params.Has("button")) { | 203 | if (params.Has("button")) { |
| 176 | return Common::Input::ButtonNames::Value; | 204 | return GetUIButtonName(params); |
| 177 | } | 205 | } |
| 178 | if (params.Has("axis")) { | 206 | if (params.Has("axis")) { |
| 179 | return Common::Input::ButtonNames::Value; | 207 | return Common::Input::ButtonNames::Value; |
| 180 | } | 208 | } |
| 209 | if (params.Has("axis_x") && params.Has("axis_y") && params.Has("axis_z")) { | ||
| 210 | return Common::Input::ButtonNames::Engine; | ||
| 211 | } | ||
| 181 | 212 | ||
| 182 | return Common::Input::ButtonNames::Invalid; | 213 | return Common::Input::ButtonNames::Invalid; |
| 183 | } | 214 | } |
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index 040446178..c5833b8ed 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h | |||
| @@ -69,6 +69,8 @@ private: | |||
| 69 | void UpdateThread(std::stop_token stop_token); | 69 | void UpdateThread(std::stop_token stop_token); |
| 70 | void StopPanning(); | 70 | void StopPanning(); |
| 71 | 71 | ||
| 72 | Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; | ||
| 73 | |||
| 72 | Common::Vec2<int> mouse_origin; | 74 | Common::Vec2<int> mouse_origin; |
| 73 | Common::Vec2<int> last_mouse_position; | 75 | Common::Vec2<int> last_mouse_position; |
| 74 | Common::Vec2<float> last_mouse_change; | 76 | Common::Vec2<float> last_mouse_change; |
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 757117f2b..ed6281772 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp | |||
| @@ -198,9 +198,15 @@ public: | |||
| 198 | if (sdl_controller) { | 198 | if (sdl_controller) { |
| 199 | switch (SDL_GameControllerGetType(sdl_controller.get())) { | 199 | switch (SDL_GameControllerGetType(sdl_controller.get())) { |
| 200 | case SDL_CONTROLLER_TYPE_XBOX360: | 200 | case SDL_CONTROLLER_TYPE_XBOX360: |
| 201 | return "XBox 360 Controller"; | 201 | return "Xbox 360 Controller"; |
| 202 | case SDL_CONTROLLER_TYPE_XBOXONE: | 202 | case SDL_CONTROLLER_TYPE_XBOXONE: |
| 203 | return "XBox One Controller"; | 203 | return "Xbox One Controller"; |
| 204 | case SDL_CONTROLLER_TYPE_PS3: | ||
| 205 | return "DualShock 3 Controller"; | ||
| 206 | case SDL_CONTROLLER_TYPE_PS4: | ||
| 207 | return "DualShock 4 Controller"; | ||
| 208 | case SDL_CONTROLLER_TYPE_PS5: | ||
| 209 | return "DualSense Controller"; | ||
| 204 | default: | 210 | default: |
| 205 | break; | 211 | break; |
| 206 | } | 212 | } |