Pouknouki

Keyboard test

Jan 6th, 2017
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.42 KB | None | 0 0
  1. // GLS = 1, bound to the L Shift key (used on my keymap to do ACTION_MACRO(GLS) instead of ACTION_MACRO(1) which is not really understandable
  2. // GLG = 2, bound to the Greek key
  3. bool greekPressed = false;
  4. bool shiftPressed = false;
  5.  
  6. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  7. {
  8.   // MACRODOWN only works in this function
  9.       switch(id) {
  10.         case GLS: // Left Shift was pressed (or released)
  11.           shiftPressed = !shiftPressed;
  12.           // Send the signal to the computer
  13.           if (record->event.pressed)
  14.             register_code(KC_LSFT);
  15.           else
  16.             unregister_code(KC_LSFT);
  17.           // Refresh Greek mode state
  18.           enableDisableGreek();
  19.           break;
  20.         case GLG: // Greek key was pressed (or released)
  21.           greekPressed = !greekPressed;
  22.           enableDisableGreek();            
  23.       }
  24.     return MACRO_NONE;
  25. };
  26.  
  27. void enableDisableGreek()
  28. {
  29.   if (!shiftPressed && !greekPressed)
  30.   {
  31.     ACTION_LAYER_OFF(L_CAPITALGREEK);
  32.     ACTION_LAYER_OFF(L_GREEK);
  33.   }
  34.   else if (!shiftPressed && greekPressed)
  35.   {
  36.     ACTION_LAYER_OFF(L_CAPITALGREEK);
  37.     ACTION_LAYER_ON (L_GREEK);
  38.   }
  39.   else if (shiftPressed && !greekPressed)
  40.   {
  41.     ACTION_LAYER_OFF(L_CAPITALGREEK);
  42.     ACTION_LAYER_OFF(L_GREEK);
  43.   }
  44.   else if (shiftPressed && greekPressed)
  45.   {
  46.     ACTION_LAYER_ON (L_CAPITALGREEK);
  47.     ACTION_LAYER_OFF(L_GREEK);
  48.   }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment