diff options
author | Josh Johnson <josh@joshajohnson.com> | 2020-07-17 22:35:44 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-17 13:35:44 +0100 |
commit | 07a817d3e5454f9dc3ecd5f7e7b49197bfb36599 (patch) | |
tree | 79eff4d7426a6243c9b45672804ca2dc43bcab08 /keyboards/hub16/matrix.c | |
parent | 56beaf7d3f5bb135fbb516b4824d3e8c3643978f (diff) | |
download | qmk_firmware-07a817d3e5454f9dc3ecd5f7e7b49197bfb36599.tar.gz qmk_firmware-07a817d3e5454f9dc3ecd5f7e7b49197bfb36599.zip |
[keymap] Add VIA support for Hub16 (#9638)
* fix encoder switch not staying depressed
* add via support
* change default keymap
* change VID-PID
* remove LTO
* fix hold bug keeping debouncing
Diffstat (limited to 'keyboards/hub16/matrix.c')
-rw-r--r-- | keyboards/hub16/matrix.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/keyboards/hub16/matrix.c b/keyboards/hub16/matrix.c index ad77c923b..a0d8314de 100644 --- a/keyboards/hub16/matrix.c +++ b/keyboards/hub16/matrix.c | |||
@@ -25,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
25 | // Encoder things | 25 | // Encoder things |
26 | #define SWITCH_1 F7 | 26 | #define SWITCH_1 F7 |
27 | #define SWITCH_2 D7 | 27 | #define SWITCH_2 D7 |
28 | static bool read_encoder_values(matrix_row_t current_matrix[], uint8_t current_row); | 28 | static bool read_encoder_switches(matrix_row_t current_matrix[], uint8_t current_row); |
29 | 29 | ||
30 | #ifdef MATRIX_MASKED | 30 | #ifdef MATRIX_MASKED |
31 | extern const matrix_row_t matrix_mask[]; | 31 | extern const matrix_row_t matrix_mask[]; |
@@ -128,7 +128,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | |||
128 | } | 128 | } |
129 | 129 | ||
130 | // Unselect row | 130 | // Unselect row |
131 | unselect_row(current_row); | 131 | unselect_row(current_row); |
132 | 132 | ||
133 | return (last_row_value != current_matrix[current_row]); | 133 | return (last_row_value != current_matrix[current_row]); |
134 | } | 134 | } |
@@ -223,27 +223,23 @@ uint8_t matrix_scan(void) { | |||
223 | debounce(raw_matrix, matrix, MATRIX_ROWS, changed); | 223 | debounce(raw_matrix, matrix, MATRIX_ROWS, changed); |
224 | 224 | ||
225 | // Read encoder switches, already debounced | 225 | // Read encoder switches, already debounced |
226 | changed |= read_encoder_values(matrix, 4); | 226 | changed |= read_encoder_switches(matrix, 4); |
227 | 227 | ||
228 | matrix_scan_quantum(); | 228 | matrix_scan_quantum(); |
229 | return (uint8_t)changed; | 229 | return (uint8_t)changed; |
230 | } | 230 | } |
231 | 231 | ||
232 | // Customisations for the encoders | 232 | // Customisations for the encoders |
233 | void matrix_init_kb(void){ | 233 | void matrix_init_kb(void) { |
234 | setPinInput(SWITCH_1); | 234 | setPinInput(SWITCH_1); |
235 | setPinInput(SWITCH_2); | 235 | setPinInput(SWITCH_2); |
236 | } | 236 | } |
237 | 237 | ||
238 | void matrix_scan_kb(void){ | 238 | void matrix_scan_kb(void) {} |
239 | 239 | ||
240 | } | 240 | void matrix_print(void) {} |
241 | |||
242 | void matrix_print(void){ | ||
243 | |||
244 | } | ||
245 | 241 | ||
246 | static bool read_encoder_values(matrix_row_t current_matrix[], uint8_t current_row) { | 242 | static bool read_encoder_switches(matrix_row_t current_matrix[], uint8_t current_row) { |
247 | // Store last value of row prior to reading | 243 | // Store last value of row prior to reading |
248 | matrix_row_t last_row_value = current_matrix[current_row]; | 244 | matrix_row_t last_row_value = current_matrix[current_row]; |
249 | 245 | ||
@@ -253,18 +249,18 @@ static bool read_encoder_values(matrix_row_t current_matrix[], uint8_t current_r | |||
253 | // Debounce the encoder buttons using a shift register | 249 | // Debounce the encoder buttons using a shift register |
254 | static uint8_t btn_1_array; | 250 | static uint8_t btn_1_array; |
255 | static uint8_t btn_2_array; | 251 | static uint8_t btn_2_array; |
256 | bool btn_1_rising = 0; | 252 | bool btn_1_pressed = 0; |
257 | bool btn_2_rising = 0; | 253 | bool btn_2_pressed = 0; |
258 | btn_1_array <<= 1; | 254 | btn_1_array <<= 1; |
259 | btn_2_array <<= 1; | 255 | btn_2_array <<= 1; |
260 | btn_1_array |= readPin(SWITCH_1); | 256 | btn_1_array |= readPin(SWITCH_1); |
261 | btn_2_array |= readPin(SWITCH_2); | 257 | btn_2_array |= readPin(SWITCH_2); |
262 | (btn_1_array == 0b01111111) ? (btn_1_rising = 1) : (btn_1_rising = 0); | 258 | (btn_1_array == 0b11111111) ? (btn_1_pressed = 1) : (btn_1_pressed = 0); |
263 | (btn_2_array == 0b01111111) ? (btn_2_rising = 1) : (btn_2_rising = 0); | 259 | (btn_2_array == 0b11111111) ? (btn_2_pressed = 1) : (btn_2_pressed = 0); |
264 | 260 | ||
265 | // Populate the matrix row with the state of the encoder | 261 | // Populate the matrix row with the state of the encoder |
266 | current_matrix[current_row] |= btn_1_rising ? (1 << 0) : 0; | 262 | current_matrix[current_row] |= btn_1_pressed ? (1 << 0) : 0; |
267 | current_matrix[current_row] |= btn_2_rising ? (1 << 1) : 0; | 263 | current_matrix[current_row] |= btn_2_pressed ? (1 << 1) : 0; |
268 | 264 | ||
269 | return (last_row_value != current_matrix[current_row]); | 265 | return (last_row_value != current_matrix[current_row]); |
270 | } \ No newline at end of file | 266 | } \ No newline at end of file |