Carliolian

LINDA, FSUIPC and Open Cockpits

Recommended Posts

Hello All

 

For some time now I have been using LINDA with my Saitek switch panel, Yoke & VRInsite MCP . Great tool, thank you Guenseli.

But eventually I thought that it was time to add more buttons and switches. I decided to buy an Open Cockpits i/p, o/p board and build it myself, having had some experience with electronics and software, no problems except that I soldered all the diodes the wrong way round. :fool:

Everything working ok, programmed most of the switches and lights with SIOC to operate via FSUIPC.
But,as I a fly several different types of aircraft and it's not easy to detect in SIOC the aircraft currently in use. So, I used LINDA to write a bit to a user byte in FSUIC which I could then detect in SIOC. Each user.lua sets a different bit (Boeing, Airbus, default, ..etc). That was a bit better.
But programming in SIOC is so... time consuming I though there has to be a better way. So more study and research. I thought to write LUA code to be run by FSUIPC. I looked at writing my own app and running it in LUA/FSUIPC but then I thought much of the code is already available in LINDA actions.lua but I don't want to touch that. After much trial and error and searching I found the lib-user.lua Just what I need. I don't need to write my own routines everything is available from here.

So what now happens. All that SIOC does is operate one of the virtual joystick buttons in FSUIPC , e.g.

# SIOC code

Var 0994, name JoyStick1, Link FSUIPC_OUT, Offset $3340, Length 4     // Joystick address
Var 0169, name SetJoyBtn, Link SUBRUTINE
{
  IF &BtnSet = 1
  {
    &JoyStick1 = SETBIT &BtnNumber
  }
  ELSE
  {
    &JoyStick1 = CLEARBIT &BtnNumber
  }
}
-- one variable for each button
Var 0170, name PBtn1, Link IOCARD_SW, Device 3, Input 8, Type I
{
  &BtnSet = &PBtn1    
  &BtnNumber = 1    
  CALL &SetJoyBtn
}

Var 0171, name PBtn2, Link IOCARD_SW, Device 3, Input 6, Type I
{
  &BtnSet = &PBtn2    
  &BtnNumber = 2    
  CALL &SetJoyBtn
}

Var 0172, name PBtn3, Link IOCARD_SW, Device 3, Input 7, Type I
{
  &BtnSet = &PBtn3    
  &BtnNumber = 3    
  CALL &SetJoyBtn
}

These button events are caught by LINDA in lib-user.lua

# LINDA lib-user.lua code
function handleButtons(joynum, button, downup)
    -- call handler
VButton_handler (joynum, button, downup)   -- this fuction is in the user.lua of each airplane
    -- or you can handle each event separtely (globaly) here.
 
  if button == 0 then
  end

  if button == 1 then
  end

  if button == 2 then
  end

  if button == 3 then
  end

   if button == 4 then
  end
-- etc
end -- function

-- events for virtual joystick buttons
event.button(64,0,3,"handleButtons")
event.button(64,1,3,"handleButtons")
event.button(64,2,3,"handleButtons")
event.button(64,3,3,"handleButtons")
event.button(64,4,3,"handleButtons")
event.button(64,5,3,"handleButtons")
-- etc

and sent to the button handler which is in LINDA user.lua

# LINDA user.lua

function VButton_handler (joyNo,btnNo,downUp)
-- switch case would be nice here
-- only joy stick 64
-- FSUIPC is from 0 .. 31, Linda 1.. 32

    if btnNo == 0 then
        VButton_1 (downUp)
    elseif btnNo == 1 then
        VButton_2 (downUp)
    elseif btnNo == 2 then
        VButton_3 (downUp)
    elseif btnNo == 3 then
        VButton_4 (downUp)
    elseif btnNo == 4 then
        VButton_5 (downUp)
    elseif btnNo == 5 then
        VButton_6 (downUp)
    end
    -- etc
end       -- end VButton_handler


This means that each aircraft in LINDA has its own set of actions for the aircraft currently in use and has full access to all the LINDA code. BINGO!!! Also all the user.lua code can be edited in LINDA editor.

lib-user.lua should not need to be changed except for generic actions. I put the default settings in the templates/users/user.lua for any new aircraft. At the moment all my encoders are working ok, but I think I might try write something to be able to control them better in lua.

What would be 'icing on the cake', if it was possible to assign functions to the virtual joystick buttons from the LINDA interface, but I realize that that is not quite as simple as I first thought. :wub:

My thanks to Guenseli and Peter Dowson for there dedication and great support.

Hope that this will be of use to others

 

A very happy
Carliolian

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Hi Carliolian

 

I am not familiar with SIOC so I need to ask for more information on what you are looking for. LINDA functions assigned to device buttons can not have parameters. The LUA examples you give would not work except as secondary calls.

 

Can you explain what you would expect LINDA to handle?

Share this post


Link to post
Share on other sites

Hi Scot

 

Don't bother trying to find out about SIOC

 

All  SIOC  does here  is set a bit in the virtual joystick buttons of FSUIPC  between address 3340 and 3363. Which appear in FSUIPC exactly as any other 'real' button, and can be programmed from there in FSUIPC. Which I did for a while.

I added events to be able to catch these buttons

         event.button(64,0,3,"handleButtons")

This will eventually be handled by a function in user.lua which calls functions from actions.lua e.g.

 

Function VButton_5 (downUp)

    if downUp ==1

               777_ENGINE_L_START_start ()

    end

end                                      --which works fine.

 

If you mean "what would I like to see in Linda for virtual buttons".

Then  :

        1.  To be able to enable/disable virtual joysticks 1..9 probably in the settings screen.

        2.  In the joysticks screen to see and assign "On Press" & "On Release".

 

This would mean detecting the events and assigning functions which could be stored in config-hid.lua.

 

Hope this was what you wanted. Thanks

 

Carliolian

Share this post


Link to post
Share on other sites

Thank you for the clarification. What would be needed is for these virtual joysticks to be "read" into LINDA so that actions could be assigned to the virtual buttons. I would need to do some detailed research to see if this can done. I can not give any timescale or guarantees.

 

Many LINDA users employ a mix of LINDA and FSUIPC4 actions using the best features of both. For example, FSUIPC4 is better from rapidly repeating operations than LINDA. 

Share this post


Link to post
Share on other sites

Hi Scot,

 

I just found this discussion looking for ways to assign SIOC Virtual Joystick Buttons to LINDA.

I don't really have to add anything but would like to say that I suppose that a lot of SIOC users would be very happy if those virtual joysticks could be detected by LINDA like any other joystick.

 

SIOC is extremely powerful but for beginners it is often a bit hard to program.

I think that the combination of SIOC/OpenCockpits hardware with LINDA (I just recently discovered LINDA's power, until then I programmed by SIOC and FSUIPC offsets) would be extremely helpful for the field of home cockpit newbies.

 

Best,

Florian

Share this post


Link to post
Share on other sites

Hi Florian

 

Welcome to the LINDA community forum. I have come across a virtual joystick by Headset called vJoy that presents itself to Windows as a virtual HID. FSUIPC4 and LINDA can read these as a HID device with axes, buttons and hats. It would require a SOIC module that did the same job.

Share this post


Link to post
Share on other sites

Hi Scot,

thanks a lot for the warm welcome.

I will suggest an interface or an additional card to the OpenCopckpits people. In principle they offer a joystick card, however only with 24 buttons. I plan to test it on the weekend if this card is recognised by LINDA. If you think of a more extensive cockpit you will soon need quite a few of the respective cards, but certainly that is something that can be overcome with a USB hub.

One of the things I miss in that context (and that will not work with those so called axes cards) is the use of encoders. With SIOC you can program a value to increase or decrease (e.g. a radio frequency). Alternatively you could of course also program the encoder to actuate a virtual joystick button #1 and #2 for, which could be used, e.g. for left or right movement of a heading bug etc.

I will keep you guys posted.

At this point also a very warm thank you to all of you who created this wonderful LINDA tool and all the applications to the different individual aircraft. It is so incredibly easy and intuitive to use, as close to plug and play as possible. If have seen few so useful, so powerful and so straight forward-to-use things in my life.

Thanks & best,

Florian

Share this post


Link to post
Share on other sites

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