Skip to content

Commit

Permalink
send
Browse files Browse the repository at this point in the history
  • Loading branch information
juliekoubova committed Jun 30, 2024
1 parent 2815605 commit 9c64d52
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
41 changes: 17 additions & 24 deletions users/juliekoubova/vim/vim_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,27 @@
#define VIM_TAP_DELAY 30

void vim_send(uint16_t code16, vim_send_type_t type) {
uint8_t mods = QK_MODS_GET_MODS(code16);
uint8_t mods = QK_MODS_GET_MODS(code16);
uint8_t keycode = QK_MODS_GET_BASIC_KEYCODE(code16);

if (mods && (type == VIM_SEND_PRESS || type == VIM_SEND_TAP)) {
VIM_DPRINTF("register mods=%x\n", mods);
register_mods(mods);
}

switch (type) {
case VIM_SEND_TAP:
VIM_DPRINTF("tap keycode=%x\n", keycode);
tap_code_delay(keycode, VIM_TAP_DELAY);
break;
case VIM_SEND_PRESS:
VIM_DPRINTF("register keycode=%x\n", keycode);
register_code(keycode);
if (type & VIM_SEND_PRESS) {
if (mods) {
VIM_DPRINTF("register mods=%x\n", mods);
register_mods(mods);
}
VIM_DPRINTF("register keycode=%x\n", keycode);
register_code(keycode);
if (type & VIM_SEND_RELEASE) {
wait_ms(VIM_TAP_DELAY);
break;
case VIM_SEND_RELEASE:
VIM_DPRINTF("unregister keycode=%x\n", keycode);
unregister_code(keycode);
wait_ms(VIM_TAP_DELAY);
break;
}
}

if (mods && (type == VIM_SEND_RELEASE || type == VIM_SEND_TAP)) {
VIM_DPRINTF("unregister mods=%x\n", mods);
unregister_mods(mods);
if (type & VIM_SEND_RELEASE) {
VIM_DPRINTF("unregister keycode=%x\n", keycode);
unregister_code(keycode);
if (mods) {
VIM_DPRINTF("unregister mods=%x\n", mods);
unregister_mods(mods);
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions users/juliekoubova/vim/vim_send.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
#include <stdint.h>

typedef enum {
VIM_SEND_TAP,
VIM_SEND_PRESS,
VIM_SEND_RELEASE,
VIM_SEND_NONE = 0x0,
VIM_SEND_PRESS = 0x1,
VIM_SEND_RELEASE = 0x2,
VIM_SEND_TAP = VIM_SEND_PRESS | VIM_SEND_RELEASE
} vim_send_type_t;

void vim_send(uint16_t keycode, vim_send_type_t);
Expand Down

0 comments on commit 9c64d52

Please sign in to comment.