diff options
| author | 2018-07-18 14:29:16 -0700 | |
|---|---|---|
| committer | 2018-07-18 14:29:16 -0700 | |
| commit | 924c473bb3a80cf1452949d8c0328912464a6807 (patch) | |
| tree | 949bfdc854d7c8874af2e24bab5a0cfc042b9037 | |
| parent | Merge pull request #681 from lioncash/const (diff) | |
| parent | Fill in more fields in TouchScreenEntryTouch (diff) | |
| download | yuzu-924c473bb3a80cf1452949d8c0328912464a6807.tar.gz yuzu-924c473bb3a80cf1452949d8c0328912464a6807.tar.xz yuzu-924c473bb3a80cf1452949d8c0328912464a6807.zip | |
Merge pull request #683 from DarkLordZach/touch
Touchscreen Support
Diffstat (limited to '')
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 6b11830f1..4f18c0fd3 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <atomic> | 5 | #include <atomic> |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/core_timing.h" | 7 | #include "core/core_timing.h" |
| 8 | #include "core/frontend/emu_window.h" | ||
| 8 | #include "core/frontend/input.h" | 9 | #include "core/frontend/input.h" |
| 9 | #include "core/hle/ipc_helpers.h" | 10 | #include "core/hle/ipc_helpers.h" |
| 10 | #include "core/hle/kernel/client_port.h" | 11 | #include "core/hle/kernel/client_port.h" |
| @@ -63,7 +64,8 @@ private: | |||
| 63 | std::transform(Settings::values.analogs.begin() + Settings::NativeAnalog::STICK_HID_BEGIN, | 64 | std::transform(Settings::values.analogs.begin() + Settings::NativeAnalog::STICK_HID_BEGIN, |
| 64 | Settings::values.analogs.begin() + Settings::NativeAnalog::STICK_HID_END, | 65 | Settings::values.analogs.begin() + Settings::NativeAnalog::STICK_HID_END, |
| 65 | sticks.begin(), Input::CreateDevice<Input::AnalogDevice>); | 66 | sticks.begin(), Input::CreateDevice<Input::AnalogDevice>); |
| 66 | // TODO(shinyquagsire23): gyro, touch, mouse, keyboard | 67 | touch_device = Input::CreateDevice<Input::TouchDevice>(Settings::values.touch_device); |
| 68 | // TODO(shinyquagsire23): gyro, mouse, keyboard | ||
| 67 | } | 69 | } |
| 68 | 70 | ||
| 69 | void UpdatePadCallback(u64 userdata, int cycles_late) { | 71 | void UpdatePadCallback(u64 userdata, int cycles_late) { |
| @@ -151,8 +153,6 @@ private: | |||
| 151 | } | 153 | } |
| 152 | } | 154 | } |
| 153 | 155 | ||
| 154 | // TODO(bunnei): Properly implement the touch screen, the below will just write empty data | ||
| 155 | |||
| 156 | TouchScreen& touchscreen = mem.touchscreen; | 156 | TouchScreen& touchscreen = mem.touchscreen; |
| 157 | const u64 last_entry = touchscreen.header.latest_entry; | 157 | const u64 last_entry = touchscreen.header.latest_entry; |
| 158 | const u64 curr_entry = (last_entry + 1) % touchscreen.entries.size(); | 158 | const u64 curr_entry = (last_entry + 1) % touchscreen.entries.size(); |
| @@ -164,7 +164,26 @@ private: | |||
| 164 | touchscreen.header.max_entry_index = touchscreen.entries.size(); | 164 | touchscreen.header.max_entry_index = touchscreen.entries.size(); |
| 165 | touchscreen.header.timestamp = timestamp; | 165 | touchscreen.header.timestamp = timestamp; |
| 166 | touchscreen.entries[curr_entry].header.timestamp = sample_counter; | 166 | touchscreen.entries[curr_entry].header.timestamp = sample_counter; |
| 167 | touchscreen.entries[curr_entry].header.num_touches = 0; | 167 | |
| 168 | TouchScreenEntryTouch touch_entry{}; | ||
| 169 | auto [x, y, pressed] = touch_device->GetStatus(); | ||
| 170 | touch_entry.timestamp = timestamp; | ||
| 171 | touch_entry.x = static_cast<u16>(x * Layout::ScreenUndocked::Width); | ||
| 172 | touch_entry.y = static_cast<u16>(y * Layout::ScreenUndocked::Height); | ||
| 173 | touch_entry.touch_index = 0; | ||
| 174 | |||
| 175 | // TODO(DarkLordZach): Maybe try to derive these from EmuWindow? | ||
| 176 | touch_entry.diameter_x = 15; | ||
| 177 | touch_entry.diameter_y = 15; | ||
| 178 | touch_entry.angle = 0; | ||
| 179 | |||
| 180 | // TODO(DarkLordZach): Implement multi-touch support | ||
| 181 | if (pressed) { | ||
| 182 | touchscreen.entries[curr_entry].header.num_touches = 1; | ||
| 183 | touchscreen.entries[curr_entry].touches[0] = touch_entry; | ||
| 184 | } else { | ||
| 185 | touchscreen.entries[curr_entry].header.num_touches = 0; | ||
| 186 | } | ||
| 168 | 187 | ||
| 169 | // TODO(shinyquagsire23): Properly implement mouse | 188 | // TODO(shinyquagsire23): Properly implement mouse |
| 170 | Mouse& mouse = mem.mouse; | 189 | Mouse& mouse = mem.mouse; |
| @@ -250,6 +269,7 @@ private: | |||
| 250 | std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeButton::NUM_BUTTONS_HID> | 269 | std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeButton::NUM_BUTTONS_HID> |
| 251 | buttons; | 270 | buttons; |
| 252 | std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID> sticks; | 271 | std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID> sticks; |
| 272 | std::unique_ptr<Input::TouchDevice> touch_device; | ||
| 253 | }; | 273 | }; |
| 254 | 274 | ||
| 255 | class IActiveVibrationDeviceList final : public ServiceFramework<IActiveVibrationDeviceList> { | 275 | class IActiveVibrationDeviceList final : public ServiceFramework<IActiveVibrationDeviceList> { |