Added alt+enter fullscreen keybind

This commit is contained in:
Marcus Minhorst 2025-08-11 12:34:42 -04:00 committed by Rachael Alexanderson
commit daff54fe1c
4 changed files with 26 additions and 10 deletions

View file

@ -34,15 +34,19 @@
*/
#include "c_bind.h"
#include "d_eventbase.h"
#include "c_console.h"
#include "c_cvars.h"
#include "d_eventbase.h"
#include "d_gui.h"
#include "menu.h"
#include "utf8.h"
#include "m_joy.h"
#include "vm.h"
#include "gamestate.h"
#include "i_interface.h"
#include "keydef.h"
#include "m_joy.h"
#include "menu.h"
#include "utf8.h"
#include "vm.h"
extern bool ToggleFullscreen;
int eventhead;
int eventtail;
@ -73,6 +77,7 @@ void D_ProcessEvents (void)
while (eventtail != eventhead)
{
event_t *ev = &events[eventtail];
eventtail = (eventtail + 1) & (MAXEVENTS - 1);
if (ev->type == EV_KeyUp && keywasdown[ev->data1])
@ -86,6 +91,16 @@ void D_ProcessEvents (void)
if (ev->type == EV_DeviceChange)
UpdateJoystickMenu(I_UpdateDeviceList());
#if defined(__linux__) || defined(_WIN32)
// I cannot test on macos, so it is disabled for now
if ((ev->type == EV_KeyDown && ev->data1 == KEY_ENTER && (ev->data3 & GKM_ALT))
|| (ev->type == EV_GUI_Event && ev->subtype == EV_GUI_KeyDown && ev->data1 == GK_RETURN && (ev->data3 & GKM_ALT)))
{
ToggleFullscreen = !ToggleFullscreen;
continue;
}
#endif
// allow the game to intercept Escape before dispatching it.
if (ev->type != EV_KeyDown || ev->data1 != KEY_ESCAPE || !sysCallbacks.WantEscape || !sysCallbacks.WantEscape())
{

View file

@ -449,6 +449,10 @@ void MessagePump (const SDL_Event &sev)
{
event.data2 = sev.key.keysym.sym;
}
SDL_Keymod kmod = SDL_GetModState();
event.data3 = ((kmod & KMOD_SHIFT) ? GKM_SHIFT : 0) |
((kmod & KMOD_CTRL) ? GKM_CTRL : 0) |
((kmod & KMOD_ALT) ? GKM_ALT : 0);
D_PostEvent (&event);
}
}

View file

@ -441,11 +441,6 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_SYSKEYDOWN:
// Pressing Alt+Enter can toggle between fullscreen and windowed.
if (wParam == VK_RETURN && k_allowfullscreentoggle && !(lParam & 0x40000000))
{
ToggleFullscreen = !ToggleFullscreen;
}
// Pressing Alt+F4 quits the program.
if (wParam == VK_F4 && !(lParam & 0x40000000))
{

View file

@ -277,7 +277,9 @@ void FKeyboard::PostKeyEvent(int key, INTBOOL down, bool foreground)
ev.data1 = key;
ev.data2 = Convert[key];
ev.data3 = 0;
if (CheckKey(DIK_LSHIFT) || CheckKey(DIK_RSHIFT)) ev.data3 |= 1;
if (CheckKey(DIK_LSHIFT) || CheckKey(DIK_RSHIFT)) ev.data3 |= GKM_SHIFT;
if (CheckKey(DIK_LCONTROL) || CheckKey(DIK_RCONTROL)) ev.data3 |= GKM_CTRL;
if (CheckKey(DIK_LALT) || CheckKey(DIK_RALT)) ev.data3 |= GKM_ALT;
D_PostEvent(&ev);
}