diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/frontend/input.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 12 | ||||
| -rw-r--r-- | src/core/settings.h | 1 |
3 files changed, 15 insertions, 4 deletions
diff --git a/src/core/frontend/input.h b/src/core/frontend/input.h index 5916a901d..8c256beb5 100644 --- a/src/core/frontend/input.h +++ b/src/core/frontend/input.h | |||
| @@ -126,4 +126,10 @@ using AnalogDevice = InputDevice<std::tuple<float, float>>; | |||
| 126 | */ | 126 | */ |
| 127 | using MotionDevice = InputDevice<std::tuple<Math::Vec3<float>, Math::Vec3<float>>>; | 127 | using MotionDevice = InputDevice<std::tuple<Math::Vec3<float>, Math::Vec3<float>>>; |
| 128 | 128 | ||
| 129 | /** | ||
| 130 | * A touch device is an input device that returns a tuple of two floats and a bool. The floats are | ||
| 131 | * x and y coordinates in the range 0.0 - 1.0, and the bool indicates whether it is pressed. | ||
| 132 | */ | ||
| 133 | using TouchDevice = InputDevice<std::tuple<float, float, bool>>; | ||
| 134 | |||
| 129 | } // namespace Input | 135 | } // namespace Input |
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 |
diff --git a/src/core/settings.h b/src/core/settings.h index 7e15b119b..088d7651a 100644 --- a/src/core/settings.h +++ b/src/core/settings.h | |||
| @@ -80,6 +80,7 @@ struct Values { | |||
| 80 | std::array<std::string, NativeButton::NumButtons> buttons; | 80 | std::array<std::string, NativeButton::NumButtons> buttons; |
| 81 | std::array<std::string, NativeAnalog::NumAnalogs> analogs; | 81 | std::array<std::string, NativeAnalog::NumAnalogs> analogs; |
| 82 | std::string motion_device; | 82 | std::string motion_device; |
| 83 | std::string touch_device; | ||
| 83 | 84 | ||
| 84 | // Core | 85 | // Core |
| 85 | bool use_cpu_jit; | 86 | bool use_cpu_jit; |