summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar german772021-11-14 14:09:29 -0600
committerGravatar Narr the Reg2021-11-24 20:30:28 -0600
commit654d76e79e84a3384fa503fac9003a5d0a32f28b (patch)
tree7a0d436a55aa73401d7b77bae4870c10ceca16cd /src/core
parentinput_common: Allow keyboard to be backwards compatible (diff)
downloadyuzu-654d76e79e84a3384fa503fac9003a5d0a32f28b.tar.gz
yuzu-654d76e79e84a3384fa503fac9003a5d0a32f28b.tar.xz
yuzu-654d76e79e84a3384fa503fac9003a5d0a32f28b.zip
core/hid: Fully implement native mouse
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hid/emulated_console.cpp11
-rw-r--r--src/core/hid/emulated_devices.cpp124
-rw-r--r--src/core/hid/emulated_devices.h56
-rw-r--r--src/core/hid/input_converter.cpp21
-rw-r--r--src/core/hid/input_converter.h9
-rw-r--r--src/core/hle/service/hid/controllers/mouse.cpp9
6 files changed, 170 insertions, 60 deletions
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp
index 374dd5d41..b224932dc 100644
--- a/src/core/hid/emulated_console.cpp
+++ b/src/core/hid/emulated_console.cpp
@@ -24,7 +24,10 @@ void EmulatedConsole::SetTouchParams() {
24 std::size_t index = 0; 24 std::size_t index = 0;
25 25
26 // Hardcode mouse, touchscreen and cemuhook parameters 26 // Hardcode mouse, touchscreen and cemuhook parameters
27 touch_params[index++] = Common::ParamPackage{"engine:mouse,axis_x:10,axis_y:11,button:0"}; 27 if (!Settings::values.mouse_enabled) {
28 // We can't use mouse as touch if native mouse is enabled
29 touch_params[index++] = Common::ParamPackage{"engine:mouse,axis_x:10,axis_y:11,button:0"};
30 }
28 touch_params[index++] = Common::ParamPackage{"engine:touch,axis_x:0,axis_y:1,button:0"}; 31 touch_params[index++] = Common::ParamPackage{"engine:touch,axis_x:0,axis_y:1,button:0"};
29 touch_params[index++] = Common::ParamPackage{"engine:touch,axis_x:2,axis_y:3,button:1"}; 32 touch_params[index++] = Common::ParamPackage{"engine:touch,axis_x:2,axis_y:3,button:1"};
30 touch_params[index++] = Common::ParamPackage{"engine:cemuhookudp,axis_x:0,axis_y:1,button:0"}; 33 touch_params[index++] = Common::ParamPackage{"engine:cemuhookudp,axis_x:0,axis_y:1,button:0"};
@@ -36,6 +39,9 @@ void EmulatedConsole::SetTouchParams() {
36 39
37 // Map the rest of the fingers from touch from button configuration 40 // Map the rest of the fingers from touch from button configuration
38 for (const auto& config_entry : touch_buttons) { 41 for (const auto& config_entry : touch_buttons) {
42 if (index >= touch_params.size()) {
43 continue;
44 }
39 Common::ParamPackage params{config_entry}; 45 Common::ParamPackage params{config_entry};
40 Common::ParamPackage touch_button_params; 46 Common::ParamPackage touch_button_params;
41 const int x = params.Get("x", 0); 47 const int x = params.Get("x", 0);
@@ -49,9 +55,6 @@ void EmulatedConsole::SetTouchParams() {
49 touch_button_params.Set("touch_id", static_cast<int>(index)); 55 touch_button_params.Set("touch_id", static_cast<int>(index));
50 touch_params[index] = touch_button_params; 56 touch_params[index] = touch_button_params;
51 index++; 57 index++;
52 if (index >= touch_params.size()) {
53 return;
54 }
55 } 58 }
56} 59}
57 60
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp
index 45e0bd80d..70a494097 100644
--- a/src/core/hid/emulated_devices.cpp
+++ b/src/core/hid/emulated_devices.cpp
@@ -15,21 +15,34 @@ EmulatedDevices::EmulatedDevices() = default;
15EmulatedDevices::~EmulatedDevices() = default; 15EmulatedDevices::~EmulatedDevices() = default;
16 16
17void EmulatedDevices::ReloadFromSettings() { 17void EmulatedDevices::ReloadFromSettings() {
18 const auto& mouse = Settings::values.mouse_buttons;
19
20 for (std::size_t index = 0; index < mouse.size(); ++index) {
21 mouse_button_params[index] = Common::ParamPackage(mouse[index]);
22 }
23 ReloadInput(); 18 ReloadInput();
24} 19}
25 20
26void EmulatedDevices::ReloadInput() { 21void EmulatedDevices::ReloadInput() {
27 std::transform(mouse_button_params.begin() + Settings::NativeMouseButton::MOUSE_HID_BEGIN, 22 // If you load any device here add the equivalent to the UnloadInput() function
28 mouse_button_params.begin() + Settings::NativeMouseButton::MOUSE_HID_END,
29 mouse_button_devices.begin(),
30 Common::Input::CreateDevice<Common::Input::InputDevice>);
31
32 std::size_t key_index = 0; 23 std::size_t key_index = 0;
24 for (auto& mouse_device : mouse_button_devices) {
25 Common::ParamPackage mouse_params;
26 mouse_params.Set("engine", "mouse");
27 mouse_params.Set("button", static_cast<int>(key_index));
28 mouse_device = Common::Input::CreateDevice<Common::Input::InputDevice>(mouse_params);
29 key_index++;
30 }
31
32 mouse_stick_device = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>(
33 "engine:mouse,axis_x:0,axis_y:1");
34
35 // First two axis are reserved for mouse position
36 key_index = 2;
37 for (auto& mouse_device : mouse_analog_devices) {
38 Common::ParamPackage mouse_params;
39 mouse_params.Set("engine", "mouse");
40 mouse_params.Set("axis", static_cast<int>(key_index));
41 mouse_device = Common::Input::CreateDevice<Common::Input::InputDevice>(mouse_params);
42 key_index++;
43 }
44
45 key_index = 0;
33 for (auto& keyboard_device : keyboard_devices) { 46 for (auto& keyboard_device : keyboard_devices) {
34 // Keyboard keys are only mapped on port 1, pad 0 47 // Keyboard keys are only mapped on port 1, pad 0
35 Common::ParamPackage keyboard_params; 48 Common::ParamPackage keyboard_params;
@@ -64,6 +77,23 @@ void EmulatedDevices::ReloadInput() {
64 mouse_button_devices[index]->SetCallback(button_callback); 77 mouse_button_devices[index]->SetCallback(button_callback);
65 } 78 }
66 79
80 for (std::size_t index = 0; index < mouse_analog_devices.size(); ++index) {
81 if (!mouse_analog_devices[index]) {
82 continue;
83 }
84 Common::Input::InputCallback button_callback{
85 [this, index](Common::Input::CallbackStatus callback) {
86 SetMouseAnalog(callback, index);
87 }};
88 mouse_analog_devices[index]->SetCallback(button_callback);
89 }
90
91 if (mouse_stick_device) {
92 Common::Input::InputCallback button_callback{
93 [this](Common::Input::CallbackStatus callback) { SetMouseStick(callback); }};
94 mouse_stick_device->SetCallback(button_callback);
95 }
96
67 for (std::size_t index = 0; index < keyboard_devices.size(); ++index) { 97 for (std::size_t index = 0; index < keyboard_devices.size(); ++index) {
68 if (!keyboard_devices[index]) { 98 if (!keyboard_devices[index]) {
69 continue; 99 continue;
@@ -91,6 +121,10 @@ void EmulatedDevices::UnloadInput() {
91 for (auto& button : mouse_button_devices) { 121 for (auto& button : mouse_button_devices) {
92 button.reset(); 122 button.reset();
93 } 123 }
124 for (auto& analog : mouse_analog_devices) {
125 analog.reset();
126 }
127 mouse_stick_device.reset();
94 for (auto& button : keyboard_devices) { 128 for (auto& button : keyboard_devices) {
95 button.reset(); 129 button.reset();
96 } 130 }
@@ -116,12 +150,6 @@ void EmulatedDevices::SaveCurrentConfig() {
116 if (!is_configuring) { 150 if (!is_configuring) {
117 return; 151 return;
118 } 152 }
119
120 auto& mouse = Settings::values.mouse_buttons;
121
122 for (std::size_t index = 0; index < mouse.size(); ++index) {
123 mouse[index] = mouse_button_params[index].Serialize();
124 }
125} 153}
126 154
127void EmulatedDevices::RestoreConfig() { 155void EmulatedDevices::RestoreConfig() {
@@ -131,21 +159,6 @@ void EmulatedDevices::RestoreConfig() {
131 ReloadFromSettings(); 159 ReloadFromSettings();
132} 160}
133 161
134Common::ParamPackage EmulatedDevices::GetMouseButtonParam(std::size_t index) const {
135 if (index >= mouse_button_params.size()) {
136 return {};
137 }
138 return mouse_button_params[index];
139}
140
141void EmulatedDevices::SetMouseButtonParam(std::size_t index, Common::ParamPackage param) {
142 if (index >= mouse_button_params.size()) {
143 return;
144 }
145 mouse_button_params[index] = param;
146 ReloadInput();
147}
148
149void EmulatedDevices::SetKeyboardButton(Common::Input::CallbackStatus callback, std::size_t index) { 162void EmulatedDevices::SetKeyboardButton(Common::Input::CallbackStatus callback, std::size_t index) {
150 if (index >= device_status.keyboard_values.size()) { 163 if (index >= device_status.keyboard_values.size()) {
151 return; 164 return;
@@ -334,6 +347,51 @@ void EmulatedDevices::SetMouseButton(Common::Input::CallbackStatus callback, std
334 TriggerOnChange(DeviceTriggerType::Mouse); 347 TriggerOnChange(DeviceTriggerType::Mouse);
335} 348}
336 349
350void EmulatedDevices::SetMouseAnalog(Common::Input::CallbackStatus callback, std::size_t index) {
351 if (index >= device_status.mouse_analog_values.size()) {
352 return;
353 }
354 std::lock_guard lock{mutex};
355 const auto analog_value = TransformToAnalog(callback);
356
357 device_status.mouse_analog_values[index] = analog_value;
358
359 if (is_configuring) {
360 device_status.mouse_position_state = {};
361 TriggerOnChange(DeviceTriggerType::Mouse);
362 return;
363 }
364
365 switch (index) {
366 case Settings::NativeMouseWheel::X:
367 device_status.mouse_wheel_state.x = static_cast<s32>(analog_value.value);
368 break;
369 case Settings::NativeMouseWheel::Y:
370 device_status.mouse_wheel_state.y = static_cast<s32>(analog_value.value);
371 break;
372 }
373
374 TriggerOnChange(DeviceTriggerType::Mouse);
375}
376
377void EmulatedDevices::SetMouseStick(Common::Input::CallbackStatus callback) {
378 std::lock_guard lock{mutex};
379 const auto stick_value = TransformToStick(callback);
380
381 device_status.mouse_stick_value = stick_value;
382
383 if (is_configuring) {
384 device_status.mouse_position_state = {};
385 TriggerOnChange(DeviceTriggerType::Mouse);
386 return;
387 }
388
389 device_status.mouse_position_state.x = stick_value.x.value;
390 device_status.mouse_position_state.y = stick_value.y.value;
391
392 TriggerOnChange(DeviceTriggerType::Mouse);
393}
394
337KeyboardValues EmulatedDevices::GetKeyboardValues() const { 395KeyboardValues EmulatedDevices::GetKeyboardValues() const {
338 return device_status.keyboard_values; 396 return device_status.keyboard_values;
339} 397}
@@ -362,6 +420,10 @@ MousePosition EmulatedDevices::GetMousePosition() const {
362 return device_status.mouse_position_state; 420 return device_status.mouse_position_state;
363} 421}
364 422
423AnalogStickState EmulatedDevices::GetMouseDeltaWheel() const {
424 return device_status.mouse_wheel_state;
425}
426
365void EmulatedDevices::TriggerOnChange(DeviceTriggerType type) { 427void EmulatedDevices::TriggerOnChange(DeviceTriggerType type) {
366 for (const auto& poller_pair : callback_list) { 428 for (const auto& poller_pair : callback_list) {
367 const InterfaceUpdateCallback& poller = poller_pair.second; 429 const InterfaceUpdateCallback& poller = poller_pair.second;
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
19namespace Core::HID { 19namespace Core::HID {
20
21using KeyboardDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, 20using KeyboardDevices = std::array<std::unique_ptr<Common::Input::InputDevice>,
22 Settings::NativeKeyboard::NumKeyboardKeys>; 21 Settings::NativeKeyboard::NumKeyboardKeys>;
23using KeyboardModifierDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, 22using KeyboardModifierDevices = std::array<std::unique_ptr<Common::Input::InputDevice>,
24 Settings::NativeKeyboard::NumKeyboardMods>; 23 Settings::NativeKeyboard::NumKeyboardMods>;
25using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, 24using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice>,
26 Settings::NativeMouseButton::NumMouseButtons>; 25 Settings::NativeMouseButton::NumMouseButtons>;
26using MouseAnalogDevices = std::array<std::unique_ptr<Common::Input::InputDevice>,
27 Settings::NativeMouseWheel::NumMouseWheels>;
28using MouseStickDevice = std::unique_ptr<Common::Input::InputDevice>;
27 29
28using MouseButtonParams = 30using 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>;
35using MouseButtonValues = 37using MouseButtonValues =
36 std::array<Common::Input::ButtonStatus, Settings::NativeMouseButton::NumMouseButtons>; 38 std::array<Common::Input::ButtonStatus, Settings::NativeMouseButton::NumMouseButtons>;
39using MouseAnalogValues =
40 std::array<Common::Input::AnalogStatus, Settings::NativeMouseWheel::NumMouseWheels>;
41using MouseStickValue = Common::Input::StickStatus;
37 42
38struct MousePosition { 43struct 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
45struct DeviceStatus { 48struct 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
58enum class DeviceTriggerType { 64enum 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;
diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp
index 480b862fd..c4e653956 100644
--- a/src/core/hid/input_converter.cpp
+++ b/src/core/hid/input_converter.cpp
@@ -242,6 +242,27 @@ Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackSta
242 return status; 242 return status;
243} 243}
244 244
245Common::Input::AnalogStatus TransformToAnalog(const Common::Input::CallbackStatus& callback) {
246 Common::Input::AnalogStatus status{};
247
248 switch (callback.type) {
249 case Common::Input::InputType::Analog:
250 status.properties = callback.analog_status.properties;
251 status.raw_value = callback.analog_status.raw_value;
252 break;
253 default:
254 LOG_ERROR(Input, "Conversion from type {} to analog not implemented", callback.type);
255 break;
256 }
257
258 SanitizeAnalog(status, false);
259
260 // Adjust if value is inverted
261 status.value = status.properties.inverted ? -status.value : status.value;
262
263 return status;
264}
265
245void SanitizeAnalog(Common::Input::AnalogStatus& analog, bool clamp_value) { 266void SanitizeAnalog(Common::Input::AnalogStatus& analog, bool clamp_value) {
246 const auto& properties = analog.properties; 267 const auto& properties = analog.properties;
247 float& raw_value = analog.raw_value; 268 float& raw_value = analog.raw_value;
diff --git a/src/core/hid/input_converter.h b/src/core/hid/input_converter.h
index 2a722b39f..1492489d7 100644
--- a/src/core/hid/input_converter.h
+++ b/src/core/hid/input_converter.h
@@ -69,6 +69,15 @@ Common::Input::TouchStatus TransformToTouch(const Common::Input::CallbackStatus&
69Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackStatus& callback); 69Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackStatus& callback);
70 70
71/** 71/**
72 * Converts raw input data into a valid analog status. Applies offset, deadzone, range and
73 * invert properties to the output.
74 *
75 * @param Supported callbacks: Analog.
76 * @return A valid AnalogStatus object.
77 */
78Common::Input::AnalogStatus TransformToAnalog(const Common::Input::CallbackStatus& callback);
79
80/**
72 * Converts raw analog data into a valid analog value 81 * Converts raw analog data into a valid analog value
73 * @param An analog object containing raw data and properties, bool that determines if the value 82 * @param An analog object containing raw data and properties, bool that determines if the value
74 * needs to be clamped between -1.0f and 1.0f. 83 * needs to be clamped between -1.0f and 1.0f.
diff --git a/src/core/hle/service/hid/controllers/mouse.cpp b/src/core/hle/service/hid/controllers/mouse.cpp
index 83e69ca94..9c408e7f4 100644
--- a/src/core/hle/service/hid/controllers/mouse.cpp
+++ b/src/core/hle/service/hid/controllers/mouse.cpp
@@ -38,13 +38,14 @@ void Controller_Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
38 if (Settings::values.mouse_enabled) { 38 if (Settings::values.mouse_enabled) {
39 const auto& mouse_button_state = emulated_devices->GetMouseButtons(); 39 const auto& mouse_button_state = emulated_devices->GetMouseButtons();
40 const auto& mouse_position_state = emulated_devices->GetMousePosition(); 40 const auto& mouse_position_state = emulated_devices->GetMousePosition();
41 const auto& mouse_wheel_state = emulated_devices->GetMouseDeltaWheel();
41 next_state.attribute.is_connected.Assign(1); 42 next_state.attribute.is_connected.Assign(1);
42 next_state.x = mouse_position_state.x; 43 next_state.x = static_cast<s32>(mouse_position_state.x * Layout::ScreenUndocked::Width);
43 next_state.y = mouse_position_state.y; 44 next_state.y = static_cast<s32>(mouse_position_state.y * Layout::ScreenUndocked::Height);
44 next_state.delta_x = next_state.x - last_entry.x; 45 next_state.delta_x = next_state.x - last_entry.x;
45 next_state.delta_y = next_state.y - last_entry.y; 46 next_state.delta_y = next_state.y - last_entry.y;
46 next_state.delta_wheel_x = mouse_position_state.delta_wheel_x; 47 next_state.delta_wheel_x = mouse_wheel_state.x;
47 next_state.delta_wheel_y = mouse_position_state.delta_wheel_y; 48 next_state.delta_wheel_y = mouse_wheel_state.y;
48 49
49 next_state.button = mouse_button_state; 50 next_state.button = mouse_button_state;
50 } 51 }