mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-10 11:56:26 +00:00
testnative: print events with --info event
This commit is contained in:
@@ -208,9 +208,16 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state);
|
|||||||
SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **argv);
|
SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **argv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common event handler for test windows if you use a standard SDL_main.
|
* Print the details of an event.
|
||||||
*
|
*
|
||||||
* This will free data from the event, like the string in a drop event!
|
* This is automatically called by SDLTest_CommonEvent() as needed.
|
||||||
|
*
|
||||||
|
* \param event The event to print.
|
||||||
|
*/
|
||||||
|
void SDLTest_PrintEvent(const SDL_Event *event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common event handler for test windows if you use a standard SDL_main.
|
||||||
*
|
*
|
||||||
* \param state The common state used to create test window.
|
* \param state The common state used to create test window.
|
||||||
* \param event The event to handle.
|
* \param event The event to handle.
|
||||||
|
@@ -615,6 +615,22 @@ int SDLTest_CommonArg(SDLTest_CommonState *state, int index)
|
|||||||
state->hide_cursor = SDL_TRUE;
|
state->hide_cursor = SDL_TRUE;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (SDL_strcasecmp(argv[index], "--info") == 0) {
|
||||||
|
++index;
|
||||||
|
if (!argv[index]) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (SDL_strcasecmp(argv[index], "all") == 0) {
|
||||||
|
state->verbose |= VERBOSE_EVENT;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (SDL_strcasecmp(argv[index], "event") == 0) {
|
||||||
|
state->verbose |= VERBOSE_EVENT;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->flags & SDL_INIT_AUDIO) {
|
if (state->flags & SDL_INIT_AUDIO) {
|
||||||
@@ -1555,7 +1571,7 @@ static const char *GamepadButtonName(const SDL_GamepadButton button)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLTest_PrintEvent(const SDL_Event *event)
|
void SDLTest_PrintEvent(const SDL_Event *event)
|
||||||
{
|
{
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case SDL_EVENT_SYSTEM_THEME_CHANGED:
|
case SDL_EVENT_SYSTEM_THEME_CHANGED:
|
||||||
|
@@ -206,6 +206,14 @@ int main(int argc, char *argv[])
|
|||||||
while (!done) {
|
while (!done) {
|
||||||
/* Check for events */
|
/* Check for events */
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
|
if (state->verbose & VERBOSE_EVENT) {
|
||||||
|
if (((event.type != SDL_EVENT_MOUSE_MOTION) &&
|
||||||
|
(event.type != SDL_EVENT_FINGER_MOTION)) ||
|
||||||
|
(state->verbose & VERBOSE_MOTION)) {
|
||||||
|
SDLTest_PrintEvent(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_EVENT_WINDOW_EXPOSED:
|
case SDL_EVENT_WINDOW_EXPOSED:
|
||||||
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
|
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
|
||||||
|
Reference in New Issue
Block a user