ckb-next
v0.2.8 at branch master
ckb-next driver for corsair devices
|
#include "device.h"
#include "devnode.h"
#include "firmware.h"
#include "input.h"
#include "led.h"
#include "notify.h"
#include "profile.h"
Go to the source code of this file.
Data Structures | |
struct | _readlines_ctx |
Macros | |
#define | S_GID_READ (gid >= 0 ? S_CUSTOM_R : S_READ) |
#define | MAX_BUFFER (1024 * 1024 - 1) |
Functions | |
int | rm_recursive (const char *path) |
void | _updateconnected () |
_updateconnected Update the list of connected devices. More... | |
void | updateconnected () |
Update the list of connected devices. More... | |
int | _mknotifynode (usbdevice *kb, int notify) |
int | mknotifynode (usbdevice *kb, int notify) |
Creates a notification node for the specified keyboard. More... | |
int | _rmnotifynode (usbdevice *kb, int notify) |
int | rmnotifynode (usbdevice *kb, int notify) |
Removes a notification node for the specified keyboard. More... | |
static int | _mkdevpath (usbdevice *kb) |
int | mkdevpath (usbdevice *kb) |
Create a dev path for the keyboard at index. Returns 0 on success. More... | |
int | rmdevpath (usbdevice *kb) |
Remove the dev path for the keyboard at index. Returns 0 on success. More... | |
int | mkfwnode (usbdevice *kb) |
Writes a keyboard's firmware version and poll rate to its device node. More... | |
void | readlines_ctx_init (readlines_ctx *ctx) |
void | readlines_ctx_free (readlines_ctx ctx) |
unsigned | readlines (int fd, readlines_ctx ctx, const char **input) |
Variables | |
const char *const | devpath = "/dev/input/ckb" |
long | gid = -1 |
Group ID for the control nodes. -1 to give read/write access to everybody. More... | |
struct _readlines_ctx |
#define MAX_BUFFER (1024 * 1024 - 1) |
Definition at line 334 of file devnode.c.
Referenced by readlines().
#define S_GID_READ (gid >= 0 ? S_CUSTOM_R : S_READ) |
Definition at line 17 of file devnode.c.
Referenced by _mkdevpath(), _mknotifynode(), _updateconnected(), and mkfwnode().
|
static |
Definition at line 136 of file devnode.c.
References _mknotifynode(), _updateconnected(), ckb_err, ckb_warn, devpath, FEAT_ADJRATE, FEAT_BIND, FEAT_FWUPDATE, FEAT_FWVERSION, FEAT_MONOCHROME, FEAT_NOTIFY, FEAT_POLLRATE, FEAT_RGB, gid, HAS_FEATURES, INDEX_OF, usbdevice::infifo, keyboard, mkfwnode(), usbdevice::name, usbdevice::product, product_str(), rm_recursive(), S_CUSTOM, S_GID_READ, S_READ, S_READDIR, S_READWRITE, usbdevice::serial, usbdevice::vendor, and vendor_str().
Referenced by mkdevpath().
int _mknotifynode | ( | usbdevice * | kb, |
int | notify | ||
) |
Definition at line 87 of file devnode.c.
References ckb_warn, devpath, gid, INDEX_OF, keyboard, usbdevice::outfifo, OUTFIFO_MAX, and S_GID_READ.
Referenced by _mkdevpath(), and mknotifynode().
int _rmnotifynode | ( | usbdevice * | kb, |
int | notify | ||
) |
Definition at line 115 of file devnode.c.
References devpath, INDEX_OF, keyboard, usbdevice::outfifo, and OUTFIFO_MAX.
Referenced by rmdevpath(), and rmnotifynode().
void _updateconnected | ( | ) |
<devicepath> normally is /dev/input/ckb or /input/ckb.
Open the normal file under <devicepath>0/connected for writing. For each device connected, print its devicepath+number, the serial number of the usb device and the usb name of the device connected to that usb interface.
eg:
/dev/input/ckb1 0F022014ABABABABABABABABABABA999 Corsair K95 RGB Gaming Keyboard
/dev/input/ckb2 0D02303DBACBACBACBACBACBACBAC998 Corsair M65 RGB Gaming Mouse
Set the file ownership to root. If the glob var gid is explicitly set to something different from -1 (the initial value), set file permission to 640, else to 644. This is used if you start the daemon with –gid=<GID> Parameter.
Because several independent threads may call updateconnected(), protect that procedure with locking/unlocking of devmutex.
Definition at line 55 of file devnode.c.
References ckb_warn, DEV_MAX, devmutex, devpath, gid, IS_CONNECTED, keyboard, and S_GID_READ.
Referenced by _mkdevpath(), and updateconnected().
int mkdevpath | ( | usbdevice * | kb | ) |
Definition at line 268 of file devnode.c.
References _mkdevpath(), euid_guard_start, and euid_guard_stop.
Referenced by _setupusb(), and main().
int mkfwnode | ( | usbdevice * | kb | ) |
Definition at line 299 of file devnode.c.
References ckb_warn, devpath, usbdevice::fwversion, gid, INDEX_OF, keyboard, usbdevice::pollrate, and S_GID_READ.
Referenced by _mkdevpath(), and fwupdate().
int mknotifynode | ( | usbdevice * | kb, |
int | notify | ||
) |
Definition at line 108 of file devnode.c.
References _mknotifynode(), euid_guard_start, and euid_guard_stop.
Referenced by readcmd().
unsigned readlines | ( | int | fd, |
readlines_ctx | ctx, | ||
const char ** | input | ||
) |
Definition at line 353 of file devnode.c.
References _readlines_ctx::buffer, _readlines_ctx::buffersize, ckb_warn, _readlines_ctx::leftover, _readlines_ctx::leftoverlen, and MAX_BUFFER.
Referenced by devmain().
void readlines_ctx_free | ( | readlines_ctx | ctx | ) |
Definition at line 348 of file devnode.c.
References _readlines_ctx::buffer.
Referenced by devmain().
void readlines_ctx_init | ( | readlines_ctx * | ctx | ) |
Definition at line 341 of file devnode.c.
Referenced by devmain().
int rm_recursive | ( | const char * | path | ) |
Definition at line 19 of file devnode.c.
Referenced by _mkdevpath(), and rmdevpath().
int rmdevpath | ( | usbdevice * | kb | ) |
Definition at line 275 of file devnode.c.
References _rmnotifynode(), ckb_info, ckb_warn, devpath, euid_guard_start, euid_guard_stop, INDEX_OF, usbdevice::infifo, keyboard, OUTFIFO_MAX, and rm_recursive().
Referenced by closeusb(), and quitWithLock().
int rmnotifynode | ( | usbdevice * | kb, |
int | notify | ||
) |
Definition at line 129 of file devnode.c.
References _rmnotifynode(), euid_guard_start, and euid_guard_stop.
Referenced by readcmd().
void updateconnected | ( | ) |
Definition at line 81 of file devnode.c.
References _updateconnected(), euid_guard_start, and euid_guard_stop.
Referenced by _setupusb(), and closeusb().
const char* const devpath = "/dev/input/ckb" |
Definition at line 11 of file devnode.c.
Referenced by _mkdevpath(), _mknotifynode(), _rmnotifynode(), _updateconnected(), mkfwnode(), and rmdevpath().
long gid = -1 |
Definition at line 16 of file devnode.c.
Referenced by _mkdevpath(), _mknotifynode(), _updateconnected(), main(), and mkfwnode().