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
```
2. Clone this repository
1. Clone this repository
```bash
git clone https://github.com/Hikari9/comfortable-swipe.git --depth 1
cd comfortable-swipe
```
3. Install
1. Install
```bash
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
@ -61,6 +61,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
```
1. You can check general program status
```basha
$> comfortable-swipe status
@ -71,6 +72,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
## List of Commands
1. Run / stop the program
```
comfortable-swipe start
comfortable-swipe stop
@ -78,6 +80,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
```
1. Show help / version
```
comfortable-swipe --help
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]
```
1. (Advanced) Run program buffer
1) (Advanced) Run program buffer
```bash
comfortable-swipe buffer
@ -135,7 +137,6 @@ After making changes, make sure to restart the program:
comfortable-swipe restart
```
> **Note**: For v1.1.0 below, the configuration file is located at
> `/usr/local/share/comfortable-swipe/comfortable-swipe.conf`
@ -143,19 +144,19 @@ comfortable-swipe restart
## Configuration Reference
| Key | Value | Examples |
| --------- | :------------------------------------------: | -------------------- |
| left3 | 3-finger swipe left | ctrl+alt+Right |
| left4 | 4-finger swipe left | ctrl+alt+shift+Right |
| right3 | 3-finger swipe right | ctrl+alt+Left |
| right4 | 4-finger swipe right | ctrl+alt+shift+Left |
| up3 | 3-finger swipe up | ctrl+alt+Down |
| up4 | 4-finger swipe up | ctrl+alt+shift+Down |
| down3 | 3-finger swipe down | ctrl+alt+Up |
| down4 | 4-finger swipe down | ctrl+alt+shift+Up |
| threshold | mouse movement pixels that trigger a swipe (can be as large as 1000.0) | 0.0, 240.0, 1000.0 |
| mouse3 | holds a mouse button when 3 fingers are down | button1 (see [Mouse Gestures](#mouse-gestures-experimental)) | |
| mouse4 | holds a mouse button when 4 fingers are down | button1 (see [Mouse Gestures](#mouse-gestures-experimental) |
| Key | Value | Examples |
| --------- | :--------------------------------------------------------------------: | ------------------------------------------------------------ |
| left3 | 3-finger swipe left | ctrl+alt+Right |
| left4 | 4-finger swipe left | ctrl+alt+shift+Right |
| right3 | 3-finger swipe right | ctrl+alt+Left |
| right4 | 4-finger swipe right | ctrl+alt+shift+Left |
| up3 | 3-finger swipe up | ctrl+alt+Down |
| up4 | 4-finger swipe up | ctrl+alt+shift+Down |
| down3 | 3-finger swipe down | ctrl+alt+Up |
| down4 | 4-finger swipe down | ctrl+alt+shift+Up |
| threshold | mouse movement pixels that trigger a swipe (can be as large as 1000.0) | 0.0, 240.0, 1000.0 |
| mouse3 | holds a mouse button when 3 fingers are down | button1 (see [Mouse Gestures](#mouse-gestures-experimental)) | |
| mouse4 | holds a mouse button when 4 fingers are down | button1 (see [Mouse Gestures](#mouse-gestures-experimental) |
Taken from `man xdotool`:
@ -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.
Keys:
* mouse3 - for 3-finger mouse gestures
* mouse4 - for 4-finger mosue gestures
* hold3 (deprecated) - old equivalent of mouse3
* hold4 (deprecated) - old equivalent of mouse4
- mouse3 - for 3-finger mouse gestures
- mouse4 - for 4-finger mosue gestures
- 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`.
Possible Values:
* button1 - hold left click on finger swipe
* button2 - hold middle click on finger swipe
* button3 - hold right click on finger swipe
* button4 - wheel up on finger swipe (experimental)
* button5 - wheel down on finger swipe (experimental)
* move - just move the mouse cursor with the fingers
* scroll - 3/4 finger natural scroll (no acceleration, very experimental)
* scroll_reverse - 3/4 finger reverse scroll (no acceleration, very experimental)
- button1 - hold left click on finger swipe
- button2 - hold middle click on finger swipe
- button3 - hold right click on finger swipe
- button4 - wheel up on finger swipe (experimental)
- button5 - wheel down on finger swipe (experimental)
- move - just move the mouse cursor with the fingers
- scroll - 3/4 finger natural scroll (no acceleration, very experimental)
- scroll_reverse - 3/4 finger reverse scroll (no acceleration, very experimental)
Examples:

View File

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

View File

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

View File

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

View File

@ -88,9 +88,11 @@ int main() {
// mouse4=button3 hold button 3 (right click) on 3 fingers
// warn user that hold3 is deprecated
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"))
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
string mouse3 = config.count("mouse3") ? config["mouse3"] : config["hold3"];
string mouse4 = config.count("mouse4") ? config["mouse4"] : config["hold4"];