Jump to content

Sioc to replicate Joystick/Keypress commands?


memento10

Recommended Posts

Can anyone tell me if it's possible to use Sioc to send joystick commands, or keypresses to DCS. I created this targeting panel but not having luck getting it to communicate.

I run Sioc on a 2nd computer... I found code that would work if it's running on the same PC by sending keystrokes but won't work from a remote PC.

 

I'd rather not buy a Keyboard Emulator if I don't have to. Any Suggestions?attachment.php?attachmentid=40946&stc=1&d=1279407786

 

 

IMG00186.jpg.23650706c74a0b663028575f6709697e.jpg

Link to comment
Share on other sites

common problem on network with SIOC

 

I can't confirm neither negate the fact SIOC may work on network or has to be on the main PC. I think it should be on main PC but I'm not sure.

 

Other bugs :

check network

check ports in lua files and sioc ini and config

 

order of launch of softwares is important, but I can't tell you what is the good one

 

version of touchpal software import [ if you use it ] , then see Oakes thread for details and comments about merging SIOC touhpal and BSVP

 

if you speek french, I know a user who made a pit with SIOC and BSVP and on network, (but I can't confirm SIOC is on main or not) ; he did it, but he reads and speaks very very bad english langage... it will be difficult to communicate with him directly

 

and many people is in holidays at this time

Link to comment
Share on other sites

Thanks for your quick reply Hellfrog.

 

I actually do have Sioc, Touchpal, BSVP all working and running on a client PC but my problem here is sending these particuliar commands:

 

Shkval Slew left, right, up down, center.

Track

Lock/Unlock Target

Gate Size

Zoom

 

There's just not these commands in Clickabledata.lua

 

So I'm guessing the only way is to send key press commands...?

Link to comment
Share on other sites

if you find an other way, you will certainly gain many reputation points on the forum !!! lOl

this is the problem with all commands not assigned in clikabledata.lua

 

I just think there is another option, but I can't test it at this time :

use a directX entry and assign that in BS directly, as for a HOTAS button...

that mean you need an interface card to emulate DirectX output to PC, but that should work...

interest / keyboard emulation ? I don't know ...

unless you have many usb sticks from garbage to recycle ...

Link to comment
Share on other sites

SIOC cannot generate keystrokes on another PC than the one it is running on. I am not familiar with the way SIOC interfaces with BS, but I guess it's a LUA-script that is talking to SIOC with the protocol IOCP? LUA is a powerful language. It may be possible to generate a keystroke in a LUA-script.

Digital-to-Synchro converter for interfacing real aircraft instruments - Thread

 

Check out my High Input Count Joystick Controller for cockpit builders, with support for 248 switches, 2 POV hats and 13 analog axes. Over 60 units sold. - B256A13

 

www.novelair.com - The world's most realistic flight simulators of the J35J Draken and the AJS37 Viggen.

Link to comment
Share on other sites

Lua will be running within the context of the DCS sim anyway, so it's pointless to have Lua send a keystroke to the OS, to then be handled by DCS. You might as well use the provided APIs to send the command directly. I would be very very surprised if this wasn't somehow possible. Even if ED doesn't publish it in the clickabledata.lua file, there are many other lua files that you can browse through to see if something looks promising. You can also try dumping the metatables to a file to check out all of the functions made available. Sure those particular commands may not be clickable from the virtual cockpit, but shouldn't all sim commands be exposed to Lua in some way? I'll look into this at home when I get a chance, I'm now curious too...

 

SIOC can't generate a remote keystroke, but does SIOC at least generate a TCP message that the virtual keystroke occurred? If so, whatever listening software on the sim computer (in this case export.lua script probably) can listen for those messages and respond with custom code as described above.

Link to comment
Share on other sites

SIOC can't generate a remote keystroke, but does SIOC at least generate a TCP message that the virtual keystroke occurred?

 

If SIOC communicates with a LUA-script over IOCP, it doesn't generate a message about a virtual keystroke. How do you set up SIOC to talk to BS? Does IOCP sound familiar? I know that with MS Flight Simulator you can have a module in SIOC which talks to FSUIPC. In that case it isn't IOCP. However I don't know if such modules are user-creatable, so that one exists for BS. If they aren't, then BS probably takes the IOCP-way.

 

IOCP is a very simple protocol that sends the values of the SIOC-variables whenever they change. Not even the name of the variable, only the number.


Edited by brydling

Digital-to-Synchro converter for interfacing real aircraft instruments - Thread

 

Check out my High Input Count Joystick Controller for cockpit builders, with support for 248 switches, 2 POV hats and 13 analog axes. Over 60 units sold. - B256A13

 

www.novelair.com - The world's most realistic flight simulators of the J35J Draken and the AJS37 Viggen.

Link to comment
Share on other sites

If SIOC communicates with a LUA-script over IOCP, it doesn't generate a message about a virtual keystroke. How do you set up SIOC to talk to BS? Does IOCP sound familiar? I know that with MS Flight Simulator you can have a module in SIOC which talks to FSUIPC. In that case it isn't IOCP. However I don't know if such modules are user-creatable, so that one exists for BS. If they aren't, then BS probably takes the IOCP-way.

 

IOCP is a very simple protocol that sends the values of the SIOC-variables whenever they change. Not even the name of the variable, only the number.

 

I think that because FSUIPC already defines its own protocol, that integrating SIOC with FSUIPC was a simple matter of translating IOCP messages sent to the IOCP server, into FSUIPC messages sent from the server to the sim software.

 

For DCS, no such protocol exists and instead we have export.lua to work with. You should be able to connect to IOCP server from export.lua and appear as an IOCP client by following the protocol. At that point, all event messages will be forwarded to the script from all other clients.

 

memento10 seems to have found something that he writes about in his thread on this topic:

inputEvents['JOY_BTN1'] = JOYSTICK_BUTTON0

while it doesn't mean much by itself, this appears to be proof that all input events are exposed to lua script and not just clickable events. What if it's just a simple matter of doing something like

sendInputEvent(inputEvents['KEY_C'])

to send a 'C' keypress to DCS? Of course, I made up the function name but there should be something like that available. Wish I was home now so I could find out for sure

Link to comment
Share on other sites

I have your answer guys

 

I used the Shkval Center command as my example, the following code will do it

 

   local dev = GetDevice(8)  -- 8 == SHKVAL
   dev:SetCommand(92)      -- 92 == Keys.iCommandPlaneRadarCenter

 

another example, lock/unlock shkval target, and toggle white/black

 

   dev:SetCommand(100)    -- 100 == Keys.iCommandPlaneChangeLock
   dev:SetCommand(846)    -- 846 == iCommandPlane_I251_Background_WhiteBlack

 

To find other commands browse SHKVAL_commands.lua, then look at command_defs.lua to find the corresponding command number

 

for other devices besides shkval browse to the appropriate folder and follow the same pattern.

Link to comment
Share on other sites

Great find! I will save this thread.

Digital-to-Synchro converter for interfacing real aircraft instruments - Thread

 

Check out my High Input Count Joystick Controller for cockpit builders, with support for 248 switches, 2 POV hats and 13 analog axes. Over 60 units sold. - B256A13

 

www.novelair.com - The world's most realistic flight simulators of the J35J Draken and the AJS37 Viggen.

Link to comment
Share on other sites

nice shot !

 

will study that ASAP !

 

[EDIT]

files are in .\scripts\aircrafts\ka50 and .\scripts\aircrafts\ka50\cockpit

 

once you have looked it and read it, it seems to be so easy... but it wasn't... as no one said it before !


Edited by C6_Hellfrog
Link to comment
Share on other sites

Thanks so much guys for help in figuring this out!

 

I understand how you're getting the corresponding numbers from those files... but how do I connect a switch on a client PC to control them?

 

I add that script to SiocConfig.lua on the BS computer?

Link to comment
Share on other sites

Put the following new function at the end of your ExportSupport.lua file

 

-- Calls non-clickable commands without parameters for two-position switch
function TwoPositionSwitch_NCC_noparam(pDevice, pCommandNumber)
    GetDevice(pDevice):SetCommand(pCommandNumber)
end

 

Then, in your siocConfig.lua file, add the switch definition

local SIOCNbr = 0 -- insert your correct SIOC button number here for shkval center

inputsTable = {
  ...
  [sIOCNbr] = {TwoPositionSwitch_NCC_noparam, 8, 92},
  ...
}

 

just keep in mind that this code is not tested at all

 

I'm taking a leap of faith here that SIOC is actually passing the switch event to the sim machine just like all other events. If it's not coming through, try configuring it as a standard switch with SIOC, instead of as a key emulation type.

Link to comment
Share on other sites

a file for work in progress to save time

 

commands_defs : this file contains many keys, but not sorted by device order, so I managed to process lua files to sort a bit all that stuff and compile it in an exel sheet.

 

compiling files *.lua in .\scripts\aircrafts\ka50\cockpit and commands_def.lua and devices.lua :

 

exel sheet with device_name, deviceID, key_name, key_ID, sorted by devices : see linked file xls 2010 format

 

lines from commands_defs.lua not in this sheet are keynames not investigated at this time : need to process lua files in sub folders from .\scripts\aircrafts\ka50\cockpit... will update when achieved...

 

it is work in progress

 

if anyone has corrections to add or remarks... appreciated...

 

since all interested peolple by this thread will have to search these informations, if it may save some time, it is usefull...

 

EDIT :

file removed : see post 21 for an update


Edited by C6_Hellfrog
Link to comment
Share on other sites

working on it... will test with touchpal (stil don't have SIOC, but same way of working) from this WE, and post results ASAP...

 

Oh I know it works standalone, tested yesterday. I meant the SIOC bits are untested, I wanted to help out memento10 with his SIOC issue.

Link to comment
Share on other sites

I wanted to help out memento10 with his SIOC issue

 

and you did it very well ! many other people had the same problem as memento10 !

 

 

One question more :

for many actions you may use the classic 'performclickableAction' way or this new 'getdevice:setcommand' way...

is there a difference between the two ones ? I think about FPS hit on large export.lua files or on complex stuff (SIOC multiscreen BSVP BS network) ?


Edited by C6_Hellfrog
Link to comment
Share on other sites

nice work on the speadsheet, that will be helpful!

 

regarding your question, I'm not sure of the difference between the clickableaction method and the setcommand method. I think in the end they probably accomplish the same thing, and I doubt there is any difference in performance. I would say use the one you like better. Do clickableaction calls work from an external view?

Link to comment
Share on other sites

Well I've been trying to get this working without any luck but I wonder if I'm making any silly mistakes.

 

First I added this code to the ExportSupport.lua:

 

-- Calls non-clickable commands without parameters for two-position switch

function TwoPositionSwitch_NCC_noparam(pDevice, pCommandNumber)

GetDevice(pDevice):SetCommand(pCommandNumber)

end

 

Then I created the Sioc variable on the client PC as follows with the physical switch 136 and using variable 485. I created this as a switch:

 

Var 485 , name ShkvalCenter, Link IOCARD_SW, Input 136

 

Then I added the following code to SiocConfig.lua:

 

inputsTable = {

...

[485] = {TwoPositionSwitch_NCC_noparam, 8, 92},

...

}

 

Is there anything obvious I'm doing that you think would be a problem? I checked the Error Log but saw no problems regarding this code. When I press the button... the Shkval doesn't center.

 

Really appreciate everyone's help with this, I'm sure many others will also appreciate this solution!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...