mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-31 17:07:39 +00:00
tests: Add a raw event mode to testrelative
Add a code path to test raw motion events (activated by '--raw').
This commit is contained in:
parent
8c849ecc6c
commit
4bfc8f84f7
1 changed files with 20 additions and 4 deletions
|
@ -25,6 +25,7 @@ static int i, done;
|
|||
static SDL_FRect rect;
|
||||
static SDL_Event event;
|
||||
static bool warp;
|
||||
static bool raw;
|
||||
|
||||
static void DrawRects(SDL_Renderer *renderer)
|
||||
{
|
||||
|
@ -88,13 +89,20 @@ static void loop(void)
|
|||
break;
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
{
|
||||
rect.x += event.motion.xrel;
|
||||
rect.y += event.motion.yrel;
|
||||
if (!raw) {
|
||||
rect.x += event.motion.xrel;
|
||||
rect.y += event.motion.yrel;
|
||||
|
||||
if (warp) {
|
||||
CenterMouse();
|
||||
if (warp) {
|
||||
CenterMouse();
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case SDL_EVENT_MOUSE_RAW_MOTION:
|
||||
{
|
||||
rect.x += event.maxis.dx / event.maxis.ux;
|
||||
rect.y += event.maxis.dy / event.maxis.uy;
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -154,12 +162,16 @@ int main(int argc, char *argv[])
|
|||
if (SDL_strcasecmp(argv[i], "--warp") == 0) {
|
||||
warp = true;
|
||||
consumed = 1;
|
||||
} else if (SDL_strcasecmp(argv[i], "--raw") == 0) {
|
||||
raw = true;
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (consumed < 0) {
|
||||
static const char *options[] = {
|
||||
"[--warp]",
|
||||
"[--raw]",
|
||||
NULL
|
||||
};
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
|
@ -195,6 +207,10 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (raw) {
|
||||
SDL_SetEventEnabled(SDL_EVENT_MOUSE_RAW_MOTION, true);
|
||||
}
|
||||
|
||||
rect.x = DEFAULT_WINDOW_WIDTH / 2;
|
||||
rect.y = DEFAULT_WINDOW_HEIGHT / 2;
|
||||
rect.w = 10;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue