mirror of
https://github.com/PixlOne/logiops.git
synced 2025-09-14 13:56:50 +08:00
Ensure wheel compaitiblity with gestures
Also uses a definition for the root service name pizza.pixl.LogiOps.
This commit is contained in:
parent
35b4dc03bf
commit
485788a74e
@ -19,6 +19,7 @@
|
|||||||
#include <Configuration.h>
|
#include <Configuration.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <ipc_defs.h>
|
||||||
|
|
||||||
using namespace logid;
|
using namespace logid;
|
||||||
using namespace libconfig;
|
using namespace libconfig;
|
||||||
@ -60,7 +61,7 @@ void Configuration::save() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Configuration::IPC::IPC(Configuration* config) :
|
Configuration::IPC::IPC(Configuration* config) :
|
||||||
ipcgull::interface("pizza.pixl.LogiOps.Config", {
|
ipcgull::interface(SERVICE_ROOT_NAME ".Config", {
|
||||||
{"Save", {config, &Configuration::save}}
|
{"Save", {config, &Configuration::save}}
|
||||||
}, {}, {}) {
|
}, {}, {}) {
|
||||||
}
|
}
|
@ -28,6 +28,7 @@
|
|||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <ipc_defs.h>
|
||||||
|
|
||||||
using namespace logid;
|
using namespace logid;
|
||||||
using namespace logid::backend;
|
using namespace logid::backend;
|
||||||
@ -246,7 +247,7 @@ void Device::_makeResetMechanism() {
|
|||||||
|
|
||||||
Device::IPC::IPC(Device* device) :
|
Device::IPC::IPC(Device* device) :
|
||||||
ipcgull::interface(
|
ipcgull::interface(
|
||||||
"pizza.pixl.LogiOps.Device",
|
SERVICE_ROOT_NAME ".Device",
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
{"Name", ipcgull::property<std::string>(
|
{"Name", ipcgull::property<std::string>(
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <ipc_defs.h>
|
||||||
|
|
||||||
using namespace logid;
|
using namespace logid;
|
||||||
using namespace logid::backend;
|
using namespace logid::backend;
|
||||||
@ -190,7 +191,7 @@ void DeviceManager::removeDevice(std::string path) {
|
|||||||
|
|
||||||
DeviceManager::DevicesIPC::DevicesIPC(DeviceManager* manager) :
|
DeviceManager::DevicesIPC::DevicesIPC(DeviceManager* manager) :
|
||||||
ipcgull::interface(
|
ipcgull::interface(
|
||||||
"pizza.pixl.LogiOps.Devices",
|
SERVICE_ROOT_NAME ".Devices",
|
||||||
{
|
{
|
||||||
{"Enumerate", {manager, &DeviceManager::listDevices, {"devices"}}}
|
{"Enumerate", {manager, &DeviceManager::listDevices, {"devices"}}}
|
||||||
},
|
},
|
||||||
@ -238,7 +239,7 @@ void DeviceManager::DevicesIPC::deviceRemoved(
|
|||||||
|
|
||||||
DeviceManager::ReceiversIPC::ReceiversIPC(DeviceManager* manager) :
|
DeviceManager::ReceiversIPC::ReceiversIPC(DeviceManager* manager) :
|
||||||
ipcgull::interface(
|
ipcgull::interface(
|
||||||
"pizza.pixl.LogiOps.Receivers",
|
SERVICE_ROOT_NAME ".Receivers",
|
||||||
{
|
{
|
||||||
{"Enumerate", {manager, &DeviceManager::listReceivers,
|
{"Enumerate", {manager, &DeviceManager::listReceivers,
|
||||||
{"receivers"}}}
|
{"receivers"}}}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <DeviceManager.h>
|
#include <DeviceManager.h>
|
||||||
#include <backend/Error.h>
|
#include <backend/Error.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
|
#include <ipc_defs.h>
|
||||||
|
|
||||||
using namespace logid;
|
using namespace logid;
|
||||||
using namespace logid::backend;
|
using namespace logid::backend;
|
||||||
@ -166,5 +167,5 @@ std::shared_ptr<dj::Receiver> Receiver::rawReceiver() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Receiver::ReceiverIPC::ReceiverIPC(Receiver* receiver) :
|
Receiver::ReceiverIPC::ReceiverIPC(Receiver* receiver) :
|
||||||
ipcgull::interface("pizza.pixl.LogiOps.Receiver", {}, {}, {}) {
|
ipcgull::interface(SERVICE_ROOT_NAME ".Receiver", {}, {}, {}) {
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <actions/CycleDPI.h>
|
#include <actions/CycleDPI.h>
|
||||||
#include <actions/ChangeDPI.h>
|
#include <actions/ChangeDPI.h>
|
||||||
#include <actions/ChangeHostAction.h>
|
#include <actions/ChangeHostAction.h>
|
||||||
|
#include <ipc_defs.h>
|
||||||
|
|
||||||
using namespace logid;
|
using namespace logid;
|
||||||
using namespace logid::actions;
|
using namespace logid::actions;
|
||||||
@ -124,6 +125,6 @@ std::shared_ptr<Action> Action::makeAction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Action::Action(Device* device, const std::string& name, tables t) :
|
Action::Action(Device* device, const std::string& name, tables t) :
|
||||||
ipcgull::interface("pizza.pixl.LogiOps.Action." + name, std::move(t)),
|
ipcgull::interface(SERVICE_ROOT_NAME ".Action." + name, std::move(t)),
|
||||||
_device(device), _pressed(false) {
|
_device(device), _pressed(false) {
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <actions/gesture/IntervalGesture.h>
|
#include <actions/gesture/IntervalGesture.h>
|
||||||
#include <actions/gesture/AxisGesture.h>
|
#include <actions/gesture/AxisGesture.h>
|
||||||
#include <actions/gesture/NullGesture.h>
|
#include <actions/gesture/NullGesture.h>
|
||||||
|
#include <ipc_defs.h>
|
||||||
|
|
||||||
using namespace logid;
|
using namespace logid;
|
||||||
using namespace logid::actions;
|
using namespace logid::actions;
|
||||||
@ -30,7 +31,7 @@ using namespace logid::actions;
|
|||||||
Gesture::Gesture(Device* device,
|
Gesture::Gesture(Device* device,
|
||||||
std::shared_ptr<ipcgull::node> node,
|
std::shared_ptr<ipcgull::node> node,
|
||||||
const std::string& name, tables t) :
|
const std::string& name, tables t) :
|
||||||
ipcgull::interface("pizza.pixl.LogiOps.Gesture." + name, std::move(t)),
|
ipcgull::interface(SERVICE_ROOT_NAME ".Gesture." + name, std::move(t)),
|
||||||
_node(std::move(node)), _device(device) {
|
_node(std::move(node)), _device(device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <Device.h>
|
#include <Device.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
|
#include <ipc_defs.h>
|
||||||
|
|
||||||
using namespace logid::features;
|
using namespace logid::features;
|
||||||
using namespace logid::backend;
|
using namespace logid::backend;
|
||||||
@ -239,9 +240,8 @@ std::shared_ptr<ipcgull::node> Button::node() const {
|
|||||||
return _node;
|
return _node;
|
||||||
}
|
}
|
||||||
|
|
||||||
Button::IPC::IPC(Button* parent,
|
Button::IPC::IPC(Button* parent, const Info& info) :
|
||||||
const Info& info) :
|
ipcgull::interface(SERVICE_ROOT_NAME ".Button", {
|
||||||
ipcgull::interface("pizza.pixl.LogiOps.Device.Button", {
|
|
||||||
{"SetAction", {this, &IPC::setAction, {"type"}}}
|
{"SetAction", {this, &IPC::setAction, {"type"}}}
|
||||||
}, {
|
}, {
|
||||||
{"ControlID", ipcgull::property<uint16_t>(
|
{"ControlID", ipcgull::property<uint16_t>(
|
||||||
@ -278,7 +278,7 @@ void Button::IPC::setAction(const std::string& type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RemapButton::IPC::IPC(RemapButton* parent) :
|
RemapButton::IPC::IPC(RemapButton* parent) :
|
||||||
ipcgull::interface("pizza.pixl.LogiOps.Buttons", {
|
ipcgull::interface(SERVICE_ROOT_NAME ".Buttons", {
|
||||||
{"Enumerate", {this, &IPC::enumerate, {"buttons"}}}
|
{"Enumerate", {this, &IPC::enumerate, {"buttons"}}}
|
||||||
}, {}, {}),
|
}, {}, {}),
|
||||||
_parent(*parent) {
|
_parent(*parent) {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <features/SmartShift.h>
|
#include <features/SmartShift.h>
|
||||||
#include <Device.h>
|
#include <Device.h>
|
||||||
|
#include <ipc_defs.h>
|
||||||
|
|
||||||
using namespace logid::features;
|
using namespace logid::features;
|
||||||
using namespace logid::backend;
|
using namespace logid::backend;
|
||||||
@ -60,7 +61,7 @@ void SmartShift::setStatus(Status status) {
|
|||||||
|
|
||||||
SmartShift::IPC::IPC(SmartShift* parent) :
|
SmartShift::IPC::IPC(SmartShift* parent) :
|
||||||
ipcgull::interface(
|
ipcgull::interface(
|
||||||
"pizza.pixl.LogiOps.SmartShift", {
|
SERVICE_ROOT_NAME ".SmartShift", {
|
||||||
{"GetStatus", {this, &IPC::getStatus, {"active", "threshold"}}},
|
{"GetStatus", {this, &IPC::getStatus, {"active", "threshold"}}},
|
||||||
{"SetActive", {this, &IPC::setActive, {"active"}}},
|
{"SetActive", {this, &IPC::setActive, {"active"}}},
|
||||||
{"SetThreshold", {this, &IPC::setThreshold, {"threshold"}}},
|
{"SetThreshold", {this, &IPC::setThreshold, {"threshold"}}},
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <actions/gesture/AxisGesture.h>
|
#include <actions/gesture/AxisGesture.h>
|
||||||
#include <Device.h>
|
#include <Device.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
|
#include <ipc_defs.h>
|
||||||
|
|
||||||
using namespace logid::features;
|
using namespace logid::features;
|
||||||
using namespace logid::backend;
|
using namespace logid::backend;
|
||||||
@ -47,8 +48,14 @@ namespace {
|
|||||||
const std::shared_ptr<ipcgull::node>& parent, const std::string& direction) {
|
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(
|
auto result = actions::Gesture::makeGesture(dev, conf.value(),
|
||||||
dev, conf.value(), parent->make_child(direction));
|
parent->make_child(direction));
|
||||||
|
if (!result->wheelCompatibility()) {
|
||||||
|
logPrintf(WARN, "Mapping thumb wheel to incompatible gesture");
|
||||||
|
return nullptr;
|
||||||
|
} else {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
} catch (actions::InvalidAction& e) {
|
} catch (actions::InvalidAction& e) {
|
||||||
logPrintf(WARN, "Mapping thumb wheel to invalid gesture");
|
logPrintf(WARN, "Mapping thumb wheel to invalid gesture");
|
||||||
}
|
}
|
||||||
@ -216,7 +223,7 @@ void ThumbWheel::_fixGesture(const std::shared_ptr<actions::Gesture>& gesture) c
|
|||||||
|
|
||||||
ThumbWheel::IPC::IPC(ThumbWheel* parent) :
|
ThumbWheel::IPC::IPC(ThumbWheel* parent) :
|
||||||
ipcgull::interface(
|
ipcgull::interface(
|
||||||
"pizza.pixl.LogiOps.ThumbWheel", {
|
SERVICE_ROOT_NAME ".ThumbWheel", {
|
||||||
{"GetConfig", {this, &IPC::getConfig, {"divert", "invert"}}},
|
{"GetConfig", {this, &IPC::getConfig, {"divert", "invert"}}},
|
||||||
{"SetDivert", {this, &IPC::setDivert, {"divert"}}},
|
{"SetDivert", {this, &IPC::setDivert, {"divert"}}},
|
||||||
{"SetInvert", {this, &IPC::setInvert, {"invert"}}},
|
{"SetInvert", {this, &IPC::setInvert, {"invert"}}},
|
||||||
@ -276,8 +283,15 @@ void ThumbWheel::IPC::setLeft(const std::string& type) {
|
|||||||
}
|
}
|
||||||
_parent._left_gesture = actions::Gesture::makeGesture(
|
_parent._left_gesture = actions::Gesture::makeGesture(
|
||||||
_parent._device, type, config.left.value(), _parent._left_node);
|
_parent._device, type, config.left.value(), _parent._left_node);
|
||||||
|
if (!_parent._left_gesture->wheelCompatibility()) {
|
||||||
|
_parent._left_gesture.reset();
|
||||||
|
config.left.reset();
|
||||||
|
|
||||||
|
throw std::invalid_argument("incompatible gesture");
|
||||||
|
} else {
|
||||||
_parent._fixGesture(_parent._left_gesture);
|
_parent._fixGesture(_parent._left_gesture);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ThumbWheel::IPC::setRight(const std::string& type) {
|
void ThumbWheel::IPC::setRight(const std::string& type) {
|
||||||
std::unique_lock lock(_parent._config_mutex);
|
std::unique_lock lock(_parent._config_mutex);
|
||||||
@ -289,8 +303,15 @@ void ThumbWheel::IPC::setRight(const std::string& type) {
|
|||||||
}
|
}
|
||||||
_parent._right_gesture = actions::Gesture::makeGesture(
|
_parent._right_gesture = actions::Gesture::makeGesture(
|
||||||
_parent._device, type, config.right.value(), _parent._right_node);
|
_parent._device, type, config.right.value(), _parent._right_node);
|
||||||
|
if (!_parent._right_gesture->wheelCompatibility()) {
|
||||||
|
_parent._right_gesture.reset();
|
||||||
|
config.right.reset();
|
||||||
|
|
||||||
|
throw std::invalid_argument("incompatible gesture");
|
||||||
|
} else {
|
||||||
_parent._fixGesture(_parent._right_gesture);
|
_parent._fixGesture(_parent._right_gesture);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ThumbWheel::IPC::setProxy(const std::string& type) {
|
void ThumbWheel::IPC::setProxy(const std::string& type) {
|
||||||
std::unique_lock lock(_parent._config_mutex);
|
std::unique_lock lock(_parent._config_mutex);
|
||||||
|
24
src/logid/ipc_defs.h
Normal file
24
src/logid/ipc_defs.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2023 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 LOGIOPS_IPC_DEFS_H
|
||||||
|
#define LOGIOPS_IPC_DEFS_H
|
||||||
|
|
||||||
|
#define SERVICE_ROOT_NAME "pizza.pixl.LogiOps"
|
||||||
|
static constexpr auto server_root_node = "/pizza/pixl/logiops";
|
||||||
|
|
||||||
|
#endif //LOGIOPS_IPC_DEFS_H
|
@ -20,6 +20,7 @@
|
|||||||
#include <InputDevice.h>
|
#include <InputDevice.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <ipc_defs.h>
|
||||||
|
|
||||||
#ifndef LOGIOPS_VERSION
|
#ifndef LOGIOPS_VERSION
|
||||||
#define LOGIOPS_VERSION "null"
|
#define LOGIOPS_VERSION "null"
|
||||||
@ -141,9 +142,7 @@ int main(int argc, char** argv) {
|
|||||||
config = std::make_shared<Configuration>();
|
config = std::make_shared<Configuration>();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto server = ipcgull::make_server("pizza.pixl.LogiOps",
|
auto server = ipcgull::make_server(SERVICE_ROOT_NAME, server_root_node, ipcgull::IPCGULL_USER);
|
||||||
"/pizza/pixl/LogiOps",
|
|
||||||
ipcgull::IPCGULL_USER);
|
|
||||||
|
|
||||||
//Create a virtual input device
|
//Create a virtual input device
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user