qmk

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.z3bra.org/qmk.git
Log | Files | Refs | Submodules | LICENSE

keymap.c (7185B)


      1 /* Copyright 2018 Holten Campbell
      2  *
      3  * This program is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published by
      5  * the Free Software Foundation, either version 2 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  * GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  */
     16 #include QMK_KEYBOARD_H
     17 
     18 // Defines the keycodes used by our macros in process_record_user
     19 enum custom_keycodes {
     20   QMKBEST = SAFE_RANGE,
     21   QMKURL
     22 };
     23 
     24 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     25     [0] = LAYOUT(
     26 		KC_NLCK, 	KC_LPRN, 	KC_RPRN, 	KC_PSLS, 	KC_PAST, 	KC_BSPC, 				KC_ESC, 		KC_Q, 			KC_W, 		KC_E, 			KC_R, 		KC_T,				 		KC_Y, 			KC_U, 			KC_I, 			KC_O, 				KC_P, 			KC_BSPC,
     27 		KC_F1, 		KC_F2, 		KC_P7, 		KC_P8, 		KC_P9, 		KC_DEL,					KC_TAB, 		KC_A, 			KC_S, 			KC_D, 			KC_F, 		KC_G,			 	 		KC_H, 			KC_J, 			KC_K, 			KC_L, 				KC_QUOT, 	KC_ENT,
     28 		KC_F3,		KC_F4,		KC_P4,		KC_P5,		KC_P6,		KC_PMNS,				KC_LSFT, 	KC_Z, 			KC_X, 			KC_C, 			KC_V, 		KC_B,				 		MO(3), 		KC_N, 			KC_M, 		KC_COMM,	KC_DOT, 	KC_SLSH, 	KC_LSFT,
     29 		KC_F5,		KC_F6,		KC_P1,		KC_P2,		KC_P3,		KC_PPLS,				KC_LCTL, 	KC_LALT, 	KC_LBRC, 	KC_RBRC, 			MO(1),									KC_SPC, 					KC_MINS, 	KC_EQL, 			KC_LGUI, 	MO(4),
     30 		KC_F7,		KC_F8,		TO(2),			KC_PDOT,	KC_P0,		KC_PENT
     31     ),
     32 
     33 	[1] = LAYOUT(
     34 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 				KC_GRV, 		KC_1, 				KC_2, 				KC_3, 				KC_4, 				KC_5,				 				KC_TRNS, 	KC_TRNS, 	KC_UP, 			KC_TRNS, 	KC_TRNS, 	KC_DEL,
     35 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS,				KC_CAPS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS,			 	 		KC_TRNS, 	KC_LEFT, 	KC_DOWN, 	KC_RGHT, 	KC_SCLN, 	KC_BSLS,
     36 		KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,				KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS,				 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 		KC_TRNS,	KC_TRNS, 	KC_TRNS, 	KC_TRNS,
     37 		KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,				KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 					KC_TRNS,												KC_TRNS, 			KC_VOLD, 		KC_VOLU, 	KC_MUTE, 	KC_TRNS,
     38 		BL_TOGG,	BL_STEP,		KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS
     39     ),
     40 
     41 		[2] = LAYOUT(
     42 		KC_ESC, 		KC_1, 			KC_2, 			KC_3, 			KC_4, 			KC_F9, 				KC_ESC, 		KC_Q, 			KC_W, 		KC_E, 			KC_R, 		KC_T,				 		KC_Y, 			KC_U, 			KC_I, 			KC_O, 				KC_P, 			KC_BSPC,
     43 		KC_TAB, 		KC_Q, 			KC_W, 		KC_E, 			KC_R, 			KC_T,					KC_TAB, 		KC_A, 			KC_S, 			KC_D, 			KC_F, 		KC_G,			 	 		KC_H, 			KC_J, 			KC_K, 			KC_L, 				KC_QUOT, 	KC_ENT,
     44 		KC_TAB,		KC_A,			KC_S,			KC_D,			KC_F,			KC_G,					KC_LSFT, 	KC_Z, 			KC_X, 			KC_C, 			KC_V, 		KC_B,				 		MO(3), 		KC_N, 			KC_M, 		KC_COMM,	KC_DOT, 	KC_SLSH, 	KC_LSFT,
     45 		KC_LSFT,		KC_Z,			KC_X,			KC_C,			KC_V,			KC_B,					KC_LCTL, 	KC_LALT, 	KC_LBRC, 	KC_RBRC, 			MO(5),									KC_SPC, 					KC_MINS, 	KC_EQL, 		KC_LGUI, 	MO(4),
     46 		KC_LCTL,		KC_LALT,	TO(0),			KC_P,			KC_H,			KC_SPC
     47     ),
     48 
     49 		[3] = LAYOUT(
     50 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 				KC_TRNS, 		KC_1, 				KC_2, 				KC_3, 				KC_4, 				KC_5,				 				KC_6, 			KC_7, 			KC_8, 			KC_9, 			KC_0, 			KC_TRNS,
     51 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS,				KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS,			 	 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS,
     52 		KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,				KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS,				 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS,	KC_TRNS, 	KC_TRNS, 	KC_TRNS,
     53 		KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,				KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 					KC_TRNS,												KC_TRNS, 			KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS,
     54 		KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS
     55     ),
     56 
     57 		[4] = LAYOUT(
     58 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 				KC_F1, 			KC_F2, 			KC_F3, 			KC_F4, 			KC_F5, 			KC_F6,				 			KC_F7, 		KC_F8, 		KC_F9, 		KC_F10, 		KC_F11, 		KC_F12,
     59 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS,				KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS,			 	 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS,
     60 		KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,				KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS,				 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS,	KC_TRNS, 	KC_TRNS, 	KC_TRNS,
     61 		KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,				KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 					KC_TRNS,												KC_TRNS, 			KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS,
     62 		KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS
     63     ),
     64 
     65 		[5] = LAYOUT(
     66 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 				KC_GRV, 		KC_1, 				KC_2, 				KC_3, 				KC_4, 				KC_5,				 				KC_TRNS, 	KC_TRNS, 	KC_UP, 			KC_TRNS, 	KC_TRNS, 	KC_DEL,
     67 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS, 	KC_TRNS,				KC_CAPS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS,			 	 		KC_TRNS, 	KC_LEFT, 	KC_DOWN, 	KC_RGHT, 	KC_SCLN, 	KC_BSLS,
     68 		KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,				KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS,				 		KC_TRNS, 	KC_TRNS, 	KC_TRNS, 		KC_TRNS,	KC_TRNS, 	KC_TRNS, 	KC_TRNS,
     69 		KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS,				KC_TRNS, 		KC_TRNS, 		KC_TRNS, 		KC_TRNS, 					KC_TRNS,												KC_TRNS, 			KC_VOLD, 		KC_VOLU, 	KC_MUTE, 	KC_TRNS,
     70 		BL_TOGG,	BL_STEP,		KC_TRNS,	KC_TRNS,	KC_TRNS,	KC_TRNS
     71     ),
     72 
     73 };
     74 
     75 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
     76   switch (keycode) {
     77     case QMKBEST:
     78       if (record->event.pressed) {
     79         // when keycode QMKBEST is pressed
     80         SEND_STRING("QMK is the best thing ever!");
     81       } else {
     82         // when keycode QMKBEST is released
     83       }
     84       break;
     85     case QMKURL:
     86       if (record->event.pressed) {
     87         // when keycode QMKURL is pressed
     88         SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER));
     89       } else {
     90         // when keycode QMKURL is released
     91       }
     92       break;
     93   }
     94   return true;
     95 }
     96 
     97 void matrix_init_user(void) {
     98   // set CapsLock LED to output and low
     99   setPinOutput(C6);
    100   writePinHigh(C6);
    101   // set NumLock LED to output and low
    102   setPinOutput(B6);
    103   writePinHigh(B6);
    104   // set ScrollLock LED to output and low
    105   setPinOutput(B5);
    106   writePinHigh(B5);
    107 }
    108 
    109 void matrix_scan_user(void) {
    110 
    111 }
    112 
    113 
    114 void led_set_user(uint8_t usb_led) {
    115   if (IS_LED_ON(usb_led, USB_LED_NUM_LOCK)) {
    116     writePinHigh(B6);
    117   } else {
    118     writePinLow(B6);
    119   }
    120   if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) {
    121     writePinHigh(B5);
    122   } else {
    123     writePinLow(B5);
    124   }
    125   /*
    126   if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) {
    127     writePinHigh(C6);
    128   } else {
    129     writePinLow(C6);
    130   }
    131   */
    132 }
    133 
    134 //function for layer indicator LED
    135 uint32_t layer_state_set_user(uint32_t state)
    136 {
    137     if (biton32(state) == 2) {
    138     writePinHigh(C6);
    139 	} else {
    140 		writePinLow(C6);
    141     }
    142     return state;
    143 }