diff options
Diffstat (limited to 'src/core/hid/emulated_devices.h')
| -rw-r--r-- | src/core/hid/emulated_devices.h | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/src/core/hid/emulated_devices.h b/src/core/hid/emulated_devices.h index d49d6d78a..49edfd255 100644 --- a/src/core/hid/emulated_devices.h +++ b/src/core/hid/emulated_devices.h | |||
| @@ -17,13 +17,15 @@ | |||
| 17 | #include "core/hid/hid_types.h" | 17 | #include "core/hid/hid_types.h" |
| 18 | 18 | ||
| 19 | namespace Core::HID { | 19 | namespace Core::HID { |
| 20 | |||
| 21 | using KeyboardDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, | 20 | using KeyboardDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, |
| 22 | Settings::NativeKeyboard::NumKeyboardKeys>; | 21 | Settings::NativeKeyboard::NumKeyboardKeys>; |
| 23 | using KeyboardModifierDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, | 22 | using KeyboardModifierDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, |
| 24 | Settings::NativeKeyboard::NumKeyboardMods>; | 23 | Settings::NativeKeyboard::NumKeyboardMods>; |
| 25 | using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, | 24 | using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, |
| 26 | Settings::NativeMouseButton::NumMouseButtons>; | 25 | Settings::NativeMouseButton::NumMouseButtons>; |
| 26 | using MouseAnalogDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, | ||
| 27 | Settings::NativeMouseWheel::NumMouseWheels>; | ||
| 28 | using MouseStickDevice = std::unique_ptr<Common::Input::InputDevice>; | ||
| 27 | 29 | ||
| 28 | using MouseButtonParams = | 30 | using MouseButtonParams = |
| 29 | std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons>; | 31 | std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons>; |
| @@ -34,12 +36,13 @@ using KeyboardModifierValues = | |||
| 34 | std::array<Common::Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardMods>; | 36 | std::array<Common::Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardMods>; |
| 35 | using MouseButtonValues = | 37 | using MouseButtonValues = |
| 36 | std::array<Common::Input::ButtonStatus, Settings::NativeMouseButton::NumMouseButtons>; | 38 | std::array<Common::Input::ButtonStatus, Settings::NativeMouseButton::NumMouseButtons>; |
| 39 | using MouseAnalogValues = | ||
| 40 | std::array<Common::Input::AnalogStatus, Settings::NativeMouseWheel::NumMouseWheels>; | ||
| 41 | using MouseStickValue = Common::Input::StickStatus; | ||
| 37 | 42 | ||
| 38 | struct MousePosition { | 43 | struct MousePosition { |
| 39 | s32 x; | 44 | f32 x; |
| 40 | s32 y; | 45 | f32 y; |
| 41 | s32 delta_wheel_x; | ||
| 42 | s32 delta_wheel_y; | ||
| 43 | }; | 46 | }; |
| 44 | 47 | ||
| 45 | struct DeviceStatus { | 48 | struct DeviceStatus { |
| @@ -47,12 +50,15 @@ struct DeviceStatus { | |||
| 47 | KeyboardValues keyboard_values{}; | 50 | KeyboardValues keyboard_values{}; |
| 48 | KeyboardModifierValues keyboard_moddifier_values{}; | 51 | KeyboardModifierValues keyboard_moddifier_values{}; |
| 49 | MouseButtonValues mouse_button_values{}; | 52 | MouseButtonValues mouse_button_values{}; |
| 53 | MouseAnalogValues mouse_analog_values{}; | ||
| 54 | MouseStickValue mouse_stick_value{}; | ||
| 50 | 55 | ||
| 51 | // Data for HID serices | 56 | // Data for HID serices |
| 52 | KeyboardKey keyboard_state{}; | 57 | KeyboardKey keyboard_state{}; |
| 53 | KeyboardModifier keyboard_moddifier_state{}; | 58 | KeyboardModifier keyboard_moddifier_state{}; |
| 54 | MouseButton mouse_button_state{}; | 59 | MouseButton mouse_button_state{}; |
| 55 | MousePosition mouse_position_state{}; | 60 | MousePosition mouse_position_state{}; |
| 61 | AnalogStickState mouse_wheel_state{}; | ||
| 56 | }; | 62 | }; |
| 57 | 63 | ||
| 58 | enum class DeviceTriggerType { | 64 | enum class DeviceTriggerType { |
| @@ -102,15 +108,6 @@ public: | |||
| 102 | /// Reverts any mapped changes made that weren't saved | 108 | /// Reverts any mapped changes made that weren't saved |
| 103 | void RestoreConfig(); | 109 | void RestoreConfig(); |
| 104 | 110 | ||
| 105 | /// Returns the current mapped mouse button device | ||
| 106 | Common::ParamPackage GetMouseButtonParam(std::size_t index) const; | ||
| 107 | |||
| 108 | /** | ||
| 109 | * Updates the current mapped mouse button device | ||
| 110 | * @param ParamPackage with controller data to be mapped | ||
| 111 | */ | ||
| 112 | void SetMouseButtonParam(std::size_t index, Common::ParamPackage param); | ||
| 113 | |||
| 114 | /// Returns the latest status of button input from the keyboard with parameters | 111 | /// Returns the latest status of button input from the keyboard with parameters |
| 115 | KeyboardValues GetKeyboardValues() const; | 112 | KeyboardValues GetKeyboardValues() const; |
| 116 | 113 | ||
| @@ -132,9 +129,12 @@ public: | |||
| 132 | /// Returns the latest mouse coordinates | 129 | /// Returns the latest mouse coordinates |
| 133 | MousePosition GetMousePosition() const; | 130 | MousePosition GetMousePosition() const; |
| 134 | 131 | ||
| 132 | /// Returns the latest mouse wheel change | ||
| 133 | AnalogStickState GetMouseDeltaWheel() const; | ||
| 134 | |||
| 135 | /** | 135 | /** |
| 136 | * Adds a callback to the list of events | 136 | * Adds a callback to the list of events |
| 137 | * @param ConsoleUpdateCallback that will be triggered | 137 | * @param InterfaceUpdateCallback that will be triggered |
| 138 | * @return an unique key corresponding to the callback index in the list | 138 | * @return an unique key corresponding to the callback index in the list |
| 139 | */ | 139 | */ |
| 140 | int SetCallback(InterfaceUpdateCallback update_callback); | 140 | int SetCallback(InterfaceUpdateCallback update_callback); |
| @@ -150,27 +150,41 @@ private: | |||
| 150 | void UpdateKey(std::size_t key_index, bool status); | 150 | void UpdateKey(std::size_t key_index, bool status); |
| 151 | 151 | ||
| 152 | /** | 152 | /** |
| 153 | * Updates the touch status of the console | 153 | * Updates the touch status of the keyboard device |
| 154 | * @param callback: A CallbackStatus containing the key status | 154 | * @param callback: A CallbackStatus containing the key status |
| 155 | * @param index: key ID to be updated | 155 | * @param index: key ID to be updated |
| 156 | */ | 156 | */ |
| 157 | void SetKeyboardButton(Common::Input::CallbackStatus callback, std::size_t index); | 157 | void SetKeyboardButton(Common::Input::CallbackStatus callback, std::size_t index); |
| 158 | 158 | ||
| 159 | /** | 159 | /** |
| 160 | * Updates the touch status of the console | 160 | * Updates the keyboard status of the keyboard device |
| 161 | * @param callback: A CallbackStatus containing the modifier key status | 161 | * @param callback: A CallbackStatus containing the modifier key status |
| 162 | * @param index: modifier key ID to be updated | 162 | * @param index: modifier key ID to be updated |
| 163 | */ | 163 | */ |
| 164 | void SetKeyboardModifier(Common::Input::CallbackStatus callback, std::size_t index); | 164 | void SetKeyboardModifier(Common::Input::CallbackStatus callback, std::size_t index); |
| 165 | 165 | ||
| 166 | /** | 166 | /** |
| 167 | * Updates the touch status of the console | 167 | * Updates the mouse button status of the mouse device |
| 168 | * @param callback: A CallbackStatus containing the button status | 168 | * @param callback: A CallbackStatus containing the button status |
| 169 | * @param index: Button ID of the to be updated | 169 | * @param index: Button ID to be updated |
| 170 | */ | 170 | */ |
| 171 | void SetMouseButton(Common::Input::CallbackStatus callback, std::size_t index); | 171 | void SetMouseButton(Common::Input::CallbackStatus callback, std::size_t index); |
| 172 | 172 | ||
| 173 | /** | 173 | /** |
| 174 | * Updates the mouse wheel status of the mouse device | ||
| 175 | * @param callback: A CallbackStatus containing the wheel status | ||
| 176 | * @param index: wheel ID to be updated | ||
| 177 | */ | ||
| 178 | void SetMouseAnalog(Common::Input::CallbackStatus callback, std::size_t index); | ||
| 179 | |||
| 180 | /** | ||
| 181 | * Updates the mouse position status of the mouse device | ||
| 182 | * @param callback: A CallbackStatus containing the position status | ||
| 183 | * @param index: stick ID to be updated | ||
| 184 | */ | ||
| 185 | void SetMouseStick(Common::Input::CallbackStatus callback); | ||
| 186 | |||
| 187 | /** | ||
| 174 | * Triggers a callback that something has changed on the device status | 188 | * Triggers a callback that something has changed on the device status |
| 175 | * @param Input type of the event to trigger | 189 | * @param Input type of the event to trigger |
| 176 | */ | 190 | */ |
| @@ -178,11 +192,11 @@ private: | |||
| 178 | 192 | ||
| 179 | bool is_configuring{false}; | 193 | bool is_configuring{false}; |
| 180 | 194 | ||
| 181 | MouseButtonParams mouse_button_params; | ||
| 182 | |||
| 183 | KeyboardDevices keyboard_devices; | 195 | KeyboardDevices keyboard_devices; |
| 184 | KeyboardModifierDevices keyboard_modifier_devices; | 196 | KeyboardModifierDevices keyboard_modifier_devices; |
| 185 | MouseButtonDevices mouse_button_devices; | 197 | MouseButtonDevices mouse_button_devices; |
| 198 | MouseAnalogDevices mouse_analog_devices; | ||
| 199 | MouseStickDevice mouse_stick_device; | ||
| 186 | 200 | ||
| 187 | mutable std::mutex mutex; | 201 | mutable std::mutex mutex; |
| 188 | std::unordered_map<int, InterfaceUpdateCallback> callback_list; | 202 | std::unordered_map<int, InterfaceUpdateCallback> callback_list; |