diff options
| author | 2020-06-24 11:39:30 -0400 | |
|---|---|---|
| committer | 2020-06-24 11:39:30 -0400 | |
| commit | c18dc9c707235d7ba6fe230cb3045f2c13d04e62 (patch) | |
| tree | 1d59dca6a2bb959572d7c12cdff1d3fdcd4abab5 /src/input_common/gcadapter/gc_adapter.cpp | |
| parent | cleanup check access, read, and factory GetNextInput funcs. Use size rather t... (diff) | |
| download | yuzu-c18dc9c707235d7ba6fe230cb3045f2c13d04e62.tar.gz yuzu-c18dc9c707235d7ba6fe230cb3045f2c13d04e62.tar.xz yuzu-c18dc9c707235d7ba6fe230cb3045f2c13d04e62.zip | |
padbutton enum class and struct initiailization
Diffstat (limited to 'src/input_common/gcadapter/gc_adapter.cpp')
| -rw-r--r-- | src/input_common/gcadapter/gc_adapter.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp index 9437d628f..bba9bcc69 100644 --- a/src/input_common/gcadapter/gc_adapter.cpp +++ b/src/input_common/gcadapter/gc_adapter.cpp | |||
| @@ -33,11 +33,13 @@ GCPadStatus Adapter::GetPadStatus(int port, const std::array<u8, 37>& adapter_pa | |||
| 33 | adapter_controllers_status[port] = type; | 33 | adapter_controllers_status[port] = type; |
| 34 | 34 | ||
| 35 | constexpr std::array<PadButton, 8> b1_buttons{ | 35 | constexpr std::array<PadButton, 8> b1_buttons{ |
| 36 | PAD_BUTTON_A, PAD_BUTTON_B, PAD_BUTTON_X, PAD_BUTTON_Y, | 36 | PadButton::PAD_BUTTON_A, PadButton::PAD_BUTTON_B, PadButton::PAD_BUTTON_X, |
| 37 | PAD_BUTTON_LEFT, PAD_BUTTON_RIGHT, PAD_BUTTON_DOWN, PAD_BUTTON_UP}; | 37 | PadButton::PAD_BUTTON_Y, PadButton::PAD_BUTTON_LEFT, PadButton::PAD_BUTTON_RIGHT, |
| 38 | PadButton::PAD_BUTTON_DOWN, PadButton::PAD_BUTTON_UP}; | ||
| 38 | 39 | ||
| 39 | constexpr std::array<PadButton, 4> b2_buttons{PAD_BUTTON_START, PAD_TRIGGER_Z, PAD_TRIGGER_R, | 40 | constexpr std::array<PadButton, 4> b2_buttons{ |
| 40 | PAD_TRIGGER_L}; | 41 | PadButton::PAD_BUTTON_START, PadButton::PAD_TRIGGER_Z, PadButton::PAD_TRIGGER_R, |
| 42 | PadButton::PAD_TRIGGER_L}; | ||
| 41 | 43 | ||
| 42 | if (adapter_controllers_status[port] != ControllerTypes::None) { | 44 | if (adapter_controllers_status[port] != ControllerTypes::None) { |
| 43 | const u8 b1 = adapter_payload[1 + (9 * port) + 1]; | 45 | const u8 b1 = adapter_payload[1 + (9 * port) + 1]; |
| @@ -45,13 +47,13 @@ GCPadStatus Adapter::GetPadStatus(int port, const std::array<u8, 37>& adapter_pa | |||
| 45 | 47 | ||
| 46 | for (int i = 0; i < b1_buttons.size(); i++) { | 48 | for (int i = 0; i < b1_buttons.size(); i++) { |
| 47 | if (b1 & (1 << i)) { | 49 | if (b1 & (1 << i)) { |
| 48 | pad.button |= b1_buttons[i]; | 50 | pad.button |= static_cast<u16>(b1_buttons[i]); |
| 49 | } | 51 | } |
| 50 | } | 52 | } |
| 51 | 53 | ||
| 52 | for (int j = 0; j < b2_buttons.size(); j++) { | 54 | for (int j = 0; j < b2_buttons.size(); j++) { |
| 53 | if (b2 & (1 << j)) { | 55 | if (b2 & (1 << j)) { |
| 54 | pad.button |= b2_buttons[j]; | 56 | pad.button |= static_cast<u16>(b2_buttons[j]); |
| 55 | } | 57 | } |
| 56 | } | 58 | } |
| 57 | 59 | ||
| @@ -70,18 +72,11 @@ GCPadStatus Adapter::GetPadStatus(int port, const std::array<u8, 37>& adapter_pa | |||
| 70 | } | 72 | } |
| 71 | 73 | ||
| 72 | void Adapter::PadToState(const GCPadStatus& pad, GCState& state) { | 74 | void Adapter::PadToState(const GCPadStatus& pad, GCState& state) { |
| 73 | state.buttons.insert_or_assign(PAD_BUTTON_A, pad.button & PAD_BUTTON_A); | 75 | for (auto button : PadButtonArray) { |
| 74 | state.buttons.insert_or_assign(PAD_BUTTON_B, pad.button & PAD_BUTTON_B); | 76 | u16 button_value = static_cast<u16>(button); |
| 75 | state.buttons.insert_or_assign(PAD_BUTTON_X, pad.button & PAD_BUTTON_X); | 77 | state.buttons.insert_or_assign(button_value, pad.button & button_value); |
| 76 | state.buttons.insert_or_assign(PAD_BUTTON_Y, pad.button & PAD_BUTTON_Y); | 78 | } |
| 77 | state.buttons.insert_or_assign(PAD_BUTTON_LEFT, pad.button & PAD_BUTTON_LEFT); | 79 | |
| 78 | state.buttons.insert_or_assign(PAD_BUTTON_RIGHT, pad.button & PAD_BUTTON_RIGHT); | ||
| 79 | state.buttons.insert_or_assign(PAD_BUTTON_DOWN, pad.button & PAD_BUTTON_DOWN); | ||
| 80 | state.buttons.insert_or_assign(PAD_BUTTON_UP, pad.button & PAD_BUTTON_UP); | ||
| 81 | state.buttons.insert_or_assign(PAD_BUTTON_START, pad.button & PAD_BUTTON_START); | ||
| 82 | state.buttons.insert_or_assign(PAD_TRIGGER_Z, pad.button & PAD_TRIGGER_Z); | ||
| 83 | state.buttons.insert_or_assign(PAD_TRIGGER_L, pad.button & PAD_TRIGGER_L); | ||
| 84 | state.buttons.insert_or_assign(PAD_TRIGGER_R, pad.button & PAD_TRIGGER_R); | ||
| 85 | state.axes.insert_or_assign(static_cast<u8>(PadAxes::StickX), pad.stick_x); | 80 | state.axes.insert_or_assign(static_cast<u8>(PadAxes::StickX), pad.stick_x); |
| 86 | state.axes.insert_or_assign(static_cast<u8>(PadAxes::StickY), pad.stick_y); | 81 | state.axes.insert_or_assign(static_cast<u8>(PadAxes::StickY), pad.stick_y); |
| 87 | state.axes.insert_or_assign(static_cast<u8>(PadAxes::SubstickX), pad.substick_x); | 82 | state.axes.insert_or_assign(static_cast<u8>(PadAxes::SubstickX), pad.substick_x); |