Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
IJKL nav and fnlock LED
This adds IJKL arrow keys when folding the fn key, and changes the caps lock LED to a fn lock LED when the fn key is held
  • Loading branch information
pantsman0 committed Mar 28, 2023
commit ce57bb12660d04bf7db2112d8f7fc8fb6ad3afcb
60 changes: 49 additions & 11 deletions board/hx30/keyboard_customization.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
{0x006a, 0x000a, 0xe074, 0xe054, 0x0000, 0x006b, 0x0073, 0x0074},
};

#ifdef CONFIG_KEYBOARD_CUSTOMIZATION_COMBINATION_KEY
#define FN_PRESSED BIT(0)
#define FN_LOCKED BIT(1)
static uint8_t Fn_key;
static uint32_t fn_key_table_media;
static uint32_t fn_key_table;
#endif


uint16_t get_scancode_set2(uint8_t row, uint8_t col)
{
Expand Down Expand Up @@ -141,13 +149,27 @@ int caps_status_check(void)

void hx20_8042_led_control(int data)
{
if (data & CAPS_LED) {
caps_led_status = 1;
gpio_set_level(GPIO_CAP_LED_L, 1);
#ifdef CONFIG_KEYBOARD_CUSTOMIZATION_COMBINATION_KEY
if (Fn_key & FN_PRESSED) {
if (Fn_key & FN_LOCKED) {
caps_led_status = 1;
gpio_set_level(GPIO_CAP_LED_L, 1);
} else {
caps_led_status = 0;
gpio_set_level(GPIO_CAP_LED_L, 0);
}
} else {
caps_led_status = 0;
gpio_set_level(GPIO_CAP_LED_L, 0);
#endif
if (data & CAPS_LED) {
caps_led_status = 1;
gpio_set_level(GPIO_CAP_LED_L, 1);
} else {
caps_led_status = 0;
gpio_set_level(GPIO_CAP_LED_L, 0);
}
#ifdef CONFIG_KEYBOARD_CUSTOMIZATION_COMBINATION_KEY
}
#endif
}

void caps_suspend(void)
Expand Down Expand Up @@ -217,11 +239,7 @@ void board_kblight_init(void)
#endif

#ifdef CONFIG_KEYBOARD_CUSTOMIZATION_COMBINATION_KEY
#define FN_PRESSED BIT(0)
#define FN_LOCKED BIT(1)
static uint8_t Fn_key;
static uint32_t fn_key_table_media;
static uint32_t fn_key_table;


int fn_table_media_set(int8_t pressed, uint32_t fn_bit)
{
Expand Down Expand Up @@ -372,14 +390,34 @@ int hotkey_special_key(uint16_t *key_code, int8_t pressed)
const uint16_t prss_key = *key_code;

switch (prss_key) {
// CUSTOM PWOOLFORD
case SCANCODE_I:
if (fn_table_set(pressed, KB_FN_I))
*key_code = SCANCODE_UP;
break;
case SCANCODE_J:
if (fn_table_set(pressed, KB_FN_J))
*key_code = SCANCODE_LEFT;
break;
case SCANCODE_K:
if (fn_table_set(pressed, KB_FN_K))
*key_code = SCANCODE_DOWN;
break;
case SCANCODE_L:
if (fn_table_set(pressed, KB_FN_L))
*key_code = SCANCODE_RIGHT;
break;
// END CUSTOM PWOOLFORD
case SCANCODE_DELETE: /* TODO: INSERT */
if (fn_table_set(pressed, KB_FN_DELETE))
*key_code = 0xe070;
break;
case SCANCODE_K: /* TODO: SCROLL_LOCK */
/* replaced by IJKL navigation
case SCANCODE_K: // TODO: SCROLL_LOCK
if (fn_table_set(pressed, KB_FN_K))
*key_code = SCANCODE_SCROLL_LOCK;
break;
*/
case SCANCODE_S: /* TODO: SYSRQ */
/*if (!fn_table_set(pressed, KB_FN_S))*/

Expand Down
5 changes: 5 additions & 0 deletions board/hx30/keyboard_customization.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ enum kb_fn_table {
KB_FN_B = BIT(20),
KB_FN_P = BIT(21),
KB_FN_SPACE = BIT(22),

// CUSTOM PWOOLFORD
KB_FN_I = BIT(23),
KB_FN_J = BIT(24),
KB_FN_L = BIT(25)
};

#ifdef CONFIG_KEYBOARD_BACKLIGHT
Expand Down
3 changes: 3 additions & 0 deletions include/keyboard_8042_sharedlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ enum scancode_values {
SCANCODE_FN = 0x00ff,
SCANCODE_ESC = 0x0076,
SCANCODE_DELETE = 0xe071,
SCANCODE_I = 0x0043,
SCANCODE_J = 0x003B,
SCANCODE_K = 0x0042,
SCANCODE_L = 0x004B,
SCANCODE_P = 0x004D,
SCANCODE_S = 0x001B,
SCANCODE_SPACE= 0x0029,
Expand Down