Travis (#62)
* Use a requirements.txt * Add initial travis configuration * Attempt fix travis configuration * Attempt fix g++ error * Bugfix missing path dir on autostart * Attempt install build-essential instead of g++ * Add missing psutil from requirements * Modify README * Attempt fix build errors in travis * Update README * Add simple build badges
This commit is contained in:
1 parent
adcb3d5e02
commit
044e215d97
21 files changed
+709
-593
No files matched your search
+166
-163
@@ -32,182 +32,185 @@ extern "C"
|
||||
// CURRENT_WINDOW
|
||||
}
|
||||
|
||||
namespace comfortable_swipe::gesture
|
||||
namespace comfortable_swipe
|
||||
{
|
||||
/**
|
||||
* Constructs a new swipe gesture, given configurations for certain swipe events.
|
||||
*/
|
||||
swipe_gesture::swipe_gesture
|
||||
(
|
||||
const float threshold,
|
||||
const char* left3 /* 000 */,
|
||||
const char* left4 /* 001 */,
|
||||
const char* right3 /* 010 */,
|
||||
const char* right4 /* 011 */,
|
||||
const char* up3 /* 100 */,
|
||||
const char* up4 /* 101 */,
|
||||
const char* down3 /* 110 */,
|
||||
const char* down4 /* 111 */
|
||||
):
|
||||
comfortable_swipe::gesture::xdo_gesture(),
|
||||
threshold_squared(threshold*threshold),
|
||||
commands(new const char*[8]{left3, left4, right3, right4, up3, up4, down3, down4}),
|
||||
flag_swiping(false)
|
||||
namespace gesture
|
||||
{
|
||||
// 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.
|
||||
*/
|
||||
swipe_gesture::~swipe_gesture()
|
||||
{
|
||||
delete[] commands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook on begin of swipe gesture.
|
||||
*/
|
||||
void swipe_gesture::begin()
|
||||
{
|
||||
xdo_get_mouse_location(this->xdo, &this->ix, &this->iy, &this->screen_num);
|
||||
this->previous_gesture = swipe_gesture::FRESH;
|
||||
this->x = 0;
|
||||
this->y = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook on update of swipe gesture.
|
||||
*/
|
||||
void swipe_gesture::update()
|
||||
{
|
||||
this->x += this->dx;
|
||||
this->y += this->dy;
|
||||
// scale threshold to 1/10 when gesture is not fresh
|
||||
float scale = this->previous_gesture == swipe_gesture::FRESH
|
||||
? 1.00f
|
||||
: 0.01f; // square root of 1/10
|
||||
static const float EPSILON = 1e-6f;
|
||||
if (this->x * this->x + this->y * this->y
|
||||
> this->threshold_squared * scale + EPSILON)
|
||||
/**
|
||||
* Constructs a new swipe gesture, given configurations for certain swipe events.
|
||||
*/
|
||||
swipe_gesture::swipe_gesture
|
||||
(
|
||||
const float threshold,
|
||||
const char* left3 /* 000 */,
|
||||
const char* left4 /* 001 */,
|
||||
const char* right3 /* 010 */,
|
||||
const char* right4 /* 011 */,
|
||||
const char* up3 /* 100 */,
|
||||
const char* up4 /* 101 */,
|
||||
const char* down3 /* 110 */,
|
||||
const char* down4 /* 111 */
|
||||
):
|
||||
comfortable_swipe::gesture::xdo_gesture(),
|
||||
threshold_squared(threshold*threshold),
|
||||
commands(new const char*[8]{left3, left4, right3, right4, up3, up4, down3, down4}),
|
||||
flag_swiping(false)
|
||||
{
|
||||
int mask = 0;
|
||||
if (this->fingers == 3) mask |= swipe_gesture::MSK_THREE_FINGERS;
|
||||
else if (this->fingers == 4) mask |= swipe_gesture::MSK_FOUR_FINGERS;
|
||||
|
||||
const float absx = x >= 0 ? x : -x;
|
||||
const float absy = y >= 0 ? y : -y;
|
||||
if (absx > absy)
|
||||
{ // horizontal
|
||||
mask |= swipe_gesture::MSK_HORIZONTAL;
|
||||
if (x < 0)
|
||||
mask |= swipe_gesture::MSK_NEGATIVE;
|
||||
else
|
||||
mask |= swipe_gesture::MSK_POSITIVE;
|
||||
}
|
||||
else /* std::abs(x) <= std::abs(y) */
|
||||
{ // vertical
|
||||
mask |= swipe_gesture::MSK_VERTICAL;
|
||||
if (y < 0)
|
||||
mask |= swipe_gesture::MSK_NEGATIVE;
|
||||
else
|
||||
mask |= swipe_gesture::MSK_POSITIVE;
|
||||
}
|
||||
|
||||
// send command on fresh OR opposite gesture
|
||||
if (this->previous_gesture == swipe_gesture::FRESH
|
||||
|| this->previous_gesture == (mask ^ swipe_gesture::MSK_POSITIVE))
|
||||
{
|
||||
xdo_send_keysequence_window(this->xdo, CURRENTWINDOW, swipe_gesture::commands[mask], 0);
|
||||
this->x = this->y = 0;
|
||||
this->previous_gesture = mask;
|
||||
std::cout << "SWIPE " << swipe_gesture::command_map[mask] << std::endl;
|
||||
}
|
||||
// improve responsiveness of first gesture by pre-empting xdotool runtime
|
||||
xdo_get_mouse_location(this->xdo, &this->ix, &this->iy, &this->screen_num);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook on end of swipe gesture.
|
||||
*/
|
||||
void swipe_gesture::end()
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Dispatches begin/update/end depending on the regex pattern provided by this class.
|
||||
*
|
||||
* @param line the line from libinput debug-events to parse
|
||||
* @return true if begin/update/end was dispatched
|
||||
*/
|
||||
bool swipe_gesture::parse_line(const char * line)
|
||||
{
|
||||
static const std::regex gesture_swipe_begin(swipe_gesture::GESTURE_BEGIN_REGEX_PATTERN);
|
||||
static const std::regex gesture_swipe_update(swipe_gesture::GESTURE_UPDATE_REGEX_PATTERN);
|
||||
static const std::regex gesture_swipe_end(swipe_gesture::GESTURE_END_REGEX_PATTERN);
|
||||
|
||||
// prepare holder for regex matches
|
||||
static std::cmatch matches;
|
||||
|
||||
if (this->flag_swiping)
|
||||
/**
|
||||
* Destructs this swipe gesture.
|
||||
*/
|
||||
swipe_gesture::~swipe_gesture()
|
||||
{
|
||||
// currently swiping
|
||||
if (std::regex_match(line, matches, gesture_swipe_update) != 0)
|
||||
{
|
||||
// assign necessary variables for swipe update
|
||||
this->fingers = std::stoi(matches[1]);
|
||||
this->dx = std::stof(matches[2]);
|
||||
this->dy = std::stof(matches[3]);
|
||||
this->udx = std::stof(matches[4]);
|
||||
this->udy = std::stof(matches[5]);
|
||||
// dispatch update
|
||||
this->update();
|
||||
return true;
|
||||
}
|
||||
else if (std::regex_match(line, matches, gesture_swipe_end) != 0)
|
||||
{
|
||||
// assign necessary variables for swipe end
|
||||
this->flag_swiping = false;
|
||||
this->fingers = std::stoi(matches[1]);
|
||||
// dispatch end
|
||||
this->end();
|
||||
return true;
|
||||
}
|
||||
delete[] commands;
|
||||
}
|
||||
else
|
||||
|
||||
/**
|
||||
* Hook on begin of swipe gesture.
|
||||
*/
|
||||
void swipe_gesture::begin()
|
||||
{
|
||||
// not swiping, check if swipe will begin
|
||||
if (std::regex_match(line, matches, gesture_swipe_begin) != 0)
|
||||
xdo_get_mouse_location(this->xdo, &this->ix, &this->iy, &this->screen_num);
|
||||
this->previous_gesture = swipe_gesture::FRESH;
|
||||
this->x = 0;
|
||||
this->y = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook on update of swipe gesture.
|
||||
*/
|
||||
void swipe_gesture::update()
|
||||
{
|
||||
this->x += this->dx;
|
||||
this->y += this->dy;
|
||||
// scale threshold to 1/10 when gesture is not fresh
|
||||
float scale = this->previous_gesture == swipe_gesture::FRESH
|
||||
? 1.00f
|
||||
: 0.01f; // square root of 1/10
|
||||
static const float EPSILON = 1e-6f;
|
||||
if (this->x * this->x + this->y * this->y
|
||||
> this->threshold_squared * scale + EPSILON)
|
||||
{
|
||||
// assign necessary variables for swipe begin
|
||||
this->flag_swiping = true;
|
||||
this->fingers = std::stoi(matches[1]);
|
||||
// dispatch begin
|
||||
this->begin();
|
||||
return true;
|
||||
int mask = 0;
|
||||
if (this->fingers == 3) mask |= swipe_gesture::MSK_THREE_FINGERS;
|
||||
else if (this->fingers == 4) mask |= swipe_gesture::MSK_FOUR_FINGERS;
|
||||
|
||||
const float absx = x >= 0 ? x : -x;
|
||||
const float absy = y >= 0 ? y : -y;
|
||||
if (absx > absy)
|
||||
{ // horizontal
|
||||
mask |= swipe_gesture::MSK_HORIZONTAL;
|
||||
if (x < 0)
|
||||
mask |= swipe_gesture::MSK_NEGATIVE;
|
||||
else
|
||||
mask |= swipe_gesture::MSK_POSITIVE;
|
||||
}
|
||||
else /* std::abs(x) <= std::abs(y) */
|
||||
{ // vertical
|
||||
mask |= swipe_gesture::MSK_VERTICAL;
|
||||
if (y < 0)
|
||||
mask |= swipe_gesture::MSK_NEGATIVE;
|
||||
else
|
||||
mask |= swipe_gesture::MSK_POSITIVE;
|
||||
}
|
||||
|
||||
// send command on fresh OR opposite gesture
|
||||
if (this->previous_gesture == swipe_gesture::FRESH
|
||||
|| this->previous_gesture == (mask ^ swipe_gesture::MSK_POSITIVE))
|
||||
{
|
||||
xdo_send_keysequence_window(this->xdo, CURRENTWINDOW, swipe_gesture::commands[mask], 0);
|
||||
this->x = this->y = 0;
|
||||
this->previous_gesture = mask;
|
||||
std::cout << "SWIPE " << swipe_gesture::command_map[mask] << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Hook on end of swipe gesture.
|
||||
*/
|
||||
void swipe_gesture::end()
|
||||
{ }
|
||||
|
||||
/* STATICS DEFINITIONS */
|
||||
const int swipe_gesture::MSK_THREE_FINGERS = 0;
|
||||
const int swipe_gesture::MSK_FOUR_FINGERS = 1;
|
||||
const int swipe_gesture::MSK_NEGATIVE = 0;
|
||||
const int swipe_gesture::MSK_POSITIVE = 2;
|
||||
const int swipe_gesture::MSK_HORIZONTAL = 0;
|
||||
const int swipe_gesture::MSK_VERTICAL = 4;
|
||||
const int swipe_gesture::FRESH = -1;
|
||||
const char * const swipe_gesture::command_map[8] = {
|
||||
"left3",
|
||||
"left4",
|
||||
"right3",
|
||||
"right4",
|
||||
"up3",
|
||||
"up4",
|
||||
"down3",
|
||||
"down4"
|
||||
};
|
||||
/**
|
||||
* Dispatches begin/update/end depending on the regex pattern provided by this class.
|
||||
*
|
||||
* @param line the line from libinput debug-events to parse
|
||||
* @return true if begin/update/end was dispatched
|
||||
*/
|
||||
bool swipe_gesture::parse_line(const char * line)
|
||||
{
|
||||
static const std::regex gesture_swipe_begin(swipe_gesture::GESTURE_BEGIN_REGEX_PATTERN);
|
||||
static const std::regex gesture_swipe_update(swipe_gesture::GESTURE_UPDATE_REGEX_PATTERN);
|
||||
static const std::regex gesture_swipe_end(swipe_gesture::GESTURE_END_REGEX_PATTERN);
|
||||
|
||||
// prepare holder for regex matches
|
||||
static std::cmatch matches;
|
||||
|
||||
if (this->flag_swiping)
|
||||
{
|
||||
// currently swiping
|
||||
if (std::regex_match(line, matches, gesture_swipe_update) != 0)
|
||||
{
|
||||
// assign necessary variables for swipe update
|
||||
this->fingers = std::stoi(matches[1]);
|
||||
this->dx = std::stof(matches[2]);
|
||||
this->dy = std::stof(matches[3]);
|
||||
this->udx = std::stof(matches[4]);
|
||||
this->udy = std::stof(matches[5]);
|
||||
// dispatch update
|
||||
this->update();
|
||||
return true;
|
||||
}
|
||||
else if (std::regex_match(line, matches, gesture_swipe_end) != 0)
|
||||
{
|
||||
// assign necessary variables for swipe end
|
||||
this->flag_swiping = false;
|
||||
this->fingers = std::stoi(matches[1]);
|
||||
// dispatch end
|
||||
this->end();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// not swiping, check if swipe will begin
|
||||
if (std::regex_match(line, matches, gesture_swipe_begin) != 0)
|
||||
{
|
||||
// assign necessary variables for swipe begin
|
||||
this->flag_swiping = true;
|
||||
this->fingers = std::stoi(matches[1]);
|
||||
// dispatch begin
|
||||
this->begin();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* STATICS DEFINITIONS */
|
||||
const int swipe_gesture::MSK_THREE_FINGERS = 0;
|
||||
const int swipe_gesture::MSK_FOUR_FINGERS = 1;
|
||||
const int swipe_gesture::MSK_NEGATIVE = 0;
|
||||
const int swipe_gesture::MSK_POSITIVE = 2;
|
||||
const int swipe_gesture::MSK_HORIZONTAL = 0;
|
||||
const int swipe_gesture::MSK_VERTICAL = 4;
|
||||
const int swipe_gesture::FRESH = -1;
|
||||
const char * const swipe_gesture::command_map[8] = {
|
||||
"left3",
|
||||
"left4",
|
||||
"right3",
|
||||
"right4",
|
||||
"up3",
|
||||
"up4",
|
||||
"down3",
|
||||
"down4"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __COMFORTABLE_SWIPE__gesture_swipe_gesture__ */
|
||||
+50
-55
@@ -21,70 +21,65 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "xdo_gesture.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
namespace comfortable_swipe::gesture
|
||||
namespace comfortable_swipe
|
||||
{
|
||||
class swipe_gesture : protected xdo_gesture
|
||||
namespace gesture
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
swipe_gesture(
|
||||
const float threshold,
|
||||
const char* left3 /* 000 */,
|
||||
const char* left4 /* 001 */,
|
||||
const char* right3 /* 010 */,
|
||||
const char* right4 /* 011 */,
|
||||
const char* up3 /* 100 */,
|
||||
const char* up4 /* 101 */,
|
||||
const char* down3 /* 110 */,
|
||||
const char* down4 /* 111 */
|
||||
);
|
||||
class swipe_gesture : protected xdo_gesture
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
swipe_gesture(
|
||||
const float threshold,
|
||||
const char* left3 /* 000 */,
|
||||
const char* left4 /* 001 */,
|
||||
const char* right3 /* 010 */,
|
||||
const char* right4 /* 011 */,
|
||||
const char* up3 /* 100 */,
|
||||
const char* up4 /* 101 */,
|
||||
const char* down3 /* 110 */,
|
||||
const char* down4 /* 111 */
|
||||
);
|
||||
|
||||
~swipe_gesture();
|
||||
~swipe_gesture();
|
||||
|
||||
// fields for xdo
|
||||
int fingers;
|
||||
float dx, dy, udx, udy;
|
||||
// fields for xdo
|
||||
int fingers;
|
||||
float dx, dy, udx, udy;
|
||||
|
||||
void begin() override;
|
||||
void update() override;
|
||||
void end() override;
|
||||
bool parse_line(const char *) override;
|
||||
void begin() override;
|
||||
void update() override;
|
||||
void end() override;
|
||||
bool parse_line(const char *) override;
|
||||
|
||||
protected:
|
||||
// location of mouse
|
||||
int screen_num, ix, iy;
|
||||
protected:
|
||||
// location of mouse
|
||||
int screen_num, ix, iy;
|
||||
|
||||
// current location
|
||||
float x, y, threshold_squared;
|
||||
int previous_gesture;
|
||||
const char ** commands;
|
||||
// current location
|
||||
float x, y, threshold_squared;
|
||||
int previous_gesture;
|
||||
const char ** commands;
|
||||
|
||||
// optimization flag for checking if GESTURE_SWIPE_BEGIN was dispatched
|
||||
bool flag_swiping;
|
||||
// optimization flag for checking if GESTURE_SWIPE_BEGIN was dispatched
|
||||
bool flag_swiping;
|
||||
|
||||
public:
|
||||
// static constants
|
||||
static const int MSK_THREE_FINGERS;
|
||||
static const int MSK_FOUR_FINGERS;
|
||||
static const int MSK_NEGATIVE;
|
||||
static const int MSK_POSITIVE;
|
||||
static const int MSK_HORIZONTAL;
|
||||
static const int MSK_VERTICAL;
|
||||
static const int FRESH;
|
||||
static const char * const command_map[8];
|
||||
// regex patterns
|
||||
static const char* GESTURE_BEGIN_REGEX_PATTERN;
|
||||
static const char* GESTURE_UPDATE_REGEX_PATTERN;
|
||||
static const char* GESTURE_END_REGEX_PATTERN;
|
||||
};
|
||||
public:
|
||||
// static constants
|
||||
static const int MSK_THREE_FINGERS;
|
||||
static const int MSK_FOUR_FINGERS;
|
||||
static const int MSK_NEGATIVE;
|
||||
static const int MSK_POSITIVE;
|
||||
static const int MSK_HORIZONTAL;
|
||||
static const int MSK_VERTICAL;
|
||||
static const int FRESH;
|
||||
static const char * const command_map[8];
|
||||
// regex patterns
|
||||
static const char* GESTURE_BEGIN_REGEX_PATTERN;
|
||||
static const char* GESTURE_UPDATE_REGEX_PATTERN;
|
||||
static const char* GESTURE_END_REGEX_PATTERN;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __COMFORTABLE_SWIPE__gesture_swipe_gesture_h__ */
|
||||
@@ -21,71 +21,74 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "swipe_gesture.h"
|
||||
|
||||
namespace comfortable_swipe::gesture
|
||||
namespace comfortable_swipe
|
||||
{
|
||||
/**
|
||||
* Regex pattern for the libinput entry for start of swipe.
|
||||
* Extracts one match for the number of fingers used during the swipe.
|
||||
*
|
||||
* eg. event15 GESTURE_SWIPE_BEGIN +34.33s 3
|
||||
* ^
|
||||
* fingers
|
||||
*/
|
||||
const char* swipe_gesture::GESTURE_BEGIN_REGEX_PATTERN =
|
||||
"^" // start of string
|
||||
"[ -]event\\d+" // event
|
||||
"\\s+GESTURE_SWIPE_BEGIN" // gesture
|
||||
"\\s+\\S+" // timestamp
|
||||
"\\s+(\\d+)" // fingers
|
||||
"\\s*$" // end of string
|
||||
;
|
||||
namespace gesture
|
||||
{
|
||||
/**
|
||||
* Regex pattern for the libinput entry for start of swipe.
|
||||
* Extracts one match for the number of fingers used during the swipe.
|
||||
*
|
||||
* eg. event15 GESTURE_SWIPE_BEGIN +34.33s 3
|
||||
* ^
|
||||
* fingers
|
||||
*/
|
||||
const char* swipe_gesture::GESTURE_BEGIN_REGEX_PATTERN =
|
||||
"^" // start of string
|
||||
"[ -]event\\d+" // event
|
||||
"\\s+GESTURE_SWIPE_BEGIN" // gesture
|
||||
"\\s+\\S+" // timestamp
|
||||
"\\s+(\\d+)" // fingers
|
||||
"\\s*$" // end of string
|
||||
;
|
||||
|
||||
/**
|
||||
* Regex pattern for the libinput entry for the end of swipe.
|
||||
* Extracts one match for the number of fingers used during the swipe.
|
||||
*
|
||||
* eg. event15 GESTURE_SWIPE_END +35.03s 3
|
||||
* ^
|
||||
* fingers
|
||||
*/
|
||||
const char* swipe_gesture::GESTURE_END_REGEX_PATTERN =
|
||||
"^" // start of string
|
||||
"[ -]event\\d+" // event
|
||||
"\\s+GESTURE_SWIPE_END" // gesture
|
||||
"\\s+\\S+" // timestamp
|
||||
"\\s+(\\d+)" // fingers
|
||||
"\\s*$" // end of string
|
||||
;
|
||||
/**
|
||||
* Regex pattern for the libinput entry for the end of swipe.
|
||||
* Extracts one match for the number of fingers used during the swipe.
|
||||
*
|
||||
* eg. event15 GESTURE_SWIPE_END +35.03s 3
|
||||
* ^
|
||||
* fingers
|
||||
*/
|
||||
const char* swipe_gesture::GESTURE_END_REGEX_PATTERN =
|
||||
"^" // start of string
|
||||
"[ -]event\\d+" // event
|
||||
"\\s+GESTURE_SWIPE_END" // gesture
|
||||
"\\s+\\S+" // timestamp
|
||||
"\\s+(\\d+)" // fingers
|
||||
"\\s*$" // end of string
|
||||
;
|
||||
|
||||
// matches signed decimal numbers (eg. "6.02" "-1.1")
|
||||
#define CF_NUMBER_REGEX "-?\\d+(?:\\.\\d+)"
|
||||
// matches signed decimal numbers (eg. "6.02" "-1.1")
|
||||
#define CF_NUMBER_REGEX "-?\\d+(?:\\.\\d+)"
|
||||
|
||||
// matches and extracts a space-prefixed signed fraction (eg. "-3.00/ 5.12")
|
||||
#define CF_NUMBER_DIVISION "\\s*(" CF_NUMBER_REGEX ")/\\s*(" CF_NUMBER_REGEX ")"
|
||||
// matches and extracts a space-prefixed signed fraction (eg. "-3.00/ 5.12")
|
||||
#define CF_NUMBER_DIVISION "\\s*(" CF_NUMBER_REGEX ")/\\s*(" CF_NUMBER_REGEX ")"
|
||||
|
||||
/**
|
||||
* Regex pattern for the libinput entry for during a swipe.
|
||||
* Extracts number of fingers used and the speed (normal and accelerated) of the swipe.
|
||||
*
|
||||
* eg. event15 GESTURE_SWIPE_UPDATE +34.70s 3 -0.12/ 4.99 (-0.33/13.50 unaccelerated)
|
||||
* ^ ^ ^ ^ ^
|
||||
* fingers dx dy udx udy
|
||||
*/
|
||||
const char* swipe_gesture::GESTURE_UPDATE_REGEX_PATTERN =
|
||||
"^" // start of string
|
||||
"[ -]event\\d+" // event
|
||||
"\\s+GESTURE_SWIPE_UPDATE" // gesture
|
||||
"\\s+\\S+" // timestamp
|
||||
"\\s+(\\d+)" // fingers
|
||||
"\\s+" CF_NUMBER_DIVISION // speed (dx/dy)
|
||||
"\\s+\\(" CF_NUMBER_DIVISION "\\s+unaccelerated\\)" // unaccelerated speed (udx/udy)
|
||||
"\\s*$" // end of string
|
||||
;
|
||||
/**
|
||||
* Regex pattern for the libinput entry for during a swipe.
|
||||
* Extracts number of fingers used and the speed (normal and accelerated) of the swipe.
|
||||
*
|
||||
* eg. event15 GESTURE_SWIPE_UPDATE +34.70s 3 -0.12/ 4.99 (-0.33/13.50 unaccelerated)
|
||||
* ^ ^ ^ ^ ^
|
||||
* fingers dx dy udx udy
|
||||
*/
|
||||
const char* swipe_gesture::GESTURE_UPDATE_REGEX_PATTERN =
|
||||
"^" // start of string
|
||||
"[ -]event\\d+" // event
|
||||
"\\s+GESTURE_SWIPE_UPDATE" // gesture
|
||||
"\\s+\\S+" // timestamp
|
||||
"\\s+(\\d+)" // fingers
|
||||
"\\s+" CF_NUMBER_DIVISION // speed (dx/dy)
|
||||
"\\s+\\(" CF_NUMBER_DIVISION "\\s+unaccelerated\\)" // unaccelerated speed (udx/udy)
|
||||
"\\s*$" // end of string
|
||||
;
|
||||
|
||||
// delete macros
|
||||
#undef CF_NUMBER_DIVISION
|
||||
#undef CF_NUMBER_EXTRACT
|
||||
#undef CF_NUMBER_REGEX
|
||||
// delete macros
|
||||
#undef CF_NUMBER_DIVISION
|
||||
#undef CF_NUMBER_EXTRACT
|
||||
#undef CF_NUMBER_REGEX
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __COMFORTABLE_SWIPE__gesture_swipe_gesture_regex__ */
|
||||
+16
-13
@@ -26,21 +26,24 @@ extern "C"
|
||||
|
||||
#include "xdo_gesture.h"
|
||||
|
||||
namespace comfortable_swipe::gesture
|
||||
namespace comfortable_swipe
|
||||
{
|
||||
/**
|
||||
* Constructs a new gesture handler with xdo.
|
||||
*/
|
||||
xdo_gesture::xdo_gesture():
|
||||
xdo(xdo_new(NULL))
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Constructs a new swipe gesture with xdo.
|
||||
*/
|
||||
xdo_gesture::~xdo_gesture()
|
||||
namespace gesture
|
||||
{
|
||||
xdo_free(this->xdo);
|
||||
/**
|
||||
* Constructs a new gesture handler with xdo.
|
||||
*/
|
||||
xdo_gesture::xdo_gesture():
|
||||
xdo(xdo_new(NULL))
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Constructs a new swipe gesture with xdo.
|
||||
*/
|
||||
xdo_gesture::~xdo_gesture()
|
||||
{
|
||||
xdo_free(this->xdo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user