Jump to content
The simFlight Network Forums

Multiple keyboard support for FSUIPC


Recommended Posts

Hi Pete,

Can you use FSUIPC with multiple keyboards. For example keypress A on the main keyboard will register as an "A" in the keypress menu, but keypress A on the second keyboard will register as "KB2 A" or whatever.

Only other program I know that can do that is HidMacros, but it seems only to output to SIMConnect and not to FSUIPC. I want to use multiple keyboards to action Mouse Macros created with FSUIPC for LevelD B767.

Regards

Henco

Link to comment
Share on other sites

Can you use FSUIPC with multiple keyboards. For example keypress A on the main keyboard will register as an "A" in the keypress menu, but keypress A on the second keyboard will register as "KB2 A" or whatever.

No, because of two reasons:

1. All the current FSUIPC keyboard support entails is intercepting the KEYDOWN and KEYUP messages which FS would otherwise receive. If they aren't programmed in FSUIPC it simply passes them on.

2. As far as I am aware ALL keyboards on a Windows PC are just THE keyboard. There's certainly no way I know of differentiating between them at normal application level. Maybe a special driver would be able to separate them off and somehow deliver different messages as a result, but if anyone went to such lengths they'd be better off treating them as a full HID device like a joystick or other gaming device with buttons.

Only other program I know that can do that is HidMacros

Sounds like the sort of driver I just suggested. ;-)

..but it seems only to output to SIMConnect and not to FSUIPC

And what does it tell SimConnect?

[LATER]I just Googled HidMacros, and it appears it deals with FSUIPC too now? Here's what it says about the release two days ago:

31.10.2010 - Version 2.0 for beta testing

The application was improved with scripting support. Also iterfacing possibilities were extended (FSX variables, FSUIPC)

Interesting program! Thanks for pointing it out to me!

Regards

Pete

Link to comment
Share on other sites

Wow that was quick!.

Thanks for the expeditious reply on my problem.

Yes I have seen the scripting option in HidMacros 2 Beta but unforunately the examples given is way over my head. Would love it if they could make an extra tab for FSUIPC like the one they have for SIMCONNECT, so that created mousemacros will then show as an option inside the HidMacros program. Registred FSUIPC users only off course.

No, because of two reasons:

1. All the current FSUIPC keyboard support entails is intercepting the KEYDOWN and KEYUP messages which FS would otherwise receive. If they aren't programmed in FSUIPC it simply passes them on.

2. As far as I am aware ALL keyboards on a Windows PC are just THE keyboard. There's certainly no way I know of differentiating between them at normal application level. Maybe a special driver would be able to separate them off and somehow deliver different messages as a result, but if anyone went to such lengths they'd be better off treating them as a full HID device like a joystick or other gaming device with buttons.

Sounds like the sort of driver I just suggested. ;-)

And what does it tell SimConnect?

[LATER]I just Googled HidMacros, and it appears it deals with FSUIPC too now? Here's what it says about the release two days ago:

Interesting program! Thanks for pointing it out to me!

Regards

Pete

Link to comment
Share on other sites

Yes I have seen the scripting option in HidMacros 2 Beta but unforunately the examples given is way over my head. Would love it if they could make an extra tab for FSUIPC like the one they have for SIMCONNECT, so that created mousemacros will then show as an option inside the HidMacros program. Registred FSUIPC users only off course.

Sorry, I didn't delve as far as looking at their examples, but I assume they will be just about reading and writing offsets?

To invoke a macro (any FSUIPC macro, not just a "mouse macro") all you need to do is write offsets as follows:

First write the parameter value, if there is one, to offset 0x0D70. Write this as a normal integer (it might be called a DWORD -- it is 4 bytes long, or 32 bits. The parameter is whatever value you would put in the 'parameter' field in the FSUIPC key assignments.

Then write the complete macro name as a string to offset 0x0D70. This is the same as the name yuo see in the assignments drop-down, consisting of the MCRO filename, then a '.' then the macro name inside the file.

Lua plug-ins can be run the same way.

Regards

Pete

Link to comment
Share on other sites

Hi Peter,

Yes, read and write. Here is an example from Hidmacro page.

HIDmacros brings several functions to read and write variables through FSUIPC. To use those functions FSUIPC of course must be installed.

view plaincopy to clipboardprint?

  1. HIDMacros.GetFSUIPCInt offset, size
  2. HIDMacros.GetFSUIPCFloat offset, size
  3. HIDMacros.GetFSUIPCString offset, size
  4. HIDMacros.GetFSUIPCRaw offset, size
  5. HIDMacros.SetFSUIPCInt offset, size, value
  6. HIDMacros.SetFSUIPCFloat offset, size, value

HIDMacros.GetFSUIPCInt offset, sizeHIDMacros.GetFSUIPCFloat offset, sizeHIDMacros.GetFSUIPCString offset, sizeHIDMacros.GetFSUIPCRaw offset, sizeHIDMacros.SetFSUIPCInt offset, size, valueHIDMacros.SetFSUIPCFloat offset, size, value Parameters are:

offsetvariable's memory offset from FSUIPC SDK.sizesize of variable in bytes, also mentioned in SDKvaluevalue to be setoffsetvariable's memory offset from FSUIPC SDK.OFFSET variable's memory offset from FSUIPC SDK

SIZE size of variable in bytes, also mentioned in SDK

VALUE value to be set

Size parameter tells how many bytes will be read or written. For int functions (GetFSUIPCInt and SetFSUIPCInt) this can be between 1 and 8. For float functions only size 4 and 8 bytes is supported (float or double float). Function GetFSUIPCRaw read part of memory and return string representing memory dump. It means every byte is represented by 2 characters in hex format, for example byte 44 would be returned as 2C. Strings can be only read.

Example

view plaincopy to clipboardprint?

  1. ' read
  2. Dim isPaused </SPAN>
  3. Set isPaused = HIDMacros.GetFSUIPCInt &H262, 2 </SPAN>
  4. Dim rawClock </SPAN>
  5. Set rawClock = HIDMacros.GetFSUIPCRaw &H238, 3 </SPAN>
  6. ' write </SPAN>
  7. HIDMacros.SetFSUIPCInt &H262, 2, 1 'pause sim </SPAN>
  8. HIDMacros.SetFSUIPCInt &H330, 2, 16096 'alt set 1006 mBars

Okay so here's my question. If I want to activate the following mouse macro I have created (Macro filename VACO.MCRO)

[Macros]

Module="B767main.GAU"

1=TCAS Display=RX30e0*Xa1cc

What do I write in the Hidmacros scriptpage? Sorry if I come across desperate, programming is not my field, so the learning curve is a bit steep for me.

</SPAN>

Link to comment
Share on other sites

Yes, read and write. Here is an example from Hidmacro page.

You'd use

HIDMacros.SetFSUIPCInt

to set the parameter to 0x0D6C and you'd want a SetFSUIPCString to set the string to 0x0D70, but I don't see it in your list. In fact I now see it says "Strings can be only read", so what I suggested cannot be done with HidMacros. You should write in the forum and ask whether a facility to write strings can be added.

I do see that HidMacros uses &H to demnote hexadecimal values, not the 0x I'm used to, so where I say 0x0D6C he would have &H0D6C

Okay so here's my question. If I want to activate the following mouse macro I have created (Macro filename VACO.MCRO)

...

1=TCAS Display=RX30e0*Xa1cc

What do I write in the Hidmacros scriptpage?

If the facility was provided then the string written to 0D70 would be

"VACO:TCAS Display"

This is the same thing you'd see if you looked in the FSUIPC assignments drop-down, as I did explain to you. Don't you remember?

You don't have any parameters to that macro, so you igonre offset 0D6C.

Until HidMacros supports string writing to offsets then the only other way I can see of using it would be to use some of the 512 "virtual buttons" in FSUIPC. You'd program HidMacros to send offset changes to let FSUIPC see the button press, and then program your Macros in FSUIPC just as if you were using real buttons. Best way to proceed with that would be to assign buttons to all the keys on the extra keyboard first, then go through, in FSUIPC, assigning as you wish. It would actually be more flexible this way as you could make the assignments aircraft or profile-specific, which you couldn't very easily the other way.

I'm surprised HidMacros doesn't offer the option to convert keyboard presses into joystick button presses. Have you checked?

If no, then to use FSUIPC's virtual buttons you need to do something like this (this is NOT HidMacro language, just English explanation):

PRESSING BUTTON 64,0

Read the byte (length 1) from &H3340

OR 1 into that byte

Write that byte, length 1, back to &H3340

RELEASING BUTTON 64,0

Read the byte (length 1) from &H3340

AND 254 with that byte

Write that byte, length 1, back to &H3340

For buttons 64,1 to 7, the value '1' doubles each time: 2, 4, 8, 126, 32, 64, 128

and the value '254' is always 255 minus that value.

For buttons 64,8-15 it is exactly the same but with offset &H3341,

and so on... you can have 512 buttons. Note that in hexadecimal, the offsets run 3341, 3342 ... 3349, 334A ... 334F then 3350 ... 335F ... etc. But you already have 8 x 10 = 80 buttons in the easy range 3340 to 3349 inclusive.

I am sorry, but that's as far as I can go. I do not have time to learn HidMacro programming. For help with HidMacros, UI suggest you use their Forum. I should think the author would be delighted to help.

Regards

Pete

Link to comment
Share on other sites

You'd use

HIDMacros.SetFSUIPCInt

I thought of a way to do this which might be a little simpler for you, using the virtual buttons I mentioned. Note that there are 288 of them, not 512 like I said earlier. Should be enough, though? ;-)

There are some user-offsets available in FSUIPC. You could use one of them to send a number to FSUIPC, using HIDMacros.SetFSUIPCInt and have a Lua plug-in to convert that to a button press for assignment in FSUIPC.

Save the following code as "ipcReady.lua" into your FS Modules folder:

function sendmybutton(off, val)
   if (val &gt;= 0) and (val &lt; 288) then
 	ipc.btnToggle(val)
 	ipc.writeUW(0x66C0,-1)
  end
end

ipc.writeUW(0x66C0,-1)
event.offset(0x66C0, "UW",  "sendmybutton")

Your HidMacros now only need to do something like:

HIDMacros.SetFSUIPCInt &H66C0, 2, N

where N is any number from 0 to 287 inclusive. Send a different value for each key. Then that Lua plug-in will convert the keypress to button events which you casn assign as usual in FSUIPC's buttons tab.

By way of explanation, the "event.offset" call at the end of that little Lua program causes FSUIPC to call the function "sendmybutton" whenever offset 66C0 (an unsigned word = 2 bytes) changes. To make sure we see changes even if you press the same key more than once in succession (or allow it to repeat) we reset offset 66C0 to -1 initially and after each change we see.

Okay?

Note that I'm here assuming you want the keyboard(s) to behave like keyboards not like joystick buttons, so I'm "toggling" the button. If you want a Key press to press the button and a key release to release the button things get a little more complex. We'd have to flag the difference between press and release by sending a different range of numbers for each, and the function in the plug-in would then use ipc.btnPress and ipc.btnRelease instead of ipc.btnToggle.

Regards

Pete

Link to comment
Share on other sites

Well I guess the easiest solution would be to add SetFSUIPCString method to HIDmacros object :-).

As I mentioned somewhere on the page - no problem to add if I see some need.

Triggering FSUIPC macros would be nice feature, so I can add it next build.

The only problem I can have would be with testing, because I don't have paid FSUIPC and I'm not sure if there's another writeable string I can use for test...

Regards

Petr

HIDmacros author

Link to comment
Share on other sites

  • 7 months later...
  • 1 month later...

Pete, (I hope you see this :) )

I have a question along the lines of information from HIDMacros to FSUIPC/Lua.

From a script in hidmacros I'm running a Lua script through FSUIPC by calling this (thanks to Petr recently adding the SetFSUIPCString call):

HIDMacros.SetFSUIPCString &amp;HD70, 40, "Lua testlua"

But at the same time I want to pass a parameter (a string) to that program. I tried the parameter offset like this (before the above line):

HIDMacros.SetFSUIPCString &amp;HD6C, 4, "mystring"      (not sure if SetFSUIPCString is correct and if I can max write 4 chars/bytes!)

But when I access the ipcPARAM variable within the Lua script it always translates to some number which I can't use for anything. Any idea how to solve this, or any other idea how to pass a string to a Lua program? I could maybe write it to a file from within hidmacros and then read that file from Lua but I would guess that would be inefficient?!!

-Allan

Link to comment
Share on other sites

Pete, (I hope you see this :) )

I'm still here so I see it, but I don't understand why it is posted within a thread entitled "Multiple keyboard support for FSUIPC".

HIDMacros.SetFSUIPCString &amp;HD70, 40, "Lua testlua"

But at the same time I want to pass a parameter (a string) to that program. I tried the parameter offset like this (before the above line):

HIDMacros.SetFSUIPCString &amp;HD6C, 4, "mystring"      (not sure if SetFSUIPCString is correct and if I can max write 4 chars/bytes!)

Two things:

1. The parameter must be written BEFORE the 0D70 write, as it is the latter which triggers the action.

2. The parameter is a NUMBER, not a STRING!

But when I access the ipcPARAM variable within the Lua script it always translates to some number which I can't use for anything.

The number is probably derived from the first 4 ASCII character values: "myst" would give 0x7473796D.

Any idea how to solve this, or any other idea how to pass a string to a Lua program?

Well, certainly not via an integer parameter. You could use the user offsets 66C0 - 66FF if your string isn't too long (max 63 characters + 0 terminator there).

What's the application? Could the string be anything, or only one of a known set of strings? If the latter it would be better to make a table in the Lua of all the strings which can be used and then just pass the index as the ipcPARAM.

Regards

Pete

Link to comment
Share on other sites

  • 6 months later...

hello, could you help me with this problem, i create a macro mouse for NGX PMDG, so im using this script

HIDMacros.SetFSUIPCString &H0D70,40,"NGX: RightLightLand" i assing it to a letter in 2nd Keyboard but the macro does not execute in FSX

Im using HIDMacros 2.2 and FSUIPC 4.30

Could you help me to find a way to execute FSUIPC Mouse macros in 2nd Keyboard as Overhead Panel

thank u so much

Link to comment
Share on other sites

If you have a license for version 4, you have a license for ALL version 4.xx releases - you don't need to buy it again.

At the top of the support forum, there is a "download links" thread, which will take you directly to the latest installer.

Cheers,

Ian P.

Link to comment
Share on other sites

If you have a license for version 4, you have a license for ALL version 4.xx releases - you don't need to buy it again.

At the top of the support forum, there is a "download links" thread, which will take you directly to the latest installer.

Cheers,

Ian P.

thanks u,

so i update my fsuipc, so how can i link mouse macros to HIDMacros for use a 2nd keyboard to simulate an overhead

Link to comment
Share on other sites

so i update my fsuipc, so how can i link mouse macros to HIDMacros for use a 2nd keyboard to simulate an overhead

I don't know HIDMacros, but your previous effort wouldn't work because you were using a very old version of FSUIPC which didn't have the facilty you were trying. So what's he problem now?

Pete

Link to comment
Share on other sites

I don't know HIDMacros, but your previous effort wouldn't work because you were using a very old version of FSUIPC which didn't have the facilty you were trying. So what's he problem now?

Pete

How Can I use virtual buttons ?? how can i create virtual joysticks???

Thanks u so much

Oscar

Link to comment
Share on other sites

Save the following code as "ipcReady.lua" into your FS Modules folder:

function sendmybutton(off, val)

if (val >= 0) and (val < 288) then

ipc.btnToggle(val)

ipc.writeUW(0x66C0,-1)

end

end

ipc.writeUW(0x66C0,-1)

event.offset(0x66C0, "UW", "sendmybutton")

Your HidMacros now only need to do something like:

HIDMacros.SetFSUIPCInt &H66C0, 2, N

i did it, but now i dont know how to link it with the virtual buttons :(

Link to comment
Share on other sites

i did it, but now i dont know how to link it with the virtual buttons :(

I don't know what "it" is in that statement. Link what?

Why not just assign the buttons to whatever you want them to do, in FSUIPC's button assignments Tab? That's the whole reason for setting the buttons, surely?

I don't understand how this relates to your original question on invoking a macro by using offset 0D70. Have you changed subjects?

Regards

Pete

Link to comment
Share on other sites

I don't know what "it" is in that statement. Link what?

Why not just assign the buttons to whatever you want them to do, in FSUIPC's button assignments Tab? That's the whole reason for setting the buttons, surely?

I don't understand how this relates to your original question on invoking a macro by using offset 0D70. Have you changed subjects?

Regards

Pete

My main goal is can assign macro mouse creates with FSUIPC for PMdG 737NGX throught HIDMacros to a 2nd keyboard. And emulate it as overhead panel. So. My question is, : whats the best way to do that?.Thank u very much

Link to comment
Share on other sites

My main goal is can assign macro mouse creates with FSUIPC for PMdG 737NGX throught HIDMacros to a 2nd keyboard. And emulate it as overhead panel. So. My question is, : whats the best way to do that?.Thank u very much

Either of the two ways you've discovered would work. The one using virtual buttons gives you more flexibility in that you can assign the buttons as you like, and change them more easily, or assign then differently for different aircraft (using profiles).

Pete

Link to comment
Share on other sites

Save the following code as "ipcReady.lua" into your FS Modules folder:

function sendmybutton(off, val)

if (val >= 0) and (val < 288) then

ipc.btnToggle(val)

ipc.writeUW(0x66C0,-1)

end

end

ipc.writeUW(0x66C0,-1)

event.offset(0x66C0, "UW", "sendmybutton")

Your HidMacros now only need to do something like:

HIDMacros.SetFSUIPCInt &H66C0, 2, N

I understan all at this point, my question is how to assing this to a virtual button, how can i create virtual buttons

ex: i run this script in HIDMacros for letter Q in 2nd Keyboard

HIDMacros.SetFSUIPCInt &H66C0, 2, 1

Now how can i connect it for the macro NGX.MCRO

1="TaxiLights"

I want to turn on TaxiLights when i press Q on 2nd Keyboard (Q in 1st Keyboard is for Sound ON/off)

FSX->Menu->Complements->FSUIPC->Swicht and Buttons, so what i have to do in the next step??

thank u so much

Link to comment
Share on other sites

  • 10 months later...

Hello.

Before nothing publicly thank Pete Dowson for the magnificent work done with FSUIPC, believe that the world community of Airsimmers you will be forever grateful.

I use:

FS9 under Windows 7 x 64

FSUIPC. 3999w (registered version).

HIDMacros 2.3.0.676 Beta.

As already explained in this thread my intention is to use a second keyboard with which to be able to send commands to FS9 using HIDMacros and FSUIPC. I've created the ipcReady.lua file with notepad and I have placed it in the folder modules of FS9, this has been recognized in the file.Ini file as follows:

[LuaFiles]

1=ipcReady.lua

20130119005035.jpg

In HIDMacros I have created the following:

20130119001334.jpg

a>20130119003227.jpg

This is the .MCRO file

20130119003847.jpg

My intention is that pressing the "Q" key on the secondary keyboard "kbd1" on the aircraft the "Emergency Lights" illuminate for example.

I've tried this in different ways and many days I've been trying to find a way to do it but I confess incapable.

You would greatly appreciate if someone could help me.

Thank you very much.

P.D.

Unfortunately I don't speak English so I used a translator for this purpose, I hope with this translation does not create any international conflict.

Sorry for this.

Link to comment
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
×
×
  • 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.