PDA

View Full Version : First SIOC script worked only once ?



tiburon
05-17-2011, 12:13 PM
Hi,

I wrote a very simple (not for me :-?) script to toggle the VOR1 button on the audio panel by means of a pushbutton connected to a USB_KEYS card by shamelessly copying a script from Nico's site and adjusting it to my own needs.

var 1 name KEY Link USB_KEYS device 5
{
L0 = &KEY
IF L0 = 4
{
&FO_JoyStick64 = CHANGEBIT 0 v1 // toggle bit 0 of joystick 64
}
}

Var 2 name FO_JoyStick64 Link FSUIPC_OUT Offset $3340 Length 4

I checked in FSUIPS buttons and switches and Strange and Wonderful thing, it worked, but only once !
I could not get it to send this key again.

What have I done wrong ?

thanks

Martin

kiek
05-17-2011, 04:14 PM
Hi Martin,

That's because your code always sets bit 0 of joystick 64 to the same value, it does not toggle ( 0 -> 1 - 0 -> 1 - ...)
Try this:


var 1 name KEY Link USB_KEYS device 5
{
L0 = &KEY
IF L0 = 4
{
L1 = &X_JoyStick64
L1 = MOD L1 2 // take current value of bit 0 of joystick 64
&X_JoyStick64 = CHANGEBITN 0 L1 // toggle bit 0 of joystick 64
}
}

Var 2 name X_JoyStick64 Link FSUIPC_INOUT Offset $3340 Length 4

Nico

tiburon
05-18-2011, 10:04 AM
ha Nico,

Thanks again. Thing is...It only works when I press the button twice...Why is that ?

martin

kiek
05-18-2011, 01:23 PM
Hi Martin,
That's defined by you in FSUIPC... Either change it over there or use this:



var 1 name KEY Link USB_KEYS device 5
{
L0 = &KEY
IF L0 = 4
{
&FO_JoyStick64 = TOGGLE 0 // toggle bit 0 of joystick 64
}
}

Var 2 name FO_JoyStick64 Link FSUIPC_OUT Offset $3340 Length 4


BTW. Although it is exciting... you should not just copy some SIOC code without any understanding what it is for.
Programming is a skill, you have to start from scratch with small examples...

groeten,
Nico

tiburon
05-18-2011, 01:51 PM
That's weird. I just defined some mouse macro's in FSUIPC.Done it many times. I can't imagine what would cause this behavior.
Undoubtedly you're right about SIOC and rest assured that I'm studying like crazy but it's tempting to start using some code in my cockpit, even though I'm not always sure how it all comes together. Don't worry, I'll get there.
I just finished the OC powerpoint presentation about SIOC and I've started on part 2 although that one is so badly translated that I'm going to do my own translation from the original Spanish.

vriendelijke groet

Martin