[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] enjoy 1.0 ( an exercise of Lua as a DSL)
- From: Steve Litt <slitt@...>
- Date: Mon, 31 Jan 2011 19:27:12 -0500
On Monday 31 January 2011 18:37:26 Lucas Zawacki wrote:
> Hey guys!
>
> So I've been working in the past few days in a little app to put some
> of my Lua skills in practice and scractch a little itch I had.
>
> Check it out: https://github.com/lfzawacki/enjoy . There's some
> documentation and honesty in the README
>
> It's a small application to read joystick inputs and map it to OS
> shell commands. It uses Lua extensively as a DSL for the mapping of
> buttons to commands, I have no parsers at all... just plain Lua.
> The code has been lualinted and still has some "warnings" (some global
> variables that I plan to squash while learning more about environments
> and the registry). The design is VERY simple and naive, but it works
> fine and I'm cheating here and calling this a 1.0 release. It uses the
> Linux kernel API to read the joystick (because I'm lazy) so it works
> only under Linux, BUT I plan in fixing that
I'm all over this like a squirrel on a tree. This is excellent. But I own no
joystick. How would I make this work with my scroll mouse instead? Would I
just change
int fd = openDevice( argc == 2 ? strdup(argv[1]) : "/dev/input/js0" );
to something else? Using tail -f I couldn't read anything off of
/dev/input/mouse0.
Also, I didn't understand one piece of Lua syntax:
cmd {
down = function ()
print(k .. ' down')
execute_cmd('xdotool keydown ' .. k)
--__send_key_event(k,true)
end ,
up = function()
print(k .. ' up')
execute_cmd('xdotool keyup ' .. k)
--__send_key_event(k,false)
end
}
Since cmd is a function, shouldn't the anonymous table be enclosed in
parentheses?
This is pretty cool. Thanks
SteveT
Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt