0.1.2
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
// gKeyMapper daemon - raw USB HID access to the keyboard's vendor interface.
|
||||
// gKeyMapper daemon - raw HID access to the keyboard's vendor interface.
|
||||
//
|
||||
// Uses the kernel's hidraw interface instead of libusb: hidraw provides
|
||||
// non-exclusive access, so other tools (OpenRGB, etc.) can talk to the same
|
||||
// device at the same time. The kernel driver (usbhid) stays attached.
|
||||
#ifndef GKEYMAPPER_DAEMON_GKEY_DEVICE_H
|
||||
#define GKEYMAPPER_DAEMON_GKEY_DEVICE_H
|
||||
|
||||
@@ -6,9 +10,6 @@
|
||||
|
||||
#include "device_tables.h"
|
||||
|
||||
struct libusb_context;
|
||||
struct libusb_device_handle;
|
||||
|
||||
namespace gkeymapper::daemon {
|
||||
|
||||
class GKeyDevice {
|
||||
@@ -19,15 +20,15 @@ public:
|
||||
GKeyDevice(const GKeyDevice&) = delete;
|
||||
GKeyDevice& operator=(const GKeyDevice&) = delete;
|
||||
|
||||
// Finds a supported keyboard, opens it and detaches the kernel driver from
|
||||
// the vendor interface. Returns false (and logs) if none is found.
|
||||
// Finds a supported keyboard and opens its hidraw node. Returns false (and
|
||||
// logs) if none is found.
|
||||
//
|
||||
// `quiet` silences the "cannot use the keyboard" lines only, which the
|
||||
// hot-plug retry uses so an unplugged keyboard does not flood the journal
|
||||
// with one line every retry; libusb-level failures always log.
|
||||
// with one line every retry.
|
||||
bool open(bool quiet = false);
|
||||
void close();
|
||||
bool is_open() const { return handle_ != nullptr; }
|
||||
bool is_open() const { return fd_ >= 0; }
|
||||
|
||||
// Sends the "stop mapping G-keys to F-keys" command if the model needs it.
|
||||
bool disable_binding();
|
||||
@@ -39,14 +40,10 @@ public:
|
||||
const DeviceProfile* profile() const { return profile_; }
|
||||
|
||||
private:
|
||||
bool find_endpoint();
|
||||
int find_hidraw_node(uint16_t vendor, uint16_t product);
|
||||
|
||||
libusb_context* context_ = nullptr;
|
||||
libusb_device_handle* handle_ = nullptr;
|
||||
int fd_ = -1;
|
||||
const DeviceProfile* profile_ = nullptr;
|
||||
uint8_t endpoint_ = 0;
|
||||
int claimed_interface_ = -1;
|
||||
bool detached_kernel_driver_ = false;
|
||||
};
|
||||
|
||||
} // namespace gkeymapper::daemon
|
||||
|
||||
Reference in New Issue
Block a user