diff options
Diffstat (limited to 'src/core/hid/input_interpreter.cpp')
| -rw-r--r-- | src/core/hid/input_interpreter.cpp | 17 |
1 files changed, 8 insertions, 9 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 | } |