Comments (2)
we don't have any support for doing something like ydotool calls (the wayland compatible variant of xdotool) in response to keybind being pressed.
You can use an unused key code for this purpose. So instead of emitting a KEY_FOO
, you write 0xbeaf
(or anything) that you can handle at the other end of the pipe. You see that key 0xbeaf
is down and you can start a process. When key 0xbeaf
is up, you just ignore that event. It is basically a map rule that ignores key but does some custom stuff.
{ .keys = { KEY_SHIFT, KEY_ESCAPE }, PRESS_ON_DOWN(KEY_SHIFT, KEY_GRAVE), DOWN_IFF_ALL_DOWN(2) }
PRESS_ON_DOWN(key)
takes only one argument. It means that it presses key
(down event followed by an up event) when this rule is toggled down and nothing when up. Basically a one shot key. (At least it should do so according to docs and my memories. :))
You would need two-two down and up events fired, that currently is not possible.
I would say you need something like this:
{ .keys = { KEY_SHIFT, KEY_ESCAPE },
.down_press = { KEY_SHIFT, KEY_RESERVED, KEY_GRAVE, KEY_RESERVED },
.up_press = { KEY_RESERVED, KEY_GRAVE, KEY_RESERVED, KEY_SHIFT },
DOWN_IFF_ALL_DOWN(2) }
And here is the patch for it:
diff --git a/k2k.c b/k2k.c
index 435d1cd..35aac6c 100644
--- a/k2k.c
+++ b/k2k.c
@@ -82,9 +82,9 @@ static struct tap_rule {
*/
static struct multi_rule {
int const keys[8]; /** Keys to watch. */
- int const down_press[2]; /** Press first key and release second key when
+ int const down_press[4]; /** Press first key and release second key when
toggled down. */
- int const up_press[2]; /** Press first key and release second key when
+ int const up_press[4]; /** Press first key and release second key when
toggled up. */
int const nbeforedown; /** Only allow toggling down after this many `keys`
have been down. Negative value means inequality. */
@@ -539,7 +539,7 @@ main(void) {
if (v->can_toggle && (!v->is_down
? ndown == ntotal
: (v->nup >= 0 ? ndown == v->nup : ndown != -v->nup))) {
- int press[2];
+ int press[4];
v->is_down ^= 1;
memcpy(press, v->is_down ? v->down_press : v->up_press, sizeof press);
@@ -555,6 +555,12 @@ main(void) {
if (press[1] != KEY_RESERVED)
write_key_event(press[1], EVENT_VALUE_KEYUP);
+
+ if (press[2] != KEY_RESERVED)
+ write_key_event(press[2], EVENT_VALUE_KEYDOWN);
+
+ if (press[3] != KEY_RESERVED)
+ write_key_event(press[3], EVENT_VALUE_KEYUP);
}
for (j = 0; j < ntotal; ++j) {
(Sorry for my laziness, it is absolutely untested.)
from interception-k2k.
Just curious, but if you don't need the physical escape key (caps2esc, etc.), wouldn't this work if you just map Esc to the Grave character?
EDIT: Just tested it, it works.
from interception-k2k.
Related Issues (9)
- How do you use it? HOT 8
- Map to key + modifiers HOT 4
- changing key up/down order for tapping HOT 6
- broken configuration for multitple keyboards HOT 8
- KEY_SPACE and HJKL into ARROWS HOT 3
- How to map a combination of 2 keys for a string ? HOT 2
- Not working on Anne Pro 2 HOT 6
- Decreasing delay of a tap remap HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from interception-k2k.