diff options
| author | 2015-03-08 03:05:56 -0400 | |
|---|---|---|
| committer | 2015-03-10 18:05:17 -0400 | |
| commit | 1a904ded40c87c41c404cfe5e74722c0a6554926 (patch) | |
| tree | 3691ced6a6cc6b5451df361392c1d079b80430df /src/core | |
| parent | HID: Moved some docstrings to the header. (diff) | |
| download | yuzu-1a904ded40c87c41c404cfe5e74722c0a6554926.tar.gz yuzu-1a904ded40c87c41c404cfe5e74722c0a6554926.tar.xz yuzu-1a904ded40c87c41c404cfe5e74722c0a6554926.zip | |
HID: Added functions to emulate the touchpad.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 48 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.h | 13 |
2 files changed, 61 insertions, 0 deletions
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 5812724d2..29213e0fe 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -29,6 +29,10 @@ static u32 next_pad_index = 0; | |||
| 29 | static s16 next_pad_circle_x = 0; | 29 | static s16 next_pad_circle_x = 0; |
| 30 | static s16 next_pad_circle_y = 0; | 30 | static s16 next_pad_circle_y = 0; |
| 31 | 31 | ||
| 32 | static u32 next_touch_index = 0; | ||
| 33 | static u16 next_touch_x = 0; | ||
| 34 | static u16 next_touch_y = 0; | ||
| 35 | |||
| 32 | /** | 36 | /** |
| 33 | * Gets a pointer to the PadData structure inside HID shared memory | 37 | * Gets a pointer to the PadData structure inside HID shared memory |
| 34 | */ | 38 | */ |
| @@ -125,6 +129,50 @@ void PadUpdateComplete() { | |||
| 125 | g_event_pad_or_touch_2->Signal(); | 129 | g_event_pad_or_touch_2->Signal(); |
| 126 | } | 130 | } |
| 127 | 131 | ||
| 132 | void TouchPress(u16 x, u16 y) { | ||
| 133 | next_touch_x = x; | ||
| 134 | next_touch_y = y; | ||
| 135 | } | ||
| 136 | |||
| 137 | void TouchRelease() { | ||
| 138 | next_touch_x = 0; | ||
| 139 | next_touch_y = 0; | ||
| 140 | } | ||
| 141 | |||
| 142 | void TouchUpdateComplete() { | ||
| 143 | SharedMem* shared_mem = GetSharedMem(); | ||
| 144 | |||
| 145 | if (shared_mem == nullptr) | ||
| 146 | return; | ||
| 147 | |||
| 148 | shared_mem->touch.index = next_touch_index; | ||
| 149 | next_touch_index = (next_touch_index + 1) % shared_mem->touch.entries.size(); | ||
| 150 | |||
| 151 | // Get the current touch entry | ||
| 152 | TouchDataEntry* current_touch_entry = &shared_mem->touch.entries[shared_mem->touch.index]; | ||
| 153 | |||
| 154 | // Set touchpad position | ||
| 155 | current_touch_entry->x = next_touch_x; | ||
| 156 | current_touch_entry->y = next_touch_y; | ||
| 157 | |||
| 158 | // TODO(bunnei): Verify this behavior on real hardware | ||
| 159 | current_touch_entry->data_valid = (next_touch_x || next_touch_y) ? 1 : 0; | ||
| 160 | |||
| 161 | // TODO(bunnei): We're not doing anything with offset 0xA8 + 0x18 of HID SharedMemory, which | ||
| 162 | // supposedly is "Touch-screen entry, which contains the raw coordinate data prior to being | ||
| 163 | // converted to pixel coordinates." (http://3dbrew.org/wiki/HID_Shared_Memory#Offset_0xA8). | ||
| 164 | |||
| 165 | // If we just updated index 0, provide a new timestamp | ||
| 166 | if (shared_mem->touch.index == 0) { | ||
| 167 | shared_mem->touch.index_reset_ticks_previous = shared_mem->touch.index_reset_ticks; | ||
| 168 | shared_mem->touch.index_reset_ticks = (s64)Core::g_app_core->GetTicks(); | ||
| 169 | } | ||
| 170 | |||
| 171 | // Signal both handles when there's an update to Pad or touch | ||
| 172 | g_event_pad_or_touch_1->Signal(); | ||
| 173 | g_event_pad_or_touch_2->Signal(); | ||
| 174 | } | ||
| 175 | |||
| 128 | void GetIPCHandles(Service::Interface* self) { | 176 | void GetIPCHandles(Service::Interface* self) { |
| 129 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 177 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 130 | 178 | ||
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index cd6263243..f2affb5c5 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h | |||
| @@ -180,6 +180,19 @@ void PadButtonRelease(const PadState& pad_state); | |||
| 180 | */ | 180 | */ |
| 181 | void PadUpdateComplete(); | 181 | void PadUpdateComplete(); |
| 182 | 182 | ||
| 183 | /** | ||
| 184 | * Signal that the touchpad has been pressed | ||
| 185 | * @param x Touchpad x-coordinate in bottom screen pixels (between 0 and 320) | ||
| 186 | * @param y Touchpad y-coordinate in bottom screen pixels (between 0 and 240) | ||
| 187 | */ | ||
| 188 | void TouchPress(u16 x, u16 y); | ||
| 189 | |||
| 190 | /// Signal that touchpad has been released | ||
| 191 | void TouchRelease(); | ||
| 192 | |||
| 193 | /// Signal that touchpad updates have been completed | ||
| 194 | void TouchUpdateComplete(); | ||
| 195 | |||
| 183 | void HIDInit(); | 196 | void HIDInit(); |
| 184 | void HIDShutdown(); | 197 | void HIDShutdown(); |
| 185 | 198 | ||