diff options
| -rw-r--r-- | src/core/hid/input_interpreter.cpp | 17 | ||||
| -rw-r--r-- | src/core/hid/input_interpreter.h | 52 | ||||
| -rw-r--r-- | src/yuzu/applets/qt_controller.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 1 |
4 files changed, 18 insertions, 54 deletions
diff --git a/src/core/hid/input_interpreter.cpp b/src/core/hid/input_interpreter.cpp index c33d8a11a..7e7c1816f 100644 --- a/src/core/hid/input_interpreter.cpp +++ b/src/core/hid/input_interpreter.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/core.h" | 5 | #include "core/core.h" |
| 6 | #include "core/hid/hid_types.h" | ||
| 6 | #include "core/hid/input_interpreter.h" | 7 | #include "core/hid/input_interpreter.h" |
| 7 | #include "core/hle/service/hid/controllers/npad.h" | 8 | #include "core/hle/service/hid/controllers/npad.h" |
| 8 | #include "core/hle/service/hid/hid.h" | 9 | #include "core/hle/service/hid/hid.h" |
| @@ -38,25 +39,23 @@ void InputInterpreter::ResetButtonStates() { | |||
| 38 | } | 39 | } |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | bool InputInterpreter::IsButtonPressed(HIDButton button) const { | 42 | bool InputInterpreter::IsButtonPressed(Core::HID::NpadButton button) const { |
| 42 | return (button_states[current_index] & (1U << static_cast<u8>(button))) != 0; | 43 | return (button_states[current_index] & static_cast<u32>(button)) != 0; |
| 43 | } | 44 | } |
| 44 | 45 | ||
| 45 | bool InputInterpreter::IsButtonPressedOnce(HIDButton button) const { | 46 | bool InputInterpreter::IsButtonPressedOnce(Core::HID::NpadButton button) const { |
| 46 | const bool current_press = | 47 | const bool current_press = (button_states[current_index] & static_cast<u32>(button)) != 0; |
| 47 | (button_states[current_index] & (1U << static_cast<u8>(button))) != 0; | 48 | const bool previous_press = (button_states[previous_index] & static_cast<u32>(button)) != 0; |
| 48 | const bool previous_press = | ||
| 49 | (button_states[previous_index] & (1U << static_cast<u8>(button))) != 0; | ||
| 50 | 49 | ||
| 51 | return current_press && !previous_press; | 50 | return current_press && !previous_press; |
| 52 | } | 51 | } |
| 53 | 52 | ||
| 54 | bool InputInterpreter::IsButtonHeld(HIDButton button) const { | 53 | bool InputInterpreter::IsButtonHeld(Core::HID::NpadButton button) const { |
| 55 | u32 held_buttons{button_states[0]}; | 54 | u32 held_buttons{button_states[0]}; |
| 56 | 55 | ||
| 57 | for (std::size_t i = 1; i < button_states.size(); ++i) { | 56 | for (std::size_t i = 1; i < button_states.size(); ++i) { |
| 58 | held_buttons &= button_states[i]; | 57 | held_buttons &= button_states[i]; |
| 59 | } | 58 | } |
| 60 | 59 | ||
| 61 | return (held_buttons & (1U << static_cast<u8>(button))) != 0; | 60 | return (held_buttons & static_cast<u32>(button)) != 0; |
| 62 | } | 61 | } |
diff --git a/src/core/hid/input_interpreter.h b/src/core/hid/input_interpreter.h index 9495e3daf..1791cf9b7 100644 --- a/src/core/hid/input_interpreter.h +++ b/src/core/hid/input_interpreter.h | |||
| @@ -12,46 +12,14 @@ namespace Core { | |||
| 12 | class System; | 12 | class System; |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | namespace Core::HID { | ||
| 16 | enum class NpadButton : u64; | ||
| 17 | } | ||
| 18 | |||
| 15 | namespace Service::HID { | 19 | namespace Service::HID { |
| 16 | class Controller_NPad; | 20 | class Controller_NPad; |
| 17 | } | 21 | } |
| 18 | 22 | ||
| 19 | enum class HIDButton : u8 { | ||
| 20 | A, | ||
| 21 | B, | ||
| 22 | X, | ||
| 23 | Y, | ||
| 24 | LStick, | ||
| 25 | RStick, | ||
| 26 | L, | ||
| 27 | R, | ||
| 28 | ZL, | ||
| 29 | ZR, | ||
| 30 | Plus, | ||
| 31 | Minus, | ||
| 32 | |||
| 33 | DLeft, | ||
| 34 | DUp, | ||
| 35 | DRight, | ||
| 36 | DDown, | ||
| 37 | |||
| 38 | LStickLeft, | ||
| 39 | LStickUp, | ||
| 40 | LStickRight, | ||
| 41 | LStickDown, | ||
| 42 | |||
| 43 | RStickLeft, | ||
| 44 | RStickUp, | ||
| 45 | RStickRight, | ||
| 46 | RStickDown, | ||
| 47 | |||
| 48 | LeftSL, | ||
| 49 | LeftSR, | ||
| 50 | |||
| 51 | RightSL, | ||
| 52 | RightSR, | ||
| 53 | }; | ||
| 54 | |||
| 55 | /** | 23 | /** |
| 56 | * The InputInterpreter class interfaces with HID to retrieve button press states. | 24 | * The InputInterpreter class interfaces with HID to retrieve button press states. |
| 57 | * Input is intended to be polled every 50ms so that a button is considered to be | 25 | * Input is intended to be polled every 50ms so that a button is considered to be |
| @@ -76,7 +44,7 @@ public: | |||
| 76 | * | 44 | * |
| 77 | * @returns True when the button is pressed. | 45 | * @returns True when the button is pressed. |
| 78 | */ | 46 | */ |
| 79 | [[nodiscard]] bool IsButtonPressed(HIDButton button) const; | 47 | [[nodiscard]] bool IsButtonPressed(Core::HID::NpadButton button) const; |
| 80 | 48 | ||
| 81 | /** | 49 | /** |
| 82 | * Checks whether any of the buttons in the parameter list is pressed. | 50 | * Checks whether any of the buttons in the parameter list is pressed. |
| @@ -85,7 +53,7 @@ public: | |||
| 85 | * | 53 | * |
| 86 | * @returns True when at least one of the buttons is pressed. | 54 | * @returns True when at least one of the buttons is pressed. |
| 87 | */ | 55 | */ |
| 88 | template <HIDButton... T> | 56 | template <Core::HID::NpadButton... T> |
| 89 | [[nodiscard]] bool IsAnyButtonPressed() { | 57 | [[nodiscard]] bool IsAnyButtonPressed() { |
| 90 | return (IsButtonPressed(T) || ...); | 58 | return (IsButtonPressed(T) || ...); |
| 91 | } | 59 | } |
| @@ -98,7 +66,7 @@ public: | |||
| 98 | * | 66 | * |
| 99 | * @returns True when the button is pressed once. | 67 | * @returns True when the button is pressed once. |
| 100 | */ | 68 | */ |
| 101 | [[nodiscard]] bool IsButtonPressedOnce(HIDButton button) const; | 69 | [[nodiscard]] bool IsButtonPressedOnce(Core::HID::NpadButton button) const; |
| 102 | 70 | ||
| 103 | /** | 71 | /** |
| 104 | * Checks whether any of the buttons in the parameter list is pressed once. | 72 | * Checks whether any of the buttons in the parameter list is pressed once. |
| @@ -107,7 +75,7 @@ public: | |||
| 107 | * | 75 | * |
| 108 | * @returns True when at least one of the buttons is pressed once. | 76 | * @returns True when at least one of the buttons is pressed once. |
| 109 | */ | 77 | */ |
| 110 | template <HIDButton... T> | 78 | template <Core::HID::NpadButton... T> |
| 111 | [[nodiscard]] bool IsAnyButtonPressedOnce() const { | 79 | [[nodiscard]] bool IsAnyButtonPressedOnce() const { |
| 112 | return (IsButtonPressedOnce(T) || ...); | 80 | return (IsButtonPressedOnce(T) || ...); |
| 113 | } | 81 | } |
| @@ -119,7 +87,7 @@ public: | |||
| 119 | * | 87 | * |
| 120 | * @returns True when the button is held down. | 88 | * @returns True when the button is held down. |
| 121 | */ | 89 | */ |
| 122 | [[nodiscard]] bool IsButtonHeld(HIDButton button) const; | 90 | [[nodiscard]] bool IsButtonHeld(Core::HID::NpadButton button) const; |
| 123 | 91 | ||
| 124 | /** | 92 | /** |
| 125 | * Checks whether any of the buttons in the parameter list is held down. | 93 | * Checks whether any of the buttons in the parameter list is held down. |
| @@ -128,7 +96,7 @@ public: | |||
| 128 | * | 96 | * |
| 129 | * @returns True when at least one of the buttons is held down. | 97 | * @returns True when at least one of the buttons is held down. |
| 130 | */ | 98 | */ |
| 131 | template <HIDButton... T> | 99 | template <Core::HID::NpadButton... T> |
| 132 | [[nodiscard]] bool IsAnyButtonHeld() const { | 100 | [[nodiscard]] bool IsAnyButtonHeld() const { |
| 133 | return (IsButtonHeld(T) || ...); | 101 | return (IsButtonHeld(T) || ...); |
| 134 | } | 102 | } |
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp index 4dd577a18..2cd5ed718 100644 --- a/src/yuzu/applets/qt_controller.cpp +++ b/src/yuzu/applets/qt_controller.cpp | |||
| @@ -9,8 +9,6 @@ | |||
| 9 | #include "common/param_package.h" | 9 | #include "common/param_package.h" |
| 10 | #include "common/string_util.h" | 10 | #include "common/string_util.h" |
| 11 | #include "core/core.h" | 11 | #include "core/core.h" |
| 12 | #include "core/hid/emulated_controller.h | ||
| 13 | #include "core/hid/hid_types.h | ||
| 14 | #include "core/hle/lock.h" | 12 | #include "core/hle/lock.h" |
| 15 | #include "core/hle/service/hid/controllers/npad.h" | 13 | #include "core/hle/service/hid/controllers/npad.h" |
| 16 | #include "core/hle/service/hid/hid.h" | 14 | #include "core/hle/service/hid/hid.h" |
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 33241ea98..103a12b12 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -24,7 +24,6 @@ | |||
| 24 | #include "common/settings.h" | 24 | #include "common/settings.h" |
| 25 | #include "core/hle/service/acc/profile_manager.h" | 25 | #include "core/hle/service/acc/profile_manager.h" |
| 26 | #include "input_common/main.h" | 26 | #include "input_common/main.h" |
| 27 | #include "input_common/udp/client.h" | ||
| 28 | #include "yuzu_cmd/config.h" | 27 | #include "yuzu_cmd/config.h" |
| 29 | #include "yuzu_cmd/default_ini.h" | 28 | #include "yuzu_cmd/default_ini.h" |
| 30 | 29 | ||