mirror of
https://github.com/PixlOne/logiops.git
synced 2025-07-13 21:02:43 +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 <util/log.h>
|
||||
#include <utility>
|
||||
#include <ipc_defs.h>
|
||||
|
||||
using namespace logid;
|
||||
using namespace libconfig;
|
||||
@ -60,7 +61,7 @@ void Configuration::save() {
|
||||
}
|
||||
|
||||
Configuration::IPC::IPC(Configuration* config) :
|
||||
ipcgull::interface("pizza.pixl.LogiOps.Config", {
|
||||
ipcgull::interface(SERVICE_ROOT_NAME ".Config", {
|
||||
{"Save", {config, &Configuration::save}}
|
||||
}, {}, {}) {
|
||||
}
|
@ -28,6 +28,7 @@
|
||||
#include <util/log.h>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <ipc_defs.h>
|
||||
|
||||
using namespace logid;
|
||||
using namespace logid::backend;
|
||||
@ -246,7 +247,7 @@ void Device::_makeResetMechanism() {
|
||||
|
||||
Device::IPC::IPC(Device* device) :
|
||||
ipcgull::interface(
|
||||
"pizza.pixl.LogiOps.Device",
|
||||
SERVICE_ROOT_NAME ".Device",
|
||||
{},
|
||||
{
|
||||
{"Name", ipcgull::property<std::string>(
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <thread>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
#include <ipc_defs.h>
|
||||
|
||||
using namespace logid;
|
||||
using namespace logid::backend;
|
||||
@ -190,7 +191,7 @@ void DeviceManager::removeDevice(std::string path) {
|
||||
|
||||
DeviceManager::DevicesIPC::DevicesIPC(DeviceManager* manager) :
|
||||
ipcgull::interface(
|
||||
"pizza.pixl.LogiOps.Devices",
|
||||
SERVICE_ROOT_NAME ".Devices",
|
||||
{
|
||||
{"Enumerate", {manager, &DeviceManager::listDevices, {"devices"}}}
|
||||
},
|
||||
@ -238,7 +239,7 @@ void DeviceManager::DevicesIPC::deviceRemoved(
|
||||
|
||||
DeviceManager::ReceiversIPC::ReceiversIPC(DeviceManager* manager) :
|
||||
ipcgull::interface(
|
||||
"pizza.pixl.LogiOps.Receivers",
|
||||
SERVICE_ROOT_NAME ".Receivers",
|
||||
{
|
||||
{"Enumerate", {manager, &DeviceManager::listReceivers,
|
||||
{"receivers"}}}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <DeviceManager.h>
|
||||
#include <backend/Error.h>
|
||||
#include <util/log.h>
|
||||
#include <ipc_defs.h>
|
||||
|
||||
using namespace logid;
|
||||
using namespace logid::backend;
|
||||
@ -166,5 +167,5 @@ std::shared_ptr<dj::Receiver> Receiver::rawReceiver() {
|
||||
}
|
||||
|
||||
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/ChangeDPI.h>
|
||||
#include <actions/ChangeHostAction.h>
|
||||
#include <ipc_defs.h>
|
||||
|
||||
using namespace logid;
|
||||
using namespace logid::actions;
|
||||
@ -124,6 +125,6 @@ std::shared_ptr<Action> Action::makeAction(
|
||||
}
|
||||
|
||||
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) {
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <actions/gesture/IntervalGesture.h>
|
||||
#include <actions/gesture/AxisGesture.h>
|
||||
#include <actions/gesture/NullGesture.h>
|
||||
#include <ipc_defs.h>
|
||||
|
||||
using namespace logid;
|
||||
using namespace logid::actions;
|
||||
@ -30,7 +31,7 @@ using namespace logid::actions;
|
||||
Gesture::Gesture(Device* device,
|
||||
std::shared_ptr<ipcgull::node> node,
|
||||
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) {
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <Device.h>
|
||||
#include <sstream>
|
||||
#include <util/log.h>
|
||||
#include <ipc_defs.h>
|
||||
|
||||
using namespace logid::features;
|
||||
using namespace logid::backend;
|
||||
@ -31,7 +32,7 @@ using namespace logid::actions;
|
||||
|
||||
static constexpr auto hidpp20_reprog_rebind =
|
||||
(hidpp20::ReprogControls::ChangeTemporaryDivert |
|
||||
hidpp20::ReprogControls::ChangeRawXYDivert);
|
||||
hidpp20::ReprogControls::ChangeRawXYDivert);
|
||||
|
||||
RemapButton::RemapButton(Device* dev) : DeviceFeature(dev),
|
||||
_config(dev->activeProfile().buttons),
|
||||
@ -239,9 +240,8 @@ std::shared_ptr<ipcgull::node> Button::node() const {
|
||||
return _node;
|
||||
}
|
||||
|
||||
Button::IPC::IPC(Button* parent,
|
||||
const Info& info) :
|
||||
ipcgull::interface("pizza.pixl.LogiOps.Device.Button", {
|
||||
Button::IPC::IPC(Button* parent, const Info& info) :
|
||||
ipcgull::interface(SERVICE_ROOT_NAME ".Button", {
|
||||
{"SetAction", {this, &IPC::setAction, {"type"}}}
|
||||
}, {
|
||||
{"ControlID", ipcgull::property<uint16_t>(
|
||||
@ -278,7 +278,7 @@ void Button::IPC::setAction(const std::string& type) {
|
||||
}
|
||||
|
||||
RemapButton::IPC::IPC(RemapButton* parent) :
|
||||
ipcgull::interface("pizza.pixl.LogiOps.Buttons", {
|
||||
ipcgull::interface(SERVICE_ROOT_NAME ".Buttons", {
|
||||
{"Enumerate", {this, &IPC::enumerate, {"buttons"}}}
|
||||
}, {}, {}),
|
||||
_parent(*parent) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
#include <features/SmartShift.h>
|
||||
#include <Device.h>
|
||||
#include <ipc_defs.h>
|
||||
|
||||
using namespace logid::features;
|
||||
using namespace logid::backend;
|
||||
@ -60,7 +61,7 @@ void SmartShift::setStatus(Status status) {
|
||||
|
||||
SmartShift::IPC::IPC(SmartShift* parent) :
|
||||
ipcgull::interface(
|
||||
"pizza.pixl.LogiOps.SmartShift", {
|
||||
SERVICE_ROOT_NAME ".SmartShift", {
|
||||
{"GetStatus", {this, &IPC::getStatus, {"active", "threshold"}}},
|
||||
{"SetActive", {this, &IPC::setActive, {"active"}}},
|
||||
{"SetThreshold", {this, &IPC::setThreshold, {"threshold"}}},
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <actions/gesture/AxisGesture.h>
|
||||
#include <Device.h>
|
||||
#include <util/log.h>
|
||||
#include <ipc_defs.h>
|
||||
|
||||
using namespace logid::features;
|
||||
using namespace logid::backend;
|
||||
@ -47,8 +48,14 @@ namespace {
|
||||
const std::shared_ptr<ipcgull::node>& parent, const std::string& direction) {
|
||||
if (conf.has_value()) {
|
||||
try {
|
||||
return actions::Gesture::makeGesture(
|
||||
dev, conf.value(), parent->make_child(direction));
|
||||
auto result = actions::Gesture::makeGesture(dev, conf.value(),
|
||||
parent->make_child(direction));
|
||||
if (!result->wheelCompatibility()) {
|
||||
logPrintf(WARN, "Mapping thumb wheel to incompatible gesture");
|
||||
return nullptr;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
} catch (actions::InvalidAction& e) {
|
||||
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) :
|
||||
ipcgull::interface(
|
||||
"pizza.pixl.LogiOps.ThumbWheel", {
|
||||
SERVICE_ROOT_NAME ".ThumbWheel", {
|
||||
{"GetConfig", {this, &IPC::getConfig, {"divert", "invert"}}},
|
||||
{"SetDivert", {this, &IPC::setDivert, {"divert"}}},
|
||||
{"SetInvert", {this, &IPC::setInvert, {"invert"}}},
|
||||
@ -276,7 +283,14 @@ void ThumbWheel::IPC::setLeft(const std::string& type) {
|
||||
}
|
||||
_parent._left_gesture = actions::Gesture::makeGesture(
|
||||
_parent._device, type, config.left.value(), _parent._left_node);
|
||||
_parent._fixGesture(_parent._left_gesture);
|
||||
if (!_parent._left_gesture->wheelCompatibility()) {
|
||||
_parent._left_gesture.reset();
|
||||
config.left.reset();
|
||||
|
||||
throw std::invalid_argument("incompatible gesture");
|
||||
} else {
|
||||
_parent._fixGesture(_parent._left_gesture);
|
||||
}
|
||||
}
|
||||
|
||||
void ThumbWheel::IPC::setRight(const std::string& type) {
|
||||
@ -289,7 +303,14 @@ void ThumbWheel::IPC::setRight(const std::string& type) {
|
||||
}
|
||||
_parent._right_gesture = actions::Gesture::makeGesture(
|
||||
_parent._device, type, config.right.value(), _parent._right_node);
|
||||
_parent._fixGesture(_parent._right_gesture);
|
||||
if (!_parent._right_gesture->wheelCompatibility()) {
|
||||
_parent._right_gesture.reset();
|
||||
config.right.reset();
|
||||
|
||||
throw std::invalid_argument("incompatible gesture");
|
||||
} else {
|
||||
_parent._fixGesture(_parent._right_gesture);
|
||||
}
|
||||
}
|
||||
|
||||
void ThumbWheel::IPC::setProxy(const std::string& type) {
|
||||
|
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 <util/log.h>
|
||||
#include <algorithm>
|
||||
#include <ipc_defs.h>
|
||||
|
||||
#ifndef LOGIOPS_VERSION
|
||||
#define LOGIOPS_VERSION "null"
|
||||
@ -141,9 +142,7 @@ int main(int argc, char** argv) {
|
||||
config = std::make_shared<Configuration>();
|
||||
}
|
||||
|
||||
auto server = ipcgull::make_server("pizza.pixl.LogiOps",
|
||||
"/pizza/pixl/LogiOps",
|
||||
ipcgull::IPCGULL_USER);
|
||||
auto server = ipcgull::make_server(SERVICE_ROOT_NAME, server_root_node, ipcgull::IPCGULL_USER);
|
||||
|
||||
//Create a virtual input device
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user