Skip to content

Commit

Permalink
events: ignore ALT mod if using Kbd-As-Controller
Browse files Browse the repository at this point in the history
disable fullscreen hotkey as such
  • Loading branch information
Apaczer committed Dec 28, 2024
1 parent 72d8a56 commit 7b1edab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Source/DiabloUI/diabloui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "DiabloUI/dialogs.h"
#include "DiabloUI/scrollbar.h"
#include "controls/controller.h"
#include "controls/devices/kbcontroller.h"
#include "controls/input.h"
#include "controls/menu_controls.h"
#include "controls/plrctrls.h"
Expand Down Expand Up @@ -463,6 +464,7 @@ void UiHandleEvents(SDL_Event *event)
return;
}

#if HAS_KBCTRL == 0
if (event->type == SDL_KEYDOWN && event->key.keysym.sym == SDLK_RETURN) {
const Uint8 *state = SDLC_GetKeyState();
if (state[SDLC_KEYSTATE_LALT] != 0 || state[SDLC_KEYSTATE_RALT] != 0) {
Expand All @@ -473,6 +475,7 @@ void UiHandleEvents(SDL_Event *event)
return;
}
}
#endif

if (event->type == SDL_QUIT)
diablo_quit(0);
Expand Down
10 changes: 9 additions & 1 deletion Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "debug.h"
#endif
#include "DiabloUI/diabloui.h"
#include "controls/devices/kbcontroller.h"
#include "controls/plrctrls.h"
#include "controls/remap_keyboard.h"
#include "diablo.h"
Expand Down Expand Up @@ -488,10 +489,13 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
}
sgOptions.Keymapper.KeyPressed(vkey);
if (vkey == SDLK_RETURN || vkey == SDLK_KP_ENTER) {
#if HAS_KBCTRL == 0
if ((modState & KMOD_ALT) != 0) {
sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen());
SaveOptions();
} else {
} else
#endif
{
control_type_message();
}
}
Expand Down Expand Up @@ -523,10 +527,12 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
sgOptions.Keymapper.KeyPressed(vkey);

if (PauseMode == 2) {
#if HAS_KBCTRL == 0
if ((vkey == SDLK_RETURN || vkey == SDLK_KP_ENTER) && (modState & KMOD_ALT) != 0) {
sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen());
SaveOptions();
}
#endif
return;
}

Expand Down Expand Up @@ -562,8 +568,10 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
case SDLK_RETURN:
case SDLK_KP_ENTER:
if ((modState & KMOD_ALT) != 0) {
#if HAS_KBCTRL == 0
sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen());
SaveOptions();
#endif
} else if (stextflag != TalkID::None) {
StoreEnter();
} else if (QuestLogIsOpen) {
Expand Down

0 comments on commit 7b1edab

Please sign in to comment.