Skip to content

Commit

Permalink
Merge branch 'r3.8.1' into vial
Browse files Browse the repository at this point in the history
  • Loading branch information
danil-tolkachev committed Nov 28, 2024
2 parents b7d478c + 5248ae3 commit 3167482
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 38 deletions.
11 changes: 7 additions & 4 deletions keyboards/ergohaven/ergohaven.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "quantum.h"

#define EH_VERSION_STR "3.8.0"
#define EH_VERSION_STR "3.8.1"

#ifndef EH_SHORT_PRODUCT_NAME
# define EH_SHORT_PRODUCT_NAME PRODUCT
Expand Down Expand Up @@ -53,13 +53,14 @@
#define APP_B LSG(KC_B)

enum custom_keycodes {
EH_RESERV1 = QK_KB,
EH_RESERV2,
EH_RESERV3,
EH_PRINFO = QK_KB,
WRD_NXT,
WRD_PRV,
WNEXT,
WPREV,
LAYER_NEXT,
LAYER_PREV,
EH_RESERV1,
};

// 1st layer on the cycle
Expand All @@ -80,3 +81,5 @@ bool split_get_mac(void);
bool split_get_caps_word(void);

void kb_config_update_ruen_toggle_mode(uint8_t mode);

void kb_config_update_ruen_mac_layout(bool mac_layout);
50 changes: 49 additions & 1 deletion keyboards/ergohaven/ergohaven_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
#include "ergohaven_rgb.h"
#include "ergohaven_display.h"
#include "hid.h"
#include "version.h"

typedef union {
uint32_t raw;
struct {
uint8_t ruen_toggle_mode : 2;
bool ruen_mac_layout : 1;
};
} kb_config_t;

Expand All @@ -19,6 +21,11 @@ void kb_config_update_ruen_toggle_mode(uint8_t mode) {
eeconfig_update_kb(kb_config.raw);
}

void kb_config_update_ruen_mac_layout(bool mac_layout) {
kb_config.ruen_mac_layout = mac_layout;
eeconfig_update_kb(kb_config.raw);
}

#ifdef AUDIO_ENABLE
float base_sound[][2] = SONG(TERMINAL_SOUND);
float caps_sound[][2] = SONG(CAPS_LOCK_ON_SOUND);
Expand All @@ -40,6 +47,20 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
// #endif

switch (keycode) { // This will do most of the grunt work with the keycodes.
case WRD_NXT:
if (record->event.pressed) {
register_code16(keymap_config.swap_lctl_lgui ? A(KC_RIGHT) : C(KC_RIGHT));
} else
unregister_code16(keymap_config.swap_lctl_lgui ? A(KC_RIGHT) : C(KC_RIGHT));
return false;

case WRD_PRV:
if (record->event.pressed) {
register_code16(keymap_config.swap_lctl_lgui ? A(KC_LEFT) : C(KC_LEFT));
} else
unregister_code16(keymap_config.swap_lctl_lgui ? A(KC_LEFT) : C(KC_LEFT));
return false;

case WNEXT:
if (record->event.pressed) {
if (!is_alt_tab_active) {
Expand Down Expand Up @@ -99,7 +120,33 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
layer_move(next_layer);
return false;

case LG_TOGGLE ... LG_END:
case EH_PRINFO: {
if (record->event.pressed) {
send_string("FW version: " QMK_VERSION "\n");
send_string("Build date: " QMK_BUILDDATE "\n");
send_string("Git hash: " QMK_GIT_HASH "\n");

send_string("Mac mode: ");
send_string(keymap_config.swap_lctl_lgui ? "on\n" : "off\n");

send_string("RuEn mode: ");
uint8_t ruen_mode = get_ruen_toggle_mode();
if (ruen_mode == TG_DEFAULT)
send_string("default\n");
else if (ruen_mode == TG_M0)
send_string("M0\n");
else if (ruen_mode == TG_M1M2)
send_string("M1M2\n");
else
send_string("error\n");

send_string("RuEn layout: ");
send_string(get_ruen_mac_layout() ? "Mac\n" : "PC\n");
}
return false;
}

case LG_START ... LG_END:
return process_record_ruen(keycode, record);
}

Expand Down Expand Up @@ -154,6 +201,7 @@ void matrix_scan_kb(void) { // The very important timer.
void keyboard_post_init_kb(void) {
kb_config.raw = eeconfig_read_kb();
set_ruen_toggle_mode(kb_config.ruen_toggle_mode);
set_ruen_mac_layout(kb_config.ruen_mac_layout);

#ifdef RGBLIGHT_ENABLE
keyboard_post_init_rgb();
Expand Down
70 changes: 50 additions & 20 deletions keyboards/ergohaven/ergohaven_ruen.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ static bool should_revert_ru = false;

static bool english_word = false;

static bool mac_layout = false;

void set_lang(uint8_t lang) {
switch (tg_mode) {
case TG_DEFAULT:
Expand Down Expand Up @@ -66,6 +68,19 @@ void set_ruen_toggle_mode(uint8_t mode) {
}
}

uint8_t get_ruen_toggle_mode(void) {
return tg_mode;
}

void set_ruen_mac_layout(bool layout)
{
mac_layout = layout;
}

bool get_ruen_mac_layout(void) {
return mac_layout;
}

void lang_toggle(void) {
if (cur_lang == LANG_EN)
set_lang(LANG_RU);
Expand All @@ -84,21 +99,6 @@ uint8_t get_cur_lang(void) {
return cur_lang;
}

typedef struct {
uint16_t en;
uint16_t ru;
} ru_en_symbol;

ru_en_symbol ru_en_table[] = {
{KC_DOT, KC_SLASH}, // LG_DOT
{KC_COMMA, LSFT(KC_SLASH)}, // LG_COMMA
{KC_SCLN, LSFT(KC_4)}, // LG_SCLN
{KC_COLON, LSFT(KC_6)}, // LG_COLON
{KC_DQUO, LSFT(KC_2)}, // LG_DQUO
{KC_QUES, LSFT(KC_7)}, // LG_QUES
{KC_SLASH, LSFT(KC_BSLS)}, // LG_SLASH
};

uint16_t en_table[] = {
KC_LBRC, // LG_LBR
KC_RBRC, // LG_RBR
Expand Down Expand Up @@ -199,11 +199,41 @@ bool process_record_ruen(uint16_t keycode, keyrecord_t *record) {
kb_config_update_ruen_toggle_mode(tg_mode);
return false;

case LG_RU_EN_START ... LG_SLASH:
if (cur_lang == 0)
tap_code16(ru_en_table[keycode - LG_RU_EN_START].en);
else
tap_code16(ru_en_table[keycode - LG_RU_EN_START].ru);
case LG_DOT: // .
tap_code16(cur_lang == LANG_EN ? KC_DOT : mac_layout ? S(KC_7) : KC_SLASH);
return false;

case LG_COMMA: // ,
tap_code16(cur_lang == LANG_EN ? KC_COMMA : mac_layout ? S(KC_6) : S(KC_SLASH));
return false;

case LG_SCLN: // ;
tap_code16(cur_lang == LANG_EN ? KC_SCLN : mac_layout ? S(KC_8) : S(KC_4));
return false;

case LG_COLON: // :
tap_code16(cur_lang == LANG_EN ? KC_COLON : mac_layout ? S(KC_5) : S(KC_6));
return false;

case LG_DQUO: // "
tap_code16(cur_lang == LANG_EN ? KC_DQUO : S(KC_2));
return false;

case LG_QUES: // ?
tap_code16(cur_lang == LANG_EN || mac_layout ? KC_QUES : S(KC_7));
return false;

case LG_SLASH: // /
tap_code16(cur_lang == LANG_EN || mac_layout ? KC_SLASH : LSFT(KC_BSLS));
return false;

case LG_PERC: // %
tap_code16(cur_lang == LANG_RU && mac_layout ? LSFT(KC_4) : LSFT(KC_5));
return false;

case LG_TG_MAC:
mac_layout = !mac_layout;
kb_config_update_ruen_mac_layout(mac_layout);
return false;

case LG_EN_START ... LG_QUOTE: {
Expand Down
18 changes: 14 additions & 4 deletions keyboards/ergohaven/ergohaven_ruen.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
#include "ergohaven.h"

enum ruen_custom_keycodes {
LG_TOGGLE = LAYER_PREV + 2,
LG_START = LAYER_PREV + 2,

LG_TOGGLE = LG_START,
LG_SYNC,
LG_SET_EN,
LG_SET_RU,
LG_SET_M0,
LG_SET_M1M2,
LG_SET_DFLT,

// symbols exist in russian and english layout
LG_RU_EN_START,
LG_DOT = LG_RU_EN_START,
LG_DOT,
LG_COMMA,
LG_SCLN,
LG_COLON,
Expand Down Expand Up @@ -47,6 +47,10 @@ enum ruen_custom_keycodes {
LG_STORE,
LG_REVERT,

// Additional keycodes for Mac
LG_PERC,
LG_TG_MAC,

// end of ru en symbols range
LG_END,
};
Expand All @@ -64,3 +68,9 @@ void housekeeping_task_ruen(void);
uint8_t get_cur_lang(void);

void set_ruen_toggle_mode(uint8_t mode);

uint8_t get_ruen_toggle_mode(void);

void set_ruen_mac_layout(bool mac_layout);

bool get_ruen_mac_layout(void);
2 changes: 2 additions & 0 deletions keyboards/ergohaven/imperial44/keymaps/v1_v2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
#define VIAL_KEYBOARD_UID {0x77, 0x36, 0x5B, 0xB5, 0xC2, 0xEF, 0xFD, 0x25}
#define VIAL_UNLOCK_COMBO_ROWS { 0, 0 }
#define VIAL_UNLOCK_COMBO_COLS { 5, 4 }
#define ENCODER_RESOLUTION 4
#define ENCODER_DEFAULT_POS 0x3
2 changes: 2 additions & 0 deletions keyboards/ergohaven/k03/keymaps/v1_v2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
#define VIAL_KEYBOARD_UID {0xF1, 0xB3, 0x4C, 0x68, 0x6C, 0x25, 0xF1, 0x53}
#define VIAL_UNLOCK_COMBO_ROWS { 0, 0 }
#define VIAL_UNLOCK_COMBO_COLS { 5, 4 }
#define ENCODER_RESOLUTION 4
#define ENCODER_DEFAULT_POS 0x3
5 changes: 5 additions & 0 deletions keyboards/ergohaven/k03pro/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
#define AZOTEQ_IQS5XX_REPORT_RATE 10
#define POINTING_DEVICE_TASK_THROTTLE_MS 10
#define AZOTEQ_IQS5XX_PRESS_AND_HOLD_ENABLE true
#define AZOTEQ_IQS5XX_HOLD_TIME 200
#define AZOTEQ_IQS5XX_TAP_TIME 175
#define AZOTEQ_IQS5XX_TAP_DISTANCE 50
#define AZOTEQ_IQS5XX_ZOOM_ENABLE true


#define I2C_DRIVER I2CD1
#define I2C1_SDA_PIN GP2
#define I2C1_SCL_PIN GP3
Expand Down
2 changes: 2 additions & 0 deletions keyboards/ergohaven/macropad/keymaps/v1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
#define VIAL_KEYBOARD_UID {0xBB, 0x17, 0xF0, 0x5B, 0x02, 0x80, 0x1D, 0x1D}
#define VIAL_UNLOCK_COMBO_ROWS { 1, 1 }
#define VIAL_UNLOCK_COMBO_COLS { 1, 2 }
#define ENCODER_RESOLUTION 4
#define ENCODER_DEFAULT_POS 0x3
2 changes: 2 additions & 0 deletions keyboards/ergohaven/macropad/keymaps/v2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
#define VIAL_KEYBOARD_UID {0xBB, 0x17, 0xF0, 0x5B, 0x02, 0x80, 0x1D, 0x1D}
#define VIAL_UNLOCK_COMBO_ROWS { 1, 1 }
#define VIAL_UNLOCK_COMBO_COLS { 1, 2 }
#define ENCODER_RESOLUTION 4
#define ENCODER_DEFAULT_POS 0x3
2 changes: 2 additions & 0 deletions keyboards/ergohaven/macropad/keymaps/v2_ccw/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
#define VIAL_UNLOCK_COMBO_ROWS { 1, 1 }
#define VIAL_UNLOCK_COMBO_COLS { 1, 2 }
#define ENCODER_DIRECTION_FLIP
#define ENCODER_RESOLUTION 4
#define ENCODER_DEFAULT_POS 0x3
18 changes: 9 additions & 9 deletions keyboards/ergohaven/vial_keycodes_base.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{"name": "",
"title": "Not using",
"shortName": ""
{"name": "EH_PRINF",
"title": "Print information about firmware and modes",
"shortName": "Print\nInfo"
},
{"name": "",
"title": "Not using",
"shortName": ""
{"name": "WRD_NXT",
"title": "Jump to next word",
"shortName": "Next\nWord"
},
{"name": "",
"title": "Not using",
"shortName": ""
{"name": "WRD_PRV",
"title": "Jump to previous word",
"shortName": "Prev\nWord"
},
{"name": "WNEXT",
"title": "Holds Alt and taps Tab, then waits for 650ms, if the key is tapped again, it will send another Tab; if there is no tap, Alt will turn off. This allows you to cycle through windows with only one key",
Expand Down
8 changes: 8 additions & 0 deletions keyboards/ergohaven/vial_keycodes_ruen.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,12 @@
{"name": "LG_REVERT",
"title": "Revert to stored layout (useful for macros)",
"shortName": "RuEn\nRevert"
},
{"name": "LG_PERC",
"title": "Send % (differs on MacOS layout)",
"shortName": "RuEn\n%"
},
{"name": "LG_TG_MAC",
"title": "Toggle to use MacOS layout for Russian instead of PC layout",
"shortName": "RuEn\nMac Tg"
}
3 changes: 3 additions & 0 deletions quantum/pointing_device/pointing_device_drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "timer.h"
#include <stddef.h>
#include <stdlib.h>
#include "quantum.h"

#define CONSTRAIN_HID(amt) ((amt) < INT8_MIN ? INT8_MIN : ((amt) > INT8_MAX ? INT8_MAX : (amt)))
#define CONSTRAIN_HID_XY(amt) ((amt) < XY_REPORT_MIN ? XY_REPORT_MIN : ((amt) > XY_REPORT_MAX ? XY_REPORT_MAX : (amt)))
Expand Down Expand Up @@ -187,9 +188,11 @@ report_mouse_t azoteq_iqs5xx_get_report(report_mouse_t mouse_report) {
} else if (base_data.gesture_events_1.zoom) {
if (AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l) < 0) {
pd_dprintf("IQS5XX - Zoom out.\n");
tap_code16(C(KC_MINUS));
temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON7);
} else if (AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l) > 0) {
pd_dprintf("IQS5XX - Zoom in.\n");
tap_code16(C(KC_EQL));
temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON8);
}
} else if (base_data.gesture_events_1.scroll) {
Expand Down

0 comments on commit 3167482

Please sign in to comment.