Skip to content
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

Copy Android pen handling code from SDLSurface to SDLControllerManager #12054

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

Susko3
Copy link
Contributor

@Susko3 Susko3 commented Jan 22, 2025

Description

Copies this fully correct pen handling code:

} else if (toolType == MotionEvent.TOOL_TYPE_STYLUS || toolType == MotionEvent.TOOL_TYPE_ERASER) {
pointerId = event.getPointerId(i);
x = event.getX(i);
y = event.getY(i);
p = event.getPressure(i);
if (p > 1.0f) {
// may be larger than 1.0f on some devices
// see the documentation of getPressure(i)
p = 1.0f;
}
// BUTTON_STYLUS_PRIMARY is 2^5, so shift by 4, and apply SDL_PEN_INPUT_DOWN/SDL_PEN_INPUT_ERASER_TIP
int buttonState = (event.getButtonState() >> 4) | (1 << (toolType == MotionEvent.TOOL_TYPE_STYLUS ? 0 : 30));
SDLActivity.onNativePen(pointerId, buttonState, action, x, y, p);

to the existing half-correct pen handling code in SDLControllerManager.java.

This should probably be handled by a common function, but I was unsure where to put it. Probably in SDLActivity but that already has 2190 lines of code, which is discouraging.

@slouken slouken merged commit 73fc2b0 into libsdl-org:main Jan 22, 2025
40 of 41 checks passed
@slouken
Copy link
Collaborator

slouken commented Jan 22, 2025

Merged, thanks!

@Susko3 Susko3 deleted the fix-android-pen branch January 22, 2025 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants