Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KEY_SPACE and HJKL into ARROWS #4

Open
maricn opened this issue Jul 16, 2020 · 3 comments
Open

KEY_SPACE and HJKL into ARROWS #4

maricn opened this issue Jul 16, 2020 · 3 comments

Comments

@maricn
Copy link

maricn commented Jul 16, 2020

My setup

Thank you for writing and sharing this piece of code. I tried to read into it, and find it a bit confusing, so I'm asking for your kind help. :)

I'm on Arch on Wayland with SwayWM. I'm using latest AUR for interception-tools and evtest.

/etc/interception/udevmon.d/keymod.yaml:

- JOB: "intercept -g $DEVNODE | /opt/interception/maricn | uinput -d $DEVNODE"
  DEVICE:
    EVENTS:
      EV_KEY: [KEY_CAPSLOCK, KEY_ESC, KEY_SPACE]

/etc/udevmon.yaml:

# - JOB: "intercept -g $DEVNODE | uinput -d $DEVNODE"
#   DEVICE:
#     NAME: "AT Translated Set 2 keyboard"

Problem 1 - can't run make test

Hi, I would like to run tests, but make always throws errors...

nikola@work-x1c-arch ~/T/interception-k2k (master *+)» sudo env CONFIG_DIR=/home/nikola/Tools/interception-k2k/maricn make test
[sudo] password for nikola:
CFLAGS=-DVERBOSE make
make[1]: Entering directory '/home/nikola/Tools/interception-k2k'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/nikola/Tools/interception-k2k'
make install
make[1]: Entering directory '/home/nikola/Tools/interception-k2k'
# If you have run `make test` then do not forget to run `make clean` after. Otherwise you may install with debug logs on.
install -D --strip -t /opt/interception out/multi-rules.h.in out/tap-rules.h.in
install: strip process terminated abnormally
install: strip process terminated abnormally
make[1]: *** [Makefile:29: install] Error 1
make[1]: Leaving directory '/home/nikola/Tools/interception-k2k'
make: *** [Makefile:34: test] Error 2

Instead I do this to run tests (albeit w/o debug output):

make clean && make && sudo make install && sudo systemctl restart udevmon.service

Problem 2 - space + home row => arrows

I want to make my space key pressed with home row keys emulate arrows. I tried:

  • multi-rules with KEY_SPACE and K mapping into PRESS(KEY_UP), but I can't make KEY_SPACE stop repeating on other key down/up (space + k keeps repeating space long after i release k)
  • tap-rule which maps KEY_SPACE into KEY_RIGHTMETA and then multi-rules that map KEY_RIGHTMETA with K into arrow up.. but then meta + k seems to have precedence, which is mapped with my tiling WM..
  • tap-rule which maps KEY_SPACE into itself with .repeat_key = KEY_RESERVED and multi-rule that maps KEY_SPACE with K into an arrow.. this doesn't change anything..

My interception-k2k/maricn/multi-rules.h.in:

/* space + nums => F-keys */
{ .keys = { KEY_SPACE, KEY_1 }, PRESS(KEY_F1), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_2 }, PRESS(KEY_F2), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_3 }, PRESS(KEY_F3), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_4 }, PRESS(KEY_F4), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_5 }, PRESS(KEY_F5), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_6 }, PRESS(KEY_F6), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_7 }, PRESS(KEY_F7), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_8 }, PRESS(KEY_F8), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_9 }, PRESS(KEY_F9), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_0 }, PRESS(KEY_F10), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_MINUS }, PRESS(KEY_F11), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_EQUAL }, PRESS(KEY_F12), DOWN_IFF_ALL_DOWN(2) },

/* space + home row => arrow keys */
{ .keys = { KEY_SPACE, KEY_H }, PRESS_ON_DOWN(KEY_LEFT), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_K }, PRESS_ON_DOWN(KEY_UP), DOWN_IFF_ALL_DOWN(2), .repeated_key = KEY_RESERVED},
{ .keys = { KEY_SPACE, KEY_J }, PRESS_ON_DOWN(KEY_DOWN), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_L }, PRESS_ON_DOWN(KEY_RIGHT), DOWN_IFF_ALL_DOWN(2) },

My interception-k2k/maricn/multi-tap.h.in:

/* caps2esc */
{ .base_key = KEY_CAPSLOCK, .tap_key = KEY_ESC, .repeat_key = KEY_LEFTCTRL, .hold_key = KEY_LEFTCTRL, .hold_immediately = 1 },

{ .base_key = KEY_SPACE, .tap_key = KEY_SPACE, .repeat_key = KEY_RESERVED, .hold_key = KEY_RESERVED, .hold_immediately = 1 },

Problem 3 - stuck letters

Sometimes when I load interception plugin, my letter J gets stuck and doesn't output.. It doesn't get registered in evtest and when I move to another window (firefox) it keeps outputting j until i press some other key.

@zsugabubus
Copy link
Owner

zsugabubus commented Jul 18, 2020

Problem 1 - can't run make test

You have something wrong with your directory structure. Move all your “maricn/*.h.in” files into a subdirectory (as you can see with “default”, “shift2caps“, “caps2esc”).

First level (“maricn”) is the config directory. Second level (new subdirectory) will be the name of the executable that will use the “*.h.in” files inside.

Problem 2 - space + home row => arrows

Phew. I haven’t used my plugin lately, but if you go with multi rules you surely need to set nbeforedown = 2 so it switches home row key down only if both keys are down. When you release a key it sends the other, because DOWN_IFF_ALL_DOWN specifies nbeforeup = nup = -2 => we are in a toggled down state and we go into a toggled up state when not 2 keys are down (negative numbers mean not). From this, I think you will have more luck with setting them to 1 or 0.

But have you tried the following tap rules?

#define KEY_VIML KEY_E
#define KEY_VIMR KEY_I
{ TAP(KEY_VIMR), .action_key = KEY_B/*X*/, .hold_key = KEY_DELETE, .tap_typing = 1 }, \
{ TAP(KEY_VIML), .action_key = KEY_H/*D*/, .hold_key = KEY_BACKSPACE, .tap_typing = 1 }, \
{ TAP(KEY_VIMR), .action_key = KEY_G/*I*/, .hold_key = KEY_INSERT, .tap_typing = 1 }, \
{ TAP(KEY_VIMR), .action_key = KEY_V/*K*/, .hold_key = KEY_UP, .tap_typing = 1 }, \
{ TAP(KEY_VIMR), .action_key = KEY_C/*J*/, .hold_key = KEY_DOWN, .tap_typing = 1 }, \
{ TAP(KEY_VIML), .action_key = KEY_J/*H*/, .hold_key = KEY_LEFT, .tap_typing = 1 }, \
{ TAP(KEY_VIML), .action_key = KEY_P/*L*/, .hold_key = KEY_RIGHT, .tap_typing = 1 }, \
{ TAP(KEY_VIML), .action_key = KEY_Y/*F*/, .hold_key = KEY_PAGEUP, .tap_typing = 1 }, \
{ TAP(KEY_VIML), .action_key = KEY_N/*B*/, .hold_key = KEY_PAGEDOWN, .tap_typing = 1 }, \
{ TAP(KEY_VIML), .action_key = KEY_U/*g*/, .hold_key = KEY_HOME, .tap_typing = 1 }, \
{ TAP(KEY_VIML), .action_key = KEY_M/*G*/, .hold_key = KEY_END, .tap_typing = 1 }, \
{ TAP(KEY_VIML), .action_key = KEY_R/*P*/, .hold_key = KEY_PRINT, .tap_typing = 1 }, \
{ TAP(KEY_VIML), .action_key = KEY_SEMICOLON/*S*/, .hold_key = KEY_PAUSE, .tap_typing = 1 },
#undef KEY_VIML
#undef KEY_VIMR

Just replace KEY_VIM* with KEY_SPACE and I think this is what you need.

Problem 3 - stuck letters

Did you type on the keyboard while restarting udevmon? That could cause issues.

If not, run make test, hopefully debug output can help.

@maricn
Copy link
Author

maricn commented Jul 21, 2020

Problem 1 - can't run make test

You have something wrong with your directory structure. Move all your “maricn/*.h.in” files into a subdirectory (as you can see with “default”, “shift2caps“, “caps2esc”).

Now, per your instructions, I have this repo cloned at ~/Tools/interception-k2k/ and inside I have my folder maricn which contains inteception-pipe-maricn folder with *.h.in files.

The command I have succeeded running is:

make clean && mkdir -p out/ && sudo env CONFIG_DIR=/home/nikola/Tools/interception-k2k/maricn make test

Thank you!

Problem 2 - space + home row => arrows

Just replace KEY_VIM* with KEY_SPACE and I think this is what you need.

Wow, thank you! Didn't realize that would work the way I wanted. On the first look it seems fine, but there's a huge problem (3) with stuck letters and some repeated and missed ones.

Problem 3 - stuck letters

Did you type on the keyboard while restarting udevmon? That could cause issues.

No, the command I'm running to apply the changes is:

make clean && make && sudo make install && sudo systemctl restart udevmon.service

Then I wait for a while so udevmon service restarts, but the letters still get stuck.

This happens especially when switching windows (i'm on Wayland with SwayWM). When I change focus to another window, some random key starts outputting there. So far I got letters e, n, comma, space, and even SHIFT stuck. They get unstuck when I press some other key. Also, my touchpad gets stuck sometimes.

Trying out make test and looking at the debug output didn't really help. The debug output looks fine, I wasn't able to replicate anything strange there. I also increased TIMEOUT and tried moving around my DE, but couldn't replicate that issue.

@zsugabubus
Copy link
Owner

zsugabubus commented Jul 22, 2020

there's a huge problem (3) with stuck letters and some repeated and missed ones.

I never experienced such issue on my machine (used also with Sway), but here are a few things I can think of:

  • Make sure no other program intercepts your keyboard input.
  • Try shrink down your configuration only to one rule.
  • “Also, my touchpad gets stuck sometimes.”, so unless your udevmon is misconfigured my stuff surely does not touch that. Using evtest, you could figure out whether there is some oddity with your keyboard.

some random key starts outputting there

That does not sound well. As mentioned above, please try shrinking down your config, maybe that key is one of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants