mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
Directly toggle fullscreen if keybind pressed in key.Poll()
This moves the responsibility of toggling fullscreen when any of the three toggle fullscreen keybinds are pressed (F11, Alt+Enter, Alt+F) directly into key.Poll() itself, and not its caller (which is main() - more specifically, fixedloop()). Furthermore, the fullscreen toggle itself has been moved to a separate function that key.Poll() just calls, to prevent cluttering key.Poll() with more business logic (the function is already quite big enough as it is). As part of my work in re-removing the 1-frame input delay in #535, I'm moving the callsite of key.Poll() around, and I don't want to have to lug this block of code around with it. I'd rather refactor it upfront than touch any more lines than necessary in that PR.
This commit is contained in:
parent
babd86916c
commit
2608db9151
3 changed files with 25 additions and 17 deletions
|
@ -41,7 +41,6 @@ KeyPoll::KeyPoll(void)
|
||||||
leftbutton=0; rightbutton=0; middlebutton=0;
|
leftbutton=0; rightbutton=0; middlebutton=0;
|
||||||
mx=0; my=0;
|
mx=0; my=0;
|
||||||
resetWindow = 0;
|
resetWindow = 0;
|
||||||
toggleFullscreen = false;
|
|
||||||
pressedbackspace=false;
|
pressedbackspace=false;
|
||||||
|
|
||||||
useFullscreenSpaces = false;
|
useFullscreenSpaces = false;
|
||||||
|
@ -78,9 +77,27 @@ bool KeyPoll::textentry(void)
|
||||||
return SDL_IsTextInputActive() == SDL_TRUE;
|
return SDL_IsTextInputActive() == SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KeyPoll::toggleFullscreen(void)
|
||||||
|
{
|
||||||
|
if (graphics.screenbuffer != NULL)
|
||||||
|
{
|
||||||
|
graphics.screenbuffer->toggleFullScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
keymap.clear(); /* we lost the input due to a new window. */
|
||||||
|
if (game.glitchrunnermode)
|
||||||
|
{
|
||||||
|
game.press_left = false;
|
||||||
|
game.press_right = false;
|
||||||
|
game.press_action = true;
|
||||||
|
game.press_map = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void KeyPoll::Poll(void)
|
void KeyPoll::Poll(void)
|
||||||
{
|
{
|
||||||
bool altpressed = false;
|
bool altpressed = false;
|
||||||
|
bool fullscreenkeybind = false;
|
||||||
SDL_Event evt;
|
SDL_Event evt;
|
||||||
while (SDL_PollEvent(&evt))
|
while (SDL_PollEvent(&evt))
|
||||||
{
|
{
|
||||||
|
@ -106,7 +123,7 @@ void KeyPoll::Poll(void)
|
||||||
bool f11pressed = evt.key.keysym.sym == SDLK_F11;
|
bool f11pressed = evt.key.keysym.sym == SDLK_F11;
|
||||||
if ((altpressed && (returnpressed || fpressed)) || f11pressed)
|
if ((altpressed && (returnpressed || fpressed)) || f11pressed)
|
||||||
{
|
{
|
||||||
toggleFullscreen = true;
|
fullscreenkeybind = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textentry())
|
if (textentry())
|
||||||
|
@ -321,6 +338,11 @@ void KeyPoll::Poll(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fullscreenkeybind)
|
||||||
|
{
|
||||||
|
toggleFullscreen();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyPoll::isDown(SDL_Keycode key)
|
bool KeyPoll::isDown(SDL_Keycode key)
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
bool resetWindow;
|
bool resetWindow;
|
||||||
|
|
||||||
bool quitProgram;
|
bool quitProgram;
|
||||||
bool toggleFullscreen;
|
void toggleFullscreen(void);
|
||||||
|
|
||||||
int sensitivity;
|
int sensitivity;
|
||||||
|
|
||||||
|
|
|
@ -454,20 +454,6 @@ static void inline fixedloop(void)
|
||||||
NETWORK_update();
|
NETWORK_update();
|
||||||
|
|
||||||
key.Poll();
|
key.Poll();
|
||||||
if(key.toggleFullscreen)
|
|
||||||
{
|
|
||||||
gameScreen.toggleFullScreen();
|
|
||||||
key.toggleFullscreen = false;
|
|
||||||
|
|
||||||
key.keymap.clear(); //we lost the input due to a new window.
|
|
||||||
if (game.glitchrunnermode)
|
|
||||||
{
|
|
||||||
game.press_left = false;
|
|
||||||
game.press_right = false;
|
|
||||||
game.press_action = true;
|
|
||||||
game.press_map = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!key.isActive)
|
if(!key.isActive)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue