예제 #1
0
void led_init(void) {
  // turn off all
  rgbsps_turnoff();

  // set trackpoint color
  rgbsps_set(LED_TRACKPOINT1, THEME_COLOR_TP1);
  rgbsps_set(LED_TRACKPOINT2, THEME_COLOR_TP2);
  rgbsps_set(LED_TRACKPOINT3, THEME_COLOR_TP3);

  // unicode input mode
  led_set_unicode_input_mode();

  // layer indicator
  led_set_layer_indicator();
  led_set_default_layer_indicator();

  // clicky
#ifdef FAUXCLICKY_ENABLE
  if (fauxclicky_enabled) {
    rgbsps_set(LED_IND_AUDIO, THEME_COLOR_AUDIO);
  } else {
    rgbsps_set(LED_IND_AUDIO, COLOR_BLANK);
  }
#endif

  rgbsps_send();
}
예제 #2
0
void led_reset(void) {
  switch (glow_mode) {
    case GLOW_NONE:
      led_turnoff_keys();
      break;
    case GLOW_MIN:
      led_turnoff_keys();
      for(uint8_t i = 0; i < COUNT(LED_HOMING); i++) {
        rgbsps_set(pgm_read_byte(&LED_HOMING[i]), THEME_COLOR_GLOW1_HOME);
      }
      rgbsps_set(LED_F, THEME_COLOR_GLOW1_HOMING);
      rgbsps_set(LED_J, THEME_COLOR_GLOW1_HOMING);
      break;
    case GLOW_FULL:
      for(uint8_t i = 0; i < COUNT(LED_ALNUM); i++) {
        rgbsps_set(pgm_read_byte(&LED_ALNUM[i]), THEME_COLOR_GLOW2_ALPHA);
      }
      for(uint8_t i = 0; i < COUNT(LED_MODS); i++) {
        rgbsps_set(pgm_read_byte(&LED_MODS[i]), THEME_COLOR_GLOW2_MODS);
      }
      for(uint8_t i = 0; i < COUNT(LED_FN); i++) {
        rgbsps_set(pgm_read_byte(&LED_FN[i]), THEME_COLOR_GLOW2_FN);
      }
      for(uint8_t i = 0; i < COUNT(LED_HOMING); i++) {
        rgbsps_set(pgm_read_byte(&LED_HOMING[i]), THEME_COLOR_GLOW2_HOME);
      }
      rgbsps_set(LED_F, THEME_COLOR_GLOW2_HOMING);
      rgbsps_set(LED_J, THEME_COLOR_GLOW2_HOMING);
      break;
  }
}
예제 #3
0
void led_turnoff_keys(void) {
  for(uint8_t i = 0; i < COUNT(LED_ALNUM); i++) {
    rgbsps_set(pgm_read_byte(&LED_ALNUM[i]), COLOR_BLACK);
  }
  for(uint8_t i = 0; i < COUNT(LED_MODS); i++) {
    rgbsps_set(pgm_read_byte(&LED_MODS[i]), COLOR_BLACK);
  }
  for(uint8_t i = 0; i < COUNT(LED_FN); i++) {
    rgbsps_set(pgm_read_byte(&LED_FN[i]), COLOR_BLACK);
  }
}
예제 #4
0
 void led_set_user(uint8_t usb_led) {
   bool new_capslock = usb_led & (1<<USB_LED_CAPS_LOCK);
   if (new_capslock ^ capslock) { // capslock state is different
     if ((capslock = new_capslock)) {
       rgbsps_set(LED_IND_CAPSLOCK, THEME_COLOR_CAPSLOCK);
     } else {
       rgbsps_set(LED_IND_CAPSLOCK, COLOR_BLANK);
     }
     rgbsps_send();
   }
 }
예제 #5
0
void led_set_default_layer_indicator(void) {
  uint8_t default_layer = biton32(default_layer_state);
  if (default_layer == _QWERTY) {
    rgbsps_set(LED_IND_QWERTY, THEME_COLOR_QWERTY);
    rgbsps_set(LED_IND_ALT, COLOR_BLANK);
  } else {
    rgbsps_set(LED_IND_QWERTY, COLOR_BLANK);
    rgbsps_set(LED_IND_ALT, THEME_COLOR_ALT);
  }
  rgbsps_send();
  return;
}
예제 #6
0
void led_set_unicode_input_mode(void) {
  rgbsps_set(LED_IND_LINUX, COLOR_BLANK);
  rgbsps_set(LED_IND_APPLE, COLOR_BLANK);
  rgbsps_set(LED_IND_WINDOWS, COLOR_BLANK);

  switch (get_unicode_input_mode()) {
    case UC_LNX:
      rgbsps_set(LED_IND_LINUX, THEME_COLOR_LINUX);
      break;
    case UC_OSX:
      rgbsps_set(LED_IND_APPLE, THEME_COLOR_APPLE);
      break;
    case UC_WIN:
    case UC_WINC:
      rgbsps_set(LED_IND_WINDOWS, THEME_COLOR_WINDOWS);
      break;
  }
  rgbsps_send();
}
예제 #7
0
void led_set_output_none(void) {
  rgbsps_set(LED_IND_BLUETOOTH, COLOR_BLANK);
  rgbsps_set(LED_IND_USB, COLOR_BLANK);
  rgbsps_send();
}
예제 #8
0
void led_set_output_usb(void) {
  rgbsps_set(LED_IND_BLUETOOTH, COLOR_BLANK);
  rgbsps_set(LED_IND_USB, THEME_COLOR_USB);
  rgbsps_send();
}
예제 #9
0
void led_set_layer_indicator(void) {
  static uint8_t oldlayer = 255;

  led_reset();

  rgbsps_set(LED_IND_GUI, COLOR_BLANK);
  rgbsps_set(LED_IND_FUN, COLOR_BLANK);
  rgbsps_set(LED_IND_NUM, COLOR_BLANK);
  rgbsps_set(LED_IND_PUNC, COLOR_BLANK);
  rgbsps_set(LED_IND_GREEK, COLOR_BLANK);
  rgbsps_set(LED_IND_EMOJI, COLOR_BLANK);

  uint8_t layer = biton32(layer_state);
  if (oldlayer == layer) {
    return;
  }

  oldlayer = layer;

  if (layer <= _DEFAULT_LAYER_MAX) {
    rgbsps_send();
    return;
  }

  switch(layer) {
    case _GUI:
      rgbsps_set(LED_IND_GUI, THEME_COLOR_GUI);
      break;
    case _FUN:
      rgbsps_set(LED_IND_FUN, THEME_COLOR_FUN);
      break;
    case _NUM:
      rgbsps_set(LED_IND_NUM, THEME_COLOR_NUM);
      break;
    case _PUNC:
      rgbsps_set(LED_IND_PUNC, THEME_COLOR_PUNC);
      break;
    case _GREEKL:
    case _GREEKU:
      rgbsps_set(LED_IND_GREEK, THEME_COLOR_GREEK);
      break;
    case _EMOJI:
      rgbsps_set(LED_IND_EMOJI, THEME_COLOR_EMOJI);
      break;
    default:
      rgbsps_set(LED_IND_GUI, THEME_COLOR_OTHERLAYER);
      rgbsps_set(LED_IND_FUN, THEME_COLOR_OTHERLAYER);
      rgbsps_set(LED_IND_NUM, THEME_COLOR_OTHERLAYER);
      rgbsps_set(LED_IND_PUNC, THEME_COLOR_OTHERLAYER);
      rgbsps_set(LED_IND_GREEK, THEME_COLOR_OTHERLAYER);
      rgbsps_set(LED_IND_EMOJI, THEME_COLOR_OTHERLAYER);
  }

  rgbsps_send();
}
예제 #10
0
void led_demo(void) {
  rgbsps_set(LED_IND_LINUX, THEME_COLOR_LINUX);
  rgbsps_set(LED_IND_APPLE, THEME_COLOR_APPLE);
  rgbsps_set(LED_IND_WINDOWS, THEME_COLOR_WINDOWS);
  rgbsps_set(LED_IND_QWERTY, THEME_COLOR_QWERTY);
  rgbsps_set(LED_IND_ALT, THEME_COLOR_ALT);
  rgbsps_set(LED_IND_AUDIO, THEME_COLOR_AUDIO);
  rgbsps_set(LED_IND_BLUETOOTH, THEME_COLOR_BLUETOOTH);
  rgbsps_set(LED_IND_USB, THEME_COLOR_USB);
  rgbsps_set(LED_IND_CAPSLOCK, THEME_COLOR_CAPSLOCK);
  rgbsps_set(LED_IND_GUI, THEME_COLOR_GUI);
  rgbsps_set(LED_IND_FUN, THEME_COLOR_FUN);
  rgbsps_set(LED_IND_NUM, THEME_COLOR_NUM);
  rgbsps_set(LED_IND_PUNC, THEME_COLOR_PUNC);
  rgbsps_set(LED_IND_GREEK, THEME_COLOR_GREEK);
  rgbsps_set(LED_IND_EMOJI, THEME_COLOR_EMOJI);
  rgbsps_send();
}
예제 #11
0
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  static bool lshift = false;
  static bool rshift = false;
  static uint8_t layer = 0;

  lshift = keyboard_report->mods & MOD_BIT(KC_LSFT);
  rshift = keyboard_report->mods & MOD_BIT(KC_RSFT);
  layer = biton32(layer_state);

#ifdef DOUBLESPACE_LAYER_ENABLE
  // double-space: send space immediately if any other key depressed before space is released
  if ((lspace_active ^ rspace_active)
      && keycode != LSPACE
      && keycode != RSPACE
      && record->event.pressed)
  {
    if (lspace_active) {
      if (!lspace_emitted) {
        register_code(KC_SPC);
        unregister_code(KC_SPC);
      }
      lspace_emitted = true;
    }
    if (rspace_active) {
      if (!rspace_emitted) {
        register_code(KC_SPC);
        unregister_code(KC_SPC);
      }
      rspace_emitted = true;
    }
  }

  if (layer == _SPACE && keycode != S(KC_TAB) && keycode != KC_TAB && keycode != KC_ESC && keycode != XXXXXXX) {
    if (record->event.pressed) {
      unregister_code(KC_LALT);
    } else {
      register_code(KC_LALT);
    }
  }
#endif

  switch (keycode) {

#ifdef DOUBLESPACE_LAYER_ENABLE
    // double-space enter space layer
    case LSPACE:
      process_doublespace(record->event.pressed, &lspace_active, &rspace_active, &lspace_emitted);
      return false;
      break;
    case RSPACE:
      process_doublespace(record->event.pressed, &rspace_active, &lspace_active, &rspace_emitted);
      return false;
      break;
#endif

    // handle greek layer shift
    case KC_LSFT:
    case KC_RSFT:
      ;
      if (layer == _GREEKU || layer == _GREEKL) {
        if (record->event.pressed) {
          layer_on(_GREEKU);
          layer_off(_GREEKL);
        } else {
          if (lshift ^ rshift) { // if only one shift was pressed
            layer_on(_GREEKL);
            layer_off(_GREEKU);
          }
        }
      }
      return true;
      break;

    // press both ctrls to activate SYS layer
    case KC_LCTL:
    case KC_RCTL:
      ;
      bool lctrl = keyboard_report->mods & MOD_BIT(KC_LCTL);
      bool rctrl = keyboard_report->mods & MOD_BIT(KC_RCTL);
      if (record->event.pressed) {
        if (lctrl ^ rctrl) { // if only one ctrl was pressed
          layer_on(_SYS);
        }
      } else {
        layer_off(_SYS);
      }
      return true;
      break;

    // QWERTZ style comma and dot: semicolon and colon when shifted
    case KC_COMM:
      if (record->event.pressed) {
        if (lshift || rshift) {
          if (lshift) unregister_code(KC_LSFT);
          if (rshift) unregister_code(KC_RSFT);
          register_code(KC_SCLN);
          unregister_code(KC_SCLN);
          if (lshift) register_code(KC_LSFT);
          if (rshift) register_code(KC_RSFT);
        } else {
          register_code(KC_COMM);
          unregister_code(KC_COMM);
        }
      }
      return false;
      break;
    case KC_DOT:
      if (record->event.pressed) {
        if ((keyboard_report->mods & MOD_BIT(KC_LSFT)) || (keyboard_report->mods & MOD_BIT(KC_RSFT))) {
          register_code(KC_SCLN);
          unregister_code(KC_SCLN);
        } else {
          register_code(KC_DOT);
          unregister_code(KC_DOT);
        }
      }
      return false;
      break;

    // layout switchers
    case QWERTY:
      if (record->event.pressed) {
        persistent_default_layer_set(1UL<<_QWERTY);
      }
      return false;
      break;
#ifdef LAYOUT_DVORAK
    case DVORAK:
      if (record->event.pressed) {
        persistent_default_layer_set(1UL<<_DVORAK);
      }
      return false;
      break;
#endif
#ifdef LAYOUT_COLEMAK
    case COLEMAK:
      if (record->event.pressed) {
        persistent_default_layer_set(1UL<<_COLEMAK);
      }
      return false;
      break;
#endif
#ifdef LAYOUT_WORKMAN
    case WORKMAN:
      if (record->event.pressed) {
        persistent_default_layer_set(1UL<<_WORKMAN);
      }
      return false;
      break;
#endif
#ifdef LAYOUT_NORMAN
    case NORMAN:
      if (record->event.pressed) {
        persistent_default_layer_set(1UL<<_NORMAN);
      }
      return false;
      break;
#endif

    // only process Fnumber on key release, and only when layer switcher is still pressed.
    // this is to avoid accidental presses on potentially destructive keys
    case KC_F1 ... KC_F12:
    case KC_PAUS:
    case KC_PSCR:
    case KC_INS:
      if (!record->event.pressed && layer == _FUN) { // key released and still in FUN layer
          register_code(keycode);
          unregister_code(keycode);
      }
      return false;
      break;

    // layer switcher
    //
    case GREEK:
      if (record->event.pressed) {
        if (lshift || rshift) {
          layer_on(_GREEKU);
          layer_off(_GREEKL);
        } else {
          layer_on(_GREEKL);
          layer_off(_GREEKU);
        }
      } else {
        layer_off(_GREEKU);
        layer_off(_GREEKL);
      }
      return false;
      break;

    // OS switchers
    case LINUX:
      set_unicode_input_mode(UC_LNX);
#ifdef RGBSPS_ENABLE
      led_set_unicode_input_mode();
#endif
      return false;
      break;
    case WIN:
      set_unicode_input_mode(UC_WINC);
#ifdef RGBSPS_ENABLE
      led_set_unicode_input_mode();
#endif
      return false;
      break;
    case OSX:
      set_unicode_input_mode(UC_OSX);
#ifdef RGBSPS_ENABLE
      led_set_unicode_input_mode();
#endif
      return false;
      break;

    // glow mode changer
#ifdef RGBSPS_ENABLE
    case GLOW:
      if (record->event.pressed) {
        glow_mode++;
        if (glow_mode > GLOW_FULL) {
          glow_mode = GLOW_NONE;
        }
        led_reset();
        rgbsps_send();
      }
      return false;
      break;
#endif

    // faux clicky indicator
#ifdef FAUXCLICKY_ENABLE
    case FC_TOG:
#ifdef RGBSPS_ENABLE
      if (fauxclicky_enabled) {
        rgbsps_set(LED_IND_AUDIO, THEME_COLOR_AUDIO);
      } else {
        rgbsps_set(LED_IND_AUDIO, COLOR_BLANK);
      }
      rgbsps_send();
#endif
      return true;
      break;
#endif

#ifdef RGBSPS_DEMO_ENABLE
    case RGBDEMO:
      led_demo();
      return false;
      break;
#endif
  }
  return true;
}
예제 #12
0
void rgbsps_setall(uint8_t r, uint8_t g, uint8_t b) {
  for (uint16_t i = 0; i < RGBSPS_NUM; i++) {
    rgbsps_set(i, r, g, b);
  }
}