Skip to content

Commit

Permalink
[Cornia/config] Remove unnecessary defines & move all callbacks to ke…
Browse files Browse the repository at this point in the history
…ymap.c
  • Loading branch information
Vaarai committed Oct 15, 2024
1 parent 71b58e2 commit 4f8e37c
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 218 deletions.
53 changes: 0 additions & 53 deletions keyboards/cornia/keymaps/fire/callback_oled.c

This file was deleted.

51 changes: 0 additions & 51 deletions keyboards/cornia/keymaps/fire/callback_pointing_device.c

This file was deleted.

75 changes: 0 additions & 75 deletions keyboards/cornia/keymaps/fire/callback_record.c

This file was deleted.

31 changes: 0 additions & 31 deletions keyboards/cornia/keymaps/fire/callback_system.c

This file was deleted.

134 changes: 132 additions & 2 deletions keyboards/cornia/keymaps/fire/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
Expand Down Expand Up @@ -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
//`--------------------------' `--------------------------'
),
};
};

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;
}
4 changes: 4 additions & 0 deletions keyboards/cornia/keymaps/fire/keymap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 0 additions & 6 deletions keyboards/cornia/keymaps/fire/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

SRC += callback_oled.c
SRC += callback_pointing_device.c
SRC += callback_record.c
SRC += callback_system.c
SRC += tap_dances.c

MOUSEKEY_ENABLE = yes
Expand All @@ -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
Expand Down

0 comments on commit 4f8e37c

Please sign in to comment.