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
notify.h File Reference
#include "includes.h"
#include "device.h"
+ Include dependency graph for notify.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void nprintf (usbdevice *kb, int nodenumber, usbmode *mode, const char *format,...)
 
void nprintkey (usbdevice *kb, int nnumber, int keyindex, int down)
 
void nprintind (usbdevice *kb, int nnumber, int led, int on)
 
void cmd_notify (usbdevice *kb, usbmode *mode, int nnumber, int keyindex, const char *toggle)
 
void cmd_get (usbdevice *kb, usbmode *mode, int nnumber, int dummy, const char *setting)
 
void cmd_restart (usbdevice *kb, usbmode *mode, int nnumber, int dummy, const char *content)
 

Function Documentation

void cmd_get ( usbdevice kb,
usbmode mode,
int  nnumber,
int  dummy,
const char *  setting 
)

Definition at line 215 of file notify.c.

References _cmd_get(), and imutex.

215  {
216  (void)dummy;
217 
218  pthread_mutex_lock(imutex(kb));
219  _cmd_get(kb, mode, nnumber, setting);
220  pthread_mutex_unlock(imutex(kb));
221 }
static void _cmd_get(usbdevice *kb, usbmode *mode, int nnumber, const char *setting)
Definition: notify.c:90
#define imutex(kb)
Definition: device.h:22

+ Here is the call graph for this function:

void cmd_notify ( usbdevice kb,
usbmode mode,
int  nnumber,
int  keyindex,
const char *  toggle 
)

Definition at line 61 of file notify.c.

References CLEAR_KEYBIT, imutex, N_KEYS_INPUT, usbmode::notify, and SET_KEYBIT.

61  {
62  if(keyindex >= N_KEYS_INPUT)
63  return;
64  pthread_mutex_lock(imutex(kb));
65  if(!strcmp(toggle, "on") || *toggle == 0)
66  SET_KEYBIT(mode->notify[nnumber], keyindex);
67  else if(!strcmp(toggle, "off"))
68  CLEAR_KEYBIT(mode->notify[nnumber], keyindex);
69  pthread_mutex_unlock(imutex(kb));
70 }
#define CLEAR_KEYBIT(array, index)
Definition: structures.h:16
#define SET_KEYBIT(array, index)
Definition: structures.h:15
#define imutex(kb)
Definition: device.h:22
#define N_KEYS_INPUT
Definition: keymap.h:36
uchar notify[10][((((152+22+12)+25)+7)/8)]
Definition: structures.h:91
void cmd_restart ( usbdevice kb,
usbmode mode,
int  nnumber,
int  dummy,
const char *  content 
)

Definition at line 225 of file notify.c.

References ckb_info, nprintf(), and restart().

225  {
226  (void)mode;
227  (void)nnumber;
228  (void)dummy;
229 
230  ckb_info("RESTART called with %s\n", content);
231  nprintf(kb, -1, 0, "RESTART called with %s\n", content);
232  restart();
233 }
void nprintf(usbdevice *kb, int nodenumber, usbmode *mode, const char *format,...)
Definition: notify.c:8
#define ckb_info(fmt, args...)
Definition: includes.h:55
int restart()
Definition: main.c:228

+ Here is the call graph for this function:

void nprintf ( usbdevice kb,
int  nodenumber,
usbmode mode,
const char *  format,
  ... 
)

Definition at line 8 of file notify.c.

References INDEX_OF, usbprofile::mode, usbdevice::outfifo, OUTFIFO_MAX, and usbdevice::profile.

Referenced by _cmd_get(), cmd_fwupdate(), cmd_restart(), fwupdate(), nprintind(), and nprintkey().

8  {
9  if(!kb)
10  return;
11  usbprofile* profile = kb->profile;
12  va_list va_args;
13  int fifo;
14  if(nodenumber >= 0){
15  // If node number was given, print to that node (if open)
16  if((fifo = kb->outfifo[nodenumber] - 1) != -1){
17  va_start(va_args, format);
18  if(mode)
19  dprintf(fifo, "mode %d ", INDEX_OF(mode, profile->mode) + 1);
20  vdprintf(fifo, format, va_args);
21  }
22  return;
23  }
24  // Otherwise, print to all nodes
25  for(int i = 0; i < OUTFIFO_MAX; i++){
26  if((fifo = kb->outfifo[i] - 1) != -1){
27  va_start(va_args, format);
28  if(mode)
29  dprintf(fifo, "mode %d ", INDEX_OF(mode, profile->mode) + 1);
30  vdprintf(fifo, format, va_args);
31  }
32  }
33 }
usbprofile * profile
Definition: structures.h:221
usbmode mode[6]
Definition: structures.h:103
int outfifo[10]
Definition: structures.h:227
#define INDEX_OF(entry, array)
Definition: includes.h:27
#define OUTFIFO_MAX
Definition: structures.h:24

+ Here is the caller graph for this function:

void nprintind ( usbdevice kb,
int  nnumber,
int  led,
int  on 
)

Definition at line 43 of file notify.c.

References I_CAPS, I_NUM, I_SCROLL, and nprintf().

Referenced by _cmd_get(), and updateindicators_kb().

43  {
44  const char* name = 0;
45  switch(led){
46  case I_NUM:
47  name = "num";
48  break;
49  case I_CAPS:
50  name = "caps";
51  break;
52  case I_SCROLL:
53  name = "scroll";
54  break;
55  default:
56  return;
57  }
58  nprintf(kb, nnumber, 0, "i %c%s\n", on ? '+' : '-', name);
59 }
void nprintf(usbdevice *kb, int nodenumber, usbmode *mode, const char *format,...)
Definition: notify.c:8
#define I_NUM
Definition: structures.h:19
#define I_CAPS
Definition: structures.h:20
#define I_SCROLL
Definition: structures.h:21

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void nprintkey ( usbdevice kb,
int  nnumber,
int  keyindex,
int  down 
)

Definition at line 35 of file notify.c.

References keymap, key::name, and nprintf().

Referenced by _cmd_get(), and inputupdate_keys().

35  {
36  const key* map = keymap + keyindex;
37  if(map->name)
38  nprintf(kb, nnumber, 0, "key %c%s\n", down ? '+' : '-', map->name);
39  else
40  nprintf(kb, nnumber, 0, "key %c#%d\n", down ? '+' : '-', keyindex);
41 }
void nprintf(usbdevice *kb, int nodenumber, usbmode *mode, const char *format,...)
Definition: notify.c:8
const key keymap[(((152+22+12)+25)+12)]
Definition: keymap.c:5
Definition: keymap.h:49
const char * name
Definition: keymap.h:50

+ Here is the call graph for this function:

+ Here is the caller graph for this function: