mirror of
https://github.com/PixlOne/logiops.git
synced 2025-09-14 13:56:50 +08:00
Initial action and gesture ipc interfaces
This commit is contained in:
parent
6e8c24b2f9
commit
87fb4371a4
@ -42,37 +42,39 @@ template <typename T>
|
|||||||
struct action_type<T&> : action_type<T> { };
|
struct action_type<T&> : action_type<T> { };
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::shared_ptr<Action> _makeAction(Device* device,
|
std::shared_ptr<Action> _makeAction(
|
||||||
T action) {
|
Device* device, T action,
|
||||||
return std::make_shared<typename action_type<T>::type>(device, action);
|
const std::shared_ptr<ipcgull::node>& parent) {
|
||||||
|
return std::make_shared<typename action_type<T>::type>(device, action, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::shared_ptr<Action> _makeAction(
|
std::shared_ptr<Action> _makeAction(
|
||||||
Device *device, const std::string &name,
|
Device *device, const std::string &name,
|
||||||
std::optional<T>& config)
|
std::optional<T>& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent)
|
||||||
{
|
{
|
||||||
if(name == ChangeDPI::interface_name) {
|
if(name == ChangeDPI::interface_name) {
|
||||||
config = config::ChangeDPI();
|
config = config::ChangeDPI();
|
||||||
return Action::makeAction(device, config.value());
|
return Action::makeAction(device, config.value(), parent);
|
||||||
} else if(name == ChangeHostAction::interface_name) {
|
} else if(name == ChangeHostAction::interface_name) {
|
||||||
config = config::ChangeHost();
|
config = config::ChangeHost();
|
||||||
return Action::makeAction(device, config.value());
|
return Action::makeAction(device, config.value(), parent);
|
||||||
} else if(name == CycleDPI::interface_name) {
|
} else if(name == CycleDPI::interface_name) {
|
||||||
config = config::CycleDPI();
|
config = config::CycleDPI();
|
||||||
return Action::makeAction(device, config.value());
|
return Action::makeAction(device, config.value(), parent);
|
||||||
} else if(name == KeypressAction::interface_name) {
|
} else if(name == KeypressAction::interface_name) {
|
||||||
config = config::KeypressAction();
|
config = config::KeypressAction();
|
||||||
return Action::makeAction(device, config.value());
|
return Action::makeAction(device, config.value(), parent);
|
||||||
} else if(name == NullAction::interface_name) {
|
} else if(name == NullAction::interface_name) {
|
||||||
config = config::NoAction();
|
config = config::NoAction();
|
||||||
return Action::makeAction(device, config.value());
|
return Action::makeAction(device, config.value(), parent);
|
||||||
} else if(name == ToggleHiresScroll::interface_name) {
|
} else if(name == ToggleHiresScroll::interface_name) {
|
||||||
config = config::ToggleHiresScroll();
|
config = config::ToggleHiresScroll();
|
||||||
return Action::makeAction(device, config.value());
|
return Action::makeAction(device, config.value(), parent);
|
||||||
} else if(name == ToggleSmartShift::interface_name) {
|
} else if(name == ToggleSmartShift::interface_name) {
|
||||||
config = config::ToggleHiresScroll();
|
config = config::ToggleHiresScroll();
|
||||||
return Action::makeAction(device, config.value());
|
return Action::makeAction(device, config.value(), parent);
|
||||||
} else if(name == "pizza.pixl.LogiOps.Action.Default") {
|
} else if(name == "pizza.pixl.LogiOps.Action.Default") {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -82,42 +84,46 @@ std::shared_ptr<Action> _makeAction(
|
|||||||
|
|
||||||
std::shared_ptr<Action> Action::makeAction(
|
std::shared_ptr<Action> Action::makeAction(
|
||||||
Device *device, const std::string &name,
|
Device *device, const std::string &name,
|
||||||
std::optional<config::BasicAction> &config)
|
std::optional<config::BasicAction> &config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent)
|
||||||
{
|
{
|
||||||
return _makeAction(device, name, config);
|
return _makeAction(device, name, config, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Action> Action::makeAction(
|
std::shared_ptr<Action> Action::makeAction(
|
||||||
Device *device, const std::string &name,
|
Device *device, const std::string &name,
|
||||||
std::optional<config::Action> &config)
|
std::optional<config::Action> &config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return _makeAction(device, name, config);
|
return _makeAction(device, name, config, parent);
|
||||||
} catch(actions::InvalidAction& e) {
|
} catch(actions::InvalidAction& e) {
|
||||||
if(name == GestureAction::interface_name) {
|
if(name == GestureAction::interface_name) {
|
||||||
config = config::GestureAction();
|
config = config::GestureAction();
|
||||||
return makeAction(device, config.value());
|
return makeAction(device, config.value(), parent);
|
||||||
}
|
}
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Action> Action::makeAction(Device *device,
|
std::shared_ptr<Action> Action::makeAction(
|
||||||
config::BasicAction& action)
|
Device *device, config::BasicAction& action,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent)
|
||||||
{
|
{
|
||||||
std::shared_ptr<Action> ret;
|
std::shared_ptr<Action> ret;
|
||||||
std::visit([&device, &ret](auto&& x) {
|
std::visit([&device, &ret, &parent](auto&& x) {
|
||||||
ret = _makeAction(device, x);
|
ret = _makeAction(device, x, parent);
|
||||||
}, action);
|
}, action);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Action> Action::makeAction(Device *device,
|
std::shared_ptr<Action> Action::makeAction(
|
||||||
config::Action& action)
|
Device *device, config::Action& action,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent)
|
||||||
{
|
{
|
||||||
std::shared_ptr<Action> ret;
|
std::shared_ptr<Action> ret;
|
||||||
std::visit([&device, &ret](auto&& x) {
|
std::visit([&device, &ret, &parent](auto&& x) {
|
||||||
ret = _makeAction(device, x);
|
ret = _makeAction(device, x, parent);
|
||||||
}, action);
|
}, action);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <libconfig.h++>
|
#include <libconfig.h++>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <ipcgull/node.h>
|
||||||
|
#include <ipcgull/interface.h>
|
||||||
#include "../config/schema.h"
|
#include "../config/schema.h"
|
||||||
|
|
||||||
namespace logid {
|
namespace logid {
|
||||||
@ -48,17 +50,21 @@ namespace actions {
|
|||||||
public:
|
public:
|
||||||
static std::shared_ptr<Action> makeAction(
|
static std::shared_ptr<Action> makeAction(
|
||||||
Device* device, const std::string& name,
|
Device* device, const std::string& name,
|
||||||
std::optional<config::BasicAction>& config);
|
std::optional<config::BasicAction>& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent);
|
||||||
|
|
||||||
static std::shared_ptr<Action> makeAction(
|
static std::shared_ptr<Action> makeAction(
|
||||||
Device* device, const std::string& name,
|
Device* device, const std::string& name,
|
||||||
std::optional<config::Action>& config);
|
std::optional<config::Action>& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent);
|
||||||
|
|
||||||
static std::shared_ptr<Action> makeAction(Device* device,
|
static std::shared_ptr<Action> makeAction(
|
||||||
config::BasicAction& action);
|
Device* device, config::BasicAction& action,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent);
|
||||||
|
|
||||||
static std::shared_ptr<Action> makeAction(Device* device,
|
static std::shared_ptr<Action> makeAction(
|
||||||
config::Action& action);
|
Device* device, config::Action& action,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent);
|
||||||
|
|
||||||
virtual void press() = 0;
|
virtual void press() = 0;
|
||||||
virtual void release() = 0;
|
virtual void release() = 0;
|
||||||
|
@ -27,7 +27,9 @@ using namespace logid::actions;
|
|||||||
const char* ChangeDPI::interface_name =
|
const char* ChangeDPI::interface_name =
|
||||||
"pizza.pixl.LogiOps.Action.ChangeDPI";
|
"pizza.pixl.LogiOps.Action.ChangeDPI";
|
||||||
|
|
||||||
ChangeDPI::ChangeDPI(Device *device, config::ChangeDPI& config) :
|
ChangeDPI::ChangeDPI(
|
||||||
|
Device *device, config::ChangeDPI& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent) :
|
||||||
Action(device), _config (config)
|
Action(device), _config (config)
|
||||||
{
|
{
|
||||||
_dpi = _device->getFeature<features::DPI>("dpi");
|
_dpi = _device->getFeature<features::DPI>("dpi");
|
||||||
@ -36,6 +38,8 @@ ChangeDPI::ChangeDPI(Device *device, config::ChangeDPI& config) :
|
|||||||
"ChangeDPI action.",
|
"ChangeDPI action.",
|
||||||
_device->hidpp20().devicePath().c_str(),
|
_device->hidpp20().devicePath().c_str(),
|
||||||
_device->hidpp20().deviceIndex());
|
_device->hidpp20().deviceIndex());
|
||||||
|
|
||||||
|
_ipc = parent->make_interface<IPC>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeDPI::press()
|
void ChangeDPI::press()
|
||||||
@ -71,3 +75,8 @@ uint8_t ChangeDPI::reprogFlags() const
|
|||||||
{
|
{
|
||||||
return backend::hidpp20::ReprogControls::TemporaryDiverted;
|
return backend::hidpp20::ReprogControls::TemporaryDiverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChangeDPI::IPC::IPC(ChangeDPI *action) :
|
||||||
|
ipcgull::interface(interface_name, {}, {}, {}), _action (*action)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -29,7 +29,8 @@ namespace logid {
|
|||||||
public:
|
public:
|
||||||
static const char* interface_name;
|
static const char* interface_name;
|
||||||
|
|
||||||
explicit ChangeDPI(Device* device, config::ChangeDPI& setting);
|
ChangeDPI(Device* device, config::ChangeDPI& setting,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent);
|
||||||
|
|
||||||
virtual void press();
|
virtual void press();
|
||||||
virtual void release();
|
virtual void release();
|
||||||
@ -39,6 +40,16 @@ namespace logid {
|
|||||||
protected:
|
protected:
|
||||||
config::ChangeDPI& _config;
|
config::ChangeDPI& _config;
|
||||||
std::shared_ptr<features::DPI> _dpi;
|
std::shared_ptr<features::DPI> _dpi;
|
||||||
|
private:
|
||||||
|
class IPC : public ipcgull::interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IPC(ChangeDPI* action);
|
||||||
|
private:
|
||||||
|
ChangeDPI& _action;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<IPC> _ipc;
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -27,7 +27,9 @@ using namespace logid::backend;
|
|||||||
const char* ChangeHostAction::interface_name =
|
const char* ChangeHostAction::interface_name =
|
||||||
"pizza.pixl.LogiOps.Action.ChangeHost";
|
"pizza.pixl.LogiOps.Action.ChangeHost";
|
||||||
|
|
||||||
ChangeHostAction::ChangeHostAction(Device *device, config::ChangeHost& config)
|
ChangeHostAction::ChangeHostAction(
|
||||||
|
Device *device, config::ChangeHost& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent)
|
||||||
: Action(device), _config (config)
|
: Action(device), _config (config)
|
||||||
{
|
{
|
||||||
if(std::holds_alternative<std::string>(_config.host)) {
|
if(std::holds_alternative<std::string>(_config.host)) {
|
||||||
@ -42,6 +44,8 @@ ChangeHostAction::ChangeHostAction(Device *device, config::ChangeHost& config)
|
|||||||
"ChangeHostAction will not work.", device->hidpp20()
|
"ChangeHostAction will not work.", device->hidpp20()
|
||||||
.devicePath().c_str(), device->hidpp20().deviceIndex());
|
.devicePath().c_str(), device->hidpp20().deviceIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ipc = parent->make_interface<IPC>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeHostAction::press()
|
void ChangeHostAction::press()
|
||||||
@ -78,3 +82,8 @@ uint8_t ChangeHostAction::reprogFlags() const
|
|||||||
{
|
{
|
||||||
return hidpp20::ReprogControls::TemporaryDiverted;
|
return hidpp20::ReprogControls::TemporaryDiverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChangeHostAction::IPC::IPC(ChangeHostAction *action) :
|
||||||
|
ipcgull::interface(interface_name, {}, {}, {}), _action (*action)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -30,7 +30,8 @@ namespace actions
|
|||||||
public:
|
public:
|
||||||
static const char* interface_name;
|
static const char* interface_name;
|
||||||
|
|
||||||
ChangeHostAction(Device* device, config::ChangeHost& config);
|
ChangeHostAction(Device* device, config::ChangeHost& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent);
|
||||||
|
|
||||||
virtual void press();
|
virtual void press();
|
||||||
virtual void release();
|
virtual void release();
|
||||||
@ -40,6 +41,16 @@ namespace actions
|
|||||||
protected:
|
protected:
|
||||||
std::shared_ptr<backend::hidpp20::ChangeHost> _change_host;
|
std::shared_ptr<backend::hidpp20::ChangeHost> _change_host;
|
||||||
config::ChangeHost& _config;
|
config::ChangeHost& _config;
|
||||||
|
private:
|
||||||
|
class IPC : public ipcgull::interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IPC(ChangeHostAction* action);
|
||||||
|
private:
|
||||||
|
ChangeHostAction& _action;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<IPC> _ipc;
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ using namespace libconfig;
|
|||||||
const char* CycleDPI::interface_name =
|
const char* CycleDPI::interface_name =
|
||||||
"pizza.pixl.LogiOps.Action.CycleDPI";
|
"pizza.pixl.LogiOps.Action.CycleDPI";
|
||||||
|
|
||||||
CycleDPI::CycleDPI(Device* device, config::CycleDPI& config) :
|
CycleDPI::CycleDPI(Device* device, config::CycleDPI& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent) :
|
||||||
Action (device), _config (config), _current_dpi (_config.dpis.begin())
|
Action (device), _config (config), _current_dpi (_config.dpis.begin())
|
||||||
{
|
{
|
||||||
_dpi = _device->getFeature<features::DPI>("dpi");
|
_dpi = _device->getFeature<features::DPI>("dpi");
|
||||||
@ -37,6 +38,8 @@ CycleDPI::CycleDPI(Device* device, config::CycleDPI& config) :
|
|||||||
"CycleDPI action.",
|
"CycleDPI action.",
|
||||||
_device->hidpp20().devicePath().c_str(),
|
_device->hidpp20().devicePath().c_str(),
|
||||||
_device->hidpp20().deviceIndex());
|
_device->hidpp20().deviceIndex());
|
||||||
|
|
||||||
|
_ipc = parent->make_interface<IPC>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CycleDPI::press()
|
void CycleDPI::press()
|
||||||
@ -73,3 +76,8 @@ uint8_t CycleDPI::reprogFlags() const
|
|||||||
{
|
{
|
||||||
return backend::hidpp20::ReprogControls::TemporaryDiverted;
|
return backend::hidpp20::ReprogControls::TemporaryDiverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CycleDPI::IPC::IPC(CycleDPI *action) :
|
||||||
|
ipcgull::interface(interface_name, {}, {}, {}), _action (*action)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -29,7 +29,8 @@ namespace actions {
|
|||||||
public:
|
public:
|
||||||
static const char* interface_name;
|
static const char* interface_name;
|
||||||
|
|
||||||
explicit CycleDPI(Device* device, config::CycleDPI& setting);
|
CycleDPI(Device* device, config::CycleDPI& setting,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent);
|
||||||
|
|
||||||
virtual void press();
|
virtual void press();
|
||||||
virtual void release();
|
virtual void release();
|
||||||
@ -41,6 +42,16 @@ namespace actions {
|
|||||||
config::CycleDPI& _config;
|
config::CycleDPI& _config;
|
||||||
std::shared_ptr<features::DPI> _dpi;
|
std::shared_ptr<features::DPI> _dpi;
|
||||||
std::list<int>::const_iterator _current_dpi;
|
std::list<int>::const_iterator _current_dpi;
|
||||||
|
private:
|
||||||
|
class IPC : public ipcgull::interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IPC(CycleDPI* action);
|
||||||
|
private:
|
||||||
|
CycleDPI& _action;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<IPC> _ipc;
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -45,6 +45,25 @@ GestureAction::Direction GestureAction::toDirection(std::string direction)
|
|||||||
throw std::invalid_argument("direction");
|
throw std::invalid_argument("direction");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GestureAction::fromDirection(Direction direction)
|
||||||
|
{
|
||||||
|
switch(direction) {
|
||||||
|
case Up:
|
||||||
|
return "up";
|
||||||
|
case Down:
|
||||||
|
return "down";
|
||||||
|
case Left:
|
||||||
|
return "left";
|
||||||
|
case Right:
|
||||||
|
return "right";
|
||||||
|
case None:
|
||||||
|
return "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
// This shouldn't happen
|
||||||
|
throw InvalidGesture();
|
||||||
|
}
|
||||||
|
|
||||||
GestureAction::Direction GestureAction::toDirection(int16_t x, int16_t y)
|
GestureAction::Direction GestureAction::toDirection(int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
if(x >= 0 && y >= 0)
|
if(x >= 0 && y >= 0)
|
||||||
@ -57,7 +76,8 @@ GestureAction::Direction GestureAction::toDirection(int16_t x, int16_t y)
|
|||||||
return x <= -y ? Up : Right;
|
return x <= -y ? Up : Right;
|
||||||
}
|
}
|
||||||
|
|
||||||
GestureAction::GestureAction(Device* dev, config::GestureAction& config) :
|
GestureAction::GestureAction(Device* dev, config::GestureAction& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent) :
|
||||||
Action (dev), _config (config)
|
Action (dev), _config (config)
|
||||||
{
|
{
|
||||||
if(_config.gestures.has_value()) {
|
if(_config.gestures.has_value()) {
|
||||||
@ -66,12 +86,16 @@ GestureAction::GestureAction(Device* dev, config::GestureAction& config) :
|
|||||||
try {
|
try {
|
||||||
auto direction = toDirection(x.first);
|
auto direction = toDirection(x.first);
|
||||||
_gestures.emplace(direction,
|
_gestures.emplace(direction,
|
||||||
Gesture::makeGesture(dev, x.second));
|
Gesture::makeGesture(
|
||||||
|
dev, x.second, parent,
|
||||||
|
fromDirection(direction)));
|
||||||
} catch(std::invalid_argument& e) {
|
} catch(std::invalid_argument& e) {
|
||||||
logPrintf(WARN, "%s is not a direction", x.first.c_str());
|
logPrintf(WARN, "%s is not a direction", x.first.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ipc = parent->make_interface<IPC>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GestureAction::press()
|
void GestureAction::press()
|
||||||
@ -193,3 +217,8 @@ uint8_t GestureAction::reprogFlags() const
|
|||||||
return (hidpp20::ReprogControls::TemporaryDiverted |
|
return (hidpp20::ReprogControls::TemporaryDiverted |
|
||||||
hidpp20::ReprogControls::RawXYDiverted);
|
hidpp20::ReprogControls::RawXYDiverted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GestureAction::IPC::IPC(GestureAction *action) :
|
||||||
|
ipcgull::interface(interface_name, {}, {}, {}), _action (*action)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -39,9 +39,11 @@ namespace actions {
|
|||||||
Right
|
Right
|
||||||
};
|
};
|
||||||
static Direction toDirection(std::string direction);
|
static Direction toDirection(std::string direction);
|
||||||
|
static std::string fromDirection(Direction direction);
|
||||||
static Direction toDirection(int16_t x, int16_t y);
|
static Direction toDirection(int16_t x, int16_t y);
|
||||||
|
|
||||||
GestureAction(Device* dev, config::GestureAction& config);
|
GestureAction(Device* dev, config::GestureAction& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent);
|
||||||
|
|
||||||
virtual void press();
|
virtual void press();
|
||||||
virtual void release();
|
virtual void release();
|
||||||
@ -53,6 +55,17 @@ namespace actions {
|
|||||||
int16_t _x, _y;
|
int16_t _x, _y;
|
||||||
std::map<Direction, std::shared_ptr<Gesture>> _gestures;
|
std::map<Direction, std::shared_ptr<Gesture>> _gestures;
|
||||||
config::GestureAction& _config;
|
config::GestureAction& _config;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class IPC : public ipcgull::interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit IPC(GestureAction* action);
|
||||||
|
private:
|
||||||
|
GestureAction& _action;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<IPC> _ipc;
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ using namespace logid::backend;
|
|||||||
const char* KeypressAction::interface_name =
|
const char* KeypressAction::interface_name =
|
||||||
"pizza.pixl.LogiOps.Action.Keypress";
|
"pizza.pixl.LogiOps.Action.Keypress";
|
||||||
|
|
||||||
KeypressAction::KeypressAction(Device *device, config::KeypressAction& config) :
|
KeypressAction::KeypressAction(Device *device, config::KeypressAction& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent) :
|
||||||
Action(device), _config (config)
|
Action(device), _config (config)
|
||||||
{
|
{
|
||||||
if(std::holds_alternative<std::string>(_config.keys)) {
|
if(std::holds_alternative<std::string>(_config.keys)) {
|
||||||
@ -65,6 +66,8 @@ KeypressAction::KeypressAction(Device *device, config::KeypressAction& config) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ipc = parent->make_interface<IPC>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeypressAction::press()
|
void KeypressAction::press()
|
||||||
@ -85,3 +88,8 @@ uint8_t KeypressAction::reprogFlags() const
|
|||||||
{
|
{
|
||||||
return hidpp20::ReprogControls::TemporaryDiverted;
|
return hidpp20::ReprogControls::TemporaryDiverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeypressAction::IPC::IPC(KeypressAction *action) : ipcgull::interface(
|
||||||
|
interface_name, {}, {}, {}), _action (*action)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -29,7 +29,9 @@ namespace actions {
|
|||||||
public:
|
public:
|
||||||
static const char* interface_name;
|
static const char* interface_name;
|
||||||
|
|
||||||
KeypressAction(Device* dev, config::KeypressAction& config);
|
KeypressAction(Device* dev,
|
||||||
|
config::KeypressAction& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent);
|
||||||
|
|
||||||
virtual void press();
|
virtual void press();
|
||||||
virtual void release();
|
virtual void release();
|
||||||
@ -38,6 +40,16 @@ namespace actions {
|
|||||||
protected:
|
protected:
|
||||||
config::KeypressAction& _config;
|
config::KeypressAction& _config;
|
||||||
std::list<uint> _keys;
|
std::list<uint> _keys;
|
||||||
|
private:
|
||||||
|
class IPC : public ipcgull::interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit IPC(KeypressAction* action);
|
||||||
|
private:
|
||||||
|
KeypressAction& _action;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<IPC> _ipc;
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -24,7 +24,9 @@ using namespace logid::actions;
|
|||||||
const char* NullAction::interface_name =
|
const char* NullAction::interface_name =
|
||||||
"pizza.pixl.LogiOps.Action.None";
|
"pizza.pixl.LogiOps.Action.None";
|
||||||
|
|
||||||
NullAction::NullAction(Device* device) : Action(device)
|
NullAction::NullAction(Device* device,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent) :
|
||||||
|
Action(device), _ipc (parent->make_interface<IPC>())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,4 +43,8 @@ void NullAction::release()
|
|||||||
uint8_t NullAction::reprogFlags() const
|
uint8_t NullAction::reprogFlags() const
|
||||||
{
|
{
|
||||||
return backend::hidpp20::ReprogControls::TemporaryDiverted;
|
return backend::hidpp20::ReprogControls::TemporaryDiverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NullAction::IPC::IPC() : ipcgull::interface(interface_name, {}, {}, {})
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -28,14 +28,22 @@ namespace actions
|
|||||||
public:
|
public:
|
||||||
static const char* interface_name;
|
static const char* interface_name;
|
||||||
|
|
||||||
explicit NullAction(Device* device);
|
NullAction(Device* device,
|
||||||
NullAction(Device* device, [[maybe_unused]] config::NoAction& config) :
|
const std::shared_ptr<ipcgull::node>& parent);
|
||||||
NullAction(device) { }
|
NullAction(Device* device, [[maybe_unused]] config::NoAction& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent) :
|
||||||
|
NullAction(device, parent) { }
|
||||||
|
|
||||||
virtual void press();
|
virtual void press();
|
||||||
virtual void release();
|
virtual void release();
|
||||||
|
|
||||||
virtual uint8_t reprogFlags() const;
|
virtual uint8_t reprogFlags() const;
|
||||||
|
private:
|
||||||
|
class IPC : public ipcgull::interface {
|
||||||
|
public:
|
||||||
|
IPC();
|
||||||
|
};
|
||||||
|
std::shared_ptr<IPC> _ipc;
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -26,7 +26,9 @@ using namespace logid::backend;
|
|||||||
const char* ToggleHiresScroll::interface_name =
|
const char* ToggleHiresScroll::interface_name =
|
||||||
"pizza.pixl.LogiOps.Action.ToggleHiresScroll";
|
"pizza.pixl.LogiOps.Action.ToggleHiresScroll";
|
||||||
|
|
||||||
ToggleHiresScroll::ToggleHiresScroll(Device *dev) : Action (dev)
|
ToggleHiresScroll::ToggleHiresScroll(
|
||||||
|
Device *dev, const std::shared_ptr<ipcgull::node>& parent) :
|
||||||
|
Action (dev), _ipc (parent->make_interface<IPC>())
|
||||||
{
|
{
|
||||||
_hires_scroll = _device->getFeature<features::HiresScroll>("hiresscroll");
|
_hires_scroll = _device->getFeature<features::HiresScroll>("hiresscroll");
|
||||||
if(!_hires_scroll)
|
if(!_hires_scroll)
|
||||||
@ -58,4 +60,8 @@ void ToggleHiresScroll::release()
|
|||||||
uint8_t ToggleHiresScroll::reprogFlags() const
|
uint8_t ToggleHiresScroll::reprogFlags() const
|
||||||
{
|
{
|
||||||
return hidpp20::ReprogControls::TemporaryDiverted;
|
return hidpp20::ReprogControls::TemporaryDiverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ToggleHiresScroll::IPC::IPC() : ipcgull::interface(interface_name, {}, {}, {})
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -29,10 +29,11 @@ namespace actions
|
|||||||
public:
|
public:
|
||||||
static const char* interface_name;
|
static const char* interface_name;
|
||||||
|
|
||||||
explicit ToggleHiresScroll(Device* dev);
|
ToggleHiresScroll(Device* dev, const std::shared_ptr<ipcgull::node>& parent);
|
||||||
ToggleHiresScroll(Device* device,
|
ToggleHiresScroll(Device* device,
|
||||||
[[maybe_unused]] config::ToggleHiresScroll& action) :
|
[[maybe_unused]] config::ToggleHiresScroll& action,
|
||||||
ToggleHiresScroll(device) { }
|
const std::shared_ptr<ipcgull::node>& parent) :
|
||||||
|
ToggleHiresScroll(device, parent) { }
|
||||||
|
|
||||||
virtual void press();
|
virtual void press();
|
||||||
virtual void release();
|
virtual void release();
|
||||||
@ -40,6 +41,14 @@ namespace actions
|
|||||||
virtual uint8_t reprogFlags() const;
|
virtual uint8_t reprogFlags() const;
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<features::HiresScroll> _hires_scroll;
|
std::shared_ptr<features::HiresScroll> _hires_scroll;
|
||||||
|
private:
|
||||||
|
class IPC : public ipcgull::interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IPC();
|
||||||
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<IPC> _ipc;
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -26,7 +26,9 @@ using namespace logid::backend;
|
|||||||
const char* ToggleSmartShift::interface_name =
|
const char* ToggleSmartShift::interface_name =
|
||||||
"pizza.pixl.LogiOps.Action.ToggleSmartShift";
|
"pizza.pixl.LogiOps.Action.ToggleSmartShift";
|
||||||
|
|
||||||
ToggleSmartShift::ToggleSmartShift(Device *dev) : Action (dev)
|
ToggleSmartShift::ToggleSmartShift(
|
||||||
|
Device *dev, const std::shared_ptr<ipcgull::node>& parent) :
|
||||||
|
Action (dev), _ipc (parent->make_interface<IPC>())
|
||||||
{
|
{
|
||||||
_smartshift = _device->getFeature<features::SmartShift>("smartshift");
|
_smartshift = _device->getFeature<features::SmartShift>("smartshift");
|
||||||
if(!_smartshift)
|
if(!_smartshift)
|
||||||
@ -58,4 +60,8 @@ void ToggleSmartShift::release()
|
|||||||
uint8_t ToggleSmartShift::reprogFlags() const
|
uint8_t ToggleSmartShift::reprogFlags() const
|
||||||
{
|
{
|
||||||
return hidpp20::ReprogControls::TemporaryDiverted;
|
return hidpp20::ReprogControls::TemporaryDiverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ToggleSmartShift::IPC::IPC() : ipcgull::interface(interface_name, {}, {}, {})
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -29,10 +29,12 @@ namespace actions {
|
|||||||
public:
|
public:
|
||||||
static const char* interface_name;
|
static const char* interface_name;
|
||||||
|
|
||||||
explicit ToggleSmartShift(Device* dev);
|
ToggleSmartShift(Device* dev,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent);
|
||||||
ToggleSmartShift(Device* device,
|
ToggleSmartShift(Device* device,
|
||||||
[[maybe_unused]] config::ToggleSmartShift& action) :
|
[[maybe_unused]] config::ToggleSmartShift& action,
|
||||||
ToggleSmartShift(device) { }
|
const std::shared_ptr<ipcgull::node>& parent) :
|
||||||
|
ToggleSmartShift(device, parent) { }
|
||||||
|
|
||||||
virtual void press();
|
virtual void press();
|
||||||
virtual void release();
|
virtual void release();
|
||||||
@ -40,6 +42,14 @@ namespace actions {
|
|||||||
virtual uint8_t reprogFlags() const;
|
virtual uint8_t reprogFlags() const;
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<features::SmartShift> _smartshift;
|
std::shared_ptr<features::SmartShift> _smartshift;
|
||||||
|
private:
|
||||||
|
class IPC : public ipcgull::interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IPC();
|
||||||
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<IPC> _ipc;
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -23,8 +23,10 @@
|
|||||||
|
|
||||||
using namespace logid::actions;
|
using namespace logid::actions;
|
||||||
|
|
||||||
AxisGesture::AxisGesture(Device *device, config::AxisGesture& config) :
|
AxisGesture::AxisGesture(Device *device, config::AxisGesture& config,
|
||||||
Gesture (device), _multiplier (1), _config (config)
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction) :
|
||||||
|
Gesture (device, parent, direction), _multiplier (1), _config (config)
|
||||||
{
|
{
|
||||||
if(std::holds_alternative<uint>(_config.axis)) {
|
if(std::holds_alternative<uint>(_config.axis)) {
|
||||||
_input_axis = std::get<uint>(_config.axis);
|
_input_axis = std::get<uint>(_config.axis);
|
||||||
|
@ -26,7 +26,9 @@ namespace logid {
|
|||||||
class AxisGesture : public Gesture
|
class AxisGesture : public Gesture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AxisGesture(Device* device, config::AxisGesture& config);
|
AxisGesture(Device* device, config::AxisGesture& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction);
|
||||||
|
|
||||||
virtual void press(bool init_threshold=false);
|
virtual void press(bool init_threshold=false);
|
||||||
virtual void release(bool primary=false);
|
virtual void release(bool primary=false);
|
||||||
|
@ -27,7 +27,10 @@
|
|||||||
using namespace logid;
|
using namespace logid;
|
||||||
using namespace logid::actions;
|
using namespace logid::actions;
|
||||||
|
|
||||||
Gesture::Gesture(Device *device) : _device (device)
|
Gesture::Gesture(Device *device,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction) : _device (device),
|
||||||
|
_node (parent->make_child(direction))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,17 +46,22 @@ template <typename T>
|
|||||||
struct gesture_type<T&> : gesture_type<T> { };
|
struct gesture_type<T&> : gesture_type<T> { };
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::shared_ptr<Gesture> _makeGesture(Device* device,
|
std::shared_ptr<Gesture> _makeGesture(
|
||||||
T gesture) {
|
Device* device, T gesture,
|
||||||
return std::make_shared<typename gesture_type<T>::type>(device, gesture);
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction) {
|
||||||
|
return std::make_shared<typename gesture_type<T>::type>(
|
||||||
|
device, gesture, parent, std::move(direction));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Gesture> Gesture::makeGesture(Device *device,
|
std::shared_ptr<Gesture> Gesture::makeGesture(
|
||||||
config::Gesture& gesture)
|
Device *device, config::Gesture& gesture,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction)
|
||||||
{
|
{
|
||||||
std::shared_ptr<Gesture> ret;
|
std::shared_ptr<Gesture> ret;
|
||||||
std::visit([&device, &ret](auto&& x) {
|
std::visit([&device, &ret, &parent, &direction](auto&& x) {
|
||||||
ret = _makeGesture(device, x);
|
ret = _makeGesture(device, x, parent, direction);
|
||||||
}, gesture);
|
}, gesture);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,16 @@ namespace actions
|
|||||||
virtual ~Gesture() = default;
|
virtual ~Gesture() = default;
|
||||||
|
|
||||||
static std::shared_ptr<Gesture> makeGesture(Device* device,
|
static std::shared_ptr<Gesture> makeGesture(Device* device,
|
||||||
config::Gesture& gesture);
|
config::Gesture& gesture,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Gesture(Device* device);
|
explicit Gesture(Device* device,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction);
|
||||||
Device* _device;
|
Device* _device;
|
||||||
|
std::shared_ptr<ipcgull::node> _node;
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -21,12 +21,14 @@
|
|||||||
|
|
||||||
using namespace logid::actions;
|
using namespace logid::actions;
|
||||||
|
|
||||||
IntervalGesture::IntervalGesture(Device *device, config::IntervalGesture& config) :
|
IntervalGesture::IntervalGesture(Device *device, config::IntervalGesture& config,
|
||||||
Gesture (device), _config (config)
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction) :
|
||||||
|
Gesture (device, parent, direction), _config (config)
|
||||||
{
|
{
|
||||||
if(config.action) {
|
if(config.action) {
|
||||||
try {
|
try {
|
||||||
_action = Action::makeAction(device, config.action.value());
|
_action = Action::makeAction(device, config.action.value(), _node);
|
||||||
} catch(InvalidAction& e) {
|
} catch(InvalidAction& e) {
|
||||||
logPrintf(WARN, "Mapping gesture to invalid action");
|
logPrintf(WARN, "Mapping gesture to invalid action");
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,9 @@ namespace actions
|
|||||||
class IntervalGesture : public Gesture
|
class IntervalGesture : public Gesture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IntervalGesture(Device* device, config::IntervalGesture& config);
|
IntervalGesture(Device* device, config::IntervalGesture& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction);
|
||||||
|
|
||||||
virtual void press(bool init_threshold=false);
|
virtual void press(bool init_threshold=false);
|
||||||
virtual void release(bool primary=false);
|
virtual void release(bool primary=false);
|
||||||
|
@ -21,8 +21,10 @@
|
|||||||
using namespace logid::actions;
|
using namespace logid::actions;
|
||||||
|
|
||||||
NullGesture::NullGesture(Device *device,
|
NullGesture::NullGesture(Device *device,
|
||||||
config::NoGesture& config) :
|
config::NoGesture& config,
|
||||||
Gesture (device), _config (config)
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction) :
|
||||||
|
Gesture (device, parent, direction), _config (config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,9 @@ namespace actions
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NullGesture(Device* device,
|
NullGesture(Device* device,
|
||||||
config::NoGesture& config);
|
config::NoGesture& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction);
|
||||||
|
|
||||||
virtual void press(bool init_threshold=false);
|
virtual void press(bool init_threshold=false);
|
||||||
virtual void release(bool primary=false);
|
virtual void release(bool primary=false);
|
||||||
|
@ -20,11 +20,13 @@
|
|||||||
|
|
||||||
using namespace logid::actions;
|
using namespace logid::actions;
|
||||||
|
|
||||||
ReleaseGesture::ReleaseGesture(Device *device, config::ReleaseGesture& config) :
|
ReleaseGesture::ReleaseGesture(Device *device, config::ReleaseGesture& config,
|
||||||
Gesture (device), _config (config)
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction) :
|
||||||
|
Gesture (device, parent, direction), _config (config)
|
||||||
{
|
{
|
||||||
if(_config.action.has_value())
|
if(_config.action.has_value())
|
||||||
_action = Action::makeAction(device, _config.action.value());
|
_action = Action::makeAction(device, _config.action.value(), _node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReleaseGesture::press(bool init_threshold)
|
void ReleaseGesture::press(bool init_threshold)
|
||||||
|
@ -26,7 +26,9 @@ namespace actions
|
|||||||
class ReleaseGesture : public Gesture
|
class ReleaseGesture : public Gesture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ReleaseGesture(Device* device, config::ReleaseGesture& config);
|
ReleaseGesture(Device* device, config::ReleaseGesture& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction);
|
||||||
|
|
||||||
virtual void press(bool init_threshold=false);
|
virtual void press(bool init_threshold=false);
|
||||||
virtual void release(bool primary=false);
|
virtual void release(bool primary=false);
|
||||||
|
@ -21,12 +21,14 @@
|
|||||||
using namespace logid::actions;
|
using namespace logid::actions;
|
||||||
|
|
||||||
ThresholdGesture::ThresholdGesture(Device *device,
|
ThresholdGesture::ThresholdGesture(Device *device,
|
||||||
config::ThresholdGesture& config) :
|
config::ThresholdGesture& config,
|
||||||
Gesture (device), _config (config)
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction) :
|
||||||
|
Gesture (device, parent, direction), _config (config)
|
||||||
{
|
{
|
||||||
if(config.action) {
|
if(config.action) {
|
||||||
try {
|
try {
|
||||||
_action = Action::makeAction(device, config.action.value());
|
_action = Action::makeAction(device, config.action.value(), _node);
|
||||||
} catch(InvalidAction& e) {
|
} catch(InvalidAction& e) {
|
||||||
logPrintf(WARN, "Mapping gesture to invalid action");
|
logPrintf(WARN, "Mapping gesture to invalid action");
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,9 @@ namespace actions
|
|||||||
class ThresholdGesture : public Gesture
|
class ThresholdGesture : public Gesture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ThresholdGesture(Device* device, config::ThresholdGesture& config);
|
ThresholdGesture(Device* device, config::ThresholdGesture& config,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent,
|
||||||
|
const std::string& direction);
|
||||||
|
|
||||||
virtual void press(bool init_threshold=false);
|
virtual void press(bool init_threshold=false);
|
||||||
virtual void release(bool primary=false);
|
virtual void release(bool primary=false);
|
||||||
|
@ -26,7 +26,8 @@ using namespace logid::backend;
|
|||||||
#define MOVE_EVENTHANDLER_NAME "HIRES_SCROLL"
|
#define MOVE_EVENTHANDLER_NAME "HIRES_SCROLL"
|
||||||
|
|
||||||
HiresScroll::HiresScroll(Device *dev) : DeviceFeature(dev),
|
HiresScroll::HiresScroll(Device *dev) : DeviceFeature(dev),
|
||||||
_config (dev->activeProfile().hiresscroll), _mode (0), _mask (0)
|
_config (dev->activeProfile().hiresscroll), _mode (0), _mask (0),
|
||||||
|
_node (dev->ipcNode()->make_child("hires"))
|
||||||
{
|
{
|
||||||
if(_config.has_value()) {
|
if(_config.has_value()) {
|
||||||
if(std::holds_alternative<bool>(_config.value())) {
|
if(std::holds_alternative<bool>(_config.value())) {
|
||||||
@ -54,8 +55,8 @@ HiresScroll::HiresScroll(Device *dev) : DeviceFeature(dev),
|
|||||||
_mode |= hidpp20::HiresScroll::Mode::Target;
|
_mode |= hidpp20::HiresScroll::Mode::Target;
|
||||||
}
|
}
|
||||||
|
|
||||||
_makeAction(_up_action, conf.up);
|
_makeAction(_up_action, conf.up, "up");
|
||||||
_makeAction(_down_action, conf.down);
|
_makeAction(_down_action, conf.down, "down");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -110,10 +111,12 @@ void HiresScroll::setMode(uint8_t mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HiresScroll::_makeAction(std::shared_ptr<actions::Gesture> &gesture,
|
void HiresScroll::_makeAction(std::shared_ptr<actions::Gesture> &gesture,
|
||||||
std::optional<config::Gesture> &config)
|
std::optional<config::Gesture> &config,
|
||||||
|
const std::string& direction)
|
||||||
{
|
{
|
||||||
if(config.has_value()) {
|
if(config.has_value()) {
|
||||||
gesture = actions::Gesture::makeGesture(_device, config.value());
|
gesture = actions::Gesture::makeGesture(_device, config.value(),
|
||||||
|
_node, direction);
|
||||||
try {
|
try {
|
||||||
auto axis = std::dynamic_pointer_cast<actions::AxisGesture>(
|
auto axis = std::dynamic_pointer_cast<actions::AxisGesture>(
|
||||||
gesture);
|
gesture);
|
||||||
|
@ -37,7 +37,8 @@ namespace features
|
|||||||
void setMode(uint8_t mode);
|
void setMode(uint8_t mode);
|
||||||
private:
|
private:
|
||||||
void _makeAction(std::shared_ptr<actions::Gesture>& gesture,
|
void _makeAction(std::shared_ptr<actions::Gesture>& gesture,
|
||||||
std::optional<config::Gesture>& config);
|
std::optional<config::Gesture>& config,
|
||||||
|
const std::string& direction);
|
||||||
|
|
||||||
void _handleScroll(backend::hidpp20::HiresScroll::WheelStatus event);
|
void _handleScroll(backend::hidpp20::HiresScroll::WheelStatus event);
|
||||||
std::shared_ptr<backend::hidpp20::HiresScroll> _hires_scroll;
|
std::shared_ptr<backend::hidpp20::HiresScroll> _hires_scroll;
|
||||||
@ -51,6 +52,8 @@ namespace features
|
|||||||
|
|
||||||
std::shared_ptr<actions::Gesture> _up_action;
|
std::shared_ptr<actions::Gesture> _up_action;
|
||||||
std::shared_ptr<actions::Gesture> _down_action;
|
std::shared_ptr<actions::Gesture> _down_action;
|
||||||
|
|
||||||
|
std::shared_ptr<ipcgull::node> _node;
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -168,19 +168,20 @@ Button::Button(Info info, int index,
|
|||||||
std::shared_ptr<ipcgull::node> root,
|
std::shared_ptr<ipcgull::node> root,
|
||||||
config::Button &config) :
|
config::Button &config) :
|
||||||
_node (root->make_child(std::to_string(index))),
|
_node (root->make_child(std::to_string(index))),
|
||||||
_interface (_node->make_interface<IPC>(this, info)),
|
|
||||||
_device (device), _conf_func (std::move(conf_func)),
|
_device (device), _conf_func (std::move(conf_func)),
|
||||||
_config (config),
|
_config (config),
|
||||||
_info (info)
|
_info (info)
|
||||||
{
|
{
|
||||||
if(_config.action.has_value()) {
|
if(_config.action.has_value()) {
|
||||||
try {
|
try {
|
||||||
_action = Action::makeAction(_device, _config.action.value());
|
_action = Action::makeAction(_device, _config.action.value(), _node);
|
||||||
} catch(std::exception& e) {
|
} catch(std::exception& e) {
|
||||||
logPrintf(WARN, "Error creating button action: %s",
|
logPrintf(WARN, "Error creating button action: %s",
|
||||||
e.what());
|
e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_interface = _node->make_interface<IPC>(this, _info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::press() const {
|
void Button::press() const {
|
||||||
|
@ -30,11 +30,12 @@ using namespace logid;
|
|||||||
#define SCROLL_EVENTHANDLER_NAME "THUMB_WHEEL"
|
#define SCROLL_EVENTHANDLER_NAME "THUMB_WHEEL"
|
||||||
|
|
||||||
std::shared_ptr<actions::Action> _genAction(
|
std::shared_ptr<actions::Action> _genAction(
|
||||||
Device* dev, std::optional<config::BasicAction>& conf)
|
Device* dev, std::optional<config::BasicAction>& conf,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent)
|
||||||
{
|
{
|
||||||
if(conf.has_value()) {
|
if(conf.has_value()) {
|
||||||
try {
|
try {
|
||||||
return actions::Action::makeAction(dev, conf.value());
|
return actions::Action::makeAction(dev, conf.value(), parent);
|
||||||
} catch(actions::InvalidAction& e) {
|
} catch(actions::InvalidAction& e) {
|
||||||
logPrintf(WARN, "Mapping thumb wheel to invalid action");
|
logPrintf(WARN, "Mapping thumb wheel to invalid action");
|
||||||
}
|
}
|
||||||
@ -44,11 +45,12 @@ std::shared_ptr<actions::Action> _genAction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<actions::Gesture> _genGesture(
|
std::shared_ptr<actions::Gesture> _genGesture(
|
||||||
Device* dev, std::optional<config::Gesture>& conf)
|
Device* dev, std::optional<config::Gesture>& conf,
|
||||||
|
const std::shared_ptr<ipcgull::node>& parent, const std::string& direction)
|
||||||
{
|
{
|
||||||
if(conf.has_value()) {
|
if(conf.has_value()) {
|
||||||
try {
|
try {
|
||||||
return actions::Gesture::makeGesture(dev, conf.value());
|
return actions::Gesture::makeGesture(dev, conf.value(), parent, direction);
|
||||||
} catch (actions::InvalidAction &e) {
|
} catch (actions::InvalidAction &e) {
|
||||||
logPrintf(WARN, "Mapping thumb wheel to invalid gesture");
|
logPrintf(WARN, "Mapping thumb wheel to invalid gesture");
|
||||||
}
|
}
|
||||||
@ -58,15 +60,19 @@ std::shared_ptr<actions::Gesture> _genGesture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ThumbWheel::ThumbWheel(Device *dev) : DeviceFeature(dev), _wheel_info(),
|
ThumbWheel::ThumbWheel(Device *dev) : DeviceFeature(dev), _wheel_info(),
|
||||||
|
_node (dev->ipcNode()->make_child("thumbwheel")),
|
||||||
|
_proxy_node (_node->make_child("proxy")),
|
||||||
|
_tap_node (_node->make_child("tap")),
|
||||||
|
_touch_node (_node->make_child("touch")),
|
||||||
_config (dev->activeProfile().thumbwheel)
|
_config (dev->activeProfile().thumbwheel)
|
||||||
{
|
{
|
||||||
if(_config.has_value()) {
|
if(_config.has_value()) {
|
||||||
auto& conf = _config.value();
|
auto& conf = _config.value();
|
||||||
_left_action = _genGesture(dev, conf.left);
|
_left_action = _genGesture(dev, conf.left, _node, "left");
|
||||||
_right_action = _genGesture(dev, conf.right);
|
_right_action = _genGesture(dev, conf.right, _node, "right");
|
||||||
_touch_action = _genAction(dev, conf.touch);
|
_touch_action = _genAction(dev, conf.touch, _touch_node);
|
||||||
_tap_action = _genAction(dev, conf.tap);
|
_tap_action = _genAction(dev, conf.tap, _tap_node);
|
||||||
_proxy_action = _genAction(dev, conf.proxy);
|
_proxy_action = _genAction(dev, conf.proxy, _proxy_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -40,11 +40,16 @@ namespace features
|
|||||||
std::shared_ptr<backend::hidpp20::ThumbWheel> _thumb_wheel;
|
std::shared_ptr<backend::hidpp20::ThumbWheel> _thumb_wheel;
|
||||||
backend::hidpp20::ThumbWheel::ThumbwheelInfo _wheel_info;
|
backend::hidpp20::ThumbWheel::ThumbwheelInfo _wheel_info;
|
||||||
|
|
||||||
|
std::shared_ptr<ipcgull::node> _node;
|
||||||
|
|
||||||
std::shared_ptr<actions::Gesture> _left_action;
|
std::shared_ptr<actions::Gesture> _left_action;
|
||||||
std::shared_ptr<actions::Gesture> _right_action;
|
std::shared_ptr<actions::Gesture> _right_action;
|
||||||
std::shared_ptr<actions::Action> _proxy_action;
|
std::shared_ptr<actions::Action> _proxy_action;
|
||||||
|
std::shared_ptr<ipcgull::node> _proxy_node;
|
||||||
std::shared_ptr<actions::Action> _tap_action;
|
std::shared_ptr<actions::Action> _tap_action;
|
||||||
|
std::shared_ptr<ipcgull::node> _tap_node;
|
||||||
std::shared_ptr<actions::Action> _touch_action;
|
std::shared_ptr<actions::Action> _touch_action;
|
||||||
|
std::shared_ptr<ipcgull::node> _touch_node;
|
||||||
|
|
||||||
int8_t _last_direction = 0;
|
int8_t _last_direction = 0;
|
||||||
bool _last_proxy = false;
|
bool _last_proxy = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user