diff --git a/src/config/config.cpp b/src/config/config.cpp index 013ea41..013ea02 100644 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -56,6 +56,9 @@ void gebaar::config::Config::load_config() swipe_four_commands[8] = *config->get_qualified_as("commands.swipe.four.down"); swipe_four_commands[9] = *config->get_qualified_as("commands.swipe.four.right_down"); + pinch_in_command = *config->get_qualified_as("commands.pinch.in"); + pinch_out_command = *config->get_qualified_as("commands.pinch.out"); + loaded = true; } } diff --git a/src/config/config.h b/src/config/config.h index 499eb51..399accf 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -35,6 +35,8 @@ namespace gebaar::config { std::string swipe_three_commands[10]; std::string swipe_four_commands[10]; + std::string pinch_in_command; + std::string pinch_out_command; private: bool config_file_exists(); diff --git a/src/io/input.cpp b/src/io/input.cpp index 943dc96..a54af58 100644 --- a/src/io/input.cpp +++ b/src/io/input.cpp @@ -103,6 +103,24 @@ void gebaar::io::Input::handle_swipe_event_with_coords(libinput_event_gesture* g gesture_swipe_event.y += libinput_event_gesture_get_dy(gev); } +/** + * Handles pinch gesture events. + * Called at the end of the pinch event, so we just need to determine the pinch type. + * + * @param gev Gesture Event + */ +void gebaar::io::Input::handle_pinch_event(libinput_event_gesture* gev) +{ + double scale = libinput_event_gesture_get_scale(gev); + if (scale < 1) { + // pinch out + std::system(config->pinch_out_command.c_str()); + } else { + // pinch in + std::system(config->pinch_in_command.c_str()); + } +} + /** * Initialize the input system * @return bool @@ -214,6 +232,7 @@ void gebaar::io::Input::handle_event() case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE: break; case LIBINPUT_EVENT_GESTURE_PINCH_END: + handle_pinch_event(libinput_event_get_gesture_event(libinput_event)); break; case LIBINPUT_EVENT_SWITCH_TOGGLE: break; diff --git a/src/io/input.h b/src/io/input.h index b40d61f..2880279 100644 --- a/src/io/input.h +++ b/src/io/input.h @@ -74,6 +74,8 @@ namespace gebaar::io { void handle_swipe_event_without_coords(libinput_event_gesture* gev, bool begin); void handle_swipe_event_with_coords(libinput_event_gesture* gev); + + void handle_pinch_event(libinput_event_gesture* gev); }; }