-
Notifications
You must be signed in to change notification settings - Fork 423
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 a way to distinguish mouse from tablet pen inputs #6488
base: master
Are you sure you want to change the base?
Conversation
OpenTabletDriver presses and releases mouse buttons without worrying about the mouse state, so why should SDL pen handling worry about it. Partially reverts commit dd45d8a.
These can be later changed to have proper UIEvent handling.
I find I understand that following a similar style to how touch input works would produce counter-intuitive behaviour with event handling, and agree with the notion of "pen input are mouse input". I'm not settled on a particular direction I'm foreseeing towards this, but it can remain within the idea that pen input influences the mouse state with clear indication that the input is sourced from a pen. i.e. something similar to the diff you proposed in ppy/osu#31182 (comment) with full coverage of the class (see the sync releases method at the bottom of the class). cc @peppy @smoogipoo |
|
||
namespace osu.Framework.Input.StateChanges | ||
{ | ||
public class TabletPenInput : MouseButtonInput, ITabletPenInput |
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.
The "Tablet" prefix has been ingrained with graphic tablets in the framework codebase, I don't think it's a good fit for these classes.
I would just drop it, I think the name "Pen" is clear and general enough to indicate any kind of stylus input, direct or non-direct.
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.
I originally had it as just PenInput
, but I changed it to TabletPen
to keep it consistent with existing TabletPenButtonInput
. I can change it all to just Pen{…}Input
, but it'll be a breaking one.
Some windows tablets have a screen, the pen input is just as direct as with an iPad, and they are still called graphics tablets.
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.
I prefer PenInput
I think.
I want that addition to be separate, because it can be. Smaller PRs are easier to review. This PR changes the native implementation to use pen inputs, and later PRs can make use of those inputs without having to worry about native. Whatever PR adds proper pen support to Would you be okay with this PR going in as is if the title was changed to "Add marker |
This doesn't change the consequence that You mention making the interface |
Change it to |
I'm okay with the passthrough / sync logic being implemented separately because from my understanding this PR will not change behaviour to existing applications (unless they use the new interfaces in some way). But I also think adding that logic here will not increase the complexity of the PR as it's all new code, and only across what should be two classes? Out of curiosity, what's a device with an "indirect" pen input? I'm struggling to imagine what this involves. |
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.
As commented.
Direct and indirect are meant to be used for showing and hiding the cursor. "Indirect" is when the pen is not over the screen, so a game would need to show the cursor so the user knows where they are pointing. It's a bad name, and is currently not that useful (it's unknown except on iPadOS). I think it's not easy to implement on windows as it sees a graphics tablet with a display as two separate devices. I would remove it as it's not useful and confusing. osu! can just hardcode not showing the cursor on iPadOS pen input. |
`syncReleasedInputs()` is not changed as the only difference is the MouseButtonInput/TabletPenInput for left click. Also, it's impossible to tell what caused the left click release in the parent state (we could check `parentState.Mouse.LastSource`, but it could have been set from a later event).
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.
Looks pretty good, pending renames
Not really user-friendly, but gets the job done.
I've tested this on a real tablet (Wacom intuos 3 PTZ-930) with latest This PR is finished, but the following still needs to be done:
|
what does this do? |
This will reset |
case MouseDownEvent penDown when penInput != null: | ||
Debug.Assert(penDown.Button == MouseButton.Left); | ||
new MouseButtonInputFromPen(true) { DeviceType = penInput.DeviceType }.Apply(CurrentState, this); | ||
break; |
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.
I don't believe we use case when
anywhere. And in this particular instance, I would agree that it reads really weirdly. Move this to an if conditional in the mouse down event below, and/or create private methods for handling each events to keep this general handler method organized.
/// </summary> | ||
public interface ISourcedFromPen : IInput | ||
{ | ||
public TabletPenDeviceType DeviceType { get; } |
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.
- missing xmldoc
public TabletPenDeviceType DeviceType { get; } | |
TabletPenDeviceType DeviceType { get; } |
public event Action<Vector2>? PenMove; | ||
|
||
/// <summary> | ||
/// invoked when a pen touches (<c>true</c>) or lifts (<c>false</c>) from the tablet surface. |
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.
/// invoked when a pen touches (<c>true</c>) or lifts (<c>false</c>) from the tablet surface. | |
/// Invoked when a pen touches (<c>true</c>) or lifts (<c>false</c>) from the tablet surface. |
Adding I'm also wondering about what kind of configuration do you think will affect this. If it's mandatory, effort to add migration support in |
Sure. We can add it when it can be used to fix an issue. I'm also expecting that users will ask to add sensitivity (i.e. scaling of apsolute input wrt centre of screen/window), so it may also be added because of that. To explain the pen handler purpose to the user, I would call it "Pen (Windows Ink)" on windows.
The
Even if there is a "correct" value of relative mouse mode for pen input, I don't see a clean way to implement migrations. Migrations are done at startup, but we don't have a magic ball that will tell us if the user is going to use pen input or not. Instead, I suggest writing an osu!wiki page for pen input in lazer, list common problems and fixes. Like https://osu.ppy.sh/wiki/en/Gameplay/Input_device/Graphics_tablet for stable. If our scream test goes well, there won't be a need for either :) |
Public additions
Tablet pen inputs are now marked with
ITabletPenInput
. This is useful for ppy/osu#31182 as it can be queried byMouseEvent.CurrentState.Mouse.LastSource as ITabletPenInput
. The pen inputs simulate mouse input as they did previously (can be changed in the future).A new
PenHandler
for SDL3 was added. No bindable settings are currently exposed.Internal changes
The SDL3 pen logic was completely rewritten as it didn't make much sense to me. Having a separate
PenHandler
was needed so a lot of the logic would have changed anyway.I've left the Windows SDL2 pen handling logic intact to prevent unintended consequences. The SDL3 logic will be ripped out as soon as SDL3-CS is released with libsdl-org/SDL#11826.
Testing
I've tested this on Windows with vTablet. The current SDL3-CS release doesn't have windows ink support, so I've manually built SDL and copied over the new
SDL3.dll
.Future changes enabled by this PR
Properly supporting pen inputs as UI events. Right now, any
ITabletPenInput
information is lost at thePassThroughInputManager
border.