summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/hid/hid.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 6b11830f1..32c781cf3 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,21 @@ 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 float x;
170 float y;
171 bool pressed;
172 std::tie(x, y, pressed) = touch_device->GetStatus();
173 touch_entry.x = static_cast<u16>(x * Layout::ScreenUndocked::Width);
174 touch_entry.y = static_cast<u16>(y * Layout::ScreenUndocked::Height);
175
176 if (pressed) {
177 touchscreen.entries[curr_entry].header.num_touches = 1;
178 touchscreen.entries[curr_entry].touches[0] = touch_entry;
179 } else {
180 touchscreen.entries[curr_entry].header.num_touches = 0;
181 }
168 182
169 // TODO(shinyquagsire23): Properly implement mouse 183 // TODO(shinyquagsire23): Properly implement mouse
170 Mouse& mouse = mem.mouse; 184 Mouse& mouse = mem.mouse;
@@ -250,6 +264,7 @@ private:
250 std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeButton::NUM_BUTTONS_HID> 264 std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeButton::NUM_BUTTONS_HID>
251 buttons; 265 buttons;
252 std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID> sticks; 266 std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID> sticks;
267 std::unique_ptr<Input::TouchDevice> touch_device;
253}; 268};
254 269
255class IActiveVibrationDeviceList final : public ServiceFramework<IActiveVibrationDeviceList> { 270class IActiveVibrationDeviceList final : public ServiceFramework<IActiveVibrationDeviceList> {