Ejemplo n.º 1
0
void reset_keyboard(void) {
  clear_keyboard();
#if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
  process_midi_all_notes_off();
#endif
#ifdef AUDIO_ENABLE
  #ifndef NO_MUSIC_MODE
    music_all_notes_off();
  #endif
  uint16_t timer_start = timer_read();
  PLAY_SONG(goodbye_song);
  shutdown_user();
  while(timer_elapsed(timer_start) < 250)
    wait_ms(1);
  stop_all_notes();
#else
  shutdown_user();
  wait_ms(250);
#endif
// this is also done later in bootloader.c - not sure if it's neccesary here
#ifdef BOOTLOADER_CATERINA
  *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
#endif
  bootloader_jump();
}
Ejemplo n.º 2
0
void reset_keyboard(void) {
  clear_keyboard();
#ifdef AUDIO_ENABLE
  stop_all_notes();
  shutdown_user();
#endif
  wait_ms(250);
#ifdef CATERINA_BOOTLOADER
  *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
#endif
  bootloader_jump();
}
Ejemplo n.º 3
0
void reset_keyboard(void) {
  clear_keyboard();
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC))
  music_all_notes_off();
  shutdown_user();
#endif
  wait_ms(250);
#ifdef CATERINA_BOOTLOADER
  *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
#endif
  bootloader_jump();
}
Ejemplo n.º 4
0
void reset_keyboard(void) {
  clear_keyboard();
#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_ENABLE_BASIC))
  music_all_notes_off();
  uint16_t timer_start = timer_read();
  PLAY_SONG(goodbye_song);
  shutdown_user();
  while(timer_elapsed(timer_start) < 250) 
    wait_ms(1);
  stop_all_notes();
#else
  wait_ms(250);
#endif
#ifdef CATERINA_BOOTLOADER
  *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
#endif
  bootloader_jump();
}
Ejemplo n.º 5
0
static bool command_common(uint8_t code)
{

#ifdef KEYBOARD_LOCK_ENABLE
    static host_driver_t *host_driver = 0;
#endif

    switch (code) {

#ifdef SLEEP_LED_ENABLE

		// test breathing sleep LED
        case MAGIC_KC(MAGIC_KEY_SLEEP_LED):
            print("Sleep LED Test\n");
            sleep_led_toggle();
            led_set(host_keyboard_leds());
            break;
#endif

#ifdef BOOTMAGIC_ENABLE

		// print stored eeprom config
        case MAGIC_KC(MAGIC_KEY_EEPROM):
            print("eeconfig:\n");
            print_eeconfig();
            break;
#endif

#ifdef KEYBOARD_LOCK_ENABLE

		// lock/unlock keyboard
        case MAGIC_KC(MAGIC_KEY_LOCK):
            if (host_get_driver()) {
                host_driver = host_get_driver();
                clear_keyboard();
                host_set_driver(0);
                print("Locked.\n");
            } else {
                host_set_driver(host_driver);
                print("Unlocked.\n");
            }
            break;
#endif

		// print help
        case MAGIC_KC(MAGIC_KEY_HELP1):
        case MAGIC_KC(MAGIC_KEY_HELP2):
            command_common_help();
            break;

		// activate console
        case MAGIC_KC(MAGIC_KEY_CONSOLE):
            debug_matrix   = false;
            debug_keyboard = false;
            debug_mouse    = false;
            debug_enable   = false;
            command_console_help();
            print("C> ");
            command_state = CONSOLE;
            break;

        // jump to bootloader
        case MAGIC_KC(MAGIC_KEY_BOOTLOADER):
            clear_keyboard(); // clear to prevent stuck keys
            print("\n\nJumping to bootloader... ");
            #ifdef AUDIO_ENABLE
	            stop_all_notes();
                shutdown_user();
            #else
	            wait_ms(1000);
            #endif
            bootloader_jump(); // not return
            break;

        // debug toggle
        case MAGIC_KC(MAGIC_KEY_DEBUG):
            debug_enable = !debug_enable;
            if (debug_enable) {
                print("\ndebug: on\n");
                debug_matrix   = true;
                debug_keyboard = true;
                debug_mouse    = true;
            } else {
                print("\ndebug: off\n");
            }
            break;

        // debug matrix toggle
        case MAGIC_KC(MAGIC_KEY_DEBUG_MATRIX):
            debug_matrix = !debug_matrix;
            if (debug_matrix) {
                print("\nmatrix: on\n");
                debug_enable = true;
            } else {
                print("\nmatrix: off\n");
            }
            break;

        // debug keyboard toggle
        case MAGIC_KC(MAGIC_KEY_DEBUG_KBD):
            debug_keyboard = !debug_keyboard;
            if (debug_keyboard) {
                print("\nkeyboard: on\n");
                debug_enable = true;
            } else {
                print("\nkeyboard: off\n");
            }
            break;

        // debug mouse toggle
        case MAGIC_KC(MAGIC_KEY_DEBUG_MOUSE):
            debug_mouse = !debug_mouse;
            if (debug_mouse) {
                print("\nmouse: on\n");
                debug_enable = true;
            } else {
				print("\nmouse: off\n");
            }
            break;

		// print version
        case MAGIC_KC(MAGIC_KEY_VERSION):
        	print_version();
		    break;

		// print status
		case MAGIC_KC(MAGIC_KEY_STATUS):
			print_status();
            break;

#ifdef NKRO_ENABLE

		// NKRO toggle
        case MAGIC_KC(MAGIC_KEY_NKRO):
            clear_keyboard(); // clear to prevent stuck keys
            keymap_config.nkro = !keymap_config.nkro;
            if (keymap_config.nkro) {
                print("NKRO: on\n");
            } else {
                print("NKRO: off\n");
            }
            break;
#endif

		// switch layers

		case MAGIC_KC(MAGIC_KEY_LAYER0_ALT1):
		case MAGIC_KC(MAGIC_KEY_LAYER0_ALT2):
            switch_default_layer(0);
            break;

#if MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM

		case MAGIC_KC(MAGIC_KEY_LAYER0):
            switch_default_layer(0);
            break;

		case MAGIC_KC(MAGIC_KEY_LAYER1):
            switch_default_layer(1);
            break;

		case MAGIC_KC(MAGIC_KEY_LAYER2):
            switch_default_layer(2);
            break;

		case MAGIC_KC(MAGIC_KEY_LAYER3):
            switch_default_layer(3);
            break;

		case MAGIC_KC(MAGIC_KEY_LAYER4):
            switch_default_layer(4);
            break;

		case MAGIC_KC(MAGIC_KEY_LAYER5):
            switch_default_layer(5);
            break;

		case MAGIC_KC(MAGIC_KEY_LAYER6):
            switch_default_layer(6);
            break;

		case MAGIC_KC(MAGIC_KEY_LAYER7):
            switch_default_layer(7);
            break;

		case MAGIC_KC(MAGIC_KEY_LAYER8):
            switch_default_layer(8);
            break;

		case MAGIC_KC(MAGIC_KEY_LAYER9):
            switch_default_layer(9);
            break;
#endif


#if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS

        case KC_F1 ... KC_F9:
            switch_default_layer((code - KC_F1) + 1);
            break;
        case KC_F10:
            switch_default_layer(0);
            break;
#endif

#if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS

        case KC_1 ... KC_9:
            switch_default_layer((code - KC_1) + 1);
            break;
        case KC_0:
            switch_default_layer(0);
            break;
#endif

        default:
            print("?");
            return false;
    }
    return true;
}
Ejemplo n.º 6
0
bool process_record_quantum(keyrecord_t *record) {

  /* This gets the keycode from the key pressed */
  keypos_t key = record->event.key;
  uint16_t keycode;

  #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
    uint8_t layer;

    if (record->event.pressed) {
      layer = layer_switch_get_layer(key);
      update_source_layers_cache(key, layer);
    } else {
      layer = read_source_layers_cache(key);
    }
    keycode = keymap_key_to_keycode(layer, key);
  #else
    keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key);
  #endif

    // This is how you use actions here
    // if (keycode == KC_LEAD) {
    //   action_t action;
    //   action.code = ACTION_DEFAULT_LAYER_SET(0);
    //   process_action(record, action);
    //   return false;
    // }

  if (!(
    process_record_kb(keycode, record) &&
  #ifdef MIDI_ENABLE
    process_midi(keycode, record) &&
  #endif
  #ifdef AUDIO_ENABLE
    process_music(keycode, record) &&
  #endif
  #ifdef TAP_DANCE_ENABLE
    process_tap_dance(keycode, record) &&
  #endif
  #ifndef DISABLE_LEADER
    process_leader(keycode, record) &&
  #endif
  #ifndef DISABLE_CHORDING
    process_chording(keycode, record) &&
  #endif
  #ifdef UNICODE_ENABLE
    process_unicode(keycode, record) &&
  #endif
      true)) {
    return false;
  }

  // Shift / paren setup

  switch(keycode) {
    case RESET:
      if (record->event.pressed) {
        clear_keyboard();
        #ifdef AUDIO_ENABLE
          stop_all_notes();
          shutdown_user();
        #endif
        wait_ms(250);
        #ifdef CATERINA_BOOTLOADER
            *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
        #endif
        bootloader_jump();
        return false;
      }
      break;
    case DEBUG:
      if (record->event.pressed) {
          print("\nDEBUG: enabled.\n");
          debug_enable = true;
          return false;
      }
      break;
    case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI:
      if (record->event.pressed) {
        // MAGIC actions (BOOTMAGIC without the boot)
        if (!eeconfig_is_enabled()) {
            eeconfig_init();
        }
        /* keymap config */
        keymap_config.raw = eeconfig_read_keymap();
        if (keycode == MAGIC_SWAP_CONTROL_CAPSLOCK) {
            keymap_config.swap_control_capslock = 1;
        } else if (keycode == MAGIC_CAPSLOCK_TO_CONTROL) {
            keymap_config.capslock_to_control = 1;
        } else if (keycode == MAGIC_SWAP_LALT_LGUI) {
            keymap_config.swap_lalt_lgui = 1;
        } else if (keycode == MAGIC_SWAP_RALT_RGUI) {
            keymap_config.swap_ralt_rgui = 1;
        } else if (keycode == MAGIC_NO_GUI) {
            keymap_config.no_gui = 1;
        } else if (keycode == MAGIC_SWAP_GRAVE_ESC) {
            keymap_config.swap_grave_esc = 1;
        } else if (keycode == MAGIC_SWAP_BACKSLASH_BACKSPACE) {
            keymap_config.swap_backslash_backspace = 1;
        } else if (keycode == MAGIC_HOST_NKRO) {
            keymap_config.nkro = 1;
        } else if (keycode == MAGIC_SWAP_ALT_GUI) {
            keymap_config.swap_lalt_lgui = 1;
            keymap_config.swap_ralt_rgui = 1;
        }
        /* UNs */
        else if (keycode == MAGIC_UNSWAP_CONTROL_CAPSLOCK) {
            keymap_config.swap_control_capslock = 0;
        } else if (keycode == MAGIC_UNCAPSLOCK_TO_CONTROL) {
            keymap_config.capslock_to_control = 0;
        } else if (keycode == MAGIC_UNSWAP_LALT_LGUI) {
            keymap_config.swap_lalt_lgui = 0;
        } else if (keycode == MAGIC_UNSWAP_RALT_RGUI) {
            keymap_config.swap_ralt_rgui = 0;
        } else if (keycode == MAGIC_UNNO_GUI) {
            keymap_config.no_gui = 0;
        } else if (keycode == MAGIC_UNSWAP_GRAVE_ESC) {
            keymap_config.swap_grave_esc = 0;
        } else if (keycode == MAGIC_UNSWAP_BACKSLASH_BACKSPACE) {
            keymap_config.swap_backslash_backspace = 0;
        } else if (keycode == MAGIC_UNHOST_NKRO) {
            keymap_config.nkro = 0;
        } else if (keycode == MAGIC_UNSWAP_ALT_GUI) {
            keymap_config.swap_lalt_lgui = 0;
            keymap_config.swap_ralt_rgui = 0;
        }
        eeconfig_update_keymap(keymap_config.raw);
        return false;
      }
      break;
    case KC_LSPO: {
      if (record->event.pressed) {
        shift_interrupted[0] = false;
        register_mods(MOD_BIT(KC_LSFT));
      }
      else {
        if (!shift_interrupted[0]) {
          register_code(LSPO_KEY);
          unregister_code(LSPO_KEY);
        }
        unregister_mods(MOD_BIT(KC_LSFT));
      }
      return false;
      break;
    }

    case KC_RSPC: {
      if (record->event.pressed) {
        shift_interrupted[1] = false;
        register_mods(MOD_BIT(KC_RSFT));
      }
      else {
        if (!shift_interrupted[1]) {
          register_code(RSPC_KEY);
          unregister_code(RSPC_KEY);
        }
        unregister_mods(MOD_BIT(KC_RSFT));
      }
      return false;
      break;
    }
    default: {
      shift_interrupted[0] = true;
      shift_interrupted[1] = true;
      break;
    }
  }

  return process_action_kb(record);
}
Ejemplo n.º 7
0
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    case QWERTY:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
        #endif
        persistant_default_layer_set(1UL<<_QWERTY);
      }
      return false;
      break;
    case COLEMAK:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_NOTE_ARRAY(tone_colemak, false, 0);
        #endif
        persistant_default_layer_set(1UL<<_COLEMAK);
      }
      return false;
      break;
    case DVORAK:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
        #endif
        persistant_default_layer_set(1UL<<_DVORAK);
      }
      return false;
      break;
    case LOWER:
      if (record->event.pressed) {
        layer_on(_LOWER);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      } else {
        layer_off(_LOWER);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      }
      return false;
      break;
    case RAISE:
      if (record->event.pressed) {
        layer_on(_RAISE);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      } else {
        layer_off(_RAISE);
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
      }
      return false;
      break;
    case BACKLIT:
      if (record->event.pressed) {
        register_code(KC_RSFT);
        #ifdef BACKLIGHT_ENABLE
          backlight_step();
        #endif
      } else {
        unregister_code(KC_RSFT);
      }
      return false;
      break;
    case PLOVER:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          stop_all_notes();
          PLAY_NOTE_ARRAY(tone_plover, false, 0);
        #endif
        layer_off(_RAISE);
        layer_off(_LOWER);
        layer_off(_ADJUST);
        layer_on(_PLOVER);
        if (!eeconfig_is_enabled()) {
            eeconfig_init();
        }
        keymap_config.raw = eeconfig_read_keymap();
        keymap_config.nkro = 1;
        eeconfig_update_keymap(keymap_config.raw);
      }
      return false;
      break;
    case EXT_PLV:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_NOTE_ARRAY(tone_plover_gb, false, 0);
        #endif
        layer_off(_PLOVER);
      }
      return false;
      break;
    case DFU:
      if (record->event.pressed) {
        clear_keyboard();
      #if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
        process_midi_all_notes_off();
      #endif
      #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE)
       music_all_notes_off();
        uint16_t timer_start = timer_read();
        PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
        shutdown_user();
      while(timer_elapsed(timer_start) < 250)
        wait_ms(1);
        stop_all_notes();
      #else
        wait_ms(250);
      #endif
      // this is also done later in bootloader.c - not sure if it's neccesary here
      #ifdef BOOTLOADER_CATERINA
        *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
      #endif
        bootloader_jump();
      }
      return false;
      break;      
  }
  return true;
}