mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-09-29 21:38:47 +02:00
Add a keymatrix_t type
This contains both the matrix number and key position, in preparation for multi-matrix support
This commit is contained in:
+1
-1
@@ -44,7 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "quantum_keycodes.h"
|
||||
|
||||
// translates key to keycode
|
||||
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
|
||||
uint16_t keymap_key_to_keycode(uint8_t layer, keymatrix_t key);
|
||||
|
||||
// translates function id to action
|
||||
uint16_t keymap_function_id_to_action( uint16_t function_id );
|
||||
|
||||
@@ -38,7 +38,7 @@ extern keymap_config_t keymap_config;
|
||||
#include <inttypes.h>
|
||||
|
||||
/* converts key to action */
|
||||
action_t action_for_key(uint8_t layer, keypos_t key)
|
||||
action_t action_for_key(uint8_t layer, keymatrix_t key)
|
||||
{
|
||||
// 16bit keycodes - important
|
||||
uint16_t keycode = keymap_key_to_keycode(layer, key);
|
||||
@@ -184,10 +184,12 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||
|
||||
// translates key to keycode
|
||||
__attribute__ ((weak))
|
||||
uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||
uint16_t keymap_key_to_keycode(uint8_t layer, keymatrix_t key)
|
||||
{
|
||||
// Read entire word (16bits)
|
||||
return pgm_read_word(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||
// The default implmention does not have multiple matrix support
|
||||
// and therfore it ignores the matrix field of the key
|
||||
return pgm_read_word(&keymaps[(layer)][(key.pos.row)][(key.pos.col)]);
|
||||
}
|
||||
|
||||
// translates function id to action
|
||||
|
||||
@@ -198,22 +198,23 @@ bool process_music(uint16_t keycode, keyrecord_t *record) {
|
||||
}
|
||||
|
||||
uint8_t note = 36;
|
||||
// Note: Multimatrix support is missing from this (it's probablly better to define it using keycodes)
|
||||
#ifdef MUSIC_MAP
|
||||
if (music_mode == MUSIC_MODE_CHROMATIC) {
|
||||
note = music_starting_note + music_offset + 36 + music_map[record->event.key.row][record->event.key.col];
|
||||
note = music_starting_note + music_offset + 36 + music_map[record->event.key.pos.row][record->event.key.pos.col];
|
||||
} else {
|
||||
uint8_t position = music_map[record->event.key.row][record->event.key.col];
|
||||
uint8_t position = music_map[record->event.key.pos.row][record->event.key.pos.col];
|
||||
note = music_starting_note + music_offset + 36 + SCALE[position % 12] + (position / 12)*12;
|
||||
}
|
||||
#else
|
||||
if (music_mode == MUSIC_MODE_CHROMATIC)
|
||||
note = (music_starting_note + record->event.key.col + music_offset - 3)+12*(MATRIX_ROWS - record->event.key.row);
|
||||
note = (music_starting_note + record->event.key.pos.col + music_offset - 3)+12*(MATRIX_ROWS - record->event.key.pos.row);
|
||||
else if (music_mode == MUSIC_MODE_GUITAR)
|
||||
note = (music_starting_note + record->event.key.col + music_offset + 32)+5*(MATRIX_ROWS - record->event.key.row);
|
||||
note = (music_starting_note + record->event.key.pos.col + music_offset + 32)+5*(MATRIX_ROWS - record->event.key.pos.row);
|
||||
else if (music_mode == MUSIC_MODE_VIOLIN)
|
||||
note = (music_starting_note + record->event.key.col + music_offset + 32)+7*(MATRIX_ROWS - record->event.key.row);
|
||||
note = (music_starting_note + record->event.key.pos.col + music_offset + 32)+7*(MATRIX_ROWS - record->event.key.pos.row);
|
||||
else if (music_mode == MUSIC_MODE_MAJOR)
|
||||
note = (music_starting_note + SCALE[record->event.key.col + music_offset] - 3)+12*(MATRIX_ROWS - record->event.key.row);
|
||||
note = (music_starting_note + SCALE[record->event.key.pos.col + music_offset] - 3)+12*(MATRIX_ROWS - record->event.key.pos.row);
|
||||
else
|
||||
note = music_starting_note;
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -190,7 +190,7 @@ static bool grave_esc_was_shifted = false;
|
||||
bool process_record_quantum(keyrecord_t *record) {
|
||||
|
||||
/* This gets the keycode from the key pressed */
|
||||
keypos_t key = record->event.key;
|
||||
keymatrix_t key = record->event.key;
|
||||
uint16_t keycode;
|
||||
|
||||
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
||||
|
||||
Reference in New Issue
Block a user