aboutsummaryrefslogtreecommitdiff
path: root/common/action.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-02-01 14:48:11 +0900
committertmk <nobody@nowhere>2013-02-01 14:48:11 +0900
commit1d7962ba8a20323dc13cc913381608e117afaeb4 (patch)
tree7f345a164f79364a3d7178be8b828d648b3e6c8a /common/action.c
parentd95463f2e0369dc0e28497bb923b3012fb09e900 (diff)
downloadqmk_firmware-1d7962ba8a20323dc13cc913381608e117afaeb4.tar.gz
qmk_firmware-1d7962ba8a20323dc13cc913381608e117afaeb4.zip
Add user defined function to action.
Diffstat (limited to 'common/action.c')
-rw-r--r--common/action.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/common/action.c b/common/action.c
index d1f493fe0..cb44e272a 100644
--- a/common/action.c
+++ b/common/action.c
@@ -110,7 +110,7 @@ static bool waiting_buffer_typed(keyevent_t event)
110} 110}
111#endif 111#endif
112 112
113static bool waiting_buffer_has_anykey_pressed(void) 113bool waiting_buffer_has_anykey_pressed(void)
114{ 114{
115 for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { 115 for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
116 if (waiting_buffer[i].event.pressed) return true; 116 if (waiting_buffer[i].event.pressed) return true;
@@ -256,7 +256,7 @@ static void process_action(keyrecord_t *record)
256 debug("MODS_TAP: Oneshot: start\n"); 256 debug("MODS_TAP: Oneshot: start\n");
257 oneshot_start(mods, event.time); 257 oneshot_start(mods, event.time);
258 } 258 }
259 else if (tap_count == 5) { 259 else if (tap_count == TAPPING_TOGGLE) {
260 debug("MODS_TAP: Oneshot: toggle\n"); 260 debug("MODS_TAP: Oneshot: toggle\n");
261 oneshot_toggle(); 261 oneshot_toggle();
262 } 262 }
@@ -356,7 +356,7 @@ static void process_action(keyrecord_t *record)
356 switch (action.layer.code) { 356 switch (action.layer.code) {
357 case 0x00: 357 case 0x00:
358 if (event.pressed) { 358 if (event.pressed) {
359 layer_switch(action.layer.opt); 359 layer_switch(action.layer.val);
360 } 360 }
361//TODO: this is ok? 361//TODO: this is ok?
362 else { 362 else {
@@ -367,19 +367,19 @@ static void process_action(keyrecord_t *record)
367 // tap toggle 367 // tap toggle
368 if (event.pressed) { 368 if (event.pressed) {
369 if (tap_count < TAPPING_TOGGLE) { 369 if (tap_count < TAPPING_TOGGLE) {
370 layer_switch(action.layer.opt); 370 layer_switch(action.layer.val);
371 } 371 }
372 } else { 372 } else {
373 if (tap_count >= TAPPING_TOGGLE) { 373 if (tap_count >= TAPPING_TOGGLE) {
374 debug("LAYER_PRESSED: tap toggle.\n"); 374 debug("LAYER_PRESSED: tap toggle.\n");
375 layer_switch(action.layer.opt); 375 layer_switch(action.layer.val);
376 } 376 }
377 } 377 }
378 break; 378 break;
379 case 0xFF: 379 case 0xFF:
380 // change default layer 380 // change default layer
381 if (event.pressed) { 381 if (event.pressed) {
382 default_layer = action.layer.opt; 382 default_layer = action.layer.val;
383 layer_switch(default_layer); 383 layer_switch(default_layer);
384 } 384 }
385 break; 385 break;
@@ -391,7 +391,7 @@ static void process_action(keyrecord_t *record)
391 register_code(action.layer.code); 391 register_code(action.layer.code);
392 } else { 392 } else {
393 debug("LAYER_PRESSED: No tap: layer_switch\n"); 393 debug("LAYER_PRESSED: No tap: layer_switch\n");
394 layer_switch(action.layer.opt); 394 layer_switch(action.layer.val);
395 } 395 }
396 } else { 396 } else {
397 if (tap_count > 0) { 397 if (tap_count > 0) {
@@ -411,7 +411,7 @@ static void process_action(keyrecord_t *record)
411 switch (action.layer.code) { 411 switch (action.layer.code) {
412 case 0x00: 412 case 0x00:
413 if (!event.pressed) { 413 if (!event.pressed) {
414 layer_switch(action.layer.opt); 414 layer_switch(action.layer.val);
415 } 415 }
416 break; 416 break;
417 case 0xF0: 417 case 0xF0:
@@ -419,18 +419,18 @@ static void process_action(keyrecord_t *record)
419 if (event.pressed) { 419 if (event.pressed) {
420 if (tap_count >= TAPPING_TOGGLE) { 420 if (tap_count >= TAPPING_TOGGLE) {
421 debug("LAYER_RELEASED: tap toggle.\n"); 421 debug("LAYER_RELEASED: tap toggle.\n");
422 layer_switch(action.layer.opt); 422 layer_switch(action.layer.val);
423 } 423 }
424 } else { 424 } else {
425 if (tap_count < TAPPING_TOGGLE) { 425 if (tap_count < TAPPING_TOGGLE) {
426 layer_switch(action.layer.opt); 426 layer_switch(action.layer.val);
427 } 427 }
428 } 428 }
429 break; 429 break;
430 case 0xFF: 430 case 0xFF:
431 // change default layer 431 // change default layer
432 if (!event.pressed) { 432 if (!event.pressed) {
433 default_layer = action.layer.opt; 433 default_layer = action.layer.val;
434 layer_switch(default_layer); 434 layer_switch(default_layer);
435 } 435 }
436 break; 436 break;
@@ -449,7 +449,7 @@ static void process_action(keyrecord_t *record)
449 unregister_code(action.layer.code); 449 unregister_code(action.layer.code);
450 } else { 450 } else {
451 debug("LAYER_RELEASED: No tap: layer_switch\n"); 451 debug("LAYER_RELEASED: No tap: layer_switch\n");
452 layer_switch(action.layer.opt); 452 layer_switch(action.layer.val);
453 } 453 }
454 } 454 }
455 break; 455 break;
@@ -459,9 +459,9 @@ static void process_action(keyrecord_t *record)
459 switch (action.layer.code) { 459 switch (action.layer.code) {
460 case 0x00: 460 case 0x00:
461 if (event.pressed) { 461 if (event.pressed) {
462 layer_switch(current_layer ^ action.layer.opt); 462 layer_switch(current_layer ^ action.layer.val);
463 } else { 463 } else {
464 layer_switch(current_layer ^ action.layer.opt); 464 layer_switch(current_layer ^ action.layer.val);
465 } 465 }
466 break; 466 break;
467 case 0xF0: 467 case 0xF0:
@@ -469,22 +469,22 @@ static void process_action(keyrecord_t *record)
469 if (event.pressed) { 469 if (event.pressed) {
470 if (tap_count < TAPPING_TOGGLE) { 470 if (tap_count < TAPPING_TOGGLE) {
471 debug("LAYER_BIT: tap toggle(press).\n"); 471 debug("LAYER_BIT: tap toggle(press).\n");
472 layer_switch(current_layer ^ action.layer.opt); 472 layer_switch(current_layer ^ action.layer.val);
473 } 473 }
474 } else { 474 } else {
475 if (tap_count <= TAPPING_TOGGLE) { 475 if (tap_count <= TAPPING_TOGGLE) {
476 debug("LAYER_BIT: tap toggle(release).\n"); 476 debug("LAYER_BIT: tap toggle(release).\n");
477 layer_switch(current_layer ^ action.layer.opt); 477 layer_switch(current_layer ^ action.layer.val);
478 } 478 }
479 } 479 }
480 break; 480 break;
481 case 0xFF: 481 case 0xFF:
482 // change default layer 482 // change default layer
483 if (event.pressed) { 483 if (event.pressed) {
484 default_layer = current_layer ^ action.layer.opt; 484 default_layer = current_layer ^ action.layer.val;
485 layer_switch(default_layer); 485 layer_switch(default_layer);
486 } else { 486 } else {
487 default_layer = current_layer ^ action.layer.opt; 487 default_layer = current_layer ^ action.layer.val;
488 layer_switch(default_layer); 488 layer_switch(default_layer);
489 } 489 }
490 break; 490 break;
@@ -496,7 +496,7 @@ static void process_action(keyrecord_t *record)
496 register_code(action.layer.code); 496 register_code(action.layer.code);
497 } else { 497 } else {
498 debug("LAYER_BIT: No tap: layer_switch(bit on)\n"); 498 debug("LAYER_BIT: No tap: layer_switch(bit on)\n");
499 layer_switch(current_layer ^ action.layer.opt); 499 layer_switch(current_layer ^ action.layer.val);
500 } 500 }
501 } else { 501 } else {
502 if (IS_TAPPING_KEY(event.key) && tap_count > 0) { 502 if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
@@ -504,14 +504,14 @@ static void process_action(keyrecord_t *record)
504 unregister_code(action.layer.code); 504 unregister_code(action.layer.code);
505 } else { 505 } else {
506 debug("LAYER_BIT: No tap: layer_switch(bit off)\n"); 506 debug("LAYER_BIT: No tap: layer_switch(bit off)\n");
507 layer_switch(current_layer ^ action.layer.opt); 507 layer_switch(current_layer ^ action.layer.val);
508 } 508 }
509 } 509 }
510 break; 510 break;
511 } 511 }
512 break; 512 break;
513 case ACT_LAYER_EXT: 513 case ACT_LAYER_EXT:
514 switch (action.layer.opt) { 514 switch (action.layer.val) {
515 case 0x00: 515 case 0x00:
516 // set default layer when pressed 516 // set default layer when pressed
517 switch (action.layer.code) { 517 switch (action.layer.code) {
@@ -620,7 +620,7 @@ static void process_action(keyrecord_t *record)
620 break; 620 break;
621 case ACT_FUNCTION: 621 case ACT_FUNCTION:
622 // TODO 622 // TODO
623 action_call_function(event, action.func.id); 623 keymap_call_function(record, action.func.id);
624 break; 624 break;
625 default: 625 default:
626 break; 626 break;
@@ -944,7 +944,7 @@ bool is_tap_key(key_t key)
944 } 944 }
945 return false; 945 return false;
946 case ACT_FUNCTION: 946 case ACT_FUNCTION:
947 if (action.func.opt & 0x1) { 947 if (action.func.opt & O_TAP) {
948 return true; 948 return true;
949 } 949 }
950 return false; 950 return false;