Skip to content

Commit

Permalink
added KEYBOARD_ESCAPE to bound keys, mapped to FN
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakz committed Mar 9, 2021
1 parent 11f1bf4 commit 10bb933
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
22 changes: 11 additions & 11 deletions desktop_version/src/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void titleinput(KeyPoll& key, Graphics& dwgfx, mapclass& map, Game& game, entity
game.jumpheld = true;
}

if (key.isDown(27) && game.currentmenuname != "youwannaquit" && game.menustart)
if (key.isDown(KEYBOARD_ESCAPE) && game.currentmenuname != "youwannaquit" && game.menustart)
{
music.playef(11, 10);
game.previousmenuname = game.currentmenuname;
Expand Down Expand Up @@ -1657,7 +1657,7 @@ void gameinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,

//Returning to editor mode must always be possible
if(map.custommode && !map.custommodeforreal){
if ((game.press_map || key.isDown(27)) && !game.mapheld){
if ((game.press_map || key.isDown(KEYBOARD_ESCAPE)) && !game.mapheld){
game.mapheld = true;
//Return to level editor
if (game.activeactivity > -1 && game.press_map){
Expand Down Expand Up @@ -1698,7 +1698,7 @@ void gameinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
}
*/
/*
if (key.isDown(27)) {
if (key.isDown(KEYBOARD_ESCAPE)) {
game.state = 0;
dwgfx.textboxremove();
Expand Down Expand Up @@ -1829,7 +1829,7 @@ void gameinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
}
}

if ((key.isDown(27)) && (!map.custommode || map.custommodeforreal))
if ((key.isDown(KEYBOARD_ESCAPE)) && (!map.custommode || map.custommodeforreal))
{
game.mapheld = true;
//Quit menu, same conditions as in game menu
Expand All @@ -1846,10 +1846,10 @@ void gameinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
if (map.extrarow) dwgfx.menuoffset -= 10;
}

if (key.keymap[SDLK_r] && game.deathseq<=0)// && map.custommode) //Have fun glitchrunners!
/*if (key.keymap[SDLK_r] && game.deathseq<=0)// && map.custommode) //Have fun glitchrunners!
{
game.deathseq = 30;
}
}*/

if (game.press_left)
{
Expand Down Expand Up @@ -1988,23 +1988,23 @@ void mapinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
if (game.menupage < 9)
{
if (key.isDown(KEYBOARD_ENTER)) game.press_map = true;
if (key.isDown(27))
if (key.isDown(KEYBOARD_ESCAPE))
{
game.mapheld = true;
game.menupage = 10;
}
}
else
{
if (key.isDown(KEYBOARD_ENTER) || key.isDown(27)) game.press_map = true;
if (key.isDown(KEYBOARD_ENTER) || key.isDown(KEYBOARD_ESCAPE)) game.press_map = true;
}

//In the menu system, all keypresses are single taps rather than holds. Therefore this test has to be done for all presses
if (!game.press_action && !game.press_left && !game.press_right)
{
game.jumpheld = false;
}
if (!game.press_map && !key.isDown(27))
if (!game.press_map && !key.isDown(KEYBOARD_ESCAPE))
{
game.mapheld = false;
}
Expand Down Expand Up @@ -2282,7 +2282,7 @@ void gamecompleteinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
game.press_action = true;
}
if (key.isDown(KEYBOARD_ENTER)) game.press_map = true;
//if (key.isDown(27)) { game.mapheld = true; game.menupage = 10; }
//if (key.isDown(KEYBOARD_ESCAPE)) { game.mapheld = true; game.menupage = 10; }

if (!game.mapheld)
{
Expand Down Expand Up @@ -2325,7 +2325,7 @@ void gamecompleteinput2(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map
game.press_action = true;
}
if (key.isDown(KEYBOARD_ENTER)) game.press_map = true;
//if (key.isDown(27)) { game.mapheld = true; game.menupage = 10; }
//if (key.isDown(KEYBOARD_ESCAPE)) { game.mapheld = true; game.menupage = 10; }

if (!game.mapheld)
{
Expand Down
1 change: 1 addition & 0 deletions desktop_version/src/KeyPoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum
KEYBOARD_RIGHT = SDLK_r,
KEYBOARD_ENTER = SDLK_s,
KEYBOARD_SPACE = SDLK_a,
KEYBOARD_ESCAPE = SDLK_k,

KEYBOARD_w = SDLK_UP,
KEYBOARD_s = SDLK_DOWN,
Expand Down
16 changes: 8 additions & 8 deletions desktop_version/src/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3663,7 +3663,7 @@ void editorinput( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, enti
};

if (key.isDown(KEYBOARD_ENTER)) game.press_map = true;
if (key.isDown(27) && !ed.settingskey)
if (key.isDown(KEYBOARD_ESCAPE) && !ed.settingskey)
{
ed.settingskey=true;
if(ed.textentry)
Expand Down Expand Up @@ -3703,7 +3703,7 @@ void editorinput( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, enti
}
}

if (!key.isDown(27))
if (!key.isDown(KEYBOARD_ESCAPE))
{
ed.settingskey=false;
}
Expand Down Expand Up @@ -3758,11 +3758,11 @@ void editorinput( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, enti
}

if (!game.press_action && !game.press_left && !game.press_right
&& !key.keymap[SDLK_UP] && !key.keymap[SDLK_DOWN] && !key.isDown(27)) game.jumpheld = false;
&& !key.keymap[SDLK_UP] && !key.keymap[SDLK_DOWN] && !key.isDown(KEYBOARD_ESCAPE)) game.jumpheld = false;
if (!game.jumpheld)
{
if (game.press_action || game.press_left || game.press_right || game.press_map
|| key.keymap[SDLK_UP] || key.keymap[SDLK_DOWN] || key.isDown(27))
|| key.keymap[SDLK_UP] || key.keymap[SDLK_DOWN] || key.isDown(KEYBOARD_ESCAPE))
{
game.jumpheld = true;
}
Expand All @@ -3785,7 +3785,7 @@ void editorinput( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, enti
ed.sbx = ed.sb[ed.pagey+ed.sby].length();
}

if (key.isDown(27))
if (key.isDown(KEYBOARD_ESCAPE))
{
ed.scripteditmod=false;
ed.settingsmod=false;
Expand All @@ -3795,7 +3795,7 @@ void editorinput( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, enti
else if(ed.scripthelppage==1)
{
//Script editor!
if (key.isDown(27))
if (key.isDown(KEYBOARD_ESCAPE))
{
ed.scripthelppage=0;
game.jumpheld = true;
Expand Down Expand Up @@ -3862,7 +3862,7 @@ void editorinput( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, enti
ed.sb[ed.pagey+ed.sby]=key.keybuffer;
ed.sbx = ed.sb[ed.pagey+ed.sby].length();

if(!game.press_map && !key.isDown(27)) game.mapheld=false;
if(!game.press_map && !key.isDown(KEYBOARD_ESCAPE)) game.mapheld=false;
if (!game.mapheld)
{
if(game.press_map)
Expand Down Expand Up @@ -3945,7 +3945,7 @@ void editorinput( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, enti
ed.Desc3=key.keybuffer;
}

if(!game.press_map && !key.isDown(27)) game.mapheld=false;
if(!game.press_map && !key.isDown(KEYBOARD_ESCAPE)) game.mapheld=false;
if (!game.mapheld)
{
if(game.press_map)
Expand Down

0 comments on commit 10bb933

Please sign in to comment.