Skip to content

Commit

Permalink
allow to toggle windowed/maximize with a single key press
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyFr3sh committed Oct 11, 2024
1 parent 01fe4f2 commit 362d053
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
3 changes: 2 additions & 1 deletion inc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ typedef struct CNCDDRAWCONFIG
struct
{
int toggle_fullscreen;
int toggle_fullscreen2;
int toggle_maximize;
int toggle_maximize2;
int unlock_cursor1;
int unlock_cursor2;
int screenshot;
Expand All @@ -100,7 +102,6 @@ typedef struct CNCDDRAWCONFIG
BOOL stronghold_hack;
BOOL mgs_hack;
BOOL tlc_hack;
BOOL homm_hack;
BOOL carma95_hack;
BOOL sirtech_hack;
BOOL flightsim98_hack;
Expand Down
17 changes: 12 additions & 5 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ void cfg_load()
/* Hotkeys */

GET_INT(g_config.hotkeys.toggle_fullscreen, "keytogglefullscreen", VK_RETURN);
GET_INT(g_config.hotkeys.toggle_fullscreen2, "keytogglefullscreen2", 0);
GET_INT(g_config.hotkeys.toggle_maximize, "keytogglemaximize", VK_NEXT);
GET_INT(g_config.hotkeys.toggle_maximize2, "keytogglemaximize2", 0);
GET_INT(g_config.hotkeys.unlock_cursor1, "keyunlockcursor1", VK_TAB);
GET_INT(g_config.hotkeys.unlock_cursor2, "keyunlockcursor2", VK_RCONTROL);
GET_INT(g_config.hotkeys.screenshot, "keyscreenshot", VK_SNAPSHOT);
Expand All @@ -110,7 +112,6 @@ void cfg_load()
GET_BOOL(g_config.stronghold_hack, "stronghold_hack", FALSE);
GET_BOOL(g_config.mgs_hack, "mgs_hack", FALSE);
GET_BOOL(g_config.tlc_hack, "tlc_hack", FALSE);
GET_BOOL(g_config.homm_hack, "homm_hack", FALSE);
GET_BOOL(g_config.carma95_hack, "carma95_hack", FALSE);
GET_BOOL(g_config.sirtech_hack, "sirtech_hack", FALSE);
GET_BOOL(g_config.flightsim98_hack, "flightsim98_hack", FALSE);
Expand Down Expand Up @@ -346,9 +347,15 @@ static void cfg_create_ini()
"; Switch between windowed and fullscreen mode = [Alt] + ???\n"
"keytogglefullscreen=0x0D\n"
"\n"
"; Switch between windowed and fullscreen mode (single key) = ???\n"
"keytogglefullscreen2=0x00\n"
"\n"
"; Maximize window = [Alt] + ???\n"
"keytogglemaximize=0x22\n"
"\n"
"; Maximize window (single key) = ???\n"
"keytogglemaximize2=0x00\n"
"\n"
"; Unlock cursor 1 = [Ctrl] + ???\n"
"keyunlockcursor1=0x09\n"
"\n"
Expand Down Expand Up @@ -983,23 +990,23 @@ static void cfg_create_ini()
"[Heroes3]\n"
"renderer=opengl\n"
"game_handles_close=true\n"
"homm_hack=true\n"
"keytogglefullscreen2=0x73\n"
"\n"
"; Heroes of Might and Magic III HD Mod\n"
"[Heroes3 HD]\n"
"renderer=opengl\n"
"game_handles_close=true\n"
"homm_hack=true\n"
"keytogglefullscreen2=0x73\n"
"\n"
"; Heroes of Might and Magic III - Master of Puppets mod\n"
"[MoP]\n"
"game_handles_close=true\n"
"homm_hack=true\n"
"keytogglefullscreen2=0x73\n"
"\n"
"; Heroes of Might and Magic IV\n"
"[heroes4]\n"
"remove_menu=true\n"
"homm_hack=true\n"
"keytogglefullscreen2=0x73\n"
"\n"
"; Hard Truck: Road to Victory\n"
"[htruck]\n"
Expand Down
12 changes: 10 additions & 2 deletions src/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ LRESULT CALLBACK keyboard_hook_proc(int code, WPARAM wParam, LPARAM lParam)
return 1;
}

if (wParam == g_config.hotkeys.toggle_fullscreen2)
{
if (key_triggered)
util_toggle_fullscreen();

return 1;
}

if (wParam == g_config.hotkeys.toggle_maximize && alt_down && key_down)
{
if (key_triggered)
Expand All @@ -70,10 +78,10 @@ LRESULT CALLBACK keyboard_hook_proc(int code, WPARAM wParam, LPARAM lParam)
return 1;
}

if (wParam == VK_F4 && g_config.homm_hack) /* Heroes of Might and Magic 3 and 4 */
if (wParam == g_config.hotkeys.toggle_maximize2)
{
if (key_triggered)
util_toggle_fullscreen();
util_toggle_maximize();

return 1;
}
Expand Down

0 comments on commit 362d053

Please sign in to comment.