mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-05 15:32:04 +00:00
Implement keyboard keycode reading using raw hid
This commit is contained in:
parent
2deeef5974
commit
5dc171218c
@ -1,7 +1,6 @@
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
|
||||
const uint16_t PROGMEM keymaps[MATRIX_LAYERS][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT(
|
||||
RGB_TOG, RGB_RMOD, RGB_MOD, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, RGB_VAD, RGB_VAI, RGB_M_P, RESET,
|
||||
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
#include "launch_test.h"
|
||||
#include "raw_hid.h"
|
||||
|
||||
void keyboard_post_init_user(void) {
|
||||
// Customise these values to desired behaviour
|
||||
@ -8,3 +8,35 @@ void keyboard_post_init_user(void) {
|
||||
debug_keyboard=true;
|
||||
//debug_mouse=true;
|
||||
}
|
||||
|
||||
static bool keymap_get(uint8_t layer, uint8_t output, uint8_t input, uint16_t *value) {
|
||||
if (layer < MATRIX_LAYERS) {
|
||||
if (output < MATRIX_ROWS) {
|
||||
if (input < MATRIX_COLS) {
|
||||
*value = keymap_key_to_keycode(layer, (keypos_t){.row = output, .col = input});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void raw_hid_receive(uint8_t *data, uint8_t length) {
|
||||
// Error response by default, set to success by commands
|
||||
data[1] = 1;
|
||||
|
||||
switch (data[0]) {
|
||||
case 9: // KEYMAP_GET
|
||||
{
|
||||
uint16_t value = 0;
|
||||
if (keymap_get(data[2], data[3], data[4], &value)) {
|
||||
data[5] = (uint8_t)value;
|
||||
data[6] = (uint8_t)(value >> 8);
|
||||
data[1] = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
raw_hid_send(data, length);
|
||||
}
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
//TODO: determine this automatically
|
||||
#define MATRIX_LAYERS 1
|
||||
|
||||
#define ___ KC_NO
|
||||
|
||||
#define LAYOUT( \
|
||||
|
@ -17,10 +17,11 @@ BOOTLOADER = atmel-dfu
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
|
||||
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||
EXTRAKEY_ENABLE = no # Audio control and System control(+450)
|
||||
CONSOLE_ENABLE = no # Console for debug(+400)
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||
RAW_ENABLE = yes # Enable RAW HID commands (used by keyboard configurator)
|
||||
RGBLIGHT_ENABLE = yes
|
||||
|
Loading…
Reference in New Issue
Block a user