Fix ThresholdGesture

Style fixes, allow to compile, add copyright notice.
This commit is contained in:
pixl 2020-08-21 16:57:40 -04:00
parent e570e7b91e
commit 41903992ef
No known key found for this signature in database
GPG Key ID: 1866C148CD593B6E
2 changed files with 17 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2019-2020 PixlOne * Copyright 2019-2020 PixlOne, michtere
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -24,27 +24,27 @@ ThresholdGesture::ThresholdGesture(Device *device, libconfig::Setting &root) :
{ {
} }
void ThresholdGesture::press() void ThresholdGesture::press(bool init_threshold)
{ {
_axis = 0; _axis = init_threshold ? _config.threshold() : 0;
this->executed = false; this->_executed = false;
} }
void ThresholdGesture::release(bool primary) void ThresholdGesture::release(bool primary)
{ {
(void)primary; // Suppress unused warning (void)primary; // Suppress unused warning
this->executed = false; this->_executed = false;
} }
void ThresholdGesture::move(int16_t axis) void ThresholdGesture::move(int16_t axis)
{ {
_axis += axis; _axis += axis;
if(!this->executed && metThreshold()) { if(!this->_executed && metThreshold()) {
_config.action()->press(); _config.action()->press();
_config.action()->release(); _config.action()->release();
this->executed = true; this->_executed = true;
} }
} }
@ -52,3 +52,8 @@ bool ThresholdGesture::metThreshold() const
{ {
return _axis >= _config.threshold(); return _axis >= _config.threshold();
} }
bool ThresholdGesture::wheelCompatibility() const
{
return false;
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2019-2020 PixlOne * Copyright 2019-2020 PixlOne, michtere
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -28,18 +28,20 @@ namespace actions
public: public:
ThresholdGesture(Device* device, libconfig::Setting& root); ThresholdGesture(Device* device, libconfig::Setting& root);
virtual void press(); virtual void press(bool init_threshold=false);
virtual void release(bool primary=false); virtual void release(bool primary=false);
virtual void move(int16_t axis); virtual void move(int16_t axis);
virtual bool metThreshold() const; virtual bool metThreshold() const;
virtual bool wheelCompatibility() const;
protected: protected:
int16_t _axis; int16_t _axis;
Gesture::Config _config; Gesture::Config _config;
private: private:
bool executed = false; bool _executed = false;
}; };
}} }}