Jump to content
The simFlight Network Forums

Recommended Posts

Posted

I am trying to understand how to get a Joystick Axis value into a LUA script.  I've read the documentation and read through several forum posts here but I'm just not connecting the dots.  I'm frustrated with myself overt this as I feel the answer is sitting there in front of me in the documentation but it's just not penetrating my thick skull...  done venting, sorry, onto my questions.

 

 

I think I need a real FSUIPC & LUA for dummies jump start here.

 

1. I have an available joystick axis Joy # 1 Axis # U, What type of action and drop down selection should I set up  on the FSUIPC Axis Assignment tab to send the joystick axis value to my LUA Script called A2AC172R.lua?

 

2. What line of code should I write in the LUA script to pick up that value?  I've read about ipc.axis, and the various ipc.read__'s and have been trying to use them with various axis actions from FSUIPC but I'm missing something (likely something very obvious) and can't seem to make it work.

 

 

What I am ultimately trying to accomplish is to get the instrument panel light dimmers, and the cabin heat and air slide controls of my A2A C172 to work via some extra axis I have to work with.

Posted

Check the Com Library section of the FSUIPC Lua Library.pdf.

 

I think what you will want is this function:

 

n = com.gethidvalue(handle, "axis", str)

 

I've never had the need to use the items in that realm so I can't offer any further insight into

what additional steps you need to take.

 

I suspect you will need to 'open' the device using one of these constructs:

 

handle, rd, rdf, wr, initreport = com.openhid(VID, PID, unit, repno)
Or
handle, rd, rdf, wr, initreport = com.openhid(“vendor”, “product”, unit, repno)

 

I'm sure Pete will be able to give you better direction on this.

 

EDIT: Digging a bit more into the documentation, it may be as simple as using the ipc read facilities, specifically:

 

n = ipc.axis(joynum, "axis")

 

That appears to return the current uncalibrated value of the axis (U for you) of Joynum (1 for you).

 

   Paul
 

Posted

I'm sure Pete will be able to give you better direction on this.

 

Yes, what you've given is correct, except that you need to read the data from the opened device (using com.read or com.readlast). The other HID functions merely decode data already input.

 

The ipc.axis function is easier to use for standard joystick devices. The HID facilities are more general and enable access to additional device types (like GoFlight and Saitek non-joystick devices), and additional axes or buttons on the more advanced joystick types.

 

Regards

Pete

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.