-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Windows precision touchpad (PTP) absolute position support (proof of concept) #6542
base: master
Are you sure you want to change the base?
Conversation
|
||
foreach (byte[] report in reports) | ||
{ | ||
data = reader!.ReadRawInput(report); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: catch possible ReadException
s here
This actually plays pretty well. But I've found that there is little to no difference if I carefully use what's currently available in osu!. By enabling high precision mouse, any windows precision touchpad acceleration is ignored. If I position the in-game cursor in the middle of the screen and my finger in the middle of the touchpad, it's functionally identical to this PR. It feels like absolute input and is just as precise. With the added benefit of being able to use the touchpad like normal outside of gameplay. I've played the same map with this PR and with release osu!(lazer), and it plays the same. There's some fiddling with mouse sensitivity to get the proportions right, but it's simple to adjust, and only needs to be done once. From what I've tried, absolute touchpad input saves you from having to re-calibrate the centre of screen and centre of touchpad. (Side though: is it possible to do a one-shot with this API, sync positions at the start of the map, and let relative mode handle the rest?) With relative input, you have to calibrate yourself, but this also allows adjusting your posture mid-map. Have you tried playing with high precision mouse like I described? Give it a try and report back your thoughts. |
I experimented with both versions for a while. My setupTouchpad: Magic Trackpad 3 with the driver from imbushuo, connected using Bluetooth. System: Windows 10 22H2, touchpad cursor speed = 7, mouse cursor speed = 10. osu! release: 1024x768, cursor sensitivity = 2.00x osu! development: 1024x768, cursor sensitivity = 3.80x (i.e. 1/3.8 of the height of the touchpad is used) I do have another laptop with built-in PTP (Surface Laptop Studio 1st gen), but it's not around now. Will try it later. They do feel similar, but there are some small differences:
VideoThe tiny square is the position read with raw input, and the white transparent rectangle is the mapped area (in dev). 2025-02-26.19-35-47.mp4
We can enable
I think for users with a smaller touchpad, or using a larger portion of it, this auto re-calibration is important. Otherwise, they will risk hitting the border and unable to move further, and that can be very frustrating.
Should be possible, but if one accidentally lift the finger (or on purpose, during rest segments), it's out of sync. |
Could you render the graphs again, but use the same X and Y scales for the different graphs. The second one is zoomed in so it may exagarate the drift in comparison to the first graphs. So either zoom in the first graphs, or zoom out the second. I guess you could also graphs the deltas. Anyways, after seeing the drift in the second image, I'm already more motivated to include this PR in some form. I'm inclined to have this in SDL, as it can benefit from raw input gathering running in a dedicated thread. |
Summary
Add absolute position support for Windows precision touchpads, make them behave like a drawing tablet.
Details
interface IHasTouchpadInput : IWindow
for windows supporting PTP data reporting.SDL2WindowsWindow
andSDL3WindowsWindow
, should also be possible on macOS once Source aspect ratio information missing in TouchFingerEvent generated by trackpads libsdl-org/SDL#12391 is fixed.WindowsRawInputManager
.WindowsRawInputManager.RawMouse
event when enabled.WindowsTouchpadReader
, usingHidP_
Windows API functions.HidSharpCore
is not used, because to extract data with it we need a HID descriptor in bytes, but raw input only provides "preparsed data". It's possible to reconstruct the descriptor from ppd (and this is whatHidSharpCore
is doing, hiding in an internal class), but the logic is complicated and I don't feel like duplicating it.TouchpadHandler
to post-process the data fromIHasTouchpadInput
windows, emitsMousePositionAbsoluteInput
.TODOs
IHasTouchpadInput
.TouchpadHandler
in the actual game, not in menus. (Possibly in the main osu repo)