Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi Pete,

 

I'm trying to send key presses to FSX using the 1070 control sent via offset 0x3110. (FSUIPC Version 4.938f).

 

In my test I'm using the 'L' key to toggle the lights. According to the logging the key seems to be getting through and is sent, but the lights do not toggle.

 

Here's me pressing 'L' on the keyboard: - the lights get toggled.

  2202204 KEYDOWN: VK=76, Waiting=0, Repeat=N, Shifts=0
  2202204 .. Key not programmed -- passed on to FS
  2202204 *** EVENT: Cntrl= 65574 (0x00010026), Param= 0 (0x00000000) ALL_LIGHTS_TOGGLE
  2202266 KEYUP: VK=76, Waiting=0

This is my program sending the 1070 control via 3110. All seems okay and the log is reporting the [L] key press being made, but the lights control is not triggered.

  2205360 WRITE repeated 1 times
  2205360 WRITE0[2788]  3114,   4 bytes: 4C 00 00 00                                      L...
  2205360 WRITE0[2788]  3110,   4 bytes: 2E 04 00 00                                      ....
  2205360 FSUIPC Control Action: Ctrl=1070, Param=76
  2205360 SendKeyToFS(0000004C=[L], KEYDOWN) ctr=0
  2205360 Sending WM_KEYDOWN, Key=76 (Scan code 38), Ctr=1
  2205500 SendKeyToFS(0000004C=[L], KEYUP) ctr=0
  2205500 Sending WM_KEYUP, Key=76 (Scan code 38), Ctr=1

Have I got something wrong here or have I misunderstood what 1070 is meant to do?

 

Thanks,

 

Paul

Posted

Hi,

 

Why aren't you toggeling the lights directly by sending the right control via FSUIPC or by setting the correct offset? Check the documents provided with FSUIPC. Much easier and straight forward out of LUA directly. No need to take the bypass via keys.

 

Rgds

Reinhard

Posted

I'm only using the L key as a basic test to prove the concept of sending key presses to FSX via the documented control. I'm not really asking about lights.

 

Paul

Posted

I'm only using the L key as a basic test to prove the concept of sending key presses to FSX via the documented control. I'm not really asking about lights.

 

What had the keyboard focus at the time? It will be that window which receives the keystroke.

 

You can easily test using a little Lua, thus:

 

ipc.writeUD(0x3114, 0x4c)
ipc.writeUD(0x3110, 1070)
 
Save as, say "test3110.lua", assign a button to it, and press it whilst FS still has focus. Then the log looks like this (with button logging adding to what you have):
 
  1261455 Button changed: bRef=0, Joy=101, Btn=0, Pressed
  1261455 [buttons] 22=P101,0,CL115:R,0
  1261455 JoystickValues PCnum=0, dwCount=1, data[2]={00000065 00000001}
  1261470 LUA.0: beginning "E:\Steam\steamapps\common\FSX\Modules\test3110.lua"
  1261486 WRITElua 3114,   4 bytes: 4C 00 00 00                                      L...
  1261517 WRITElua 3110,   4 bytes: 2E 04 00 00                                      ....
  1261517 FSUIPC Control Action: Ctrl=1070, Param=76
  1261517 SendKeyToFS(0000004C=[L], KEYDOWN) ctr=0
  1261517 LUA.0: ended "E:\Steam\steamapps\common\FSX\Modules\test3110.lua"
  1261517 Sending WM_KEYDOWN, Key=76 (Scan code 38), Ctr=1
  1261548 KEYDOWN: VK=76, Waiting=0, Repeat=N, Shifts=0
  1261548 .. Key not programmed -- passed on to FS
  1261548 *** EVENT: Cntrl= 65574 (0x00010026), Param= 0 (0x00000000) ALL_LIGHTS_TOGGLE
  1261580 Button changed: bRef=0, Joy=101, Btn=0, Released
  1261580 JoystickValues PCnum=0, dwCount=1, data[2]={00000065 00000000}
  1261642 SendKeyToFS(0000004C=[L], KEYUP) ctr=0
  1261642 Sending WM_KEYUP, Key=76 (Scan code 38), Ctr=1
  1261673 KEYUP: VK=76, Waiting=0
 
Regards
Pete
:
Posted

Hi Pete,

 

I misunderstood then. I thought this would send the keypress to the FSX window as the name suggests as opposed to the active window. My C# program has the focus and that's trying to send a key press through to FSX. I'll have to give focus to the FSX window first.

 

Thanks,

 

Paul

Posted

I misunderstood then. I thought this would send the keypress to the FSX window as the name suggests as opposed to the active window. My C# program has the focus and that's trying to send a key press through to FSX. I'll have to give focus to the FSX window first.

 

Paul, there IS a control in FSUIPC to restore focus to FSX. It is 1125. Here's the text from the History document describing all this (it was introduced in version 4.70 in April 2011.

 

·         Two new facilities are added to allow users to ensure keypresses assigned to buttons (or sent by external programs as FSUIPC controls)  are directed to the main FS window for processing. This would normally  be the case except that folks using Windows external to FS might be  changing the keyboard focus away from the main FS window. Using a touchscreen, for instance, moves the keyboard focus even though it is the mouse which is activated by touch.

The two facilities are for use in different user circumstances. First, you can add the line

        KeyboardFocus=Yes

into the main [buttons] section in the FSUIPC.INI file. This will  make FSUIPC restore focus to the main FS window every time it is asked  to send a keypress. The FS window will become the foreground window at  the same time.

The second is an alternative for use by more ambitious users who wish to  retain focus elsewhere for some keypresses. It is the addition of a new assignable control called "key focus restore" (number 1125) You  can assign this to a button separately to restore the focus when you  need to, or use multiple assignments just with those buttons intended to send keypresses to FS. Multiple assignments either means editing the INI to make the additional assignment to the same button press, or else just assigning the key focus restore control to the 'press' and the keypress sending to the 'release'. In this case you'd need to use the "key press and release" control for the keypress action instead of programming it directly on the left-hand side of the button assignments tab.

 

 

Hope this is useful!

 

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.