Add HiresScroll device feature
This commit is contained in:
parent
d6f5c35983
commit
055d136b09
|
@ -18,6 +18,7 @@ add_executable(logid
|
|||
Configuration.cpp
|
||||
features/DPI.cpp
|
||||
features/SmartShift.cpp
|
||||
features/HiresScroll.cpp
|
||||
features/RemapButton.cpp
|
||||
actions/Action.cpp
|
||||
actions/KeypressAction.cpp
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "features/SmartShift.h"
|
||||
#include "features/RemapButton.h"
|
||||
#include "backend/hidpp20/features/Reset.h"
|
||||
#include "features/HiresScroll.h"
|
||||
|
||||
using namespace logid;
|
||||
using namespace logid::backend;
|
||||
|
@ -48,6 +49,7 @@ void Device::_init()
|
|||
|
||||
_addFeature<features::DPI>("dpi");
|
||||
_addFeature<features::SmartShift>("smartshift");
|
||||
_addFeature<features::HiresScroll>("hiresscroll");
|
||||
_addFeature<features::RemapButton>("remapbutton");
|
||||
|
||||
_makeResetMechanism();
|
||||
|
|
101
src/logid/features/HiresScroll.cpp
Normal file
101
src/logid/features/HiresScroll.cpp
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright 2019-2020 PixlOne
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "HiresScroll.h"
|
||||
#include "../Device.h"
|
||||
|
||||
using namespace logid::features;
|
||||
using namespace logid::backend;
|
||||
|
||||
HiresScroll::HiresScroll(Device *dev) : DeviceFeature(dev),
|
||||
_hires_scroll(&dev->hidpp20()), _config(dev)
|
||||
{
|
||||
}
|
||||
|
||||
void HiresScroll::configure()
|
||||
{
|
||||
auto mode = _hires_scroll.getMode();
|
||||
mode &= ~_config.getMask();
|
||||
mode |= (_config.getMode() & _config.getMask());
|
||||
_hires_scroll.setMode(mode);
|
||||
}
|
||||
|
||||
void HiresScroll::listen()
|
||||
{
|
||||
///TODO: Map hires scroll events
|
||||
}
|
||||
|
||||
HiresScroll::Config::Config(Device *dev) : DeviceFeature::Config(dev)
|
||||
{
|
||||
try {
|
||||
auto& config_root = dev->config().getSetting("hiresscroll");
|
||||
if(!config_root.isGroup()) {
|
||||
logPrintf(WARN, "Line %d: hiresscroll must be a group",
|
||||
config_root.getSourceLine());
|
||||
return;
|
||||
}
|
||||
_mode = 0;
|
||||
_mask = 0;
|
||||
try {
|
||||
auto& hires = config_root.lookup("hires");
|
||||
if(hires.getType() == libconfig::Setting::TypeBoolean) {
|
||||
_mask |= hidpp20::HiresScroll::Mode::HiRes;
|
||||
if(hires)
|
||||
_mode |= hidpp20::HiresScroll::Mode::HiRes;
|
||||
} else {
|
||||
logPrintf(WARN, "Line %d: hires must be a boolean",
|
||||
hires.getSourceLine());
|
||||
}
|
||||
} catch(libconfig::SettingNotFoundException& e) { }
|
||||
|
||||
try {
|
||||
auto& invert = config_root.lookup("invert");
|
||||
if(invert.getType() == libconfig::Setting::TypeBoolean) {
|
||||
_mask |= hidpp20::HiresScroll::Mode::Inverted;
|
||||
if(invert)
|
||||
_mode |= hidpp20::HiresScroll::Mode::Inverted;
|
||||
} else {
|
||||
logPrintf(WARN, "Line %d: invert must be a boolean, ignoring.",
|
||||
invert.getSourceLine());
|
||||
}
|
||||
} catch(libconfig::SettingNotFoundException& e) { }
|
||||
|
||||
try {
|
||||
auto& target = config_root.lookup("target");
|
||||
if(target.getType() == libconfig::Setting::TypeBoolean) {
|
||||
_mask |= hidpp20::HiresScroll::Mode::Target;
|
||||
if(target)
|
||||
_mode |= hidpp20::HiresScroll::Mode::Target;
|
||||
} else {
|
||||
logPrintf(WARN, "Line %d: target must be a boolean, ignoring.",
|
||||
target.getSourceLine());
|
||||
}
|
||||
} catch(libconfig::SettingNotFoundException& e) { }
|
||||
} catch(libconfig::SettingNotFoundException& e) {
|
||||
// HiresScroll not configured, use default
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t HiresScroll::Config::getMode() const
|
||||
{
|
||||
return _mode;
|
||||
}
|
||||
|
||||
uint8_t HiresScroll::Config::getMask() const
|
||||
{
|
||||
return _mask;
|
||||
}
|
50
src/logid/features/HiresScroll.h
Normal file
50
src/logid/features/HiresScroll.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2019-2020 PixlOne
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef LOGID_FEATURE_HIRESSCROLL_H
|
||||
#define LOGID_FEATURE_HIRESSCROLL_H
|
||||
|
||||
#include "../backend/hidpp20/features/HiresScroll.h"
|
||||
#include "DeviceFeature.h"
|
||||
|
||||
namespace logid {
|
||||
namespace features
|
||||
{
|
||||
class HiresScroll : public DeviceFeature
|
||||
{
|
||||
public:
|
||||
explicit HiresScroll(Device* dev);
|
||||
virtual void configure();
|
||||
virtual void listen();
|
||||
|
||||
class Config : public DeviceFeature::Config
|
||||
{
|
||||
public:
|
||||
explicit Config(Device* dev);
|
||||
uint8_t getMode() const;
|
||||
uint8_t getMask() const;
|
||||
protected:
|
||||
uint8_t _mode;
|
||||
uint8_t _mask;
|
||||
};
|
||||
private:
|
||||
backend::hidpp20::HiresScroll _hires_scroll;
|
||||
Config _config;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif //LOGID_FEATURE_HIRESSCROLL_H
|
|
@ -55,7 +55,7 @@ SmartShift::Config::Config(Device *dev) : DeviceFeature::Config(dev), _status()
|
|||
if(_status.setDefaultAutoDisengage)
|
||||
_status.defaultAutoDisengage = tmp;
|
||||
} catch(libconfig::SettingNotFoundException& e) {
|
||||
// DPI not configured, use default
|
||||
// SmartShift not configured, use default
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user