diff --git a/src/studio/editors/code.c b/src/studio/editors/code.c index 97238f1c6..79eaceb57 100644 --- a/src/studio/editors/code.c +++ b/src/studio/editors/code.c @@ -2957,9 +2957,15 @@ static void processKeyboard(Code* code) } bool usedKeybinding = true; - + + if(hasJustSwitchedToCodeMode(code->studio)) + { + setJustSwitchedToCodeMode(code->studio, false); + return; // Skip processing other inputs for this frame + } + // handle bookmarks - if(keyWasPressed(code->studio, tic_key_f7)) + if(keyWasPressed(code->studio, tic_key_f1)) { if(ctrl && shift) { diff --git a/src/studio/studio.c b/src/studio/studio.c index 7bea1972a..6dbe8a420 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -1771,6 +1771,23 @@ static bool enterWasPressedOnce(Studio* studio) keyWasPressedOnce(studio, tic_key_numpadenter); } +#if defined(BUILD_EDITORS) +// These three are to fix the f1 hotkey conflict + +// Add a static variable in studio.c to track the mode switch +static bool justSwitchedToCodeMode = false; + +void setJustSwitchedToCodeMode(Studio* studio, bool value) +{ + justSwitchedToCodeMode = value; +} + +bool hasJustSwitchedToCodeMode(Studio* studio) +{ + return justSwitchedToCodeMode; +} +#endif + #if defined(BUILD_EDITORS) static bool showGameMenu(Studio* studio) @@ -1890,7 +1907,14 @@ static void processShortcuts(Studio* studio) if(!showGameMenu(studio) || studio->mode != TIC_RUN_MODE) { - if(keyWasPressedOnce(studio, tic_key_f1)) setStudioMode(studio, TIC_CODE_MODE); + if(keyWasPressedOnce(studio, tic_key_f1)) + { + if(studio->mode != TIC_CODE_MODE) + { + setStudioMode(studio, TIC_CODE_MODE); + setJustSwitchedToCodeMode(studio, true); + } + } else if(keyWasPressedOnce(studio, tic_key_f2)) setStudioMode(studio, TIC_SPRITE_MODE); else if(keyWasPressedOnce(studio, tic_key_f3)) setStudioMode(studio, TIC_MAP_MODE); else if(keyWasPressedOnce(studio, tic_key_f4)) setStudioMode(studio, TIC_SFX_MODE); diff --git a/src/studio/system.h b/src/studio/system.h index f7e970a9b..a1ba3a81e 100644 --- a/src/studio/system.h +++ b/src/studio/system.h @@ -156,6 +156,8 @@ typedef struct typedef struct Studio Studio; +void setJustSwitchedToCodeMode(Studio* studio, bool value); +bool hasJustSwitchedToCodeMode(Studio* studio); const tic_mem* studio_mem(Studio* studio); void studio_tick(Studio* studio, tic80_input input); void studio_sound(Studio* studio);