Compare commits
3 Commits
0.1.0
...
eebd03bb4e
| Author | SHA1 | Date | |
|---|---|---|---|
|
eebd03bb4e
|
|||
|
65bc8e9b18
|
|||
|
6021ec89f5
|
@@ -12,7 +12,7 @@ For info that with "EVIOCGRAB" the keyboard events can be consumed exclusively b
|
||||
|
||||
## Configuration
|
||||
|
||||
The configuration can be provided by either specifying a config file path via the `-c` parameter. If no parameter is provided, the default config path under `$HOME/.config/UsbMakroBoard.yaml` is used.
|
||||
The configuration can be provided by either specifying a config file path via the `-c` parameter. If no parameter is provided, the default config path under `$HOME/.config/usbMakroBoard.yaml` is used.
|
||||
|
||||
Find the config schema in [schemas/config.schema.json](./schemas/config.schema.json) as well as a default config in [config.yaml](./config.yaml).
|
||||
|
||||
|
||||
23
src/main.cpp
23
src/main.cpp
@@ -7,7 +7,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <linux/input.h>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <spdlog/sinks/stdout_sinks.h>
|
||||
#include <yaml-cpp/yaml.h>
|
||||
@@ -58,7 +57,7 @@ std::pair<int, int> mapKeyEventToRowColumn(int keyEventNumber, const std::unorde
|
||||
|
||||
std::string getConfigPathFromCliArguments(int argc, char *argv[])
|
||||
{
|
||||
std::string configPath;
|
||||
std::string configPath = "";
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "c:")) != -1)
|
||||
{
|
||||
@@ -68,30 +67,14 @@ std::string getConfigPathFromCliArguments(int argc, char *argv[])
|
||||
configPath = optarg;
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Usage: " << argv[0] << " [-c config_file_path]\n";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (configPath.empty()) {
|
||||
const char *home = std::getenv("HOME");
|
||||
if (home != nullptr) {
|
||||
configPath = std::string(home) + "/.config/usbMakroBoard.yaml";
|
||||
}
|
||||
else {
|
||||
std::cerr << "HOME environment variable is not set. Exiting.\n";
|
||||
exit(EXIT_FAILURE);
|
||||
std::cout << "No config path provided. Using default config path: $HOME/.config/usbMakroBoard.yaml\n";
|
||||
configPath = "$HOME/.config/usbMakroBoard.yaml";
|
||||
}
|
||||
}
|
||||
|
||||
return configPath;
|
||||
}
|
||||
|
||||
YAML::Node loadConfig(const std::string &configPath)
|
||||
{
|
||||
return YAML::LoadFile(configPath);
|
||||
}
|
||||
|
||||
int openDevice(const std::string &devicePath)
|
||||
{
|
||||
int fdKeyboard = open(devicePath.c_str(), O_RDONLY);
|
||||
|
||||
Reference in New Issue
Block a user