From c6243da12f6643747a24a7aa761e103cc4a848c2 Mon Sep 17 00:00:00 2001
From: lalalademaxiya1 <2831039915@qq.com>
Date: Wed, 15 Mar 2023 16:51:53 +0800
Subject: Update Keychron K Pro series keyboards
---
.../keychron/q2_pro/ansi_encoder/ansi_encoder.c | 136 +++++++-------
keyboards/keychron/q2_pro/ansi_encoder/config.h | 7 -
keyboards/keychron/q2_pro/chconf.h | 30 ---
keyboards/keychron/q2_pro/config.h | 7 +
keyboards/keychron/q2_pro/matrix.c | 204 +++++++++++----------
keyboards/keychron/q2_pro/q2_pro.c | 18 +-
keyboards/keychron/q2_pro/readme.md | 8 +-
keyboards/keychron/q2_pro/rules.mk | 3 -
8 files changed, 207 insertions(+), 206 deletions(-)
delete mode 100755 keyboards/keychron/q2_pro/chconf.h
(limited to 'keyboards/keychron/q2_pro')
diff --git a/keyboards/keychron/q2_pro/ansi_encoder/ansi_encoder.c b/keyboards/keychron/q2_pro/ansi_encoder/ansi_encoder.c
index e74af39920..ca92d5e5f1 100755
--- a/keyboards/keychron/q2_pro/ansi_encoder/ansi_encoder.c
+++ b/keyboards/keychron/q2_pro/ansi_encoder/ansi_encoder.c
@@ -18,83 +18,83 @@
#ifdef RGB_MATRIX_ENABLE
const ckled2001_led g_ckled2001_leds[RGB_MATRIX_LED_COUNT] = {
-/* Refer to IS31 manual for these locations
+/* Refer to CKLED2001 manual for these locations
* driver
* | R location
* | | G location
* | | | B location
* | | | | */
- {0, C_16, A_16, B_16},
- {0, C_15, A_15, B_15},
- {0, C_14, A_14, B_14},
- {0, C_13, A_13, B_13},
- {0, C_12, A_12, B_12},
- {0, C_11, A_11, B_11},
- {0, C_10, A_10, B_10},
- {0, C_9, A_9, B_9},
- {0, C_8, A_8, B_8},
- {0, C_7, A_7, B_7},
- {0, C_6, A_6, B_6},
- {0, C_5, A_5, B_5},
- {0, C_4, A_4, B_4},
- {0, C_3, A_3, B_3},
- {0, C_1, A_1, B_1},
+ {0, C_16, A_16, B_16},
+ {0, C_15, A_15, B_15},
+ {0, C_14, A_14, B_14},
+ {0, C_13, A_13, B_13},
+ {0, C_12, A_12, B_12},
+ {0, C_11, A_11, B_11},
+ {0, C_10, A_10, B_10},
+ {0, C_9, A_9, B_9},
+ {0, C_8, A_8, B_8},
+ {0, C_7, A_7, B_7},
+ {0, C_6, A_6, B_6},
+ {0, C_5, A_5, B_5},
+ {0, C_4, A_4, B_4},
+ {0, C_3, A_3, B_3},
+ {0, C_1, A_1, B_1},
- {0, F_16, D_16, E_16},
- {0, F_15, D_15, E_15},
- {0, F_14, D_14, E_14},
- {0, F_13, D_13, E_13},
- {0, F_12, D_12, E_12},
- {0, F_11, D_11, E_11},
- {0, F_10, D_10, E_10},
- {0, F_9, D_9, E_9},
- {0, F_8, D_8, E_8},
- {0, F_7, D_7, E_7},
- {0, F_6, D_6, E_6},
- {0, F_5, D_5, E_5},
- {0, F_4, D_4, E_4},
- {0, F_3, D_3, E_3},
- {0, F_1, D_1, E_1},
+ {0, F_16, D_16, E_16},
+ {0, F_15, D_15, E_15},
+ {0, F_14, D_14, E_14},
+ {0, F_13, D_13, E_13},
+ {0, F_12, D_12, E_12},
+ {0, F_11, D_11, E_11},
+ {0, F_10, D_10, E_10},
+ {0, F_9, D_9, E_9},
+ {0, F_8, D_8, E_8},
+ {0, F_7, D_7, E_7},
+ {0, F_6, D_6, E_6},
+ {0, F_5, D_5, E_5},
+ {0, F_4, D_4, E_4},
+ {0, F_3, D_3, E_3},
+ {0, F_1, D_1, E_1},
- {1, C_16, A_16, B_16},
- {1, C_15, A_15, B_15},
- {1, C_14, A_14, B_14},
- {1, C_13, A_13, B_13},
- {1, C_12, A_12, B_12},
- {1, C_11, A_11, B_11},
- {1, C_10, A_10, B_10},
- {1, C_9, A_9, B_9},
- {1, C_8, A_8, B_8},
- {1, C_7, A_7, B_7},
- {1, C_6, A_6, B_6},
- {1, C_5, A_5, B_5},
- {1, C_3, A_3, B_3},
- {1, C_1, A_1, B_1},
+ {1, C_16, A_16, B_16},
+ {1, C_15, A_15, B_15},
+ {1, C_14, A_14, B_14},
+ {1, C_13, A_13, B_13},
+ {1, C_12, A_12, B_12},
+ {1, C_11, A_11, B_11},
+ {1, C_10, A_10, B_10},
+ {1, C_9, A_9, B_9},
+ {1, C_8, A_8, B_8},
+ {1, C_7, A_7, B_7},
+ {1, C_6, A_6, B_6},
+ {1, C_5, A_5, B_5},
+ {1, C_3, A_3, B_3},
+ {1, C_1, A_1, B_1},
- {1, I_16, G_16, H_16},
- {1, I_14, G_14, H_14},
- {1, I_13, G_13, H_13},
- {1, I_12, G_12, H_12},
- {1, I_11, G_11, H_11},
- {1, I_10, G_10, H_10},
- {1, I_9, G_9, H_9},
- {1, I_8, G_8, H_8},
- {1, I_7, G_7, H_7},
- {1, I_6, G_6, H_6},
- {1, I_5, G_5, H_5},
- {1, I_3, G_3, H_3},
- {1, I_2, G_2, H_2},
+ {1, I_16, G_16, H_16},
+ {1, I_14, G_14, H_14},
+ {1, I_13, G_13, H_13},
+ {1, I_12, G_12, H_12},
+ {1, I_11, G_11, H_11},
+ {1, I_10, G_10, H_10},
+ {1, I_9, G_9, H_9},
+ {1, I_8, G_8, H_8},
+ {1, I_7, G_7, H_7},
+ {1, I_6, G_6, H_6},
+ {1, I_5, G_5, H_5},
+ {1, I_3, G_3, H_3},
+ {1, I_2, G_2, H_2},
- {1, F_16, D_16, E_16},
- {1, F_15, D_15, E_15},
- {1, F_14, D_14, E_14},
- {1, F_10, D_10, E_10},
- {1, F_6, D_6, E_6},
- {1, F_5, D_5, E_5},
- {1, F_4, D_4, E_4},
- {1, F_3, D_3, E_3},
- {1, F_2, D_2, E_2},
- {1, F_1, D_1, E_1}
+ {1, F_16, D_16, E_16},
+ {1, F_15, D_15, E_15},
+ {1, F_14, D_14, E_14},
+ {1, F_10, D_10, E_10},
+ {1, F_6, D_6, E_6},
+ {1, F_5, D_5, E_5},
+ {1, F_4, D_4, E_4},
+ {1, F_3, D_3, E_3},
+ {1, F_2, D_2, E_2},
+ {1, F_1, D_1, E_1}
};
#define __ NO_LED
diff --git a/keyboards/keychron/q2_pro/ansi_encoder/config.h b/keyboards/keychron/q2_pro/ansi_encoder/config.h
index 5812a72a1d..9349e263bc 100755
--- a/keyboards/keychron/q2_pro/ansi_encoder/config.h
+++ b/keyboards/keychron/q2_pro/ansi_encoder/config.h
@@ -28,13 +28,6 @@
# define DRIVER_2_LED_TOTAL 37
# define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
-/* Increase I2C speed to 1000 KHz */
-# define I2C1_TIMINGR_PRESC 0U
-# define I2C1_TIMINGR_SCLDEL 3U
-# define I2C1_TIMINGR_SDADEL 0U
-# define I2C1_TIMINGR_SCLH 15U
-# define I2C1_TIMINGR_SCLL 30U
-
/* Set to infinit, which is use in USB mode by default */
# define RGB_MATRIX_TIMEOUT RGB_MATRIX_TIMEOUT_INFINITE
diff --git a/keyboards/keychron/q2_pro/chconf.h b/keyboards/keychron/q2_pro/chconf.h
deleted file mode 100755
index 3f4365ac24..0000000000
--- a/keyboards/keychron/q2_pro/chconf.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright 2023 QMK
- *
- * 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 .
- */
-
-/*
- * This file was auto-generated by:
- * `qmk chibios-confmigrate -i keyboards/acheron/arctic/chconf.h -r platforms/chibios/common/configs/chconf.h`
- */
-
-#pragma once
-
-#define CH_CFG_ST_FREQUENCY 10000
-
-#define CH_CFG_OPTIMIZE_SPEED FALSE
-
-#define CH_CFG_USE_CONDVARS_TIMEOUT FALSE
-
-#include_next
diff --git a/keyboards/keychron/q2_pro/config.h b/keyboards/keychron/q2_pro/config.h
index b42ea8559b..756af46e08 100755
--- a/keyboards/keychron/q2_pro/config.h
+++ b/keyboards/keychron/q2_pro/config.h
@@ -36,6 +36,13 @@
#define DIP_SWITCH_PINS \
{ A8 }
+/* Increase I2C speed to 1000 KHz */
+#define I2C1_TIMINGR_PRESC 0U
+#define I2C1_TIMINGR_SCLDEL 3U
+#define I2C1_TIMINGR_SDADEL 0U
+#define I2C1_TIMINGR_SCLH 15U
+#define I2C1_TIMINGR_SCLL 51U
+
#ifdef KC_BLUETOOTH_ENABLE
/* Hardware configuration */
# define USB_BT_MODE_SELECT_PIN C15
diff --git a/keyboards/keychron/q2_pro/matrix.c b/keyboards/keychron/q2_pro/matrix.c
index b20774d370..c6710b22d5 100755
--- a/keyboards/keychron/q2_pro/matrix.c
+++ b/keyboards/keychron/q2_pro/matrix.c
@@ -14,78 +14,30 @@
* along with this program. If not, see .
*/
-#include "stdint.h"
-#include "hal.h"
-#include "gpio.h"
#include "quantum.h"
#define HC595_STCP B0
#define HC595_SHCP A1
#define HC595_DS A7
-#define DIRECT_COL_NUM 1
-
pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
-static inline void HC595_delay(uint16_t n) {
- while (n-- > 0) {
- asm volatile("nop" ::: "memory");
- }
-}
-
-#ifdef DRIVE_SHRIFT_REGISTER_WITH_SPI
-// clang-format off
-const SPIConfig hs_spicfg = {
- .circular = false,
- .slave = false,
- .data_cb = NULL,
- .error_cb = NULL,
- .ssport = PAL_PORT(HC595_STCP),
- .sspad = PAL_PAD(HC595_STCP),
- .cr1 = SPI_CR1_BR_1,
- .cr2 = SPI_CR2_DS_3 | SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 | SPI_CR2_SSOE | SPI_CR2_NSSP
-};
-// clang-format on
-#endif
-static void HC595_output(uint16_t data) {
-#ifdef DRIVE_SHRIFT_REGISTER_WITH_SPI
- spiSend(&SPID1, 1, &data);
-#else
- uint8_t i;
- uint8_t n = 1;
-
- for (i = 16; i > 0; i--) {
- writePinLow(HC595_SHCP);
-
- if (data & 0x8000)
- writePinHigh(HC595_DS);
- else
- writePinLow(HC595_DS);
-
- data <<= 1;
-
- HC595_delay(n);
-
- writePinHigh(HC595_SHCP);
- HC595_delay(n);
+static inline void setPinOutput_writeLow(pin_t pin) {
+ ATOMIC_BLOCK_FORCEON {
+ setPinOutput(pin);
+ writePinLow(pin);
}
-
- HC595_delay(n);
- writePinLow(HC595_STCP);
- HC595_delay(n);
- writePinHigh(HC595_STCP);
-#endif
}
-static inline void setPinOutput_writeLow(pin_t pin) {
+static inline void setPinOutput_writeHigh(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
setPinOutput(pin);
- writePinLow(pin);
+ writePinHigh(pin);
}
}
-static inline void setPinInputHigh_atomic(pin_t pin) {
+static inline void setPinInput_high(pin_t pin) {
ATOMIC_BLOCK_FORCEON {
setPinInputHigh(pin);
}
@@ -99,16 +51,65 @@ static inline uint8_t readMatrixPin(pin_t pin) {
}
}
+static inline void HC595_delay(uint16_t n) {
+ while (n-- > 0) {
+ asm volatile("nop" ::: "memory");
+ }
+}
+
+static void HC595_output(uint16_t data) {
+ ATOMIC_BLOCK_FORCEON {
+ for (uint8_t i = 0; i < MATRIX_COLS; i++) {
+ if (data & 0x1) {
+ writePinHigh(HC595_DS);
+ } else {
+ writePinLow(HC595_DS);
+ }
+
+ data = data >> 1;
+
+ writePinHigh(HC595_SHCP);
+ HC595_delay(1);
+ writePinLow(HC595_SHCP);
+ HC595_delay(1);
+ }
+ writePinHigh(HC595_STCP);
+ HC595_delay(1);
+ writePinLow(HC595_STCP);
+ HC595_delay(1);
+ }
+}
+
+static void HC595_output_oneBit(uint8_t data) {
+ ATOMIC_BLOCK_FORCEON {
+ if (data & 0x1) {
+ writePinHigh(HC595_DS);
+ } else {
+ writePinLow(HC595_DS);
+ }
+
+ writePinHigh(HC595_SHCP);
+ HC595_delay(1);
+ writePinLow(HC595_SHCP);
+ HC595_delay(1);
+
+ writePinHigh(HC595_STCP);
+ HC595_delay(1);
+ writePinLow(HC595_STCP);
+ HC595_delay(1);
+ }
+}
+
static bool select_col(uint8_t col) {
pin_t pin = col_pins[col];
- if (col < 0) {
- if (pin != NO_PIN) {
- setPinOutput_writeLow(pin);
- return true;
- }
+ if (pin != NO_PIN) {
+ setPinOutput_writeLow(pin);
+ return true;
} else {
- HC595_output(~(0x01 << col));
+ if (col == 0) {
+ HC595_output_oneBit(0x00);
+ }
return true;
}
return false;
@@ -117,81 +118,96 @@ static bool select_col(uint8_t col) {
static void unselect_col(uint8_t col) {
pin_t pin = col_pins[col];
- if (col < 0) {
- if (pin != NO_PIN) {
- setPinInputHigh_atomic(pin);
- }
+ if (pin != NO_PIN) {
+#ifdef MATRIX_UNSELECT_DRIVE_HIGH
+ setPinOutput_writeHigh(pin);
+#else
+ setPinInput_high(pin);
+#endif
} else {
- if (col >= MATRIX_COLS - 1) HC595_output(0xFFFF);
+ HC595_output_oneBit(0x01);
}
}
static void unselect_cols(void) {
- if (col_pins[0] != NO_PIN) setPinInputHigh_atomic(col_pins[0]);
- HC595_output(0xFFFF);
+ for (uint8_t x = 0; x < MATRIX_COLS; x++) {
+ pin_t pin = col_pins[x];
+ if (pin != NO_PIN) {
+#ifdef MATRIX_UNSELECT_DRIVE_HIGH
+ setPinOutput_writeHigh(pin);
+#else
+ setPinInput_high(pin);
+#endif
+ } else {
+ if (x == 0) HC595_output(0xFFFF);
+ }
+ }
}
void select_all_cols(void) {
- if (col_pins[0] != NO_PIN) setPinOutput_writeLow(col_pins[0]);
- HC595_output(0x0000);
+ for (uint8_t x = 0; x < MATRIX_COLS; x++) {
+ pin_t pin = col_pins[x];
+ if (pin != NO_PIN) {
+ setPinOutput_writeLow(pin);
+ } else {
+ if (x == 0) HC595_output(0x0000);
+ }
+ }
}
-void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
+static void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col, matrix_row_t row_shifter) {
+ bool key_pressed = false;
+
// Select col
if (!select_col(current_col)) { // select col
return; // skip NO_PIN col
}
- HC595_delay(100);
+ matrix_output_select_delay();
// For each row...
for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
// Check row pin state
if (readMatrixPin(row_pins[row_index]) == 0) {
// Pin LO, set col bit
- current_matrix[row_index] |= (MATRIX_ROW_SHIFTER << current_col);
- // key_pressed = true;
+ current_matrix[row_index] |= row_shifter;
+ key_pressed = true;
} else {
// Pin HI, clear col bit
- current_matrix[row_index] &= ~(MATRIX_ROW_SHIFTER << current_col);
+ current_matrix[row_index] &= ~row_shifter;
}
}
+ // Unselect col
unselect_col(current_col);
- HC595_delay(100);
+ matrix_output_unselect_delay(current_col, key_pressed); // wait for all Row signals to go HIGH
}
void matrix_init_custom(void) {
+ setPinOutput(HC595_DS);
+ setPinOutput(HC595_STCP);
+ setPinOutput(HC595_SHCP);
+
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
if (row_pins[x] != NO_PIN) {
- setPinInputHigh_atomic(row_pins[x]);
+ setPinInput_high(row_pins[x]);
}
}
-#ifdef DRIVE_SHRIFT_REGISTER_WITH_SPI
- palSetPadMode(PAL_PORT(HC595_SHCP), PAL_PAD(HC595_SHCP), PAL_MODE_ALTERNATE(5) | PAL_STM32_OSPEED_HIGHEST); /* SCK */
- palSetPadMode(PAL_PORT(HC595_DS), PAL_PAD(HC595_DS), PAL_MODE_ALTERNATE(5) | PAL_STM32_OSPEED_HIGHEST); /* MOSI*/
- palSetPadMode(PAL_PORT(HC595_STCP), PAL_PAD(HC595_STCP), PAL_MODE_ALTERNATE(5) | PAL_STM32_OSPEED_HIGHEST); /* CS*/
- spiStart(&SPID1, &hs_spicfg);
-#else
- setPinOutput(HC595_DS);
- setPinOutput(HC595_STCP);
- setPinOutput(HC595_SHCP);
-#endif
+
unselect_cols();
}
bool matrix_scan_custom(matrix_row_t current_matrix[]) {
- bool matrix_has_changed = false;
-
matrix_row_t curr_matrix[MATRIX_ROWS] = {0};
// Set col, read rows
- for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
- matrix_read_rows_on_col(curr_matrix, current_col);
+ matrix_row_t row_shifter = MATRIX_ROW_SHIFTER;
+ for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++, row_shifter <<= 1) {
+ matrix_read_rows_on_col(curr_matrix, current_col, row_shifter);
}
- matrix_has_changed = memcmp(current_matrix, curr_matrix, sizeof(curr_matrix)) != 0;
- if (matrix_has_changed) memcpy(current_matrix, curr_matrix, sizeof(curr_matrix));
+ bool changed = memcmp(current_matrix, curr_matrix, sizeof(curr_matrix)) != 0;
+ if (changed) memcpy(current_matrix, curr_matrix, sizeof(curr_matrix));
- return matrix_has_changed;
+ return changed;
}
diff --git a/keyboards/keychron/q2_pro/q2_pro.c b/keyboards/keychron/q2_pro/q2_pro.c
index 1c430e4e66..72e36b4a54 100755
--- a/keyboards/keychron/q2_pro/q2_pro.c
+++ b/keyboards/keychron/q2_pro/q2_pro.c
@@ -176,7 +176,8 @@ void matrix_scan_kb(void) {
#ifdef KC_BLUETOOTH_ENABLE
static void ckbt51_param_init(void) {
/* Set bluetooth device name */
- ckbt51_set_local_name(STR(PRODUCT));
+ // ckbt51_set_local_name(STR(PRODUCT));
+ ckbt51_set_local_name(PRODUCT);
/* Set bluetooth parameters */
module_param_t param = {.event_mode = 0x02,
.connected_idle_timeout = 7200,
@@ -204,6 +205,21 @@ void bluetooth_enter_disconnected_kb(uint8_t host_idx) {
}
}
+void ckbt51_default_ack_handler(uint8_t *data, uint8_t len) {
+ if (data[1] == 0x45) {
+ module_param_t param = {.event_mode = 0x02,
+ .connected_idle_timeout = 7200,
+ .pairing_timeout = 180,
+ .pairing_mode = 0,
+ .reconnect_timeout = 5,
+ .report_rate = 90,
+ .vendor_id_source = 1,
+ .verndor_id = 0, // Must be 0x3434
+ .product_id = PRODUCT_ID};
+ ckbt51_set_param(¶m);
+ }
+}
+
void bluetooth_pre_task(void) {
static uint8_t mode = 1;
diff --git a/keyboards/keychron/q2_pro/readme.md b/keyboards/keychron/q2_pro/readme.md
index c7cbdfe0b0..f46a26f308 100755
--- a/keyboards/keychron/q2_pro/readme.md
+++ b/keyboards/keychron/q2_pro/readme.md
@@ -1,18 +1,20 @@
# Keychron Q2 Pro
+![Keychron Q2 Pro]()
+
A customizable 60% keyboard.
* Keyboard Maintainer: [Keychron](https://github.com/keychron)
* Hardware Supported: Keychron Q2 Pro
-* Hardware Availability: [Keychron](https://www.keychron.com/)
+* Hardware Availability: [Keychron Q2 Pro]()
Make example for this keyboard (after setting up your build environment):
- make keychron/q2_pro/ansi/rgb:default
+ make keychron/q2_pro/ansi_encoder:default
Flashing example for this keyboard:
- make keychron/q2_pro/ansi/rgb:default:flash
+ make keychron/q2_pro/ansi_encoder:default:flash
**Reset Key**: Connect the USB cable, toggle mode switch to "Off", hold down the *Esc* key or reset button underneath space bar, then toggle then switch to "Cable".
diff --git a/keyboards/keychron/q2_pro/rules.mk b/keyboards/keychron/q2_pro/rules.mk
index d1f9ae0f7c..0824dfed8b 100755
--- a/keyboards/keychron/q2_pro/rules.mk
+++ b/keyboards/keychron/q2_pro/rules.mk
@@ -7,9 +7,6 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
NKRO_ENABLE = yes # USB Nkey Rollover
-BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
-RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
-AUDIO_ENABLE = no # Audio output
DIP_SWITCH_ENABLE = yes
BLUETOOTH_ENABLE = no
BLUETOOTH_DRIVER = custom
--
cgit v1.2.3
From 1ff70d666a4c5f8ffa45adbdbd3f2628a4cbbdb4 Mon Sep 17 00:00:00 2001
From: lalalademaxiya1 <2831039915@qq.com>
Date: Thu, 16 Mar 2023 11:49:53 +0800
Subject: Added pal callback function for Q2Pro and Q3Pro
---
keyboards/keychron/q2_pro/q2_pro.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
(limited to 'keyboards/keychron/q2_pro')
diff --git a/keyboards/keychron/q2_pro/q2_pro.c b/keyboards/keychron/q2_pro/q2_pro.c
index 72e36b4a54..55551bbc58 100755
--- a/keyboards/keychron/q2_pro/q2_pro.c
+++ b/keyboards/keychron/q2_pro/q2_pro.c
@@ -141,6 +141,14 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
return true;
}
+#ifdef KC_BLUETOOTH_ENABLE
+void encoder0_pad_cb(void *param) {
+ (void)param;
+
+ encoder_insert_state();
+}
+#endif
+
void keyboard_post_init_kb(void) {
dip_switch_read(true);
@@ -155,6 +163,15 @@ void keyboard_post_init_kb(void) {
ckbt51_init(false);
bluetooth_init();
+
+ pin_t encoders_pad_a[NUM_ENCODERS] = ENCODERS_PAD_A;
+ pin_t encoders_pad_b[NUM_ENCODERS] = ENCODERS_PAD_B;
+ for (uint8_t i = 0; i < NUM_ENCODERS; i++) {
+ palEnableLineEvent(encoders_pad_a[i], PAL_EVENT_MODE_BOTH_EDGES);
+ palEnableLineEvent(encoders_pad_b[i], PAL_EVENT_MODE_BOTH_EDGES);
+ palSetLineCallback(encoders_pad_a[i], encoder0_pad_cb, NULL);
+ palSetLineCallback(encoders_pad_b[i], encoder0_pad_cb, NULL);
+ }
#endif
keyboard_post_init_user();
@@ -289,3 +306,7 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
}
}
#endif
+
+void restart_usb_driver(USBDriver *usbp) {
+ (void)usbp;
+}
--
cgit v1.2.3