Code Monkey home page Code Monkey logo

Comments (11)

valpackett avatar valpackett commented on June 5, 2024

/dev/input/event/1 doesn't sound like a file that should exist. It should be /dev/input/event1!

from evscript.

tugurio avatar tugurio commented on June 5, 2024

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: ^

from evscript.

valpackett avatar valpackett commented on June 5, 2024

Well that's an error from dyon interpreting your file. Have you tried the code from the readme?

from evscript.

tugurio avatar tugurio commented on June 5, 2024

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.

from evscript.

hallettj avatar hallettj commented on June 5, 2024

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.

from evscript.

tugurio avatar tugurio commented on June 5, 2024

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

from evscript.

valpackett avatar valpackett commented on June 5, 2024

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.

from evscript.

tugurio avatar tugurio commented on June 5, 2024

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"?

from evscript.

valpackett avatar valpackett commented on June 5, 2024

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.

from evscript.

tugurio avatar tugurio commented on June 5, 2024

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!

from evscript.

valpackett avatar valpackett commented on June 5, 2024

(FYI, stdlib.dyon is written Dyon, not Rust.)

from evscript.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.