Skip to content

Commit 55bded7

Browse files
committed
commi
1 parent 6ba311c commit 55bded7

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

project/lib/sdl/src/video/android/SDL_androidmouse.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
#include "../../core/android/SDL_android.h"
3131

32+
#include "SDL_androidvideo.h"
33+
3234
// See Android's MotionEvent class for constants
3335
#define ACTION_DOWN 0
3436
#define ACTION_UP 1
@@ -216,6 +218,19 @@ void Android_OnMouse(SDL_Window *window, int state, int action, float x, float y
216218
return;
217219
}
218220

221+
// The draw scale shrinks the window/framebuffer (see SDL_androidwindow.c), but
222+
// mouse coordinates arrive in full-surface View pixels. Scale absolute positions
223+
// into the same space so the pointer matches what's rendered. Relative-mode deltas
224+
// are already in motion units, and ACTION_SCROLL reuses x/y as wheel amounts; neither
225+
// must be scaled.
226+
if (!relative && action != ACTION_SCROLL) {
227+
float scale = Android_GetDrawScale();
228+
if (Android_ShouldUseDrawScale(scale)) {
229+
x *= scale;
230+
y *= scale;
231+
}
232+
}
233+
219234
switch (action) {
220235
case ACTION_DOWN:
221236
changes = state & ~last_state;

project/lib/sdl/src/video/android/SDL_androidpen.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "SDL_androidpen.h"
2626
#include "../../events/SDL_pen_c.h"
2727
#include "../../core/android/SDL_android.h"
28+
#include "SDL_androidvideo.h"
2829

2930
#define ACTION_DOWN 0
3031
#define ACTION_UP 1
@@ -40,6 +41,15 @@ void Android_OnPen(SDL_Window *window, int pen_id_in, SDL_PenDeviceType device_t
4041
return;
4142
}
4243

44+
// The draw scale shrinks the window/framebuffer (see SDL_androidwindow.c), but pen
45+
// coordinates arrive in full-surface View pixels. Scale them into the same space so
46+
// the pointer matches what's rendered.
47+
float scale = Android_GetDrawScale();
48+
if (Android_ShouldUseDrawScale(scale)) {
49+
x *= scale;
50+
y *= scale;
51+
}
52+
4353
// pointer index starts from zero.
4454
pen_id_in++;
4555

0 commit comments

Comments
 (0)