mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-02 09:57:40 +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_FRect rect;
|
||||||
static SDL_Event event;
|
static SDL_Event event;
|
||||||
static bool warp;
|
static bool warp;
|
||||||
|
static bool raw;
|
||||||
|
|
||||||
static void DrawRects(SDL_Renderer *renderer)
|
static void DrawRects(SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
|
@ -88,13 +89,20 @@ static void loop(void)
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_MOUSE_MOTION:
|
case SDL_EVENT_MOUSE_MOTION:
|
||||||
{
|
{
|
||||||
rect.x += event.motion.xrel;
|
if (!raw) {
|
||||||
rect.y += event.motion.yrel;
|
rect.x += event.motion.xrel;
|
||||||
|
rect.y += event.motion.yrel;
|
||||||
|
|
||||||
if (warp) {
|
if (warp) {
|
||||||
CenterMouse();
|
CenterMouse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} 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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -154,12 +162,16 @@ int main(int argc, char *argv[])
|
||||||
if (SDL_strcasecmp(argv[i], "--warp") == 0) {
|
if (SDL_strcasecmp(argv[i], "--warp") == 0) {
|
||||||
warp = true;
|
warp = true;
|
||||||
consumed = 1;
|
consumed = 1;
|
||||||
|
} else if (SDL_strcasecmp(argv[i], "--raw") == 0) {
|
||||||
|
raw = true;
|
||||||
|
consumed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (consumed < 0) {
|
if (consumed < 0) {
|
||||||
static const char *options[] = {
|
static const char *options[] = {
|
||||||
"[--warp]",
|
"[--warp]",
|
||||||
|
"[--raw]",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
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.x = DEFAULT_WINDOW_WIDTH / 2;
|
||||||
rect.y = DEFAULT_WINDOW_HEIGHT / 2;
|
rect.y = DEFAULT_WINDOW_HEIGHT / 2;
|
||||||
rect.w = 10;
|
rect.w = 10;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue