Restructure MouseKeys to be aware of Macros virtual keys (#1114)
parent
72ee63386e
commit
06196fb20b
@ -0,0 +1,67 @@
|
||||
/* -*- mode: c++ -*-
|
||||
* Copyright (C) 2022 Keyboard.io, Inc.
|
||||
*
|
||||
* 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, version 3.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <Kaleidoscope.h>
|
||||
#include <Kaleidoscope-Macros.h>
|
||||
#include <Kaleidoscope-MouseKeys.h>
|
||||
|
||||
// *INDENT-OFF*
|
||||
KEYMAPS(
|
||||
[0] = KEYMAP_STACKED
|
||||
(
|
||||
Key_mouseUp, Key_mouseDn, Key_mouseL, Key_mouseR, ___, ___, ___,
|
||||
Key_mouseScrollUp, Key_mouseScrollDn, Key_mouseScrollL, Key_mouseScrollR, ___, ___, ___,
|
||||
Key_mouseBtnL, Key_mouseBtnM, Key_mouseBtnR, ___, ___, ___,
|
||||
M(0), M(1), ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___,
|
||||
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___, ___, ___, ___,
|
||||
___, ___, ___, ___,
|
||||
___
|
||||
),
|
||||
)
|
||||
// *INDENT-ON*
|
||||
|
||||
const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
|
||||
if (keyToggledOn(event.state)) {
|
||||
switch (macro_id) {
|
||||
case 0:
|
||||
Macros.tap(Key_mouseBtnR);
|
||||
break;
|
||||
case 1:
|
||||
Macros.press(Key_mouseScrollUp);
|
||||
Macros.release(Key_mouseScrollUp);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return MACRO_NONE;
|
||||
}
|
||||
|
||||
KALEIDOSCOPE_INIT_PLUGINS(Macros, MouseKeys);
|
||||
|
||||
void setup() {
|
||||
Kaleidoscope.setup();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Kaleidoscope.loop();
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"cpu": {
|
||||
"fqbn": "keyboardio:virtual:model01",
|
||||
"port": ""
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
VERSION 1
|
||||
|
||||
KEYSWITCH MOVE_UP 0 0
|
||||
KEYSWITCH MOVE_DOWN 0 1
|
||||
KEYSWITCH MOVE_LEFT 0 2
|
||||
KEYSWITCH MOVE_RIGHT 0 3
|
||||
|
||||
KEYSWITCH SCROLL_UP 1 0
|
||||
KEYSWITCH SCROLL_DOWN 1 1
|
||||
KEYSWITCH SCROLL_LEFT 1 2
|
||||
KEYSWITCH SCROLL_RIGHT 1 3
|
||||
|
||||
KEYSWITCH BUTTON_L 2 0
|
||||
KEYSWITCH BUTTON_M 2 1
|
||||
KEYSWITCH BUTTON_R 2 2
|
||||
|
||||
KEYSWITCH MACRO_0 3 0
|
||||
KEYSWITCH MACRO_1 3 1
|
||||
|
||||
# ==============================================================================
|
||||
NAME Mouse button key tap in Macros
|
||||
|
||||
RUN 3 ms
|
||||
PRESS MACRO_0
|
||||
RUN 1 cycle
|
||||
EXPECT mouse-report button=R
|
||||
EXPECT mouse-report empty
|
||||
|
||||
RUN 5 ms
|
||||
RELEASE MACRO_0
|
||||
RUN 1 cycle
|
||||
EXPECT no mouse-report
|
||||
|
||||
RUN 5 ms
|
||||
|
||||
# ==============================================================================
|
||||
NAME Mouse scroll key tap in Macros
|
||||
|
||||
RUN 4 ms
|
||||
PRESS MACRO_1
|
||||
RUN 1 cycle
|
||||
EXPECT mouse-report v=1
|
||||
|
||||
RUN 5 ms
|
||||
RELEASE MACRO_1
|
||||
RUN 1 cycle
|
||||
EXPECT no mouse-report
|
||||
|
||||
RUN 5 ms
|
Loading…
Reference in new issue