SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Add basic Android pen backend

Open hwsmm opened this issue 1 year ago • 1 comments

Related to https://github.com/libsdl-org/SDL/issues/10516

This PR implements Android pen backend. It is very basic because a pen I have is missing a lot of features. It only has a pen tip and a single button (no tilt support or whatever). I added some code for eraser, but I couldn't test because I don't have.

It also refactors input handling to use pointer count more extensively to reduce duplicate code, which also removes a DeX-specific workaround. I know I should have separated PRs, but this doc suggested that one shouldn't use getSource to determine whether the event came from stylus, so I ended up combining them.

ACTION_BUTTON_PRESS/ACTION_BUTTON_RELEASE doesn't seem to get triggered for stylus, so it currently compares bitflags on pen events for now.

SDLGenericMotionListener_API12 is now SDLGenericMotionListener_API14 since Android 4.0 (14) is the first version to support stylus. Current minimum API requirement is 19, so it shouldn't matter so much.

Tested on Galaxy Tab S7 FE (Android 14) with a cheap compatible pen.

hwsmm avatar Nov 12 '24 15:11 hwsmm

At first glance this looks good, but I need to look it over more carefully before merging.

icculus avatar Nov 13 '24 19:11 icculus