Jump to content
The simFlight Network Forums

Offset 3340


Recommended Posts

dear Pete,

I've been trying 2 use offset &H3340 to assign virtual buttons, my problem is that

I only get 1 button( switch) 2 work.

if FSUIPC_Write (&H3340,4,btn_1,dwresult) then

end if

if FSUIPC_Write (&H3340,4,btn_2,dwresult) then

end if

if FSUIPC_Process (dwresult) then

if kit.getInputState(1) = true then

btn_1.uInt32Value(0)=1

elseif kit.getInputState(1)= false then

btn_1.uInt32Value(0)=0

end

the moment a start with the second button( btn_2) the btn_1 does not work any more.

if kit.getInputState(2) = true then

btn_2.uInt32Value(0)=2

elseif kit.getInputState(2)= false then

btn_2.uInt32Value(0)=0

end

end if

I think it has something 2 do with the bits and bytes ?? but what or where??

or do i use Ex :btn_1.byte(0)=1 instead of btn_1.uInt32Value(0)=1

do you have any clue? and hope you can help

regards,

Capie :oops:

Link to comment
Share on other sites

I've been trying 2 use offset &H3340 to assign virtual buttons, my problem is that

I only get 1 button( switch) 2 work.I think it has something 2 do with the bits and bytes ?? but what or where??

Sorry, I cannot make head nor tail out of your code fragment, but I suspect you are simply writing 32 bit values to the offsets, so "destroying" the state of 32 buttons all at once?

If you want to manipulate the virtual buttons directly, via the offsets, then you must READ the relevant offset first, then OR in (to set) or AND out (to clear) or XOR (to toggle) the single BIT you want to signal, and write it back.

Note that is foolproof if you are the only program doing this, but if there are others then you might get conflicts -- there's bound to be a short period between your read and your write then some other program could read, then write wither before your write or after. The result could be unpredictable button changes for both.

To reduce that possibility considerably you should use single byte reads and writes, thus only affecting 8 button bits at a time. If you can select a range of 8 buttons which only your program is using, that'll work well.

**** STOP PRESS ****

I had planned, for the next main FSUIPC release, a new facility to make this a lot easier and foolproof. I've decided to release it now, in an interim update. Please look out for FSUIPC version 3.976 or 4.593 in the Updates annoucement in this Forum a little later today (Monday).

With this facility to can set, clear or toggle any of the virtual buttons without needing to read anything first. It will be like this:

Write to offset 29F0 a 32-bit value (4 bytes) made up as follows:

Byte 0 = Button Number on Joystick (0 - 31)

Byte 1 = Virtual Joystick Number (64 - 72)

Byte 2 = Action: 0 = Toggle, 1 = Set (Press/On), 2 = Clear (Release/Off).

Byte 3 = 0 (Reserved)

So, for example, you can send 0x00014016 to offset 29F0 to "press" button 22 (hex 16) on joy 64 (hex 40). Or you could use a 4 bytes array:

BYTE mybuttons[4] = { 22, 64, 1, 0 };

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.