Closed tugurio closed 4 years ago
/dev/input/event/1
doesn't sound like a file that should exist. It should be /dev/input/event1
!
Thanks a lot for the fast reply.
Oh god, don't know how I mistyped that.. Thanks a lot.
But now, always with the same file, i get an error:
❯ evscript -f .evscript_temp.dyon -d /dev/input/event4
--- ERROR ---
In `.evscript_temp.dyon`: Type mismatch (#200): Expected `[]`, found `{}` 9,19: for i len(evts) { 9,19: ^
Well that's an error from dyon interpreting your file. Have you tried the code from the readme?
Yeah, it the exact copy and paste.
Here is it's content..
//! [events] //! keys = ['ESC', 'LEFTSHIFT', '9', '0'] fn main() ~ evdevs, uinput { should_esc := false should_lshift := false should_rshift := false loop { evts := next_events(evdevs) for i len(evts) { evt := evts[i] xcape(mut should_esc, evt, KEY_CAPSLOCK(), [KEY_ESC()]) xcape(mut should_lshift, evt, KEY_LEFTSHIFT(), [KEY_LEFTSHIFT(), KEY_9()]) xcape(mut should_rshift, evt, KEY_RIGHTSHIFT(), [KEY_LEFTSHIFT(), KEY_0()]) } } }
Also, as we are here.. I have a little question. I see from the examples that if I want to map a key to a sequence of action I can just do something like
xcape(mut should_lshift, evt, KEY_LEFTSHIFT(), [KEY_LEFTSHIFT(), KEY_9()])
But is it also true the other way around, like this?
xcape(mut should_esc, evt, [KEY_CAPSLOCK(), KEY_N()], [KEY_H()])
Because I am using Colemak, and as I am used to vim binds, I would like to place the fingers in the same position for moving just with a remap. Precisely keeping pressed CAPS and pressing the keys that should correspond to the movement using QWERTY.
Oh, hi! I had the same problem, Expected [], found {} 9,19: for i len(evts)
. It seems that the iteration syntax in the readme is not correct. I think you can fix it by changing for i len(evts) { ... }
to for i { ... }
as explained in Inferring range by indexing. I know it looks weird to write a for loop without declaring the range to iterate over. It seems that Dyon can see that i
is used as an index into evts
, and infers that it should iterate over every index of evts
.
Uh, thanks also to you for the fast reply. It now runs without any "ERROR". But still doesn't do what the example script should do. Precisely.. If I press "left shift", it writes an open round bracket "(". The "right shift" writes a closed round bracket ")". And when pressing the "caps".. Yeah it act as and "ESC", but it also switch case, so it act as both. Don't know what is going on. If you can help me that would be great.
Back to my previous question, the syntax I used to associate two keys to one doesn't work. I get this error:
❯ evscript -f .evscript_layout.dyon -d /dev/input/event4
--- ERROR --- In `.evscript_layout.dyon`:
Type mismatch (#200): Expected `f64`, found `[]` 9,40: xcape(mut should_esc, evt, [KEY_ESC(), KEY_N()], [KEY_H()]) 9,40:
Hope there is a way to make also it working
as explained in Inferring range by indexing
But the first loop there says for i len(list)
. This has always worked, at least with the version of dyon that's saved in Cargo.lock
here. You didn't cargo update
by any chance?
when pressing the "caps".. Yeah it act as and "ESC", but it also switch case, so it act as both
This is intended for use with the ctrl:nocaps
xkb option, i.e. when you press on its own, it's Esc, and when you hold, it's Ctrl.
Hope there is a way to make also it working
Yes: write your own logic instead of my xcape
.
Also, if you remap Caps Lock to Ctrl, these keys would just be normal Ctrl-Something that you can handle in vim.
Thanks again for the reply.
Later I'll check the cargo version.
Could you elaborate on what I should do to map two combined keys to one? I don't know how I should modify the codeline that I wrote before.
This is the variable declaration
should_esc := false
and this the "xcape inside the for loop"
xcape(mut should_esc, evt, [KEY_ESC(), KEY_N()], [KEY_H()])
What do you mean by "write your own logic"?
I mean xcape
is not special magic, it's a function I wrote to do what it does, you can't use it for this purpose, instead you have to study how it works in stdlib.dyon
and write your own function that does what you want.
Oh now I see what you mean. The problem is that I completely don't know Rust. So I really can't make it. If you have some spare time and will to implement this, I think it would be helpful to more than just me. Thanks anyway for the help!
(FYI, stdlib.dyon
is written Dyon, not Rust.)
Hi. I just discovered this project and it sounds extremely promising. However, I really can't make it run. I copied the example in the README in a file named "test". This is what it outputs
❯ evscript -f test -d /dev/input/event/1 thread 'main' panicked at 'evdev open(): Sys(ENOENT)', src/libcore/result.rs:1165:5 note: run with
RUST_BACKTRACE=1environment variable to display a backtrace.
If I try with using RUST_BACKTRACE=full
❯ export RUST_BACKTRACE=full
❯ evscript -f test -d /dev/input/event/1 thread 'main' panicked at 'evdev open(): Sys(ENOENT)', src/libcore/result.rs:1165:5 stack backtrace: 0: 0x55e84acbccb4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4c5e39dd6bf38933 1: 0x55e84acd9b5c - core::fmt::write::h94b22f3cbda6422c 2: 0x55e84acbaa97 - std::io::Write::write_fmt::he7e02466cb3dc860 3: 0x55e84acbf1de - std::panicking::default_hook::{{closure}}::h077f2d0f0f4550db 4: 0x55e84acbeed1 - std::panicking::default_hook::hcc1ceebfaf9d0a58 5: 0x55e84acbf8db - std::panicking::rust_panic_with_hook::h328d8e7ed959397b 6: 0x55e84acbf47e - std::panicking::continue_panic_fmt::h745b12464b662c8f 7: 0x55e84acbf366 - rust_begin_unwind 8: 0x55e84acd5b8e - core::panicking::panic_fmt::hdb91b8826feb6fc9 9: 0x55e84acd5c87 - core::result::unwrap_failed::haba3c6d5a6de1991 10: 0x55e84aaf6678 - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter::h55f5e3626a98043f 11: 0x55e84aafb546 - evscript::main::h56bd2ac18487527c 12: 0x55e84ab04863 - std::rt::lang_start::{{closure}}::h869c81dbafb8a017 13: 0x55e84acbf303 - std::panicking::try::do_call::h81508b6a18a6e157 14: 0x55e84acc1dea - __rust_maybe_catch_panic 15: 0x55e84acbfdbd - std::rt::lang_start_internal::hfccf8c6e859ea61a 16: 0x55e84aaffdb2 - main 17: 0x7f7aac4e0153 - __libc_start_main 18: 0x55e84aad70ae - _start 19: 0x0 - <unknown>
I am on wayland, precisely sway. Don't really know what I should do. Can you help me? Thanks