diff options
| author | 2017-08-29 11:29:10 -0400 | |
|---|---|---|
| committer | 2017-08-29 11:29:10 -0400 | |
| commit | 75cd28a7cc1c73e1be1fc72d4b86b267cbb79081 (patch) | |
| tree | 18f3e7e5b864511da54d847e645dd23a69033924 /src/core/hle | |
| parent | Merge pull request #2905 from danzel/fix-2902 (diff) | |
| parent | EmuWindow: refactor touch input into a TouchDevice (diff) | |
| download | yuzu-75cd28a7cc1c73e1be1fc72d4b86b267cbb79081.tar.gz yuzu-75cd28a7cc1c73e1be1fc72d4b86b267cbb79081.tar.xz yuzu-75cd28a7cc1c73e1be1fc72d4b86b267cbb79081.zip | |
Merge pull request #2899 from wwylele/touch-refactor
Refactor touch input into a TouchDevice
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 31f34a7ae..aa5d821f9 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -7,9 +7,9 @@ | |||
| 7 | #include <cmath> | 7 | #include <cmath> |
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 10 | #include "core/3ds.h" | ||
| 10 | #include "core/core.h" | 11 | #include "core/core.h" |
| 11 | #include "core/core_timing.h" | 12 | #include "core/core_timing.h" |
| 12 | #include "core/frontend/emu_window.h" | ||
| 13 | #include "core/frontend/input.h" | 13 | #include "core/frontend/input.h" |
| 14 | #include "core/hle/ipc.h" | 14 | #include "core/hle/ipc.h" |
| 15 | #include "core/hle/kernel/event.h" | 15 | #include "core/hle/kernel/event.h" |
| @@ -19,7 +19,6 @@ | |||
| 19 | #include "core/hle/service/hid/hid_spvr.h" | 19 | #include "core/hle/service/hid/hid_spvr.h" |
| 20 | #include "core/hle/service/hid/hid_user.h" | 20 | #include "core/hle/service/hid/hid_user.h" |
| 21 | #include "core/hle/service/service.h" | 21 | #include "core/hle/service/service.h" |
| 22 | #include "video_core/video_core.h" | ||
| 23 | 22 | ||
| 24 | namespace Service { | 23 | namespace Service { |
| 25 | namespace HID { | 24 | namespace HID { |
| @@ -59,6 +58,7 @@ static std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeButton:: | |||
| 59 | buttons; | 58 | buttons; |
| 60 | static std::unique_ptr<Input::AnalogDevice> circle_pad; | 59 | static std::unique_ptr<Input::AnalogDevice> circle_pad; |
| 61 | static std::unique_ptr<Input::MotionDevice> motion_device; | 60 | static std::unique_ptr<Input::MotionDevice> motion_device; |
| 61 | static std::unique_ptr<Input::TouchDevice> touch_device; | ||
| 62 | 62 | ||
| 63 | DirectionState GetStickDirectionState(s16 circle_pad_x, s16 circle_pad_y) { | 63 | DirectionState GetStickDirectionState(s16 circle_pad_x, s16 circle_pad_y) { |
| 64 | // 30 degree and 60 degree are angular thresholds for directions | 64 | // 30 degree and 60 degree are angular thresholds for directions |
| @@ -96,6 +96,7 @@ static void LoadInputDevices() { | |||
| 96 | circle_pad = Input::CreateDevice<Input::AnalogDevice>( | 96 | circle_pad = Input::CreateDevice<Input::AnalogDevice>( |
| 97 | Settings::values.analogs[Settings::NativeAnalog::CirclePad]); | 97 | Settings::values.analogs[Settings::NativeAnalog::CirclePad]); |
| 98 | motion_device = Input::CreateDevice<Input::MotionDevice>(Settings::values.motion_device); | 98 | motion_device = Input::CreateDevice<Input::MotionDevice>(Settings::values.motion_device); |
| 99 | touch_device = Input::CreateDevice<Input::TouchDevice>(Settings::values.touch_device); | ||
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | static void UnloadInputDevices() { | 102 | static void UnloadInputDevices() { |
| @@ -104,6 +105,7 @@ static void UnloadInputDevices() { | |||
| 104 | } | 105 | } |
| 105 | circle_pad.reset(); | 106 | circle_pad.reset(); |
| 106 | motion_device.reset(); | 107 | motion_device.reset(); |
| 108 | touch_device.reset(); | ||
| 107 | } | 109 | } |
| 108 | 110 | ||
| 109 | static void UpdatePadCallback(u64 userdata, int cycles_late) { | 111 | static void UpdatePadCallback(u64 userdata, int cycles_late) { |
| @@ -172,8 +174,10 @@ static void UpdatePadCallback(u64 userdata, int cycles_late) { | |||
| 172 | // Get the current touch entry | 174 | // Get the current touch entry |
| 173 | TouchDataEntry& touch_entry = mem->touch.entries[mem->touch.index]; | 175 | TouchDataEntry& touch_entry = mem->touch.entries[mem->touch.index]; |
| 174 | bool pressed = false; | 176 | bool pressed = false; |
| 175 | 177 | float x, y; | |
| 176 | std::tie(touch_entry.x, touch_entry.y, pressed) = VideoCore::g_emu_window->GetTouchState(); | 178 | std::tie(x, y, pressed) = touch_device->GetStatus(); |
| 179 | touch_entry.x = static_cast<u16>(x * Core::kScreenBottomWidth); | ||
| 180 | touch_entry.y = static_cast<u16>(y * Core::kScreenBottomHeight); | ||
| 177 | touch_entry.valid.Assign(pressed ? 1 : 0); | 181 | touch_entry.valid.Assign(pressed ? 1 : 0); |
| 178 | 182 | ||
| 179 | // TODO(bunnei): We're not doing anything with offset 0xA8 + 0x18 of HID SharedMemory, which | 183 | // TODO(bunnei): We're not doing anything with offset 0xA8 + 0x18 of HID SharedMemory, which |