38 #define V_CORSAIR       0x1b1c 
   39 #define V_CORSAIR_STR   "1b1c" 
   42 #define P_K65_STR       "1b17" 
   43 #define P_K65_NRGB      0x1b07 
   44 #define P_K65_NRGB_STR  "1b07" 
   45 #define P_K65_LUX       0x1b37 
   46 #define P_K65_LUX_STR   "1b37" 
   47 #define P_K65_RFIRE     0x1b39 
   48 #define P_K65_RFIRE_STR "1b39" 
   49 #define IS_K65(kb)      ((kb)->vendor == V_CORSAIR && ((kb)->product == P_K65 || (kb)->product == P_K65_NRGB || (kb)->product == P_K65_LUX || (kb)->product == P_K65_RFIRE)) 
   52 #define P_K70_STR            "1b13" 
   53 #define P_K70_NRGB           0x1b09 
   54 #define P_K70_NRGB_STR       "1b09" 
   55 #define P_K70_LUX            0x1b33 
   56 #define P_K70_LUX_STR        "1b33" 
   57 #define P_K70_LUX_NRGB       0x1b36 
   58 #define P_K70_LUX_NRGB_STR   "1b36" 
   59 #define P_K70_RFIRE          0x1b38 
   60 #define P_K70_RFIRE_STR      "1b38" 
   61 #define P_K70_RFIRE_NRGB     0x1b3a 
   62 #define P_K70_RFIRE_NRGB_STR "1b3a" 
   63 #define IS_K70(kb)           ((kb)->vendor == V_CORSAIR && ((kb)->product == P_K70 || (kb)->product == P_K70_NRGB || (kb)->product == P_K70_RFIRE || (kb)->product == P_K70_RFIRE_NRGB || (kb)->product == P_K70_LUX || (kb)->product == P_K70_LUX_NRGB)) 
   66 #define P_K95_STR       "1b11" 
   67 #define P_K95_NRGB      0x1b08 
   68 #define P_K95_NRGB_STR  "1b08" 
   69 #define P_K95_PLATINUM  0x1b2d 
   70 #define P_K95_PLATINUM_STR "1b2d" 
   71 #define IS_K95(kb)      ((kb)->vendor == V_CORSAIR && ((kb)->product == P_K95 || (kb)->product == P_K95_NRGB || (kb)->product == P_K95_PLATINUM)) 
   73 #define P_STRAFE            0x1b20 
   74 #define P_STRAFE_STR        "1b20" 
   75 #define P_STRAFE_NRGB       0x1b15 
   76 #define P_STRAFE_NRGB_STR   "1b15" 
   77 #define IS_STRAFE(kb)       ((kb)->vendor == V_CORSAIR && ((kb)->product == P_STRAFE || (kb)->product == P_STRAFE_NRGB)) 
   80 #define P_M65_STR       "1b12" 
   81 #define P_M65_PRO       0x1b2e 
   82 #define P_M65_PRO_STR   "1b2e" 
   83 #define IS_M65(kb)      ((kb)->vendor == V_CORSAIR && ((kb)->product == P_M65 || (kb)->product == P_M65_PRO)) 
   85 #define P_SABRE_O       0x1b14   
   86 #define P_SABRE_O_STR   "1b14" 
   87 #define P_SABRE_L       0x1b19   
   88 #define P_SABRE_L_STR   "1b19" 
   89 #define P_SABRE_N       0x1b2f   
   90 #define P_SABRE_N_STR   "1b2f" 
   91 #define P_SABRE_O2      0x1b32  
   92 #define P_SABRE_O2_STR  "1b32" 
   93 #define IS_SABRE(kb)    ((kb)->vendor == V_CORSAIR && ((kb)->product == P_SABRE_O || (kb)->product == P_SABRE_L || (kb)->product == P_SABRE_N || (kb)->product == P_SABRE_O2)) 
   95 #define P_SCIMITAR          0x1b1e 
   96 #define P_SCIMITAR_STR      "1b1e" 
   97 #define P_SCIMITAR_PRO      0x1b3e 
   98 #define P_SCIMITAR_PRO_STR  "1b3e" 
   99 #define IS_SCIMITAR(kb) ((kb)->vendor == V_CORSAIR && ((kb)->product == P_SCIMITAR || (kb)->product == P_SCIMITAR_PRO)) 
  124 #define IS_RGB(vendor, product)         ((vendor) == (V_CORSAIR) && (product) != (P_K65_NRGB) && (product) != (P_K70_NRGB) && (product) != (P_K95_NRGB)) 
  129 #define IS_MONOCHROME(vendor, product)  ((vendor) == (V_CORSAIR) && (product) == (P_STRAFE_NRGB)) 
  132 #define IS_RGB_DEV(kb)                  IS_RGB((kb)->vendor, (kb)->product) 
  135 #define IS_MONOCHROME_DEV(kb)           IS_MONOCHROME((kb)->vendor, (kb)->product) 
  138 #define IS_FULLRANGE(kb)                (IS_RGB((kb)->vendor, (kb)->product) && (kb)->product != P_K65 && (kb)->product != P_K70 && (kb)->product != P_K95) 
  141 #define IS_MOUSE(vendor, product)       ((vendor) == (V_CORSAIR) && ((product) == (P_M65) || (product) == (P_M65_PRO) || (product) == (P_SABRE_O) || (product) == (P_SABRE_L) || (product) == (P_SABRE_N) || (product) == (P_SCIMITAR) || (product) == (P_SCIMITAR_PRO) || (product) == (P_SABRE_O2))) 
  144 #define IS_MOUSE_DEV(kb)                IS_MOUSE((kb)->vendor, (kb)->product) 
  149 #define DELAY_SHORT(kb)     usleep((int)(kb)->usbdelay * 1000)  // base (default: 5ms) 
  152 #define DELAY_MEDIUM(kb)    usleep((int)(kb)->usbdelay * 10000) // x10 (default: 50ms) 
  155 #define DELAY_LONG(kb)      usleep(100000)                      // long, fixed 100ms 
  160 #define USB_DELAY_DEFAULT   5 
  214 #define resetusb(kb) _resetusb(kb, __FILE_NOPATH__, __LINE__) 
  239 #define usbsend(kb, messages, count) _usbsend(kb, messages, count, __FILE_NOPATH__, __LINE__) 
  256 #define usbrecv(kb, out_msg, in_msg) _usbrecv(kb, out_msg, in_msg, __FILE_NOPATH__, __LINE__) 
  296 #define nk95cmd(kb, command) _nk95cmd(kb, (command) >> 16 & 0xFF, (command) & 0xFFFF, __FILE_NOPATH__, __LINE__) 
  301 #define NK95_HWOFF  0x020030 
  304 #define NK95_HWON   0x020001 
  307 #define NK95_M1     0x140001 
  310 #define NK95_M2     0x140002 
  313 #define NK95_M3     0x140003 
int usbmain()
Start the USB main loop. Returns program exit code when finished. 
 
int os_resetusb(usbdevice *kb, const char *file, int line)
os_resetusb is the os specific implementation for resetting usb 
 
void * os_inputmain(void *context)
os_inputmain is run in a separate thread and will be detached from the main thread, so it needs to clean up its own resources. 
 
void os_closeusb(usbdevice *kb)
os_closeusb unclaim it, destroy the udev device and clear data structures at kb 
 
const char * vendor_str(short vendor)
uncomment the following Define to see USB packets sent to the device 
 
int os_usbrecv(usbdevice *kb, uchar *in_msg, const char *file, int line)
os_usbrecv receives a max MSGSIZE long buffer from usb device 
 
int os_setupusb(usbdevice *kb)
os_setupusb OS-specific setup for a specific usb device. 
 
int usb_tryreset(usbdevice *kb)
usb_tryreset does what the name means: Try to reset the usb via resetusb() 
 
int closeusb(usbdevice *kb)
closeusb Close a USB device and remove device entry. 
 
int _usbsend(usbdevice *kb, const uchar *messages, int count, const char *file, int line)
_usbsend send a logical message completely to the given device 
 
const char * product_str(short product)
product_str returns a condensed view on what type of device we have. 
 
int revertusb(usbdevice *kb)
revertusb sets a given device to inactive (hardware controlled) mode if not a fw-ugrade is indicated ...
 
void setupusb(usbdevice *kb)
setupusb starts a thread with kb as parameter and _setupusb() as entrypoint. 
 
int _resetusb(usbdevice *kb, const char *file, int line)
_resetusb Reset a USB device. 
 
void os_sendindicators(usbdevice *kb)
os_sendindicators update the indicators for the special keys (Numlock, Capslock and what else...
 
int _nk95cmd(usbdevice *kb, uchar bRequest, ushort wValue, const char *file, int line)
_nk95cmd If we control a non RGB keyboard, set the keyboard via ioctl with usbdevfs_ctrltransfer ...
 
int _usbrecv(usbdevice *kb, const uchar *out_msg, uchar *in_msg, const char *file, int line)
_usbrecv Request data from a USB device by first sending an output packet and then reading the respon...
 
void usbkill()
Stop the USB system. 
 
int os_usbsend(usbdevice *kb, const uchar *out_msg, int is_recv, const char *file, int line)
os_usbsend sends a data packet (MSG_SIZE = 64) Bytes long