Cockpitbuilders.com

LUA Projects => Code Sharing - => Topic started by: RayS on November 20, 2015, 11:54:20 AM

Title: LUA First question: Keyboard events....
Post by: RayS on November 20, 2015, 11:54:20 AM
This is more abstract and deals with functionality.

I downloaded the SimInnovation gauge suite and it's all based on LUA programming.

Does LUA have a library/facility to work with keyboard events? I see facilities for Joystick events which has me thinking. With regard to rotary encoders, they need to be spun with some vigor sometimes. My concern is that if the rotaries use joystick events, that the overall joystick architecture will end up missing a lot of those button events, while my experience has shown that working with keyboard events is a lot cleaner.

Can anyone share their experiences?
Title: Re: LUA First question: Keyboard events....
Post by: Trevor Hale on November 20, 2015, 02:28:46 PM
Ray,

Lua itself does not natively accept inputs. But like arduino there are library's you can import.

Take a look at the io library, which by default has standard-input as the default input file:

http://www.lua.org/pil/21.1.html (http://www.lua.org/pil/21.1.html)

Quote
local answer
repeat
   io.write("continue with this operation (y/n)? ")
   io.flush()
   answer=io.read()
until answer=="y" or answer=="n"

Trev