Skip to content

Commit

Permalink
Copy pen handling code from SDLSurface to SDLControllerManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Susko3 authored and slouken committed Jan 22, 2025
1 parent 6f3d0b3 commit 73fc2b0
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,14 @@ public boolean onGenericMotion(View v, MotionEvent event) {
x = event.getX(i);
y = event.getY(i);
float 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
int buttons = event.getButtonState() >> 4;
// BUTTON_STYLUS_PRIMARY is 2^5, so shift by 4, and apply SDL_PEN_INPUT_DOWN/SDL_PEN_INPUT_ERASER_TIP
int buttons = (event.getButtonState() >> 4) | (1 << (toolType == MotionEvent.TOOL_TYPE_STYLUS ? 0 : 30));

SDLActivity.onNativePen(event.getPointerId(i), buttons, action, x, y, p);
consumed = true;
Expand Down

0 comments on commit 73fc2b0

Please sign in to comment.