Fix ThresholdGesture

Style fixes, allow to compile, add copyright notice.
master
pixl 4 years ago
parent e570e7b91e
commit 41903992ef
No known key found for this signature in database
GPG Key ID: 1866C148CD593B6E
  1. 19
      src/logid/actions/gesture/ThresholdGesture.cpp
  2. 8
      src/logid/actions/gesture/ThresholdGesture.h

@ -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
* it under the terms of the GNU General Public License as published by
@ -24,31 +24,36 @@ ThresholdGesture::ThresholdGesture(Device *device, libconfig::Setting &root) :
{
}
void ThresholdGesture::press()
void ThresholdGesture::press(bool init_threshold)
{
_axis = 0;
this->executed = false;
_axis = init_threshold ? _config.threshold() : 0;
this->_executed = false;
}
void ThresholdGesture::release(bool primary)
{
(void)primary; // Suppress unused warning
this->executed = false;
this->_executed = false;
}
void ThresholdGesture::move(int16_t axis)
{
_axis += axis;
if(!this->executed && metThreshold()) {
if(!this->_executed && metThreshold()) {
_config.action()->press();
_config.action()->release();
this->executed = true;
this->_executed = true;
}
}
bool ThresholdGesture::metThreshold() const
{
return _axis >= _config.threshold();
}
bool ThresholdGesture::wheelCompatibility() const
{
return false;
}

@ -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
* it under the terms of the GNU General Public License as published by
@ -28,18 +28,20 @@ namespace actions
public:
ThresholdGesture(Device* device, libconfig::Setting& root);
virtual void press();
virtual void press(bool init_threshold=false);
virtual void release(bool primary=false);
virtual void move(int16_t axis);
virtual bool metThreshold() const;
virtual bool wheelCompatibility() const;
protected:
int16_t _axis;
Gesture::Config _config;
private:
bool executed = false;
bool _executed = false;
};
}}

Loading…
Cancel
Save