mirror of
https://github.com/PixlOne/logiops.git
synced 2025-07-14 13:22:33 +08:00
Limit use of C-style definitions
This commit is contained in:
parent
c15419a234
commit
35b4dc03bf
@ -302,12 +302,12 @@ void Device::sendReportNoACK(const Report& report) {
|
|||||||
void Device::reportFixup(Report& report) const {
|
void Device::reportFixup(Report& report) const {
|
||||||
switch (report.type()) {
|
switch (report.type()) {
|
||||||
case Report::Type::Short:
|
case Report::Type::Short:
|
||||||
if (!(supported_reports & HIDPP_REPORT_SHORT_SUPPORTED))
|
if (!(supported_reports & ShortReportSupported))
|
||||||
report.setType(Report::Type::Long);
|
report.setType(Report::Type::Long);
|
||||||
break;
|
break;
|
||||||
case Report::Type::Long:
|
case Report::Type::Long:
|
||||||
/* Report can be truncated, but that isn't a good idea. */
|
/* Report can be truncated, but that isn't a good idea. */
|
||||||
assert(supported_reports & HIDPP_REPORT_LONG_SUPPORTED);
|
assert(supported_reports & LongReportSupported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ uint8_t hidpp::getSupportedReports(const std::vector<uint8_t>& report_desc) {
|
|||||||
it = std::search(report_desc.begin(), report_desc.end(),
|
it = std::search(report_desc.begin(), report_desc.end(),
|
||||||
ShortReportDesc2.begin(), ShortReportDesc2.end());
|
ShortReportDesc2.begin(), ShortReportDesc2.end());
|
||||||
if (it != report_desc.end())
|
if (it != report_desc.end())
|
||||||
ret |= HIDPP_REPORT_SHORT_SUPPORTED;
|
ret |= ShortReportSupported;
|
||||||
|
|
||||||
it = std::search(report_desc.begin(), report_desc.end(),
|
it = std::search(report_desc.begin(), report_desc.end(),
|
||||||
LongReportDesc.begin(), LongReportDesc.end());
|
LongReportDesc.begin(), LongReportDesc.end());
|
||||||
@ -101,7 +101,7 @@ uint8_t hidpp::getSupportedReports(const std::vector<uint8_t>& report_desc) {
|
|||||||
it = std::search(report_desc.begin(), report_desc.end(),
|
it = std::search(report_desc.begin(), report_desc.end(),
|
||||||
LongReportDesc2.begin(), LongReportDesc2.end());
|
LongReportDesc2.begin(), LongReportDesc2.end());
|
||||||
if (it != report_desc.end())
|
if (it != report_desc.end())
|
||||||
ret |= HIDPP_REPORT_LONG_SUPPORTED;
|
ret |= LongReportSupported;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,14 @@
|
|||||||
#include <backend/hidpp/defs.h>
|
#include <backend/hidpp/defs.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
/* Some devices only support a subset of these reports */
|
|
||||||
#define HIDPP_REPORT_SHORT_SUPPORTED 1U
|
|
||||||
#define HIDPP_REPORT_LONG_SUPPORTED 1U<<1U
|
|
||||||
/* Very long reports exist, however they have not been encountered so far */
|
|
||||||
|
|
||||||
namespace logid::backend::hidpp {
|
namespace logid::backend::hidpp {
|
||||||
uint8_t getSupportedReports(const std::vector<uint8_t>& report_desc);
|
uint8_t getSupportedReports(const std::vector<uint8_t>& report_desc);
|
||||||
|
|
||||||
|
/* Some devices only support a subset of these reports */
|
||||||
|
static constexpr uint8_t ShortReportSupported = 1U;
|
||||||
|
static constexpr uint8_t LongReportSupported = (1U<<1);
|
||||||
|
/* Very long reports exist, however they have not been encountered so far */
|
||||||
|
|
||||||
namespace Offset {
|
namespace Offset {
|
||||||
static constexpr uint8_t Type = 0;
|
static constexpr uint8_t Type = 0;
|
||||||
static constexpr uint8_t DeviceIndex = 1;
|
static constexpr uint8_t DeviceIndex = 1;
|
||||||
|
@ -25,8 +25,13 @@ using namespace logid::features;
|
|||||||
using namespace logid::backend;
|
using namespace logid::backend;
|
||||||
using namespace logid::actions;
|
using namespace logid::actions;
|
||||||
|
|
||||||
#define HIDPP20_REPROG_REBIND (hidpp20::ReprogControls::ChangeTemporaryDivert \
|
#define REPROG_FLAG(x) (control.second.flags & hidpp20::ReprogControls::x ? "YES" : "")
|
||||||
| hidpp20::ReprogControls::ChangeRawXYDivert)
|
#define REPROG_FLAG_ADDITIONAL(x) (control.second.additionalFlags & \
|
||||||
|
hidpp20::ReprogControls::x ? "YES" : "")
|
||||||
|
|
||||||
|
static constexpr auto hidpp20_reprog_rebind =
|
||||||
|
(hidpp20::ReprogControls::ChangeTemporaryDivert |
|
||||||
|
hidpp20::ReprogControls::ChangeRawXYDivert);
|
||||||
|
|
||||||
RemapButton::RemapButton(Device* dev) : DeviceFeature(dev),
|
RemapButton::RemapButton(Device* dev) : DeviceFeature(dev),
|
||||||
_config(dev->activeProfile().buttons),
|
_config(dev->activeProfile().buttons),
|
||||||
@ -49,7 +54,7 @@ RemapButton::RemapButton(Device* dev) : DeviceFeature(dev),
|
|||||||
const std::shared_ptr<actions::Action>& action) {
|
const std::shared_ptr<actions::Action>& action) {
|
||||||
hidpp20::ReprogControls::ControlInfo report{};
|
hidpp20::ReprogControls::ControlInfo report{};
|
||||||
report.controlID = info.controlID;
|
report.controlID = info.controlID;
|
||||||
report.flags = HIDPP20_REPROG_REBIND;
|
report.flags = hidpp20_reprog_rebind;
|
||||||
|
|
||||||
if (action) {
|
if (action) {
|
||||||
if ((action->reprogFlags() &
|
if ((action->reprogFlags() &
|
||||||
@ -72,11 +77,6 @@ RemapButton::RemapButton(Device* dev) : DeviceFeature(dev),
|
|||||||
_ipc_interface = _device->ipcNode()->make_interface<IPC>(this);
|
_ipc_interface = _device->ipcNode()->make_interface<IPC>(this);
|
||||||
|
|
||||||
if (global_loglevel <= DEBUG) {
|
if (global_loglevel <= DEBUG) {
|
||||||
#define FLAG(x) (control.second.flags & hidpp20::ReprogControls::x ? \
|
|
||||||
"YES" : "")
|
|
||||||
#define ADDITIONAL_FLAG(x) (control.second.additionalFlags & \
|
|
||||||
hidpp20::ReprogControls::x ? "YES" : "")
|
|
||||||
|
|
||||||
// Print CIDs, originally by zv0n
|
// Print CIDs, originally by zv0n
|
||||||
logPrintf(DEBUG, "%s:%d remappable buttons:",
|
logPrintf(DEBUG, "%s:%d remappable buttons:",
|
||||||
dev->hidpp20().devicePath().c_str(),
|
dev->hidpp20().devicePath().c_str(),
|
||||||
@ -85,10 +85,8 @@ RemapButton::RemapButton(Device* dev) : DeviceFeature(dev),
|
|||||||
"gesture support?");
|
"gesture support?");
|
||||||
for (const auto& control: _reprog_controls->getControls())
|
for (const auto& control: _reprog_controls->getControls())
|
||||||
logPrintf(DEBUG, "0x%02x | %-7s | %-7s | %-10s | %s",
|
logPrintf(DEBUG, "0x%02x | %-7s | %-7s | %-10s | %s",
|
||||||
control.first, FLAG(TemporaryDivertable), FLAG(FKey),
|
control.first, REPROG_FLAG(TemporaryDivertable), REPROG_FLAG(FKey),
|
||||||
FLAG(MouseButton), ADDITIONAL_FLAG(RawXY));
|
REPROG_FLAG(MouseButton), REPROG_FLAG_ADDITIONAL(RawXY));
|
||||||
#undef ADDITIONAL_FLAG
|
|
||||||
#undef FLAG
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +25,7 @@ using namespace logid::features;
|
|||||||
using namespace logid::backend;
|
using namespace logid::backend;
|
||||||
using namespace logid;
|
using namespace logid;
|
||||||
|
|
||||||
#define FLAG_STR(b) (_wheel_info.capabilities & _thumb_wheel->b ? "YES" : \
|
#define FLAG_STR(b) (_wheel_info.capabilities & _thumb_wheel->b ? "YES" : "NO")
|
||||||
"NO")
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
std::shared_ptr<actions::Action> _genAction(
|
std::shared_ptr<actions::Action> _genAction(
|
||||||
|
@ -21,18 +21,18 @@
|
|||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#define LOGID_VIRTUAL_INPUT_NAME "LogiOps Virtual Input"
|
|
||||||
#define DEFAULT_CONFIG_FILE "/etc/logid.cfg"
|
|
||||||
|
|
||||||
#ifndef LOGIOPS_VERSION
|
#ifndef LOGIOPS_VERSION
|
||||||
#define LOGIOPS_VERSION "null"
|
#define LOGIOPS_VERSION "null"
|
||||||
#warning Version is undefined!
|
#warning Version is undefined!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static constexpr auto virtual_input_name = "LogiOps Virtual Input";
|
||||||
|
static constexpr auto default_config = "/etc/logid.cfg";
|
||||||
|
|
||||||
using namespace logid;
|
using namespace logid;
|
||||||
|
|
||||||
struct CmdlineOptions {
|
struct CmdlineOptions {
|
||||||
std::string config_file = DEFAULT_CONFIG_FILE;
|
std::string config_file = default_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
LogLevel logid::global_loglevel = INFO;
|
LogLevel logid::global_loglevel = INFO;
|
||||||
@ -115,7 +115,7 @@ Possible options are:
|
|||||||
-V,--version Print version number
|
-V,--version Print version number
|
||||||
-c,--config [file path] Change config file from default at %s
|
-c,--config [file path] Change config file from default at %s
|
||||||
-h,--help Print this message.
|
-h,--help Print this message.
|
||||||
)", LOGIOPS_VERSION, argv[0], DEFAULT_CONFIG_FILE);
|
)", LOGIOPS_VERSION, argv[0], default_config);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
case Option::Version:
|
case Option::Version:
|
||||||
printf("%s\n", LOGIOPS_VERSION);
|
printf("%s\n", LOGIOPS_VERSION);
|
||||||
@ -147,7 +147,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
//Create a virtual input device
|
//Create a virtual input device
|
||||||
try {
|
try {
|
||||||
virtual_input = std::make_unique<InputDevice>(LOGID_VIRTUAL_INPUT_NAME);
|
virtual_input = std::make_unique<InputDevice>(virtual_input_name);
|
||||||
} catch (std::system_error& e) {
|
} catch (std::system_error& e) {
|
||||||
logPrintf(ERROR, "Could not create input device: %s", e.what());
|
logPrintf(ERROR, "Could not create input device: %s", e.what());
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
Loading…
Reference in New Issue
Block a user