Update comfortable-swipe status
This commit is contained in:
parent
cb51d47a60
commit
6a6bbf52e9
@ -90,7 +90,7 @@ void mouse_hold_gesture::do_mouseup(const char *mouseinput) {
|
|||||||
* Utility method to parse mouse number from input.
|
* Utility method to parse mouse number from input.
|
||||||
* Returns -1 on failure.
|
* Returns -1 on failure.
|
||||||
*/
|
*/
|
||||||
int mouse_hold_gesture::parse_mouse_button(const char *input) const {
|
int mouse_hold_gesture::parse_mouse_button(const char *input) {
|
||||||
// just move without holding button down
|
// just move without holding button down
|
||||||
if (std::strcmp(input, "move") == 0)
|
if (std::strcmp(input, "move") == 0)
|
||||||
return MOUSE_MOVE;
|
return MOUSE_MOVE;
|
||||||
|
|||||||
@ -52,7 +52,7 @@ namespace comfortable_swipe::gesture
|
|||||||
virtual bool is_mousedown() const;
|
virtual bool is_mousedown() const;
|
||||||
|
|
||||||
// utility method to parse mouse input given config characters
|
// utility method to parse mouse input given config characters
|
||||||
virtual int parse_mouse_button(const char*) const;
|
static int parse_mouse_button(const char*);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// command holders
|
// command holders
|
||||||
|
|||||||
@ -56,6 +56,10 @@ void status() {
|
|||||||
auto config = comfortable_swipe::util::read_config_file(
|
auto config = comfortable_swipe::util::read_config_file(
|
||||||
comfortable_swipe::util::conf_filename());
|
comfortable_swipe::util::conf_filename());
|
||||||
|
|
||||||
|
// formatting
|
||||||
|
const char *FORMAT_NO_ARGS = " %9s is %9s\n";
|
||||||
|
const char *FORMAT_ARGS = " %9s is %9s (%s)\n";
|
||||||
|
|
||||||
// print threshold
|
// print threshold
|
||||||
if (config.count("threshold") > 0) {
|
if (config.count("threshold") > 0) {
|
||||||
auto &threshold = config["threshold"];
|
auto &threshold = config["threshold"];
|
||||||
@ -66,25 +70,55 @@ void status() {
|
|||||||
std::regex("^\\d+(?:\\.\\d+)??$")) != 0);
|
std::regex("^\\d+(?:\\.\\d+)??$")) != 0);
|
||||||
|
|
||||||
// print status of threshold
|
// print status of threshold
|
||||||
std::printf(" %9s is %s (%s)\n", "threshold", ok ? "OK" : "INVALID",
|
std::printf(FORMAT_ARGS, "threshold", ok ? "VALID" : "INVALID",
|
||||||
threshold.data());
|
threshold.data());
|
||||||
} else
|
} else
|
||||||
std::printf(" %9s is OFF\n", "threshold");
|
std::printf(FORMAT_NO_ARGS, "threshold", "NOTSET");
|
||||||
|
|
||||||
|
// print mouse hold commands
|
||||||
|
const char *mouse_hold_commands[] = {"hold3", "hold4"};
|
||||||
|
bool has_mouse_hold[] = {false, false};
|
||||||
|
int index = 0;
|
||||||
|
for (const auto *command : mouse_hold_commands) {
|
||||||
|
if (config.count(command) > 0) {
|
||||||
|
// check if command is valid
|
||||||
|
const auto &input = config[command];
|
||||||
|
int button =
|
||||||
|
comfortable_swipe::gesture::mouse_hold_gesture::parse_mouse_button(
|
||||||
|
input.c_str());
|
||||||
|
if (button != comfortable_swipe::gesture::MOUSE_NONE) {
|
||||||
|
std::printf(FORMAT_ARGS, command, "VALID", input.c_str());
|
||||||
|
has_mouse_hold[index] = button;
|
||||||
|
} else {
|
||||||
|
std::printf(FORMAT_ARGS, command, "INVALID", input.c_str());
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
std::printf(FORMAT_NO_ARGS, command, "NOTSET");
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
|
||||||
// print swipe commands
|
// print swipe commands
|
||||||
for (auto &command :
|
for (auto &command :
|
||||||
comfortable_swipe::gesture::keyboard_swipe_gesture::command_map) {
|
comfortable_swipe::gesture::keyboard_swipe_gesture::command_map) {
|
||||||
if (config.count(command) > 0)
|
if (config.count(command) > 0) {
|
||||||
std::printf(" %9s is OK (%s)\n", command, config[command].data());
|
int fingers = int(command[strlen(command) - 1] - '0');
|
||||||
else
|
if (has_mouse_hold[fingers - 3]) {
|
||||||
std::printf(" %9s is OFF\n", command);
|
// command is disabled because mouse hold exists
|
||||||
|
std::printf(FORMAT_ARGS, command, "DISABLED", config[command].data());
|
||||||
|
} else {
|
||||||
|
// check if it's disabled by checking button
|
||||||
|
std::printf(FORMAT_ARGS, command, "VALID", config[command].data());
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
std::printf(FORMAT_NO_ARGS, command, "NOTSET");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (const std::runtime_error &e) {
|
} catch (const std::runtime_error &e) {
|
||||||
std::printf("config error: %s\n", e.what());
|
std::printf("config error: %s\n", e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
// print status
|
// print status
|
||||||
std::printf("autostart is %s\n", autostart_on ? "ON" : "OFF");
|
std::printf("\nautostart is %s\n", autostart_on ? "ON" : "OFF");
|
||||||
std::printf("comfortable-swipe program is %s\n",
|
std::printf("comfortable-swipe program is %s\n",
|
||||||
running ? "RUNNING" : "STOPPED");
|
running ? "RUNNING" : "STOPPED");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user