Jump to content
The simFlight Network Forums

Coding help for Virtual joystick


Recommended Posts

Hi

Hope someone can help me with a small virtual button coding challenges in FSUIPC.

I need codes for the following:

When changing button 17 on virtual joystick 65 from value 0 to 1, I want FSUIPC to send the keypress SHIFT F4.

When changing the same button from value 1 to 0, I want to send the keypress SHIFT F4 twice in a row

I now have the following, but it doesn't work

96=CP(F-65,17)65,17,K112,10

97=CU(F-65,17)65,17,K112,10

98=CU(F-65,17)65,17,K112,10

I have read the manual and tried several variations of CU and CP command with FLAG and without,but can't find the correct combination.

rgs,

Roar K

Edited by roa
Link to comment
Share on other sites

I need codes for the following:

When changing button 17 on virtual joystick 64 from value 0 to 1, I want FSUIPC to send the keypress SHIFT F4.

When changing the same button from value 1 to 0, I want to send the keypress SHIFT F4 twice in a row

Well you can program both initially in the Button assignments in FSUIPC. Just toggle your "virtual button" so that FSUIPC sees it, assign the Shift F4 key press to both "press" and "release", then edit the INI and duplicate the release line (U64,0 ...) with a new sequence number, and you are done.

I now have the following, but it doesn't work

96=CP(F-65,17)65,17,K112,10

97=CU(F-65,17)65,17,K112,10

98=CU(F-65,17)65,17,K112,10

I have read the manual and tried several variations of CU and CP command with FLAG and without,but can't find the correct combination.

Why are you using a Flag? The change of a button from 0 to 1 is called "pressing" the button, and from 1 to 0 is "releasing". Or for a toggle, "on" and "off" respectively. What is the flag for?

And if you are using 64,17 as you say, why do your parameters refer to 65,17?

I can't work out what you are trying to use flags for. And the above doesn't make sense at all, so I can't even guess.

Regards

Pete

Link to comment
Share on other sites

Well you can program both initially in the Button assignments in FSUIPC. Just toggle your "virtual button" so that FSUIPC sees it, assign the Shift F4 key press to both "press" and "release", then edit the INI and duplicate the release line (U64,0 ...) with a new sequence number, and you are done.

Why are you using a Flag? The change of a button from 0 to 1 is called "pressing" the button, and from 1 to 0 is "releasing". Or for a toggle, "on" and "off" respectively. What is the flag for?

And if you are using 64,17 as you say, why do your parameters refer to 65,17?

I can't work out what you are trying to use flags for. And the above doesn't make sense at all, so I can't even guess.

Regards

Pete

I shall try to explain my challenge a little better this time.

I have now the following in my FSUIPX config file:

96=P65,17,K79,8 // ( my EFIS VOR1/ADF1 hardware switch is switched to VOR1 pos and a O key is sent to NGX and VOR1 is selected)

97=U65,17,K79,8 //(my EFIS VOR1/ADF1 hardware switch is switched to middle pos from VOR1 pos and a O key is sent to NGX and ADF1 is selected, should be in the middle pos in the software aswell so another O key sent by FSUIPC is needed , therefore the second U press below(105 )

98=P65,19,K73,8

99=U65,19,K73,8

100=P65,18,K79,8 //(my EFIS VOR1/ADF1 hardware switch is switched to ADF1 pos and a O key is sent to NGX and VOR1 is selected, should be in the ADF1 in the software aswell so another O key sent by FSUIPC is needed , therefore the second P press below(101 )

101=P65,18,K79,8

102=P65,20,K73,8

103=P65,20,K73,8

104=U65,17,K79,8

105=U65,18,K79,8 //(my EFIS VOR1/ADF1 hardware switch is switched to middle pos from ADF1 pos and a O key is sent to NGX and middle pos is selected)

106=U65,19,K73,8

107=U65,20,K73,8

Logging result:

[Continuation log requested by user]

Running inside FSX on Windows 7 (using SimConnect Acc/SP2 Oct07)

Module base=61000000

Wind smoothing fix is fully installed

6177671 System time = 08/11/2011 14:00:36, Simulator time = 14:33:06 (12:33Z)

6197888 Button changed: bRef=0, Joy=65, Btn=17, Pressed

6197888 [buttons] 96=P65,17,K79,8

6197888 SendKeyToFS(0000004F=[O], KEYDOWN) ctr=0

6197888 [buttons] 97=U65,17,K79,8

6197888 [buttons] 104=U65,17,K79,8

6197888 Sending WM_KEYDOWN, Key=79 (Scan code 24), Ctr=1

6198013 SendKeyToFS(0000004F=[O], KEYUP) ctr=0

6198013 Sending WM_KEYUP, Key=79 (Scan code 24), Ctr=1

6198044 KEYUP: VK=79, Waiting=0

6199183 Button changed: bRef=0, Joy=65, Btn=17, Released

6199183 [buttons] 96=P65,17,K79,8

6199183 [buttons] 97=U65,17,K79,8

6199183 SendKeyToFS(0000004F=[O], KEYDOWN) ctr=0

6199183 [buttons] 104=U65,17,K79,8

6199183 SendKeyToFS(0000004F=[O], KEYDOWN) ctr=1

6199183 Sending WM_KEYDOWN, Key=79 (Scan code 24), Ctr=2

6199199 Sending WM_KEYDOWN, Key=79 (Scan code 24), Ctr=1

6199308 SendKeyToFS(0000004F=[O], KEYUP) ctr=0

6199308 Sending WM_KEYUP, Key=79 (Scan code 24), Ctr=1

6199339 KEYUP: VK=79, Waiting=0

6203442 Button changed: bRef=0, Joy=65, Btn=18, Pressed

6203442 [buttons] 100=P65,18,K79,8

6203442 SendKeyToFS(0000004F=[O], KEYDOWN) ctr=0

6203442 [buttons] 101=P65,18,K79,8

6203442 SendKeyToFS(0000004F=[O], KEYDOWN) ctr=1

6203442 [buttons] 105=U65,18,K79,8

6203442 Sending WM_KEYDOWN, Key=79 (Scan code 24), Ctr=2

6203458 Sending WM_KEYDOWN, Key=79 (Scan code 24), Ctr=1

6203567 SendKeyToFS(0000004F=[O], KEYUP) ctr=0

6203567 Sending WM_KEYUP, Key=79 (Scan code 24), Ctr=1

6203614 KEYUP: VK=79, Waiting=0

This looks OK from FSUIPC side

but the program receiving (PMDG NGX in this case) the keypresses sent by FSUIPC ( see log) doesn't reacts to the second repeating keypress sent. To me it seems like PMDG NGX need some time between the keypresses to detect 2 presses..

Is there a way to insert a delay between repeating U and P commands?

rgs

Link to comment
Share on other sites

I have now the following in my FSUIPX config file:

I see there's still no reference to the 64,17 button you were intending to use.

This looks OK from FSUIPC side

but the program receiving (PMDG NGX in this case) the keypresses sent by FSUIPC ( see log) doesn't reacts to the second repeating keypress sent. To me it seems like PMDG NGX need some time between the keypresses to detect 2 presses..

I'm not sure why you are using keypresses in any case. Haven't all of the switches in the NGX been discovered and shown to be programmable via controls or L:Vars? Check the postings in the User Contributions sub-forum.

It is usually best to avoid using keypresses wherever possible.

Is there a way to insert a delay between repeating U and P commands?

"U" lines are executed when you release a button, "P" when you press the button, so you can delay re-pressing it for as long as you like.

Possibly you really mean a delay between the sending of two separate keystrokes by the one button press or release? If so, then, no, not without using a Lua plug in. You can use delays quite easily then.

Regards

Pete

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.