Results 1 to 5 of 5
  1. #1
    300+ Forum Addict


    tiburon's Avatar
    Join Date
    May 2007
    Location
    Amsterdam
    Posts
    353
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    First SIOC script worked only once ?

    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

  2. #2
    2000+ Poster - Never Leaves the Sim kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    2,222
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: First SIOC script worked only once ?

    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:
    Code:
    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

  3. #3
    300+ Forum Addict


    tiburon's Avatar
    Join Date
    May 2007
    Location
    Amsterdam
    Posts
    353
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: First SIOC script worked only once ?

    ha Nico,

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

    martin

  4. #4
    2000+ Poster - Never Leaves the Sim kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    2,222
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: First SIOC script worked only once ?

    Hi Martin,
    That's defined by you in FSUIPC... Either change it over there or use this:

    Code:
    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
    Last edited by kiek; 05-18-2011 at 03:30 PM.

  5. #5
    300+ Forum Addict


    tiburon's Avatar
    Join Date
    May 2007
    Location
    Amsterdam
    Posts
    353
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: First SIOC script worked only once ?

    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