Skip to content

Commit 9a9989d

Browse files
committed
use keymap rom and keymap default
Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
1 parent 3c72c25 commit 9a9989d

2 files changed

Lines changed: 16 additions & 33 deletions

File tree

RetroFE/Source/Execute/Launcher.cpp

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -120,37 +120,16 @@ bool Launcher::run(std::string collection, Item *collectionItem)
120120
selectedItemsDirectory,
121121
collection);
122122

123-
/* Apply key mapping for selected item's directory if found */
124-
std::string selectedItemDirnameKeyfile = Utils::getDirectory(selectedItemsPath) + "/default_config.key";
125-
if (!access(selectedItemDirnameKeyfile.c_str(), R_OK)) {
123+
/* Create shell cmd */
124+
std::string cmd = SHELL_CMD_MAPPING_ROM;
125+
cmd += " \"" + selectedItemsPath + "\"";
126126

127-
/* Create shell cmd */
128-
std::string cmd = SHELL_CMD_MAPPING_SET;
129-
cmd += " " + selectedItemDirnameKeyfile;
130-
131-
/* Log shell cmd */
132-
Logger::write(Logger::ZONE_INFO, "Launcher", "Applying keymap file: " + selectedItemDirnameKeyfile);
133-
printf("Applying keymap file cmd: \"%s\"\n", cmd.c_str());
134-
135-
/* Launch shell cmd */
136-
system(cmd.c_str());
137-
}
138-
139-
/* Apply specific key mapping for selected item if found */
140-
std::string selectedItemBasenameKeyfile = Utils::removeExtension(selectedItemsPath) + ".key";
141-
if (!access(selectedItemBasenameKeyfile.c_str(), R_OK)) {
142-
143-
/* Create shell cmd */
144-
std::string cmd = SHELL_CMD_MAPPING_SET;
145-
cmd += " " + selectedItemBasenameKeyfile;
146-
147-
/* Log shell cmd */
148-
Logger::write(Logger::ZONE_INFO, "Launcher", "Applying keymap file: " + selectedItemBasenameKeyfile);
149-
printf("Applying keymap file cmd: \"%s\"\n", cmd.c_str());
127+
/* Log shell cmd */
128+
Logger::write(Logger::ZONE_INFO, "Launcher", "Applying keymap rom: " + selectedItemsPath);
129+
printf("Applying keymap rom cmd: \"%s\"\n", cmd.c_str());
150130

151-
/* Launch shell cmd */
152-
system(cmd.c_str());
153-
}
131+
/* Launch shell cmd */
132+
system(cmd.c_str());
154133

155134
/* Restart audio amp */
156135
system(SHELL_CMD_TURN_AMPLI_ON);
@@ -165,8 +144,12 @@ bool Launcher::run(std::string collection, Item *collectionItem)
165144
/* Stop audio amp */
166145
system(SHELL_CMD_TURN_AMPLI_OFF);
167146

168-
/* Reset default key mapping */
169-
system(SHELL_CMD_MAPPING_RESET);
147+
/* Log shell cmd */
148+
Logger::write(Logger::ZONE_INFO, "Launcher", "Applying keymap default");
149+
printf("Applying keymap default cmd: \"%s\"\n", SHELL_CMD_MAPPING_DEFAULT);
150+
151+
/* Restore default key mapping */
152+
system(SHELL_CMD_MAPPING_DEFAULT);
170153

171154
/* Restore stored PID */
172155
char shellCmd[20];

RetroFE/Source/Utility/Utils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#define SHELL_CMD_RECORD_PID "record_pid"
2626
#define SHELL_CMD_TURN_AMPLI_ON "start_audio_amp 1"
2727
#define SHELL_CMD_TURN_AMPLI_OFF "start_audio_amp 0"
28-
#define SHELL_CMD_MAPPING_SET "keymap"
29-
#define SHELL_CMD_MAPPING_RESET "keymap reset"
28+
#define SHELL_CMD_MAPPING_ROM "keymap rom"
29+
#define SHELL_CMD_MAPPING_DEFAULT "keymap default"
3030

3131
class Utils
3232
{

0 commit comments

Comments
 (0)