10 if(key1[i] != key2[i])
30 perror(
"macro_pt_enqueue: ");
36 pt_head = pt_tail = new_elem;
38 pt_tail->
next = new_elem;
52 if (pt_head == 0 && pt_tail == 0) {
53 ckb_err(
"macro_pt_dequeue: called on empty list.\n");
57 pt_head = pt_head->
next;
58 if (pt_head == 0) pt_tail = 0;
86 pthread_mutex_lock(
mmutex2(kb));
94 pthread_mutex_unlock(
mmutex2(kb));
97 pthread_mutex_lock(
mmutex(kb));
104 pthread_mutex_unlock(
mmutex(kb));
105 if (action->
delay != UINT_MAX && action->
delay) {
106 clock_nanosleep(CLOCK_MONOTONIC, 0, &(
struct timespec) {.tv_nsec = action->
delay * 1000}, NULL);
107 }
else if (kb->
delay != UINT_MAX && kb->
delay) {
108 clock_nanosleep(CLOCK_MONOTONIC, 0, &(
struct timespec) {.tv_nsec = kb->
delay * 1000}, NULL);
111 clock_nanosleep(CLOCK_MONOTONIC, 0, &(
struct timespec) {.tv_nsec = action->
delay * 100000}, NULL);
113 clock_nanosleep(CLOCK_MONOTONIC, 0, &(
struct timespec) {.tv_nsec = 30000}, NULL);
116 pthread_mutex_lock(
mmutex(kb));
120 pthread_mutex_lock(
mmutex2(kb));
123 pthread_cond_broadcast(
mvar(kb));
124 pthread_mutex_unlock(
mmutex2(kb));
126 pthread_mutex_unlock(
mmutex(kb));
150 perror(
"inputupdate_keys got no more mem:");
152 pthread_t thread = 0;
154 params->
macro = macro;
155 int retval = pthread_create(&thread, 0,
play_macro, (
void*)params);
157 perror(
"inputupdate_keys: Creating thread returned not null");
172 int modcount = 0, keycount = 0, rmodcount = 0;
174 char oldb = input->
prevkeys[byte], newb = input->
keys[byte];
177 for(
int bit = 0; bit < 8; bit++){
178 int keyindex = byte * 8 + bit;
183 char mask = 1 << bit;
184 char old = oldb & mask,
new = newb & mask;
192 for(
int i = keycount + rmodcount; i > 0; i--)
193 events[modcount + i] = events[modcount + i - 1];
196 events[modcount++] = scancode + 1;
199 events[modcount + keycount + rmodcount++] = -(scancode + 1);
203 for(
int i = rmodcount; i > 0; i--)
204 events[modcount + keycount + i] = events[modcount + keycount + i - 1];
205 events[modcount + keycount++] =
new ? (scancode + 1) : -(scancode + 1);
207 #define IS_WHEEL(scan, kb) (((scan) == KEY_VOLUMEUP || (scan) == KEY_VOLUMEDOWN || (scan) == BTN_WHEELUP || (scan) == BTN_WHEELDOWN) && (!IS_K65(kb) && !IS_K63(kb)))
209 for(
int i = rmodcount; i > 0; i--)
210 events[modcount + keycount + i] = events[modcount + keycount + i - 1];
211 events[modcount + keycount++] = -(scancode + 1);
212 input->
keys[byte] &= ~mask;
218 for(
int notify = 0; notify <
OUTFIFO_MAX; notify++){
219 if(mode->
notify[notify][byte] & mask){
233 int totalkeys = modcount + keycount + rmodcount;
234 for(
int i = 0; i < totalkeys; i++){
235 int scancode = events[i];
236 os_keypress(kb, (scancode < 0 ? -scancode : scancode) - 1, scancode > 0);
268 new = (
new & ~mode->
ioff) | mode->
ion;
272 if(old !=
new || force){
281 for(
unsigned i = 0; i <
sizeof(indicators) /
sizeof(
uchar); i++){
282 uchar mask = indicators[i];
283 if((hw_old & mask) == (hw_new & mask))
285 for(
int notify = 0; notify <
OUTFIFO_MAX; notify++){
286 if(mode->
inotify[notify] & mask)
287 nprintind(kb, notify, mask, hw_new & mask);
304 memset(bind, 0,
sizeof(*bind));
314 if(sscanf(to,
"#x%ux", &tocode) != 1 && sscanf(to,
"#%u", &tocode) == 1 && tocode <
N_KEYS_INPUT){
315 pthread_mutex_lock(
imutex(kb));
317 pthread_mutex_unlock(
imutex(kb));
323 pthread_mutex_lock(
imutex(kb));
325 pthread_mutex_unlock(
imutex(kb));
337 pthread_mutex_lock(
imutex(kb));
339 pthread_mutex_unlock(
imutex(kb));
348 pthread_mutex_lock(
imutex(kb));
350 pthread_mutex_unlock(
imutex(kb));
355 if(!keys && !assignment){
366 memset(¯o, 0,
sizeof(macro));
369 int left = strlen(keys),
right = strlen(assignment);
370 int position = 0, field = 0;
372 while(position < left && sscanf(keys + position,
"%10[^+]%n", keyname, &field) == 1){
374 if((sscanf(keyname,
"#%d", &keycode) && keycode >= 0 && keycode <
N_KEYS_INPUT)
375 || (sscanf(keyname,
"#x%x", &keycode) && keycode >= 0 && keycode <
N_KEYS_INPUT)){
383 macro.
combo[i / 8] |= 1 << (i % 8);
389 if(keys[position += field] ==
'+')
396 for(
const char* c = assignment; *c != 0; c++){
407 while(position <
right && sscanf(assignment + position,
"%23[^,]%n", keyname, &field) == 1){
408 if(!strcmp(keyname,
"clear"))
413 unsigned int delay = UINT_MAX;
414 char real_keyname[12];
415 int scan_matches = sscanf(keyname,
"%11[^=]=%ld", real_keyname, &long_delay);
416 if (scan_matches == 2) {
417 if (0 <= long_delay && long_delay < UINT_MAX) {
418 delay = (
unsigned int)long_delay;
419 strcpy(keyname, real_keyname);
423 int down = (keyname[0] ==
'+');
424 if(down || keyname[0] ==
'-'){
426 if((sscanf(keyname + 1,
"#%d", &keycode) && keycode >= 0 && keycode <
N_KEYS_INPUT)
427 || (sscanf(keyname + 1,
"#x%x", &keycode) && keycode >= 0 && keycode <
N_KEYS_INPUT)){
436 if(
keymap[i].name && !strcmp(keyname + 1,
keymap[i].name)){
446 if(assignment[position += field] ==
',')
454 free(macros[i].actions);
458 memcpy(macros + j - 1, macros + j,
sizeof(
keymacro));
462 memcpy(macros + i, ¯o,
sizeof(
keymacro));
478 pthread_mutex_lock(
imutex(kb));
480 pthread_mutex_unlock(
imutex(kb));
#define DELAY_SHORT(kb)
USB delays for when the keyboards get picky about timing That was the original comment, but it is used anytime.
const key keymap[(((152+22+12)+25)+12)]
#define ckb_err(fmt, args...)
uchar prevkeys[((((152+22+12)+25)+7)/8)]
#define SET_KEYBIT(array, index)
void nprintkey(usbdevice *kb, int nnumber, int keyindex, int down)
void nprintind(usbdevice *kb, int nnumber, int led, int on)
uchar combo[((((152+22+12)+25)+7)/8)]
int base[((152+22+12)+25)]
uchar notify[10][((((152+22+12)+25)+7)/8)]
void os_sendindicators(usbdevice *kb)
os_sendindicators update the indicators for the special keys (Numlock, Capslock and what else...
uchar keys[((((152+22+12)+25)+7)/8)]