Changed to new clang format
This commit is contained in:
parent
a21aea6f22
commit
f281d32774
@ -1 +1 @@
|
|||||||
Subproject commit 6a2b179d8f624d69b41a5d30df7b46080a1deec6
|
Subproject commit 88cb7c10ca12ea33fb96aa10ae97a14d087da852
|
||||||
@ -45,8 +45,7 @@ const char keyboard_matrix_id[KEYBOARD_MATRIX_ROWS][KEYBOARD_MATRIX_COLS] = {
|
|||||||
Keypad keyboard_matrix =
|
Keypad keyboard_matrix =
|
||||||
Keypad(makeKeymap(keyboard_matrix_id), keyboard_martix_row_pins, keyboard_matrix_col_pins, KEYBOARD_MATRIX_ROWS, KEYBOARD_MATRIX_COLS);
|
Keypad(makeKeymap(keyboard_matrix_id), keyboard_martix_row_pins, keyboard_matrix_col_pins, KEYBOARD_MATRIX_ROWS, KEYBOARD_MATRIX_COLS);
|
||||||
|
|
||||||
struct Button
|
struct Button {
|
||||||
{
|
|
||||||
uint16_t keycode = NO_KEY;
|
uint16_t keycode = NO_KEY;
|
||||||
uint16_t fn1_keycode = NO_KEY;
|
uint16_t fn1_keycode = NO_KEY;
|
||||||
uint16_t fn2_keycode = NO_KEY;
|
uint16_t fn2_keycode = NO_KEY;
|
||||||
@ -135,66 +134,51 @@ Button buttons[NBR_OF_BUTTONS] =
|
|||||||
/* End of keymap config ------------------------------------------------------------------ */
|
/* End of keymap config ------------------------------------------------------------------ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
set_key.
|
* @breif set_key.
|
||||||
|
*
|
||||||
@param keycode code to apply action.
|
* @param keycode code to apply action.
|
||||||
@param kstate PRESSED or RELEASED.
|
* @param kstate PRESSED or RELEASED.
|
||||||
*/
|
*/
|
||||||
void set_key(uint16_t keycode, uint8_t kstate)
|
void set_key(uint16_t keycode, uint8_t kstate) {
|
||||||
{
|
|
||||||
if (keycode == NO_KEY || keycode == KEY_FN) return;
|
if (keycode == NO_KEY || keycode == KEY_FN) return;
|
||||||
|
|
||||||
if (keycode == KEY_GUI_LATCH)
|
if (keycode == KEY_GUI_LATCH) {
|
||||||
{
|
|
||||||
win_latched = true;
|
win_latched = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kstate == RELEASED)
|
if (kstate == RELEASED) {
|
||||||
{
|
if (win_latched == true) {
|
||||||
if (win_latched == true)
|
|
||||||
{
|
|
||||||
Keyboard.release(keycode);
|
Keyboard.release(keycode);
|
||||||
Keyboard.release(KEY_LEFT_GUI);
|
Keyboard.release(KEY_LEFT_GUI);
|
||||||
win_latched = false;
|
win_latched = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Keyboard.release(keycode);
|
Keyboard.release(keycode);
|
||||||
}
|
}
|
||||||
}
|
} else if (kstate == PRESSED) {
|
||||||
else if (kstate == PRESSED)
|
if (win_latched == true) {
|
||||||
{
|
|
||||||
if (win_latched == true)
|
|
||||||
{
|
|
||||||
Keyboard.press(KEY_LEFT_GUI);
|
Keyboard.press(KEY_LEFT_GUI);
|
||||||
Keyboard.press(keycode);
|
Keyboard.press(keycode);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Keyboard.press(keycode);
|
Keyboard.press(keycode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* process_keypad
|
* @breif process_keys in keyboard matrix.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
void process_keys()
|
void process_keys() {
|
||||||
{
|
|
||||||
/* Scan keypad, exit if not ready */
|
/* Scan keypad, exit if not ready */
|
||||||
if (keyboard_matrix.getKeys() == false) return;
|
if (keyboard_matrix.getKeys() == false) return;
|
||||||
|
|
||||||
int fn_mode = 0;
|
int fn_mode = 0;
|
||||||
int corner_pressed = 0;
|
int corner_pressed = 0;
|
||||||
|
|
||||||
for (int i = 0; i < MAX_SIMULTANIOUS_KEYS; i++)
|
for (int i = 0; i < MAX_SIMULTANIOUS_KEYS; i++) {
|
||||||
{
|
|
||||||
/* Update button table if key pressed/releaseed */
|
/* Update button table if key pressed/releaseed */
|
||||||
if ((keyboard_matrix.key[i].kstate == PRESSED || keyboard_matrix.key[i].kstate == RELEASED) &&
|
if ((keyboard_matrix.key[i].kstate == PRESSED || keyboard_matrix.key[i].kstate == RELEASED) &&
|
||||||
(keyboard_matrix.key[i].stateChanged == true))
|
(keyboard_matrix.key[i].stateChanged == true)) {
|
||||||
{
|
|
||||||
buttons[keyboard_matrix.key[i].kchar - 1].run_keycode = true;
|
buttons[keyboard_matrix.key[i].kchar - 1].run_keycode = true;
|
||||||
buttons[keyboard_matrix.key[i].kchar - 1].kstate = keyboard_matrix.key[i].kstate;
|
buttons[keyboard_matrix.key[i].kchar - 1].kstate = keyboard_matrix.key[i].kstate;
|
||||||
}
|
}
|
||||||
@ -212,8 +196,7 @@ void process_keys()
|
|||||||
if (buttons[keyboard_matrix.key[i].kchar - 1].keycode == KEY_FN) fn_mode++;
|
if (buttons[keyboard_matrix.key[i].kchar - 1].keycode == KEY_FN) fn_mode++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (corner_pressed == 4)
|
if (corner_pressed == 4) {
|
||||||
{
|
|
||||||
Keyboard.releaseAll();
|
Keyboard.releaseAll();
|
||||||
status_led.on();
|
status_led.on();
|
||||||
status_led.update();
|
status_led.update();
|
||||||
@ -221,73 +204,56 @@ void process_keys()
|
|||||||
_reboot_Teensyduino_();
|
_reboot_Teensyduino_();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < NBR_OF_BUTTONS; i++)
|
for (int i = 0; i < NBR_OF_BUTTONS; i++) {
|
||||||
{
|
|
||||||
/* Check if key is ready to be set. Else skip to next button */
|
/* Check if key is ready to be set. Else skip to next button */
|
||||||
if (buttons[i].run_keycode == false) continue;
|
if (buttons[i].run_keycode == false) continue;
|
||||||
buttons[i].run_keycode = false;
|
buttons[i].run_keycode = false;
|
||||||
|
|
||||||
if (buttons[i].kstate == RELEASED)
|
if (buttons[i].kstate == RELEASED) {
|
||||||
{
|
|
||||||
set_key(buttons[i].last_keycode, RELEASED);
|
set_key(buttons[i].last_keycode, RELEASED);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fn_mode == 0)
|
if (fn_mode == 0) {
|
||||||
{
|
|
||||||
set_key(buttons[i].keycode, PRESSED);
|
set_key(buttons[i].keycode, PRESSED);
|
||||||
buttons[i].last_keycode = buttons[i].keycode;
|
buttons[i].last_keycode = buttons[i].keycode;
|
||||||
}
|
} else if (fn_mode == 1) {
|
||||||
else if (fn_mode == 1)
|
|
||||||
{
|
|
||||||
set_key(buttons[i].fn1_keycode, PRESSED);
|
set_key(buttons[i].fn1_keycode, PRESSED);
|
||||||
buttons[i].last_keycode = buttons[i].fn1_keycode;
|
buttons[i].last_keycode = buttons[i].fn1_keycode;
|
||||||
}
|
} else if (fn_mode == 2) {
|
||||||
else if (fn_mode == 2)
|
|
||||||
{
|
|
||||||
set_key(buttons[i].fn2_keycode, PRESSED);
|
set_key(buttons[i].fn2_keycode, PRESSED);
|
||||||
buttons[i].last_keycode = buttons[i].fn2_keycode;
|
buttons[i].last_keycode = buttons[i].fn2_keycode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
/* Init HW */
|
/* Init HW */
|
||||||
status_led.begin();
|
status_led.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop() {
|
||||||
{
|
|
||||||
/* Update current time (ms) */
|
/* Update current time (ms) */
|
||||||
current_timestamp = millis();
|
current_timestamp = millis();
|
||||||
|
|
||||||
/* Scan buttons 1ms */
|
/* Scan buttons 1ms */
|
||||||
if (current_timestamp >= button_timestamp)
|
if (current_timestamp >= button_timestamp) {
|
||||||
{
|
|
||||||
process_keys();
|
process_keys();
|
||||||
button_timestamp = current_timestamp + 1;
|
button_timestamp = current_timestamp + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update indicator 200ms */
|
/* Update indicator 200ms */
|
||||||
if (current_timestamp >= indicator_timestamp)
|
if (current_timestamp >= indicator_timestamp) {
|
||||||
{
|
|
||||||
/* Set status indication */
|
/* Set status indication */
|
||||||
if (keyboard_leds & (1 << USB_LED_CAPS_LOCK))
|
if (keyboard_leds & (1 << USB_LED_CAPS_LOCK)) {
|
||||||
{
|
|
||||||
status_led.blink();
|
status_led.blink();
|
||||||
}
|
} else if (win_latched) {
|
||||||
else if (win_latched)
|
|
||||||
{
|
|
||||||
status_led.on();
|
status_led.on();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status_led.off();
|
status_led.off();
|
||||||
}
|
}
|
||||||
|
|
||||||
status_led.update();
|
status_led.update();
|
||||||
|
|
||||||
indicator_timestamp = current_timestamp + 200;
|
indicator_timestamp = current_timestamp + 200;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user