noah
Almost Aviator
Posts: 13
|
Post by noah on Feb 6, 2015 5:17:45 GMT
Hey, Mark.
My project is coming along but I am still a long ways away from building any switches of my own. In the meantime I am hoping to use a second keyboard to account for various inputs. I am aware of programs like HIDmacro that allow you to treat a second keyboard like a joystick so as to assign unique commands, but I am wondering if you have any insight as to how I could link those commands to the Aerosoft Twin Otter functions. I can see the work that has gone into creating the Linda library file, so I was considering trying to link those programs (HIDmacro and Linda) to achieve my desired results. Unfortunately I think I am in over my head as far as programming this arrangement.
Any thoughts on how I can do this? In other words, how can I make "G" on the main keyboard trigger landing gear but have "G" on my second keyboard test the fire alarm or something equally unique to the Twotter?
Thanks for any advice you might have.
Best, -Noah
|
|
|
Post by MarkH on Feb 6, 2015 8:13:04 GMT
Hi Noah. I don't think you can do this wil LINDA as such because LINDA only maps buttons, not keystrokes. However, you can do it with FSUIPC because that can send keystrokes. To do this you would need to pull apart the Twin Otter LINDA library so each function is packaged in its own file. These can then be called directly from FSUIPC. It may not be quite that straightforward as anything that uses local Lua variables to preserve data between function calls will not work.
I will look at this later (no time now, I have to go to work!)
|
|
noah
Almost Aviator
Posts: 13
|
Post by noah on Feb 6, 2015 16:51:26 GMT
Thanks, Mark. I'd definitely be interested to hear more about how to merge the Lua files with FSUIPC, or any other possible solutions, whenever you get a chance.
-Noah
|
|
|
Post by MarkH on Feb 6, 2015 19:15:42 GMT
This is simple in principle but it may be a bit impractical in practice, depending on how many functions you want to implement. Here is an example for the Twin Otter. If you look at the LINDA library (fsx\modules\linda\aircrafts\Aerosoft_dhc6\actions.lua) you will find a function called 'Armrest_Up' and another called 'Armrest_Down':
function Armrest_Up() ipc.writeLvar("L:Twot_Armrest", 1) end
function Armrest_Down() ipc.writeLvar("L:Twot_Armrest", 0) end To map these to keys (or buttons), you need to do the following.
(1) Copy the BODY of the first function and paste it into a new text file called 'TWO_ArmrestUp.lua'. Save this file in the fsx\modules folder. (2) Copy the BODY of the second function and paste it into a new text file called 'TWO_ArmrestDown.lua'. Save this as before.
(file TWO_ArmrestUp) ipc.writeLvar("L:Twot_Armrest", 1)
(file TWO_ArmrestDown) ipc.writeLvar("L:Twot_Armrest", 0)
You will see that by 'the BODY' I mean you drop the 'function' and 'end' wrapper in each case. In slightly technical terms, instead of being implemented as functions these are now implemented as separate Lua programs. (If that distinction is lost on you, just ignore it.)
(3) Go to FSUIPC, find the 'Key Presses' tab, click 'Set' and press the key combination you want (e.g. CTRL+A). Now look in the 'Control to send when keys pressed' list and select the item called 'Lua TWO ArmrestUp'. Set the 'Control to send when main key released' to 'Lua TWO ArmrestDown'.
You should now find that this makes the armrest go up and down when you press and release CTRL+A. (This doesn't make much sense in practice, but the Toggle_Armrest function is slightly more complicated because it uses a helper function.)
That's basically it - you can do this for all the Twin Otter functions if you really want, but that's lot of functions! If you only want to do a few, there's no reason why it shouldn't be doable. Check out the FSUIPC documents for more details.
|
|
|
Post by MarkH on Feb 6, 2015 19:58:10 GMT
Actually, there is another way to organise this. A Lua program can take a parameter, which you can specify when you hook it up to a button or keystroke. This is available to the program in a variable called 'ipcPARAM'. This means you could, in principle, almost take the Twin Otter LINDA library and add something like this at the bottom:
if ipcPARAM ==1 then Feather_Left_Prop() elseif ipcPARAM == 2 then Unfeather_Left_Prop() elseif ipcPARAM == 3 then Feather_Right_Prop() elseif ipcPARAM == 4 then Unfeather_Right_Prop() elseif ipcPARAM == 5 then Gear_Down() elseif... etc. end
There are probably more sophisticated ways to do this conditional statement but I don't really know Lua.
The major disadvantage to this is that the entire Lua program runs and defines all the functions each time any one is invoked. This is probably slow. You can compile Lua programs, which might help speed things up, but some kind of compromise by splitting into smaller prorgams would probably be advisable.
|
|
noah
Almost Aviator
Posts: 13
|
Post by noah on Feb 7, 2015 14:42:33 GMT
Thanks again for taking the time to look into this for me. I will try to play around with what you've suggested and see what I can get to work. I'll let you know!
Best, -Noah
|
|
noah
Almost Aviator
Posts: 13
|
Post by noah on Feb 7, 2015 18:51:18 GMT
Hey, Mark. I tried the steps exactly as you described above but the actions to raise/lower the armrest aren't appearing in the FSUIPC controls list. I checked the entire list (under "A" for armrest, "T" for TWO... etc.) and it's not anywhere to be found. Any idea what I might be doing wrong?
As always, thanks for the time.
-Noah
|
|
|
Post by MarkH on Feb 7, 2015 19:58:05 GMT
Hey, Mark. I tried the steps exactly as you described above but the actions to raise/lower the armrest aren't appearing in the FSUIPC controls list. I checked the entire list (under "A" for armrest, "T" for TWO... etc.) and it's not anywhere to be found. Any idea what I might be doing wrong? It will say 'Lua TWO ArmrestUp', not just 'TWO ArmrestUp'. It is bascially the name of the file preceded by 'Lua '. The only other thing I can think is that you have put the files in the wrong place - they must be in the modules folder. Can you verify those things?
|
|
noah
Almost Aviator
Posts: 13
|
Post by noah on Feb 8, 2015 0:35:58 GMT
Ahh, sure enough. I must've moved too quickly through the "L's" on that massive list of input controls. I see "Lua TWO ArmrestUp" as well as "Set," "Toggle," "Kill," "Clear," etc. Now to assign about 50 more functions!
Best, -Noah
|
|
noah
Almost Aviator
Posts: 13
|
Post by noah on Feb 8, 2015 0:59:40 GMT
Well this is peculiar... I am trying to create commands for "DC Master Switch ON" and "DC Master Switch OFF" and I performed the identical steps for each function that I used to successfully modify the armrest command. For some reason DC Master Switch ON is showing up in FSUIPC (ie. Lua TWO_DCMasterSwOn) but Master Switch OFF is NOT showing up. Is there any reason you can think of why FSUIPC may not be picking up the OFF file?
Sorry for all these small questions but I am not used to working with any of the behind-the-scenes stuff in FSX.
Thanks!
-Noah
|
|
noah
Almost Aviator
Posts: 13
|
Post by noah on Feb 8, 2015 1:06:46 GMT
Here is a snip showing the files and their contents in the FSX Modules folder. Armrest UP and Master Switch ON are working but Master Switch OFF is not...
|
|
|
Post by MarkH on Feb 8, 2015 9:14:20 GMT
For some reason DC Master Switch ON is showing up in FSUIPC (ie. Lua TWO_DCMasterSwOn) but Master Switch OFF is NOT showing up. Is there any reason you can think of why FSUIPC may not be picking up the OFF file? Yes, the filenames are limited to 16 unique characters In other words, they can be as long as you want but anything after 16 (not including the '.lua') is ignored. That said, by my reckoning your filenames are unique in the 16th character, but I'd guess that's where the problem lies anyway.
|
|
noah
Almost Aviator
Posts: 13
|
Post by noah on Feb 8, 2015 18:48:17 GMT
Sure enough. "TWO_DCMasterSwOFF" is 17 characters. Shortening the name fixed the problem.
Thanks again!
-Noah
|
|
|
Post by MarkH on Feb 8, 2015 18:49:51 GMT
Sure enough. "TWO_DCMasterSwOFF" is 17 characters. Shortening the name fixed the problem. Great!
|
|
noah
Almost Aviator
Posts: 13
|
Post by noah on Feb 15, 2015 5:04:05 GMT
Hey, Mark. Can't seem to find the commands for "Vent Fan" ON/OFF in the actions.lua file. Any idea what I am missing?
As always, thanks for your time.
-Noah
|
|