Reformat files with clang and prettier

This commit is contained in:
Rico Tiongson 2020-04-21 03:35:57 +08:00
parent f3de83fb83
commit c7eeb66dfa
5 changed files with 50 additions and 55 deletions

View File

@ -23,20 +23,20 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
sudo apt install libinput-tools libconfuse-dev libxdo-dev sudo apt install libinput-tools libconfuse-dev libxdo-dev
``` ```
2. Clone this repository 1. Clone this repository
```bash ```bash
git clone https://github.com/Hikari9/comfortable-swipe.git --depth 1 git clone https://github.com/Hikari9/comfortable-swipe.git --depth 1
cd comfortable-swipe cd comfortable-swipe
``` ```
3. Install 1. Install
```bash ```bash
bash install bash install
``` ```
4. You may delete the downloaded `comfortable-swipe` folder after installation. 1. You may delete the downloaded `comfortable-swipe` folder after installation.
## How to Run ## How to Run
@ -61,6 +61,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
``` ```
1. You can check general program status 1. You can check general program status
```basha ```basha
$> comfortable-swipe status $> comfortable-swipe status
@ -71,6 +72,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
## List of Commands ## List of Commands
1. Run / stop the program 1. Run / stop the program
``` ```
comfortable-swipe start comfortable-swipe start
comfortable-swipe stop comfortable-swipe stop
@ -78,6 +80,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
``` ```
1. Show help / version 1. Show help / version
``` ```
comfortable-swipe --help comfortable-swipe --help
comfortable-swipe --version comfortable-swipe --version
@ -95,8 +98,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
comfortable-swipe autostart [on|off|toggle|status|path] comfortable-swipe autostart [on|off|toggle|status|path]
``` ```
1) (Advanced) Run program buffer
1. (Advanced) Run program buffer
```bash ```bash
comfortable-swipe buffer comfortable-swipe buffer
@ -135,7 +137,6 @@ After making changes, make sure to restart the program:
comfortable-swipe restart comfortable-swipe restart
``` ```
> **Note**: For v1.1.0 below, the configuration file is located at > **Note**: For v1.1.0 below, the configuration file is located at
> `/usr/local/share/comfortable-swipe/comfortable-swipe.conf` > `/usr/local/share/comfortable-swipe/comfortable-swipe.conf`
@ -144,7 +145,7 @@ comfortable-swipe restart
## Configuration Reference ## Configuration Reference
| Key | Value | Examples | | Key | Value | Examples |
| --------- | :------------------------------------------: | -------------------- | | --------- | :--------------------------------------------------------------------: | ------------------------------------------------------------ |
| left3 | 3-finger swipe left | ctrl+alt+Right | | left3 | 3-finger swipe left | ctrl+alt+Right |
| left4 | 4-finger swipe left | ctrl+alt+shift+Right | | left4 | 4-finger swipe left | ctrl+alt+shift+Right |
| right3 | 3-finger swipe right | ctrl+alt+Left | | right3 | 3-finger swipe right | ctrl+alt+Left |
@ -282,22 +283,24 @@ You can also play around with mouse gestures during swipe.
This enables certain mouse behaviour to trigger along with a 3/4-finger swipe. This enables certain mouse behaviour to trigger along with a 3/4-finger swipe.
Keys: Keys:
* mouse3 - for 3-finger mouse gestures
* mouse4 - for 4-finger mosue gestures - mouse3 - for 3-finger mouse gestures
* hold3 (deprecated) - old equivalent of mouse3 - mouse4 - for 4-finger mosue gestures
* hold4 (deprecated) - old equivalent of mouse4 - hold3 (deprecated) - old equivalent of mouse3
- hold4 (deprecated) - old equivalent of mouse4
We have included simple mouse gestures on swipe by setting `hold3` and `hold4`. We have included simple mouse gestures on swipe by setting `hold3` and `hold4`.
Possible Values: Possible Values:
* button1 - hold left click on finger swipe
* button2 - hold middle click on finger swipe - button1 - hold left click on finger swipe
* button3 - hold right click on finger swipe - button2 - hold middle click on finger swipe
* button4 - wheel up on finger swipe (experimental) - button3 - hold right click on finger swipe
* button5 - wheel down on finger swipe (experimental) - button4 - wheel up on finger swipe (experimental)
* move - just move the mouse cursor with the fingers - button5 - wheel down on finger swipe (experimental)
* scroll - 3/4 finger natural scroll (no acceleration, very experimental) - move - just move the mouse cursor with the fingers
* scroll_reverse - 3/4 finger reverse scroll (no acceleration, very experimental) - scroll - 3/4 finger natural scroll (no acceleration, very experimental)
- scroll_reverse - 3/4 finger reverse scroll (no acceleration, very experimental)
Examples: Examples:

View File

@ -55,12 +55,8 @@ public:
// override this when keyboard gesture is to be performed // override this when keyboard gesture is to be performed
virtual void do_keyboard_gesture(int mask); virtual void do_keyboard_gesture(int mask);
// public accessors // public accessors
virtual int get_previous_gesture() const { virtual int get_previous_gesture() const { return this->previous_gesture; }
return this->previous_gesture; virtual int get_current_mask() const { return this->current_mask; }
}
virtual int get_current_mask() const {
return this->current_mask;
}
protected: protected:
// stores square of threshold so we can compute faster // stores square of threshold so we can compute faster
@ -112,12 +108,10 @@ decltype(
*/ */
gesture_swipe_xdokey::gesture_swipe_xdokey( gesture_swipe_xdokey::gesture_swipe_xdokey(
const decltype(gesture_swipe_xdokey::commands) &commands, float threshold) const decltype(gesture_swipe_xdokey::commands) &commands, float threshold)
: gesture_swipe(), : gesture_swipe(), commands(commands),
commands(commands),
threshold_squared(threshold * threshold), threshold_squared(threshold * threshold),
previous_gesture(gesture_swipe_xdokey::FRESH), previous_gesture(gesture_swipe_xdokey::FRESH),
current_mask(gesture_swipe_xdokey::FRESH) current_mask(gesture_swipe_xdokey::FRESH) {}
{}
/** /**
* Destructs this keyboard swipe gesture. * Destructs this keyboard swipe gesture.
*/ */
@ -172,15 +166,15 @@ void gesture_swipe_xdokey::update() {
// update our mask // update our mask
current_mask = mask; current_mask = mask;
// send command on fresh OR opposite gesture // send command on fresh OR opposite gesture
if (previous_gesture == FRESH || previous_gesture == (mask ^ MSK_POSITIVE)) { if (previous_gesture == FRESH ||
previous_gesture == (mask ^ MSK_POSITIVE)) {
// do keyboard gesture // do keyboard gesture
do_keyboard_gesture(mask); do_keyboard_gesture(mask);
// reset our location variables // reset our location variables
x = y = 0; x = y = 0;
previous_gesture = mask; previous_gesture = mask;
} }
} } else { // not in threshold, set mask to fresh
else { // not in threshold, set mask to fresh
current_mask = FRESH; current_mask = FRESH;
} }
} }

View File

@ -86,7 +86,6 @@ protected:
// command holders // command holders
const char *mouse3; const char *mouse3;
const char *mouse4; const char *mouse4;
}; };
/** /**
* Constructs a new mouse gesture, given "mouse3" and "mouse4" configurations. * Constructs a new mouse gesture, given "mouse3" and "mouse4" configurations.
@ -166,8 +165,7 @@ void gesture_swipe_xdomouse::update() {
if (0 <= button && button <= 3) { if (0 <= button && button <= 3) {
// drag mouse with pointer during update // drag mouse with pointer during update
xdo_move_mouse_relative(xdo, udx, udy); xdo_move_mouse_relative(xdo, udx, udy);
} else if (button == MOUSE_SCROLL || } else if (button == MOUSE_SCROLL || button == MOUSE_SCROLL_REVERSE) {
button == MOUSE_SCROLL_REVERSE) {
// perform naive scroll depending on vertical direction // perform naive scroll depending on vertical direction
int wheel = MOUSE_WHEEL_DOWN; int wheel = MOUSE_WHEEL_DOWN;
if ((udy > 0) == (button == MOUSE_SCROLL)) if ((udy > 0) == (button == MOUSE_SCROLL))
@ -175,8 +173,7 @@ void gesture_swipe_xdomouse::update() {
// click wheel on update (note: this is not precise) // click wheel on update (note: this is not precise)
xdo_mouse_down(xdo, CURRENTWINDOW, wheel); xdo_mouse_down(xdo, CURRENTWINDOW, wheel);
xdo_mouse_up(xdo, CURRENTWINDOW, wheel); xdo_mouse_up(xdo, CURRENTWINDOW, wheel);
} else if (button == MOUSE_WHEEL_UP || } else if (button == MOUSE_WHEEL_UP || button == MOUSE_WHEEL_DOWN) {
button == MOUSE_WHEEL_DOWN) {
// click wheel button on 4 or 5 // click wheel button on 4 or 5
xdo_mouse_down(xdo, CURRENTWINDOW, button); xdo_mouse_down(xdo, CURRENTWINDOW, button);
xdo_mouse_up(xdo, CURRENTWINDOW, button); xdo_mouse_up(xdo, CURRENTWINDOW, button);
@ -192,7 +189,8 @@ void gesture_swipe_xdomouse::end() {
// map fingers to gesture command // map fingers to gesture command
// perform mouseup on the button and print to console // perform mouseup on the button and print to console
do_mouseup(button, fingers); do_mouseup(button, fingers);
std::printf("MOUSE UP mouse%d %s\n", fingers, fingers == 3 ? mouse3 : mouse4); std::printf("MOUSE UP mouse%d %s\n", fingers,
fingers == 3 ? mouse3 : mouse4);
} }
// reset button // reset button
button = MOUSE_NONE; button = MOUSE_NONE;

View File

@ -69,9 +69,7 @@ public:
virtual void end(); virtual void end();
virtual bool run(const char *); virtual bool run(const char *);
// public check if currently swiping // public check if currently swiping
virtual bool is_swiping() const { virtual bool is_swiping() const { return this->flag_swiping; }
return this->flag_swiping;
}
protected: protected:
// xdo container // xdo container

View File

@ -88,9 +88,11 @@ int main() {
// mouse4=button3 hold button 3 (right click) on 3 fingers // mouse4=button3 hold button 3 (right click) on 3 fingers
// warn user that hold3 is deprecated // warn user that hold3 is deprecated
if (config.count("hold3")) if (config.count("hold3"))
std::cerr << "WARNING: hold3 is deprecated. Use mouse3 instead." << std:: endl; std::cerr << "WARNING: hold3 is deprecated. Use mouse3 instead."
<< std::endl;
if (config.count("hold4")) if (config.count("hold4"))
std::cerr << "WARNING: hold4 is deprecated. Use mouse4 instead." << std::endl; std::cerr << "WARNING: hold4 is deprecated. Use mouse4 instead."
<< std::endl;
// get input values // get input values
string mouse3 = config.count("mouse3") ? config["mouse3"] : config["hold3"]; string mouse3 = config.count("mouse3") ? config["mouse3"] : config["hold3"];
string mouse4 = config.count("mouse4") ? config["mouse4"] : config["hold4"]; string mouse4 = config.count("mouse4") ? config["mouse4"] : config["hold4"];