diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-07-18 20:06:33 +0200 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-07-18 20:06:33 +0200 |
commit | f2f368014e2bc9e181aeb371adde79767f82a64f (patch) | |
tree | 4c03982cbcf435fa752b0d9290359348c3165b3c /src | |
parent | Merge pull request #681 from lioncash/const (diff) | |
download | yuzu-f2f368014e2bc9e181aeb371adde79767f82a64f.tar yuzu-f2f368014e2bc9e181aeb371adde79767f82a64f.tar.gz yuzu-f2f368014e2bc9e181aeb371adde79767f82a64f.tar.bz2 yuzu-f2f368014e2bc9e181aeb371adde79767f82a64f.tar.lz yuzu-f2f368014e2bc9e181aeb371adde79767f82a64f.tar.xz yuzu-f2f368014e2bc9e181aeb371adde79767f82a64f.tar.zst yuzu-f2f368014e2bc9e181aeb371adde79767f82a64f.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hle/service/hid/hid.cpp | 23 |
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 @@ #include <atomic> #include "common/logging/log.h" #include "core/core_timing.h" +#include "core/frontend/emu_window.h" #include "core/frontend/input.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/client_port.h" @@ -63,7 +64,8 @@ private: std::transform(Settings::values.analogs.begin() + Settings::NativeAnalog::STICK_HID_BEGIN, Settings::values.analogs.begin() + Settings::NativeAnalog::STICK_HID_END, sticks.begin(), Input::CreateDevice<Input::AnalogDevice>); - // TODO(shinyquagsire23): gyro, touch, mouse, keyboard + touch_device = Input::CreateDevice<Input::TouchDevice>(Settings::values.touch_device); + // TODO(shinyquagsire23): gyro, mouse, keyboard } void UpdatePadCallback(u64 userdata, int cycles_late) { @@ -151,8 +153,6 @@ private: } } - // TODO(bunnei): Properly implement the touch screen, the below will just write empty data - TouchScreen& touchscreen = mem.touchscreen; const u64 last_entry = touchscreen.header.latest_entry; const u64 curr_entry = (last_entry + 1) % touchscreen.entries.size(); @@ -164,7 +164,21 @@ private: touchscreen.header.max_entry_index = touchscreen.entries.size(); touchscreen.header.timestamp = timestamp; touchscreen.entries[curr_entry].header.timestamp = sample_counter; - touchscreen.entries[curr_entry].header.num_touches = 0; + + TouchScreenEntryTouch touch_entry{}; + float x; + float y; + bool pressed; + std::tie(x, y, pressed) = touch_device->GetStatus(); + touch_entry.x = static_cast<u16>(x * Layout::ScreenUndocked::Width); + touch_entry.y = static_cast<u16>(y * Layout::ScreenUndocked::Height); + + if (pressed) { + touchscreen.entries[curr_entry].header.num_touches = 1; + touchscreen.entries[curr_entry].touches[0] = touch_entry; + } else { + touchscreen.entries[curr_entry].header.num_touches = 0; + } // TODO(shinyquagsire23): Properly implement mouse Mouse& mouse = mem.mouse; @@ -250,6 +264,7 @@ private: std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeButton::NUM_BUTTONS_HID> buttons; std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID> sticks; + std::unique_ptr<Input::TouchDevice> touch_device; }; class IActiveVibrationDeviceList final : public ServiceFramework<IActiveVibrationDeviceList> { |