Merge current branch with upstream 'master'
This commit is contained in:
commit
0fdf94b723
31
README.md
31
README.md
@ -41,7 +41,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
|
|||||||
```
|
```
|
||||||
comfortable-swipe autostart
|
comfortable-swipe autostart
|
||||||
```
|
```
|
||||||
5. _Optional_: Change keyboard [configurations](#configurations). After making changes, run
|
5. _Optional_: Change [configurations](#configurations) (see below). After making changes, run
|
||||||
```
|
```
|
||||||
comfortable-swipe restart
|
comfortable-swipe restart
|
||||||
```
|
```
|
||||||
@ -78,9 +78,38 @@ Taken from `man xdotool`:
|
|||||||
Refer to https://www.linux.org/threads/xdotool-keyboard.10528/ for a complete list of keycodes you can use.
|
Refer to https://www.linux.org/threads/xdotool-keyboard.10528/ for a complete list of keycodes you can use.
|
||||||
|
|
||||||
|
|
||||||
|
## Debugging
|
||||||
|
|
||||||
|
You can check your touchpad driver by running `comfortable-swipe debug`. This is an alias of `libinput debug-events`. This logs all gestures you make on your touchpad, along with other input-based events that can be captured by libinput.
|
||||||
|
|
||||||
|
A working swipe gesture will show the following:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ comfortable-swipe debug
|
||||||
|
...
|
||||||
|
-event9 DEVICE_ADDED TouchPad seat0 default group7 cap:pg size 70x50mm tap(dl off) left scroll-nat scroll-2fg-edge click-buttonareas-clickfinger dwt-on
|
||||||
|
...
|
||||||
|
event9 GESTURE_SWIPE_BEGIN +2.03s 3
|
||||||
|
event9 GESTURE_SWIPE_UPDATE +2.03s 3 -9.95/ 2.64 (-26.90/ 7.12 unaccelerated)
|
||||||
|
event9 GESTURE_SWIPE_UPDATE +2.03s 3 -10.44/ 3.19 (-28.22/ 8.62 unaccelerated)
|
||||||
|
event9 GESTURE_SWIPE_UPDATE +2.04s 3 -9.71/ 2.64 (-26.25/ 7.12 unaccelerated)
|
||||||
|
event9 GESTURE_SWIPE_UPDATE +2.05s 3 -8.98/ 2.64 (-24.28/ 7.12 unaccelerated)
|
||||||
|
event9 GESTURE_SWIPE_UPDATE +2.06s 3 -7.40/ 2.36 (-20.01/ 6.37 unaccelerated)
|
||||||
|
event9 GESTURE_SWIPE_UPDATE +2.06s 3 -6.31/ 2.50 (-17.06/ 6.75 unaccelerated)
|
||||||
|
event9 GESTURE_SWIPE_UPDATE +2.07s 3 -5.34/ 1.80 (-14.44/ 4.87 unaccelerated)
|
||||||
|
event9 GESTURE_SWIPE_UPDATE +2.08s 3 -4.61/ 2.08 (-12.47/ 5.62 unaccelerated)
|
||||||
|
event9 GESTURE_SWIPE_UPDATE +2.09s 3 -4.49/ 1.53 (-12.14/ 4.12 unaccelerated)
|
||||||
|
event9 GESTURE_SWIPE_UPDATE +2.09s 3 -4.01/ 1.25 (-10.83/ 3.37 unaccelerated)
|
||||||
|
event9 GESTURE_SWIPE_UPDATE +2.10s 3 -4.13/ 0.42 (-11.15/ 1.12 unaccelerated)
|
||||||
|
event9 GESTURE_SWIPE_END +2.11s 3
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
If you can see `GESTURE_SWIPE_XXX` in your output, that means your touchpad supports multi-touch swipe gestures.
|
||||||
|
|
||||||
## Uninstall
|
## Uninstall
|
||||||
Download the `uninstall` script then run `bash uninstall`
|
Download the `uninstall` script then run `bash uninstall`
|
||||||
|
|
||||||
|
|
||||||
## Bug Reports
|
## Bug Reports
|
||||||
Create an issue [here](https://github.com/Hikari9/comfortable-swipe-ubuntu/issues/new) to report a bug.
|
Create an issue [here](https://github.com/Hikari9/comfortable-swipe-ubuntu/issues/new) to report a bug.
|
||||||
|
|||||||
2
comfortable-swipe.compile.sh
Executable file
2
comfortable-swipe.compile.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
g++ $(dirname $0)/comfortable-swipe.cpp -std=c++11 -O2 -lxdo -Wno-unused-result -o $1
|
||||||
@ -16,8 +16,6 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Compile: g++ main.cpp -std=c++11 -lxdo
|
|
||||||
|
|
||||||
#include <string> // std::string
|
#include <string> // std::string
|
||||||
#include "lib/comfortable_swipe"
|
#include "lib/comfortable_swipe"
|
||||||
|
|
||||||
@ -45,6 +43,9 @@ int main(int argc, char** args)
|
|||||||
else if (arg == "autostart")
|
else if (arg == "autostart")
|
||||||
comfortable_swipe::service::autostart();
|
comfortable_swipe::service::autostart();
|
||||||
|
|
||||||
|
else if (arg == "debug")
|
||||||
|
comfortable_swipe::service::debug();
|
||||||
|
|
||||||
else /* if (arg == "help") */
|
else /* if (arg == "help") */
|
||||||
comfortable_swipe::service::help();
|
comfortable_swipe::service::help();
|
||||||
}
|
}
|
||||||
39
install
39
install
@ -2,8 +2,9 @@
|
|||||||
# prefer running as root
|
# prefer running as root
|
||||||
DIR=$(dirname $0)
|
DIR=$(dirname $0)
|
||||||
PROGRAM=/usr/local/bin/comfortable-swipe
|
PROGRAM=/usr/local/bin/comfortable-swipe
|
||||||
|
COMPILE=$DIR/comfortable-swipe.compile.sh
|
||||||
CONF_PATH=/usr/local/share/comfortable-swipe/comfortable-swipe.conf
|
CONF_PATH=/usr/local/share/comfortable-swipe/comfortable-swipe.conf
|
||||||
DCONF_PATH=$DIR/src/defaults.conf
|
DCONF_PATH=$DIR/defaults.conf
|
||||||
OLD_CONF_PATH=${XDG_CONFIG_HOME:-$HOME/.config}/comfortable-swipe.conf
|
OLD_CONF_PATH=${XDG_CONFIG_HOME:-$HOME/.config}/comfortable-swipe.conf
|
||||||
|
|
||||||
if [ -x "$(command -v $PROGRAM)" ]; then
|
if [ -x "$(command -v $PROGRAM)" ]; then
|
||||||
@ -16,6 +17,20 @@ abort () {
|
|||||||
exec echo "Installation aborted"
|
exec echo "Installation aborted"
|
||||||
}
|
}
|
||||||
sudo mkdir -p $(dirname $CONF_PATH) || abort
|
sudo mkdir -p $(dirname $CONF_PATH) || abort
|
||||||
|
|
||||||
|
# check if "-y" or "--yes" is passed as an argument
|
||||||
|
YES=false
|
||||||
|
while test $# -gt 0
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
-y) YES=true
|
||||||
|
;;
|
||||||
|
--yes) YES=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
sudo chown $USER $(dirname $CONF_PATH)
|
sudo chown $USER $(dirname $CONF_PATH)
|
||||||
if [ ! -f $CONF_PATH ]; then
|
if [ ! -f $CONF_PATH ]; then
|
||||||
if [ ! -f $OLD_CONF_PATH ]; then
|
if [ ! -f $OLD_CONF_PATH ]; then
|
||||||
@ -29,15 +44,17 @@ if [ ! -f $CONF_PATH ]; then
|
|||||||
else
|
else
|
||||||
# config file found, ask user if overwrite
|
# config file found, ask user if overwrite
|
||||||
echo "Old conf file found in $CONF_PATH"
|
echo "Old conf file found in $CONF_PATH"
|
||||||
read -r -p "Keep the old conf file? (default: yes) [Y/n] " response
|
if [ $YES == false ]; then
|
||||||
response=${response,,} # tolower
|
read -r -p "Keep the old conf file? (default: yes) [Y/n] " response
|
||||||
if [[ "$response" =~ ^(no|n)$ ]]; then
|
response=${response,,} # tolower
|
||||||
read -r -p "Conf file will be overwritten. Are you sure? [Y/n] " response
|
if [[ "$response" =~ ^(no|n)$ ]]; then
|
||||||
response=${response,,}
|
read -r -p "Conf file will be overwritten. Are you sure? [Y/n] " response
|
||||||
if [[ "$response" =~ ^(yes|y)$ ]]; then
|
response=${response,,}
|
||||||
cat $DCONF_PATH > $CONF_PATH || abort
|
if [[ "$response" =~ ^(yes|y)$ ]]; then
|
||||||
else
|
cat $DCONF_PATH > $CONF_PATH || abort
|
||||||
abort
|
else
|
||||||
|
abort
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -50,7 +67,7 @@ if [ -x "$(command -v $PROGRAM)" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# compile library
|
# compile library
|
||||||
sudo $DIR/src/compile $PROGRAM || abort
|
sudo $COMPILE $PROGRAM || abort
|
||||||
|
|
||||||
# add permissions to input group (defer)
|
# add permissions to input group (defer)
|
||||||
# GROUP=$(ls -l /dev/input/event* | awk '{print $4}' | head --line=1) || abort
|
# GROUP=$(ls -l /dev/input/event* | awk '{print $4}' | head --line=1) || abort
|
||||||
|
|||||||
@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "gesture/swipe_gesture.regex.cpp"
|
#include "gesture/swipe_gesture.regex.cpp"
|
||||||
#include "service/autostart.cpp"
|
#include "service/autostart.cpp"
|
||||||
#include "service/buffer.cpp"
|
#include "service/buffer.cpp"
|
||||||
|
#include "service/debug.cpp"
|
||||||
#include "service/help.cpp"
|
#include "service/help.cpp"
|
||||||
#include "service/restart.cpp"
|
#include "service/restart.cpp"
|
||||||
#include "service/start.cpp"
|
#include "service/start.cpp"
|
||||||
@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include <iostream> // std::cout, std::endl
|
#include <iostream> // std::cout, std::endl
|
||||||
#include <regex> // std::regex, std::cmatch, std::regex_match
|
#include <regex> // std::regex, std::cmatch, std::regex_match
|
||||||
#include "xdo_gesture.h"
|
#include "xdo_gesture.h"
|
||||||
|
#include "pinch_gesture.h"
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -129,7 +130,7 @@ namespace comfortable_swipe::gesture
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* !flag_swiping */
|
else /* if (!this->flag_pinching) */
|
||||||
{
|
{
|
||||||
// not swiping, check if swipe will begin
|
// not swiping, check if swipe will begin
|
||||||
if (std::regex_match(line, matches, gesture_swipe_begin) != 0)
|
if (std::regex_match(line, matches, gesture_swipe_begin) != 0)
|
||||||
@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include <regex> // std::regex, std::regex_match
|
#include <regex> // std::regex, std::regex_match
|
||||||
#include <string> // std::stof, std::stoi
|
#include <string> // std::stof, std::stoi
|
||||||
#include "xdo_gesture.h"
|
#include "xdo_gesture.h"
|
||||||
|
#include "swipe_gesture.h"
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -51,7 +52,10 @@ namespace comfortable_swipe::gesture
|
|||||||
comfortable_swipe::gesture::xdo_gesture(),
|
comfortable_swipe::gesture::xdo_gesture(),
|
||||||
threshold_squared(threshold*threshold),
|
threshold_squared(threshold*threshold),
|
||||||
commands(new const char*[8]{left3, left4, right3, right4, up3, up4, down3, down4})
|
commands(new const char*[8]{left3, left4, right3, right4, up3, up4, down3, down4})
|
||||||
{ }
|
{
|
||||||
|
// improve responsiveness of first gesture by pre-empting xdotool runtime
|
||||||
|
xdo_get_mouse_location(this->xdo, &this->ix, &this->iy, &this->screen_num);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructs this swipe gesture.
|
* Destructs this swipe gesture.
|
||||||
@ -147,40 +151,43 @@ namespace comfortable_swipe::gesture
|
|||||||
// currently swiping
|
// currently swiping
|
||||||
if (std::regex_match(line, matches, gesture_swipe_update) != 0)
|
if (std::regex_match(line, matches, gesture_swipe_update) != 0)
|
||||||
{
|
{
|
||||||
// update swipe
|
// assign necessary variables for swipe update
|
||||||
this->fingers = std::stoi(matches[1]);
|
this->fingers = std::stoi(matches[1]);
|
||||||
this->dx = std::stof(matches[2]);
|
this->dx = std::stof(matches[2]);
|
||||||
this->dy = std::stof(matches[3]);
|
this->dy = std::stof(matches[3]);
|
||||||
this->udx = std::stof(matches[4]);
|
this->udx = std::stof(matches[4]);
|
||||||
this->udy = std::stof(matches[5]);
|
this->udy = std::stof(matches[5]);
|
||||||
|
// dispatch update
|
||||||
this->update();
|
this->update();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (std::regex_match(line, matches, gesture_swipe_end) != 0)
|
else if (std::regex_match(line, matches, gesture_swipe_end) != 0)
|
||||||
{
|
{
|
||||||
// end swipe
|
// assign necessary variables for swipe end
|
||||||
this->flag_swiping = false;
|
this->flag_swiping = false;
|
||||||
this->fingers = std::stoi(matches[1]);
|
this->fingers = std::stoi(matches[1]);
|
||||||
|
// dispatch end
|
||||||
this->end();
|
this->end();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* !flag_swiping */
|
else /* if (!this->flag_swiping) */
|
||||||
{
|
{
|
||||||
// not swiping, check if swipe will begin
|
// not swiping, check if swipe will begin
|
||||||
if (std::regex_match(line, matches, gesture_swipe_begin) != 0)
|
if (std::regex_match(line, matches, gesture_swipe_begin) != 0)
|
||||||
{
|
{
|
||||||
// begin swipe
|
// assign necessary variables for swipe begin
|
||||||
this->flag_swiping = true;
|
this->flag_swiping = true;
|
||||||
this->fingers = std::stoi(matches[1]);
|
this->fingers = std::stoi(matches[1]);
|
||||||
|
// dispatch begin
|
||||||
this->begin();
|
this->begin();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* STATICS DEFINITIONS */
|
/* STATICS DEFINITIONS */
|
||||||
const int swipe_gesture::MSK_THREE_FINGERS = 0;
|
const int swipe_gesture::MSK_THREE_FINGERS = 0;
|
||||||
const int swipe_gesture::MSK_FOUR_FINGERS = 1;
|
const int swipe_gesture::MSK_FOUR_FINGERS = 1;
|
||||||
@ -61,9 +61,11 @@ namespace comfortable_swipe::gesture
|
|||||||
// current location
|
// current location
|
||||||
float x, y, threshold_squared;
|
float x, y, threshold_squared;
|
||||||
int previous_gesture;
|
int previous_gesture;
|
||||||
bool flag_swiping;
|
|
||||||
const char ** commands;
|
const char ** commands;
|
||||||
|
|
||||||
|
// optimization flag for checking if GESTURE_SWIPE_BEGIN was dispatched
|
||||||
|
bool flag_swiping;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// static constants
|
// static constants
|
||||||
static const int MSK_THREE_FINGERS;
|
static const int MSK_THREE_FINGERS;
|
||||||
@ -50,6 +50,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
void autostart();
|
void autostart();
|
||||||
void buffer();
|
void buffer();
|
||||||
|
void debug();
|
||||||
void help();
|
void help();
|
||||||
void restart();
|
void restart();
|
||||||
void start();
|
void start();
|
||||||
@ -33,7 +33,7 @@ namespace comfortable_swipe::service
|
|||||||
auto config = comfortable_swipe::util::read_config_file(comfortable_swipe::util::conf_filename());
|
auto config = comfortable_swipe::util::read_config_file(comfortable_swipe::util::conf_filename());
|
||||||
|
|
||||||
// initialize swipe gesture handler
|
// initialize swipe gesture handler
|
||||||
comfortable_swipe::gesture::swipe_gesture swipe
|
comfortable_swipe::gesture::swipe_gesture swipe_gesture_handler
|
||||||
(
|
(
|
||||||
config.count("threshold") ? std::stof(config["threshold"]) : 0.0,
|
config.count("threshold") ? std::stof(config["threshold"]) : 0.0,
|
||||||
config["left3"].c_str(),
|
config["left3"].c_str(),
|
||||||
@ -48,12 +48,13 @@ namespace comfortable_swipe::service
|
|||||||
|
|
||||||
// prepare data containers
|
// prepare data containers
|
||||||
static const int MAX_LINE_LENGTH = 256;
|
static const int MAX_LINE_LENGTH = 256;
|
||||||
static char line[MAX_LINE_LENGTH];
|
static char data[MAX_LINE_LENGTH];
|
||||||
|
|
||||||
// start reading lines from input one by one
|
// start reading lines from input one by one
|
||||||
while (fgets_unlocked(line, MAX_LINE_LENGTH, stdin) != NULL)
|
while (fgets_unlocked(data, MAX_LINE_LENGTH, stdin) != NULL)
|
||||||
{
|
{
|
||||||
swipe.parse_line(line);
|
// attempt to parse swipe gestures
|
||||||
|
swipe_gesture_handler.parse_line(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
35
lib/service/debug.cpp
Normal file
35
lib/service/debug.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef __COMFORTABLE_SWIPE__service_debug__
|
||||||
|
#define __COMFORTABLE_SWIPE__service_debug__
|
||||||
|
|
||||||
|
/*
|
||||||
|
Comfortable Swipe
|
||||||
|
by Rico Tiongson
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <cstdlib> // std::system
|
||||||
|
|
||||||
|
namespace comfortable_swipe::service
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Debugs output from `libinput debug-events`.
|
||||||
|
*/
|
||||||
|
void debug()
|
||||||
|
{
|
||||||
|
(void) std::system("stdbuf -oL -e0 libinput debug-events");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __COMFORTABLE_SWIPE__service_debug__ */
|
||||||
@ -30,7 +30,7 @@ namespace comfortable_swipe::service
|
|||||||
void help()
|
void help()
|
||||||
{
|
{
|
||||||
using comfortable_swipe::util::conf_filename;
|
using comfortable_swipe::util::conf_filename;
|
||||||
std::puts("comfortable-swipe [start|stop|restart|autostart|buffer|help]");
|
std::puts("comfortable-swipe [start|stop|restart|autostart|buffer|help|debug]");
|
||||||
std::puts("");
|
std::puts("");
|
||||||
std::puts("start - starts 3/4-finger gesture service");
|
std::puts("start - starts 3/4-finger gesture service");
|
||||||
std::puts("stop - stops 3/4-finger gesture service");
|
std::puts("stop - stops 3/4-finger gesture service");
|
||||||
@ -38,6 +38,7 @@ namespace comfortable_swipe::service
|
|||||||
std::puts("autostart - automatically run on startup (toggleable)");
|
std::puts("autostart - automatically run on startup (toggleable)");
|
||||||
std::puts("buffer - parses output of libinput debug-events");
|
std::puts("buffer - parses output of libinput debug-events");
|
||||||
std::puts("help - shows the help dialog");
|
std::puts("help - shows the help dialog");
|
||||||
|
std::puts("debug - logs raw output from input events taken from libinput");
|
||||||
std::puts("");
|
std::puts("");
|
||||||
std::printf("Configuration file can be found in %s\n", conf_filename());
|
std::printf("Configuration file can be found in %s\n", conf_filename());
|
||||||
}
|
}
|
||||||
@ -28,8 +28,8 @@ namespace comfortable_swipe::service
|
|||||||
*/
|
*/
|
||||||
void restart()
|
void restart()
|
||||||
{
|
{
|
||||||
comfortable_swipe::service::start();
|
|
||||||
comfortable_swipe::service::stop();
|
comfortable_swipe::service::stop();
|
||||||
|
comfortable_swipe::service::start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
g++ $(dirname $0)/main.cpp -std=c++11 -O2 -lxdo -Wno-unused-result -o $1
|
|
||||||
@ -2,8 +2,8 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../src/lib/gesture/swipe_gesture.h"
|
#include "../lib/gesture/swipe_gesture.h"
|
||||||
#include "../src/lib/gesture/swipe_gesture.regex.cpp"
|
#include "../lib/gesture/swipe_gesture.regex.cpp"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Comfortable Swipe
|
Comfortable Swipe
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user