Add Libra Mini joystick remapping (#334)

* Enable remapping Libra Mini joystick as keys

* Move config to default keycap so make passes
This commit is contained in:
somepin
2023-01-14 22:35:08 -05:00
committed by GitHub
parent a6554d242f
commit 9470468ede
7 changed files with 148 additions and 217 deletions

View File

@ -4,21 +4,18 @@
/* Matrix config */ /* Matrix config */
#define MATRIX_ROWS 4 #define MATRIX_ROWS 5
#define MATRIX_COLS 12 #define MATRIX_COLS 12
#define MATRIX_ROW_PINS { E6, B4, B5, B2 } #define MATRIX_ROW_PINS { E6, B4, B5, B2, NO_PIN }
#define MATRIX_COL_PINS { B3, B1, F7, F6, F5, F4, C6, D4, D0, D1, D2, D3 } #define MATRIX_COL_PINS { B3, B1, F7, F6, F5, F4, C6, D4, D0, D1, D2, D3 }
#define DIODE_DIRECTION ROW2COL #define DIODE_DIRECTION ROW2COL
/* Joystick config */ // Max 32
#define JOYSTICK_BUTTON_COUNT 0
#define ANALOG_JOYSTICK_Y_AXIS_PIN B6 // Max 6: X, Y, Z, Rx, Ry, Rz
#define ANALOG_JOYSTICK_X_AXIS_PIN D7 #define JOYSTICK_AXES_COUNT 2
#define POINTING_DEVICE_INVERT_X
#define POINTING_DEVICE_INVERT_Y
/* Use 1000hz polling */ /* Use 1000hz polling */
#define USB_POLLING_INTERVAL_MS 1 #define USB_POLLING_INTERVAL_MS 1

View File

@ -8,5 +8,11 @@
#define ANALOG_JOYSTICK_SPEED_MAX 5 #define ANALOG_JOYSTICK_SPEED_MAX 5
#define ANALOG_JOYSTICK_SPEED_REGULATOR 10 #define ANALOG_JOYSTICK_SPEED_REGULATOR 10
#define ANALOG_JOYSTICK_Y_AXIS_PIN B6
#define ANALOG_JOYSTICK_X_AXIS_PIN D7
#define POINTING_DEVICE_INVERT_X
#define POINTING_DEVICE_INVERT_Y
/* Mouse inertia (keeps sliding after a flick) */ /* Mouse inertia (keeps sliding after a flick) */
// #define POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE // #define POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE

View File

@ -5,12 +5,3 @@
#define VIAL_KEYBOARD_UID {0xEA, 0xE3, 0x29, 0x4F, 0x79, 0xFF, 0x86, 0xC6} #define VIAL_KEYBOARD_UID {0xEA, 0xE3, 0x29, 0x4F, 0x79, 0xFF, 0x86, 0xC6}
#define VIAL_UNLOCK_COMBO_ROWS {0, 1} #define VIAL_UNLOCK_COMBO_ROWS {0, 1}
#define VIAL_UNLOCK_COMBO_COLS {0, 11} #define VIAL_UNLOCK_COMBO_COLS {0, 11}
/* Mouse control configuration */
/* Cursor speed */
#define ANALOG_JOYSTICK_SPEED_MAX 5
#define ANALOG_JOYSTICK_SPEED_REGULATOR 10
/* Mouse inertia (keeps sliding after a flick) */
// #define POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE

View File

@ -1,9 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
#include QMK_KEYBOARD_H
#include "joystick.h"
#include "analog.h"
#define KC_LSQB S(KC_LBRC) // Left square bracket #define KC_LSQB S(KC_LBRC) // Left square bracket
#define KC_RSQB S(KC_RBRC) // Right square bracket #define KC_RSQB S(KC_RBRC) // Right square bracket
#include QMK_KEYBOARD_H static int actuation = 256; // actuation point for arrows (0-511)
bool arrows[4];
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
@ -36,3 +41,52 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
), ),
}; };
void matrix_scan_user(void) {
// Up
if (!arrows[0] && analogReadPin(B6) - 512 > actuation) {
arrows[0] = true;
uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4,3);
register_code16(keycode);
} else if (arrows[0] && analogReadPin(B6) - 512 < actuation) {
arrows[0] = false;
uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4,3);
unregister_code16(keycode);
}
// Down
if (!arrows[1] && analogReadPin(B6) - 512 < -actuation) {
arrows[1] = true;
uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4,4);
register_code16(keycode);
} else if (arrows[1] && analogReadPin(B6) - 512 > -actuation) {
arrows[1] = false;
uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4,4);
unregister_code16(keycode);
}
// Left
if (!arrows[2] && analogReadPin(D7) - 512 > actuation) {
arrows[2] = true;
uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4,6);
register_code16(keycode);
} else if (arrows[2] && analogReadPin(D7) - 512 < actuation) {
arrows[2] = false;
uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4,6);
unregister_code16(keycode);
}
// Right
if (!arrows[3] && analogReadPin(D7) - 512 < -actuation) {
arrows[3] = true;
uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4,7);
register_code16(keycode);
} else if (arrows[3] && analogReadPin(D7) - 512 > -actuation) {
arrows[3] = false;
uint16_t keycode = dynamic_keymap_get_keycode(biton32(layer_state), 4,7);
unregister_code16(keycode);
}
}
// Joystick config
joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {
[0] = JOYSTICK_AXIS_VIRTUAL,
[1] = JOYSTICK_AXIS_VIRTUAL
};

View File

@ -1,8 +1,3 @@
VIA_ENABLE = yes VIA_ENABLE = yes
VIAL_ENABLE = yes VIAL_ENABLE = yes
LTO_ENABLE = yes LTO_ENABLE = yes
# Enable joystick as mouse
POINTING_DEVICE_ENABLE = yes
POINTING_DEVICE_DRIVER = analog_joystick

View File

@ -4,7 +4,7 @@
"productId": "0x4C24", "productId": "0x4C24",
"lighting": "none", "lighting": "none",
"matrix": { "matrix": {
"rows": 4, "rows": 5,
"cols": 12 "cols": 12
}, },
"layouts": { "layouts": {
@ -13,197 +13,82 @@
"Joystick" "Joystick"
], ],
"keymap": [ "keymap": [
[ [{ "x": 12.5 }, "0,11\n\n\n0,1", "3,11\n\n\n0,1"],
{ [
"x": 12.5 { "y": 0.25, "x": 0.25 },
}, "0,0",
"0,11\n\n\n0,1", "0,1",
"3,11\n\n\n0,1" { "x": 9.25 },
], "0,10",
[ { "w": 2 },
{ "0,11\n\n\n0,0"
"y": 0.25, ],
"x": 0.25 [
}, { "x": 0.125, "w": 1.25 },
"0,0", "1,0",
"0,1", "1,1",
{ { "x": 9.5 },
"x": 9.25 "1,10",
}, { "w": 1.75 },
"0,10", "1,11"
{ ],
"w": 2 [
}, { "w": 1.75 },
"0,11\n\n\n0,0" "2,0",
], "2,1",
[ { "x": 8.75 },
{ "2,10",
"x": 0.125, "2,11",
"w": 1.25 { "w": 1.25 },
}, "3,10"
"1,0", ],
"1,1", [{ "y": 1.25, "x": 12.625 }, "3,8\n\n\n1,1", "3,9\n\n\n1,1"],
{ [{ "y": -0.9, "x": 11.6, "w": 0.5, "h": 0.5 }, "4,3\n\n\n1,1"],
"x": 9.5 [
}, { "y": -0.5, "x": 11.1, "w": 0.5, "h": 0.5 },
"1,10", "4,6\n\n\n1,1",
{ { "w": 0.5, "h": 0.5 },
"w": 1.75 "4,4\n\n\n1,1",
}, { "w": 0.5, "h": 0.5 },
"1,11" "4,7\n\n\n1,1"
], ],
[ [
{ { "ry": 4.5, "y": -0.25, "x": 0.125, "w": 1.25 },
"w": 1.75 "3,0",
}, { "w": 1.25 },
"2,0", "3,1",
"2,1", { "x": 9.5, "w": 1.25 },
{ "3,8\n\n\n1,0",
"x": 8.75 { "w": 1.25 },
}, "3,9\n\n\n1,0"
"2,10", ],
"2,11", [
{ { "r": 8, "rx": 3, "ry": 2.25, "y": -1, "x": -0.75 },
"w": 1.25 "0,2",
}, "0,3",
"3,10" "0,4",
], "0,5"
[ ],
{ [{ "ry": 3.25, "y": -1, "x": -0.625 }, "1,2", "1,3", "1,4", "1,5"],
"y": 1.25, [{ "ry": 4.25, "y": -1, "x": -0.25 }, "2,2", "2,3", "2,4", "2,5"],
"x": 12.625 [{ "x": 1.75, "w": 2 }, "3,4"],
}, [{ "ry": 5.25, "y": -1, "x": 0.375, "w": 1.25 }, "3,3"],
"3,8\n\n\n1,1", [
"3,9\n\n\n1,1" { "r": -8, "rx": 11.5, "ry": 2.25, "y": -1, "x": -4 },
], "0,6",
[ "0,7",
{ "0,8",
"ry": 4.5, "0,9"
"y": -0.25, ],
"x": 0.125, [{ "ry": 3.25, "y": -1, "x": -3.625 }, "1,6", "1,7", "1,8", "1,9"],
"w": 1.25 [{ "ry": 4.25, "y": -1, "x": -4 }, "2,6", "2,7", "2,8", "2,9"],
}, [
"3,0", { "ry": 5.25, "y": -1, "x": -3.875, "w": 2.25 },
{ "3,6",
"w": 1.25 { "w": 1.25 },
}, "3,7\n\n\n1,0"
"3,1", ],
{ [{ "y": 0.25, "x": -1.625 }, "3,7\n\n\n1,1"]
"x": 9.5,
"w": 1.25
},
"3,8\n\n\n1,0",
{
"w": 1.25
},
"3,9\n\n\n1,0"
],
[
{
"r": 8,
"rx": 3,
"ry": 2.25,
"y": -1,
"x": -0.75
},
"0,2",
"0,3",
"0,4",
"0,5"
],
[
{
"ry": 3.25,
"y": -1,
"x": -0.625
},
"1,2",
"1,3",
"1,4",
"1,5"
],
[
{
"ry": 4.25,
"y": -1,
"x": -0.25
},
"2,2",
"2,3",
"2,4",
"2,5"
],
[
{
"x": 1.75,
"w": 2
},
"3,4"
],
[
{
"ry": 5.25,
"y": -1,
"x": 0.375,
"w": 1.25
},
"3,3"
],
[
{
"r": -8,
"rx": 11.5,
"ry": 2.25,
"y": -1,
"x": -4
},
"0,6",
"0,7",
"0,8",
"0,9"
],
[
{
"ry": 3.25,
"y": -1,
"x": -3.625
},
"1,6",
"1,7",
"1,8",
"1,9"
],
[
{
"ry": 4.25,
"y": -1,
"x": -4
},
"2,6",
"2,7",
"2,8",
"2,9"
],
[
{
"ry": 5.25,
"y": -1,
"x": -3.875,
"w": 2.25
},
"3,6",
{
"w": 1.25
},
"3,7\n\n\n1,0"
],
[
{
"y": 0.25,
"x": -1.625
},
"3,7\n\n\n1,1"
]
] ]
} }
} }

View File

@ -1,2 +1,5 @@
JOYSTICK_ENABLE = yes
JOYSTICK_DRIVER = analog
BOOTMAGIC_ENABLE = yes
# Add analog functionality to the source tree # Add analog functionality to the source tree
SRC += analog.c SRC += analog.c