Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for pinch in/out gestures #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ void gebaar::config::Config::load_config()
swipe_four_commands[8] = *config->get_qualified_as<std::string>("commands.swipe.four.down");
swipe_four_commands[9] = *config->get_qualified_as<std::string>("commands.swipe.four.right_down");

pinch_in_command = *config->get_qualified_as<std::string>("commands.pinch.in");
pinch_out_command = *config->get_qualified_as<std::string>("commands.pinch.out");

loaded = true;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
19 changes: 19 additions & 0 deletions src/io/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/io/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}

Expand Down