Skip to content

Commit

Permalink
Merge pull request qmk#8 from JcdeA/keyboard-annepro2
Browse files Browse the repository at this point in the history
* Move custom keycodes from keymap files to the keyboard 
* Merge record thing from keymaps to already existing record thing in annepro2.c (already there for bluetooth key stuff)
* Change handler for KC_AP_LED_ON so it changes the keymap before the user sees it
* Add custom keycodes to switch led profiles
* Improve readability in code
  • Loading branch information
Codetector1374 authored Aug 22, 2020
2 parents 41da6b1 + 061045e commit b61973f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 66 deletions.
25 changes: 25 additions & 0 deletions keyboards/annepro2/annepro2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "hal.h"
#include "annepro2.h"
#include "annepro2_ble.h"
#include "qmk_ap2_led.h"

static const SerialConfig ledUartConfig = {
.speed = 115200,
Expand Down Expand Up @@ -52,21 +53,45 @@ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) {
case KC_AP2_BT1:
annepro2_ble_broadcast(0);
return false;

case KC_AP2_BT2:
annepro2_ble_broadcast(1);
return false;

case KC_AP2_BT3:
annepro2_ble_broadcast(2);
return false;

case KC_AP2_BT4:
annepro2_ble_broadcast(3);
return false;

case KC_AP2_USB:
annepro2_ble_disconnect();
return false;

case KC_AP2_BT_UNPAIR:
annepro2_ble_unpair();
return false;

case KC_AP_LED_OFF:
annepro2LedPrevProfile();
annepro2LedDisable();
return false;

case KC_AP_LED_ON:
annepro2LedNextProfile();
annepro2LedEnable();
return false;

case KC_AP_LED_NEXT_PROFILE:
annepro2LedNextProfile();
return false;

case KC_AP_LED_PREV_PROFILE:
annepro2LedPrevProfile();
return false;

default:
break;
}
Expand Down
9 changes: 8 additions & 1 deletion keyboards/annepro2/annepro2.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

#pragma once

#include "annepro2.h"
#include "quantum.h"

#define OVERRIDE __attribute__ ((noinline))
Expand All @@ -32,3 +32,10 @@ enum AP2KeyCodes {
KC_AP2_USB,
AP2_SAFE_RANGE,
};

enum custom_keys {
KC_AP_LED_ON = AP2_SAFE_RANGE,
KC_AP_LED_OFF,
KC_AP_LED_NEXT_PROFILE,
KC_AP_LED_PREV_PROFILE
};
28 changes: 0 additions & 28 deletions keyboards/annepro2/keymaps/codetector/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ enum anne_pro_layers {
_FN_LAYER,
};

enum custom_keys {
KC_AP_LED_ON = AP2_SAFE_RANGE,
KC_AP_LED_OFF,
};

const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_BASE_LAYER] = KEYMAP( /* Base */
KC_GRAVE, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC,
Expand Down Expand Up @@ -58,26 +53,3 @@ void matrix_scan_user(void) {
layer_state_t layer_state_set_user(layer_state_t layer) {
return layer;
}

/*!
* @returns false processing for this keycode has been completed.
*/
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_AP_LED_OFF:
if (record->event.pressed) {
annepro2LedDisable();
annepro2LedPrevProfile();
}
return false;
case KC_AP_LED_ON:
if (record->event.pressed) {
annepro2LedEnable();
annepro2LedNextProfile();
}
return false;
default:
break;
}
return true;
}
38 changes: 1 addition & 37 deletions keyboards/annepro2/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ enum anne_pro_layers {
_FN1_LAYER,
_FN2_LAYER,
};
enum custom_keys {
KC_AP_LED_ON = AP2_SAFE_RANGE,
KC_AP_LED_OFF,
KC_AP_LED_NEXT_PROFILE,
KC_AP_LED_PREV_PROFILE
};

/*
* Layer _BASE_LAYER
* ,-----------------------------------------------------------------------------------------.
Expand Down Expand Up @@ -105,34 +100,3 @@ void matrix_scan_user(void) {
layer_state_t layer_state_set_user(layer_state_t layer) {
return layer;
}

/*!
* @returns false processing for this keycode has been completed.
*/
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_AP_LED_OFF:
if (record->event.pressed) {
annepro2LedDisable();
annepro2LedPrevProfile();
}
return false;
case KC_AP_LED_ON:
if (record->event.pressed) {
annepro2LedEnable();
annepro2LedNextProfile();
}
return false;
case KC_AP_LED_NEXT_PROFILE:
if (record->event.pressed)
annepro2LedNextProfile();
return false;
case KC_AP_LED_PREV_PROFILE:
if (record->event.pressed)
annepro2LedPrevProfile();
return false;
default:
break;
}
return true;
}

0 comments on commit b61973f

Please sign in to comment.