mirror of
https://github.com/encounter/SDL.git
synced 2025-12-20 18:29:22 +00:00
Implemented SDL_CaptureMouse().
This commit is contained in:
@@ -999,10 +999,12 @@ default: return "???";
|
||||
static void
|
||||
SDLTest_PrintEvent(SDL_Event * event)
|
||||
{
|
||||
#if 0
|
||||
if ((event->type == SDL_MOUSEMOTION) || (event->type == SDL_FINGERMOTION)) {
|
||||
/* Mouse and finger motion are really spammy */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (event->type) {
|
||||
case SDL_WINDOWEVENT:
|
||||
@@ -1379,6 +1381,14 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (withShift) {
|
||||
SDL_Window *current_win = SDL_GetKeyboardFocus();
|
||||
if (current_win) {
|
||||
const SDL_bool shouldCapture = (SDL_GetWindowFlags(current_win) & SDL_WINDOW_MOUSE_CAPTURE) == 0;
|
||||
const int rc = SDL_CaptureMouse(shouldCapture);
|
||||
printf("%sapturing mouse %s!\n", shouldCapture ? "C" : "Unc", (rc == 0) ? "succeeded" : "failed");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDLK_v:
|
||||
if (withControl) {
|
||||
|
||||
Reference in New Issue
Block a user