From 4f8e37c4fc9a5440d89c2fa67b589f2a9cb2600c Mon Sep 17 00:00:00 2001 From: Vaarai Date: Wed, 16 Oct 2024 00:54:57 +0200 Subject: [PATCH] [Cornia/config] Remove unnecessary defines & move all callbacks to keymap.c --- keyboards/cornia/keymaps/fire/callback_oled.c | 53 ------- .../keymaps/fire/callback_pointing_device.c | 51 ------- .../cornia/keymaps/fire/callback_record.c | 75 ---------- .../cornia/keymaps/fire/callback_system.c | 31 ---- keyboards/cornia/keymaps/fire/keymap.c | 134 +++++++++++++++++- keyboards/cornia/keymaps/fire/keymap.h | 4 + keyboards/cornia/keymaps/fire/rules.mk | 6 - 7 files changed, 136 insertions(+), 218 deletions(-) delete mode 100644 keyboards/cornia/keymaps/fire/callback_oled.c delete mode 100644 keyboards/cornia/keymaps/fire/callback_pointing_device.c delete mode 100644 keyboards/cornia/keymaps/fire/callback_record.c delete mode 100644 keyboards/cornia/keymaps/fire/callback_system.c diff --git a/keyboards/cornia/keymaps/fire/callback_oled.c b/keyboards/cornia/keymaps/fire/callback_oled.c deleted file mode 100644 index 2c3422477b37..000000000000 --- a/keyboards/cornia/keymaps/fire/callback_oled.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright 2024 Vaarai - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include QMK_KEYBOARD_H - -#include "./keymap.h" -#include "./cornia.h" - -oled_rotation_t oled_init_user(oled_rotation_t rotation) { - return OLED_ROTATION_270; -} - -bool oled_task_user(void) { - /* Print cornia logo */ - cornia_render_logo(); - - /* Print layer status */ - oled_set_cursor(0, 7); - switch (get_highest_layer(layer_state)) { - case _ALPHA: - oled_write_ln("ALPHA", 0); - break; - case _NAV: - oled_write_ln("NAV", 0); - break; - case _NUM: - oled_write_ln("NUM", 0); - break; - case _ADJUST: - oled_write_ln("ADJUS", 0); - break; - case _G0: - oled_write_ln("GAME0", 0); - break; - case _G1: - oled_write_ln("GAME1", 0); - break; - } - return false; -} diff --git a/keyboards/cornia/keymaps/fire/callback_pointing_device.c b/keyboards/cornia/keymaps/fire/callback_pointing_device.c deleted file mode 100644 index 5aa7392925af..000000000000 --- a/keyboards/cornia/keymaps/fire/callback_pointing_device.c +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2024 Vaarai - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include QMK_KEYBOARD_H - -#include "./keymap.h" - -/* Trackpad srolling speed adjustment */ -#define SCROLL_DIVISOR_H 8.0 -#define SCROLL_DIVISOR_V 8.0 - -bool set_scrolling = false; - -/* Variables to store accumulated scroll values */ -float scroll_accumulated_h = 0; -float scroll_accumulated_v = 0; - -report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) { - /* Check if drag scrolling is active */ - if (set_scrolling) { - /* Calculate and accumulate scroll values based on mouse movement and divisors */ - scroll_accumulated_h += (float)mouse_report.x / SCROLL_DIVISOR_H; - scroll_accumulated_v += (float)mouse_report.y / SCROLL_DIVISOR_V; - - /* Assign integer parts of accumulated scroll values to the mouse report */ - mouse_report.h = (int8_t)scroll_accumulated_h; - mouse_report.v = (int8_t)scroll_accumulated_v; - - /* Update accumulated scroll values by subtracting the integer parts */ - scroll_accumulated_h -= (int8_t)scroll_accumulated_h; - scroll_accumulated_v -= (int8_t)scroll_accumulated_v; - - /* Clear the X and Y values of the mouse report */ - mouse_report.x = 0; - mouse_report.y = 0; - } - return mouse_report; -} diff --git a/keyboards/cornia/keymaps/fire/callback_record.c b/keyboards/cornia/keymaps/fire/callback_record.c deleted file mode 100644 index 6b9ea45da6e5..000000000000 --- a/keyboards/cornia/keymaps/fire/callback_record.c +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright 2024 Vaarai - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include QMK_KEYBOARD_H - -#include "./keymap.h" -#include "./tap_dances.h" - -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case CK_RKJMP: /* Warframe rocket jump */ - if (record->event.pressed) { - SEND_STRING(SS_DOWN(X_C)); - } else { - SEND_STRING(SS_DOWN(X_SPC) SS_DELAY(50) SS_UP(X_C) SS_DELAY(50) SS_UP(X_SPC)); - } - return false; - case CK_DPII: /* Increase trackpad DPI */ - if (record->event.pressed) { - pointing_device_set_cpi(pointing_device_get_cpi()+100); - } - return false; - case CK_DPID: /* Decrease trackpad DPI */ - if (record->event.pressed) { - pointing_device_set_cpi(pointing_device_get_cpi()-100); - } - return false; - case CK_SCRL: /* Toggle set_scrolling when CK_SCRL key is pressed or released */ - set_scrolling = record->event.pressed; - return false; - } - /* Accented letters */ - if (accent_state != ACCENT_NONE && record->event.pressed) - { - switch (keycode) { - case KC_A: - SEND_STRING(SS_ACCENT_A_GRAVE); - return false; - case KC_C: - SEND_STRING(SS_ACCENT_C_CEDIL); - return false; - case KC_E: - switch (accent_state) { - case ACCENT_LEFT: - SEND_STRING(SS_ACCENT_E_ACUTE); break; - case ACCENT_RIGHT: - SEND_STRING(SS_ACCENT_E_GRAVE); break; - case ACCENT_NONE: - break; - } - return false; - case KC_O: - SEND_STRING(SS_ACCENT_O_CIRCU); - return false; - case KC_U: - SEND_STRING(SS_ACCENT_U_GRAVE); - return false; - } - accent_state = ACCENT_NONE; - } - return true; -} diff --git a/keyboards/cornia/keymaps/fire/callback_system.c b/keyboards/cornia/keymaps/fire/callback_system.c deleted file mode 100644 index 16f1980856f5..000000000000 --- a/keyboards/cornia/keymaps/fire/callback_system.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2024 Vaarai - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include QMK_KEYBOARD_H - -#include "./keymap.h" - -bool shutdown_user(bool jump_to_bootloader) { - oled_clear(); - oled_set_cursor(0, 2); - if (jump_to_bootloader) { - oled_write_P(PSTR("FLASH"), false); - } else { - oled_write_P(PSTR("RESET"), false); - } - oled_render_dirty(true); - return false; -} diff --git a/keyboards/cornia/keymaps/fire/keymap.c b/keyboards/cornia/keymaps/fire/keymap.c index 76d912682ee5..da7c58a47ad5 100644 --- a/keyboards/cornia/keymaps/fire/keymap.c +++ b/keyboards/cornia/keymaps/fire/keymap.c @@ -19,6 +19,13 @@ #include "./keymap.h" #include "./tap_dances.h" +/* Flag to enable/disable trackpad scroll */ +bool set_scrolling = false; + +/* Variables to store accumulated scroll values */ +float scroll_accumulated_h = 0; +float scroll_accumulated_v = 0; + const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_ALPHA] = LAYOUT_split_3x6_3( /* Fire (Oxey) : https://bit.ly/layout-doc-v2 */ //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| @@ -88,9 +95,132 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| KC_F, KC_LSFT, KC_A, KC_S, KC_D, KC_3, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| - KC_LGUI, KC_LCTL, KC_Z, KC_C, KC_X, KC_4, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, + KC_LGUI, KC_LCTL, KC_M, KC_Y, KC_X, KC_4, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| KC_SPC,CK_RKJMP, KC_5, XXXXXXX, TG(_G1), XXXXXXX //`--------------------------' `--------------------------' ), -}; \ No newline at end of file +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case CK_RKJMP: /* Warframe rocket jump */ + if (record->event.pressed) { + SEND_STRING(SS_DOWN(X_C)); + } else { + SEND_STRING(SS_DOWN(X_SPC) SS_DELAY(50) SS_UP(X_C) SS_DELAY(50) SS_UP(X_SPC)); + } + return false; + case CK_DPII: /* Increase trackpad DPI */ + if (record->event.pressed) { + pointing_device_set_cpi(pointing_device_get_cpi()+100); + } + return false; + case CK_DPID: /* Decrease trackpad DPI */ + if (record->event.pressed) { + pointing_device_set_cpi(pointing_device_get_cpi()-100); + } + return false; + case CK_SCRL: /* Toggle set_scrolling when CK_SCRL key is pressed or released */ + set_scrolling = record->event.pressed; + return false; + } + /* Accented letters */ + if (accent_state != ACCENT_NONE && record->event.pressed) + { + switch (keycode) { + case KC_A: + SEND_STRING(SS_ACCENT_A_GRAVE); + break; + case KC_C: + SEND_STRING(SS_ACCENT_C_CEDIL); + break; + case KC_E: + switch (accent_state) { + case ACCENT_LEFT: + SEND_STRING(SS_ACCENT_E_ACUTE); break; + case ACCENT_RIGHT: + SEND_STRING(SS_ACCENT_E_GRAVE); break; + case ACCENT_NONE: + break; + } + break; + case KC_O: + SEND_STRING(SS_ACCENT_O_CIRCU); + break; + case KC_U: + SEND_STRING(SS_ACCENT_U_GRAVE); + break; + } + accent_state = ACCENT_NONE; + return false; + } + return true; +} + +bool shutdown_user(bool jump_to_bootloader) { + oled_clear(); + oled_set_cursor(0, 2); + if (jump_to_bootloader) { + oled_write_P(PSTR("FLASH"), false); + } else { + oled_write_P(PSTR("RESET"), false); + } + oled_render_dirty(true); + return false; +} + +oled_rotation_t oled_init_user(oled_rotation_t rotation) { + return OLED_ROTATION_270; +} + +bool oled_task_user(void) { + /* Print cornia logo */ + cornia_render_logo(); + + /* Print layer status */ + oled_set_cursor(0, 7); + switch (get_highest_layer(layer_state)) { + case _ALPHA: + oled_write_ln("ALPHA", 0); + break; + case _NAV: + oled_write_ln("NAV", 0); + break; + case _NUM: + oled_write_ln("NUM", 0); + break; + case _ADJUST: + oled_write_ln("ADJUS", 0); + break; + case _G0: + oled_write_ln("GAME0", 0); + break; + case _G1: + oled_write_ln("GAME1", 0); + break; + } + return false; +} + +report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) { + /* Check if drag scrolling is active */ + if (set_scrolling) { + /* Calculate and accumulate scroll values based on mouse movement and divisors */ + scroll_accumulated_h += (float)mouse_report.x / SCROLL_DIVISOR_H; + scroll_accumulated_v += (float)mouse_report.y / SCROLL_DIVISOR_V; + + /* Assign integer parts of accumulated scroll values to the mouse report */ + mouse_report.h = (int8_t)scroll_accumulated_h; + mouse_report.v = (int8_t)scroll_accumulated_v; + + /* Update accumulated scroll values by subtracting the integer parts */ + scroll_accumulated_h -= (int8_t)scroll_accumulated_h; + scroll_accumulated_v -= (int8_t)scroll_accumulated_v; + + /* Clear the X and Y values of the mouse report */ + mouse_report.x = 0; + mouse_report.y = 0; + } + return mouse_report; +} \ No newline at end of file diff --git a/keyboards/cornia/keymaps/fire/keymap.h b/keyboards/cornia/keymaps/fire/keymap.h index 225d2b2fd84e..13f007364b95 100644 --- a/keyboards/cornia/keymaps/fire/keymap.h +++ b/keyboards/cornia/keymaps/fire/keymap.h @@ -18,6 +18,10 @@ #include QMK_KEYBOARD_H +/* Trackpad srolling speed adjustment */ +#define SCROLL_DIVISOR_H 8.0 +#define SCROLL_DIVISOR_V 8.0 + /* Trackpad srolling enablement flag */ extern bool set_scrolling; diff --git a/keyboards/cornia/keymaps/fire/rules.mk b/keyboards/cornia/keymaps/fire/rules.mk index 6253f6673d0b..68d32c7c04c0 100644 --- a/keyboards/cornia/keymaps/fire/rules.mk +++ b/keyboards/cornia/keymaps/fire/rules.mk @@ -13,10 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -SRC += callback_oled.c -SRC += callback_pointing_device.c -SRC += callback_record.c -SRC += callback_system.c SRC += tap_dances.c MOUSEKEY_ENABLE = yes @@ -25,8 +21,6 @@ TAP_DANCE_ENABLE = yes # OLED I²C configuration OLED_ENABLE = yes -OLED_DRIVER = ssd1306 -OLED_TRANSPORT = i2c # Cirque Trackpad I²C configuration POINTING_DEVICE_ENABLE = yes