Skip to content

Commit adbebb0

Browse files
committed
add FunKey menu
Signed-off-by: Michel-FK <[email protected]>
1 parent 5edf05f commit adbebb0

File tree

9 files changed

+1550
-0
lines changed

9 files changed

+1550
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ set(DinguxCommander_SRCS
6262
fileutils.cpp
6363
keyboard.cpp
6464
main.cpp
65+
menu.cpp
6566
panel.cpp
6667
resourceManager.cpp
6768
screen.cpp

commander.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "screen.h"
1717
#include "sdlutils.h"
1818
#include "text_viewer.h"
19+
#include "menu.h"
1920

2021
#define SPLITTER_LINE_W static_cast<int>(1 * screen.ppu_x)
2122
#define X_LEFT static_cast<int>(1 * screen.ppu_x)
@@ -103,6 +104,13 @@ const bool CCommander::keyPress(const SDL_Event &p_event)
103104
CWindow::keyPress(p_event);
104105
const auto sym = p_event.key.keysym.sym;
105106
const auto &c = config();
107+
if (sym == c.key_menu) {
108+
if (FK_RunMenu(screen.surface) == MENU_RETURN_EXIT) {
109+
// Quit
110+
m_retVal = -1;
111+
}
112+
return true;
113+
}
106114
if (sym == c.key_system) {
107115
if (openSystemMenu()) m_panelSource->refresh();
108116
return true;

config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ SDLC_Keycode parseKeycode(const std::string &value)
9393
// We support a few common SDLK codes as config values.
9494
// We then allow single-char keys and ints for the rest.
9595
static const std::unordered_map<std::string, SDLC_Keycode> kSdlkToInt {
96+
{ "SDLK_MENU", SDLK_MENU },
9697
{ "SDLK_BACKSPACE", SDLK_BACKSPACE },
9798
{ "SDLK_DOWN", SDLK_DOWN },
9899
{ "SDLK_ESCAPE", SDLK_ESCAPE },
@@ -179,6 +180,7 @@ void Config::Load(const std::string &path)
179180

180181
CFG_BOOL(osk_key_system_is_backspace)
181182

183+
CFG_SDLK(key_menu)
182184
CFG_SDLK(key_down)
183185
CFG_SDLK(key_left)
184186
CFG_SDLK(key_open)

config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct Config {
3131
std::string res_dir { RES_DIR };
3232

3333
// Keyboard key code mappings
34+
SDLC_Keycode key_menu = MYKEY_MENU;
3435
SDLC_Keycode key_down = MYKEY_DOWN;
3536
SDLC_Keycode key_left = MYKEY_LEFT;
3637
SDLC_Keycode key_open = MYKEY_OPEN;

config_def.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
#define FILE_SYSTEM "/dev/sda4"
4747
#endif
4848

49+
#ifndef MYKEY_MENU
50+
#define MYKEY_MENU SDLK_MENU
51+
#endif
4952
#ifndef MYKEY_UP
5053
#define MYKEY_UP SDLK_UP
5154
#endif

main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "resourceManager.h"
1414
#include "screen.h"
1515
#include "sdlutils.h"
16+
#include "menu.h"
1617

1718
// Globals
1819
const SDL_Color Globals::g_colorTextNormal = {COLOR_TEXT_NORMAL};
@@ -117,6 +118,9 @@ int main(int argc, char *argv[])
117118
SDL_EnableUNICODE(1);
118119
#endif
119120

121+
// Init menu
122+
Menu::init();
123+
120124
// Create instances
121125
CResourceManager::instance();
122126

0 commit comments

Comments
 (0)