use keymap rom and keymap default

Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
Vincent-FK 2021-04-26 08:15:14 +02:00
parent 3c72c25b9e
commit 9a9989d6ac
2 changed files with 16 additions and 33 deletions

View File

@ -120,37 +120,16 @@ bool Launcher::run(std::string collection, Item *collectionItem)
selectedItemsDirectory, selectedItemsDirectory,
collection); collection);
/* Apply key mapping for selected item's directory if found */
std::string selectedItemDirnameKeyfile = Utils::getDirectory(selectedItemsPath) + "/default_config.key";
if (!access(selectedItemDirnameKeyfile.c_str(), R_OK)) {
/* Create shell cmd */ /* Create shell cmd */
std::string cmd = SHELL_CMD_MAPPING_SET; std::string cmd = SHELL_CMD_MAPPING_ROM;
cmd += " " + selectedItemDirnameKeyfile; cmd += " \"" + selectedItemsPath + "\"";
/* Log shell cmd */ /* Log shell cmd */
Logger::write(Logger::ZONE_INFO, "Launcher", "Applying keymap file: " + selectedItemDirnameKeyfile); Logger::write(Logger::ZONE_INFO, "Launcher", "Applying keymap rom: " + selectedItemsPath);
printf("Applying keymap file cmd: \"%s\"\n", cmd.c_str()); printf("Applying keymap rom cmd: \"%s\"\n", cmd.c_str());
/* Launch shell cmd */ /* Launch shell cmd */
system(cmd.c_str()); system(cmd.c_str());
}
/* Apply specific key mapping for selected item if found */
std::string selectedItemBasenameKeyfile = Utils::removeExtension(selectedItemsPath) + ".key";
if (!access(selectedItemBasenameKeyfile.c_str(), R_OK)) {
/* Create shell cmd */
std::string cmd = SHELL_CMD_MAPPING_SET;
cmd += " " + selectedItemBasenameKeyfile;
/* Log shell cmd */
Logger::write(Logger::ZONE_INFO, "Launcher", "Applying keymap file: " + selectedItemBasenameKeyfile);
printf("Applying keymap file cmd: \"%s\"\n", cmd.c_str());
/* Launch shell cmd */
system(cmd.c_str());
}
/* Restart audio amp */ /* Restart audio amp */
system(SHELL_CMD_TURN_AMPLI_ON); system(SHELL_CMD_TURN_AMPLI_ON);
@ -165,8 +144,12 @@ bool Launcher::run(std::string collection, Item *collectionItem)
/* Stop audio amp */ /* Stop audio amp */
system(SHELL_CMD_TURN_AMPLI_OFF); system(SHELL_CMD_TURN_AMPLI_OFF);
/* Reset default key mapping */ /* Log shell cmd */
system(SHELL_CMD_MAPPING_RESET); Logger::write(Logger::ZONE_INFO, "Launcher", "Applying keymap default");
printf("Applying keymap default cmd: \"%s\"\n", SHELL_CMD_MAPPING_DEFAULT);
/* Restore default key mapping */
system(SHELL_CMD_MAPPING_DEFAULT);
/* Restore stored PID */ /* Restore stored PID */
char shellCmd[20]; char shellCmd[20];

View File

@ -25,8 +25,8 @@
#define SHELL_CMD_RECORD_PID "record_pid" #define SHELL_CMD_RECORD_PID "record_pid"
#define SHELL_CMD_TURN_AMPLI_ON "start_audio_amp 1" #define SHELL_CMD_TURN_AMPLI_ON "start_audio_amp 1"
#define SHELL_CMD_TURN_AMPLI_OFF "start_audio_amp 0" #define SHELL_CMD_TURN_AMPLI_OFF "start_audio_amp 0"
#define SHELL_CMD_MAPPING_SET "keymap" #define SHELL_CMD_MAPPING_ROM "keymap rom"
#define SHELL_CMD_MAPPING_RESET "keymap reset" #define SHELL_CMD_MAPPING_DEFAULT "keymap default"
class Utils class Utils
{ {