ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
input.h
Go to the documentation of this file.
1 #ifndef INPUT_H
2 #define INPUT_H
3 
4 #include "includes.h"
5 #include "usb.h"
6 
7 // Open input device. Return 0 on success
8 int os_inputopen(usbdevice* kb);
9 // Close input device
10 void os_inputclose(usbdevice* kb);
11 
12 // Updates keypresses on input device. Lock imutex first (see device.h).
13 void inputupdate(usbdevice* kb);
14 // Read indicator LED state and send it back to the keyboard if needed. Lock dmutex first.
15 void updateindicators_kb(usbdevice* kb, int force);
16 
17 // Initializes key bindings for a device. Lock imutex first.
18 void initbind(binding* bind);
19 // Frees key binding data for a device. Lock imutex first.
20 void freebind(binding* bind);
21 
22 // Note: unlike most commands, bind commands will lock/unlock the device's imutex
23 // Binds a key
24 void cmd_bind(usbdevice* kb, usbmode* mode, int dummy, int keyindex, const char* to);
25 // Unbinds a key
26 void cmd_unbind(usbdevice* kb, usbmode* mode, int dummy, int keyindex, const char* ignored);
27 // Resets a key binding
28 void cmd_rebind(usbdevice* kb, usbmode* mode, int dummy, int keyindex, const char* ignored);
29 // Creates or updates a macro. Pass null strings to clear all macros
30 void cmd_macro(usbdevice* kb, usbmode* mode, const int notifynumber, const char* keys, const char* assignment);
31 
32 #ifdef OS_LINUX
33 // Is a key a modifier?
34 #define IS_MOD(s) ((s) == KEY_CAPSLOCK || (s) == KEY_NUMLOCK || (s) == KEY_SCROLLLOCK || (s) == KEY_LEFTSHIFT || (s) == KEY_RIGHTSHIFT || (s) == KEY_LEFTCTRL || (s) == KEY_RIGHTCTRL || (s) == KEY_LEFTMETA || (s) == KEY_RIGHTMETA || (s) == KEY_LEFTALT || (s) == KEY_RIGHTALT || (s) == KEY_FN)
35 #else
36 // Scroll Lock and Num Lock aren't modifiers on OSX
37 #define IS_MOD(s) ((s) == KEY_CAPSLOCK || (s) == KEY_LEFTSHIFT || (s) == KEY_RIGHTSHIFT || (s) == KEY_LEFTCTRL || (s) == KEY_RIGHTCTRL || (s) == KEY_LEFTMETA || (s) == KEY_RIGHTMETA || (s) == KEY_LEFTALT || (s) == KEY_RIGHTALT || (s) == KEY_FN)
38 #endif
39 
40 // OS-specific event handlers. Should only be called within the above functions.
41 
42 // Generate a keypress or mouse button event
43 void os_keypress(usbdevice* kb, int scancode, int down);
44 // Generate mouse movement
45 void os_mousemove(usbdevice* kb, int x, int y);
46 
47 // Perform OS-specific setup for indicator lights. Called when the device is created. Return 0 on success.
49 
54 typedef struct parameter {
57 } parameter_t;
58 
62 typedef struct ptlist {
63  struct ptlist* next;
64  pthread_t thread_id;
65 } ptlist_t;
66 
67 #endif // INPUT_H
float y
Definition: main.c:66
void freebind(binding *bind)
Definition: input.c:300
struct ptlist is one element in the single linked list to store macro_play threads waiting for their ...
Definition: input.h:62
void cmd_macro(usbdevice *kb, usbmode *mode, const int notifynumber, const char *keys, const char *assignment)
Definition: input.c:475
float x
Definition: main.c:66
void os_mousemove(usbdevice *kb, int x, int y)
Definition: input_linux.c:143
struct parameter contains the values for a fresh started macro_play thread. parameter_t is the typede...
Definition: input.h:54
keymacro * macro
Definition: input.h:56
void os_keypress(usbdevice *kb, int scancode, int down)
Definition: input_linux.c:118
struct ptlist * next
Definition: input.h:63
void cmd_bind(usbdevice *kb, usbmode *mode, int dummy, int keyindex, const char *to)
Definition: input.c:307
void inputupdate(usbdevice *kb)
Definition: input.c:241
int os_inputopen(usbdevice *kb)
os_inputopen
Definition: input_linux.c:55
usbdevice * kb
Definition: input.h:55
pthread_t thread_id
Definition: input.h:64
int os_setupindicators(usbdevice *kb)
Definition: input_linux.c:189
void cmd_rebind(usbdevice *kb, usbmode *mode, int dummy, int keyindex, const char *ignored)
Definition: input.c:342
void os_inputclose(usbdevice *kb)
Definition: input_linux.c:76
Definitions for using USB interface.
struct ptlist ptlist_t
struct ptlist is one element in the single linked list to store macro_play threads waiting for their ...
void cmd_unbind(usbdevice *kb, usbmode *mode, int dummy, int keyindex, const char *ignored)
Definition: input.c:331
void initbind(binding *bind)
Definition: input.c:292
struct parameter parameter_t
struct parameter contains the values for a fresh started macro_play thread. parameter_t is the typede...
void updateindicators_kb(usbdevice *kb, int force)
Definition: input.c:261