Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  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

    Trying to get USBkeys to work with SIOC

    A total newbie at SIOC, I'm trying to get my USBkeyscard to send a simple 0/1 command to FSUIPC offset x0BC8 to release and apply the parking brakes in the PMDG 737. I know I can use IOCkeys to define a keystroke but I already have the ATC module rotary working through SIOC thanks to a script by a member of this forum and I would like to get my head around it fot future interfacing.
    So I connected the card, opened sioc and read the device id : 44. I then opened SIOC.ini and changed it to read USBkeys=0,44
    here's my sioc.ini :

    [************** SIOC ***************]
    [ IOCP port ]
    IOCP_port=8090

    [ IOCP Timeout ]
    IOCP_timeout=4000

    [ Start minimized in tray ]
    Minimized=No

    [ Deley needed for var. toggles (Project Magenta) ]
    toggle_delay=20

    [ Configuration File ]
    CONFIG_FILE=.\SCRIPTS\SIOC ATC PMDG.txt


    [************** IOCARDS MODULE ***************]
    [ Disable IOCards module ]
    IOCard_disable=No

    [ Use LPT port in IOCards ]
    IOCard_LPT=No


    [------------- CARDS CONFIG -------------]

    [ IOCard Master ]
    [...............]


    [ English : ]

    [ MASTER=(Device index),(Type),(Number of cards),(Device number) ]

    [ Device index : Index used in SIOC variable like device, this is the card used for SIOC sentence ]
    [ Use 0 for only one card, for this value you not need specify Device number. If you not use DEVICE parameter in a definition in SIOC script, the default index used is 0]

    [ type = 0 : Master Card Emulator ]
    [ type = 1 : Master Card connected directly to parallel port ]
    [ type = 2 : Master Card connected throught compatibility cable to parallel port ]
    [ type = 3 : Expansion Card connected throught parallel port ]
    [ type = 4 : USBExpansion Card used ]
    [ type = 5 : Opencockpits MCP module ]
    [ type = 6 : USBOutputs Card used ]
    [ type = 7 : Opencockpits EFIS module ]
    [ type = 8 : Opencockpits Radio COM module ]
    [ type = 9 : Opencockpits Radio NAV module ]
    [ type = 10 : Opencockpits Radio ADF module ]
    [ type = 11 : Opencockpits Radio ATC module ]

    [ Number of Cards = Master cards connecteds, 1 to 4 for expansion cards, 1 for a Master card directly connected or Emulator ]

    [ Number of device = 0 for Emulator or first USB card detected, parallel port address, device number for specifies USBexpansion card ]

    [ For example, a Master Card connected directly to parallel port : ]
    [ MASTER=0,1,1,$0378 ]

    [ For example, two USBExpansion cards connected with 3 and 2 Master cards used ]
    [ MASTER=0,4,3,22 ]
    [ MASTER=1,4,2,24 ]

    [ For example, use of Master card emulator ]
    [ MASTER=0,0,1,0 ]

    [ Use the first USBExpansion card connected with only one Master Card attached ]
    [ Esta definición es para usar la primera tarjeta USBExpansion que se encuentre instalada que además llevará conectada una placa Master ]

    [MASTER=3,6,1,252]
    [MASTER=0,4,1,0]
    [MASTER=0,4,1,0]
    MASTER=0,4,2,0
    MASTER=0,11,2,0



    [ Name_of_card=(Device index),(Device number) ]

    [ Device index : Index used in SIOC variable like device, this is the card used for SIOC sentence ]
    [ Use 0 for only one card, for this value you not need specify Device number. If you not use DEVICE parameter in a definition in SIOC script, the default index used is 0]

    [ Number of device = 0 for first USB card of this type detected, or device number for a specifies device ]

    [ Example of two USBServos for index 0 and 1, and device number 17 and 23 ]

    [ USBServos=0,17 ]
    [ USBServos=1,23 ]


    USBStepper=0,0
    USBKeys=0,44
    USBServos=0,0
    USBRelays=0,0
    USBDCmotor=0,0

    [ Para los ejes analógicos se usan los números de devices de las tarjetas donde están alojados ]
    [ For analogic axles, you use the device number of cards what allow the axles ]

    USBAnalogic=0,0


    [************** FSUIPC MODULE ***************]

    [ Desabilitar lectura de las FSUIPC ]
    [ FSUIPC disable mode yes/no ]
    FSUipcdisable=No

    [ Refresco recepción FSUIPC ]
    [ FSUIPC refresh ]
    FSUipcRefresh=50


    [************** IOCP CLIENTS MODULES ***************]

    [ Retraso para inicializacion una vez conectado el cliente en milisegundos ]
    [ Delay for initialization when client has been connected in mseconds ]
    IOCPini_delay=3000

    [************** IOCP CLIENT MODULE #0 ***************]

    [ Desactivar el módulo cliente IOCP ]
    [ Disable IOCP client module ]
    IOCPclient0_disable=Yes

    [ IP del servidor donde debe de conectar el cliente ]
    [ IOCP client host name ]
    IOCPclient0_host=localhost

    [ Puerto de envio del protocolo IOCP cliente ]
    [ IOCP client port ]
    IOCPclient0_port=8090


    [************** IOCP CLIENT MODULE #1 ***************]

    [ Desactivar el módulo cliente IOCP ]
    [ Disable IOCP client module ]
    IOCPclient1_disable=Yes

    [ IP del servidor donde debe de conectar el cliente ]
    [ IOCP client host name ]
    IOCPclient1_host=localhost

    [ Puerto de envio del protocolo IOCP cliente ]
    [ IOCP client port ]
    IOCPclient1_port=8099


    [************** SOUND MODULE ***************]

    [ Ficheros de sonido ]
    [ Sound Files ]

    [ Desactivar el módulo de sonido ]
    [ Disable Sound module ]
    Sound_disable=yes

    [ Volumen general de los sonidos 0-100 ]
    [ Master Volume 0-100 ]
    Volume=100


    [ put '*' first filename for loop Sound ]
    [ anteponer '*' en el fichero para bucle continuo de sonido]

    [ Sound=wav_file,frequency,volume,pan ]
    [ frequency=100 to 100000 0=original -1=current ]
    [ volume=0 to 100, -1=current ]
    [ pan=-100 (left) to +100 (right) 0=center -1=current ]

    [ Sound=Fichero_wav,frecuencia,volumen,balance ]
    [ frecuencia=100 hasta 100000 0=original -1=Por defecto ]
    [ volumen=0 hasta 100 -1=Volumen por defecto ]
    [ balance=-100 (Izquierda) hasta +100 (Derecha) 0=centro -1=Por defecto ]

    [ #1 ]
    Sound=APDis.wav,-1,-1,-1

    [ #2 ]
    Sound=*outermk.wav,-1,-1,-1

    [ #3 ]
    Sound=*hello.wav

    [************** KEYBOARD EMULATOR MODULE ***************]

    [ Nombre exacto de la ventana donde se enviarán las teclas ]
    [ Name of window for key send ]
    [window = "Project Magenta Glass Cockpit - Build 396" ]

    window =a.txt - Bloc de notas


    [ Asignación de teclas ]
    [ assign youe keys ]

    #1=\3I\4
    #2=\3\1I\2\4
    #3=C
    #4=D
    #5=E
    #6=F
    #7=G
    #8=H
    #9=I
    #10=J
    #11=K
    #12=L
    #13=M
    #14=N
    #15=O
    #16=P
    #17=Q
    #18=R
    #19=S
    #20=T
    #21=U
    #22=V
    #23=W
    #24=X
    #25=Y
    #26=Z
    #27=1
    #28=2
    #29=3
    #30=4
    #31=5
    #32=6
    #33=7
    #34=8
    #35=9
    #36=0
    #37=<
    #38=,
    #39=.
    #40=-
    #41=*
    #42=+
    #43=//
    #44=/0
    #45=/1
    #46=/A
    #47=
    #48=
    #49=
    #50=
    #51=
    #52=
    #53=
    #54=
    #55=
    #56=
    #57=
    #58=
    #59=
    #60=
    #61=
    #62=
    #63=
    #64=
    #65=
    #66=
    #67=
    #68=
    #69=
    #70=
    #71=
    #72=
    #73=
    #74=
    #75=
    #76=
    #77=
    #78=
    #79=
    #80=
    #81=
    #82=
    #83=
    #84=
    #85=
    #86=
    #87=
    #88= #200=
    [ End of File ]

    If this works (how can I test it?) the next step would be to write a script.
    I've looked at a lot of examples at Niko's site, Ive tried a few things but it's unclear to me how to tell a script that when I toggle a switch it should be sent to my flight sim
    Could someone please walk me through this ? I would be very grateful.

    Martin

  2. #2
    500+ This must be a daytime job mpl330's Avatar
    Join Date
    Mar 2007
    Location
    Yorkshire - UK
    Posts
    513
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Trying to get USBkeys to work with SIOC

    Hi Martin,

    I'm not sure but I think the USB Keys Card only sends key strokes to an active window rather than FSUIPC offsets but you could send 'G' as a key stroke to the FS window which would do the gear... Someone else may be able to confirm this...?

    Cheers
    Mike

  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: Trying to get USBkeys to work with SIOC

    Hi Mike,

    The way I have done it with IOCkeys was assign a keystroke to the offset in FSUIPC and assign the keystroke to the USBkeys card.
    I was under the impression I could do this directly in SIOC but maybe I'm wrong ?

  4. #4
    500+ This must be a daytime job
    Join Date
    Jul 2013
    Posts
    948
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Trying to get USBkeys to work with SIOC

    Martin

    You can write a script in sioc to read the key presses from the USBKeys card and then dependent on what you want send a value to any FSUIPC offset. You need to do a bit of studying on SIOC syntax, though you are well on the way reading Nico`s site. Have a try, by first writing out the logic flow of what you want eg

    Has key G been pressed
    If so then send the value to the correct FSUIPC offset

    Then code this in SIOC syntax with the variable definitions. If you get stuck then post again

    David

  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: Trying to get USBkeys to work with SIOC

    I have been studying Nico's site quite a while but I don't seem to be able to make it work. Is it for example different to connect a switch to a mastercard or to a USBkeyscard ? How do you tell SIOC there is a USBcard connected ? Do you use the key defintions at the end of SIOC.ini ?

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

    Re: Trying to get USBkeys to work with SIOC

    Hi,
    There are two ways of working possible with the USBKeys card:

    1) To let it generate keys. There are plenty of examples of this in the Opencockpits Forum

    2) To let it generate integer codes (you can use IOCKeys to check the code generated for a key). In a SIOC script you can receive these codes and do whatever you want.

    In sioc.ini define:
    Code:
    [USBKEYS]
    USBKeys=5,44
    In a SIOC script write:
    Code:
    Var 6000 Static name Key Link USB_KEYS Device 5
    {
       L0 = &Key
       IF L0 = "your on key code code here"
       {
          &ParkBrake = 32767    // park brake ON
       } 
       ELSE
       {
          IF L0 = "your off key code here"
          {
             &ParkBrake = 0   // park brake OFF
          }
       }
    }
    
    Var 1 name ParkBrake Link FSUIPC_OUT Length 2 Offset $0BC8
    Regards,
    Nico Kaan
    Last edited by kiek; 05-15-2011 at 03:33 PM.

  7. #7
    500+ This must be a daytime job
    Join Date
    Jul 2013
    Posts
    948
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Trying to get USBkeys to work with SIOC

    Martin

    The USBKeys card is like a keyboard matrix and will return a value dependent on the row and column selected (joined) by your keypress. You have approx 88 "keys" ie that is the number of rows multiplied by the number of columns.

    SIOC knows that there is an USBkeys card because you have given it a device number in the sioc.ini file

    You now need to write a .txt file in notepad containing your SIOC instructions and also put the reference in the sioc.ini file for example CONFIG_FILE=.\SCRIPTS\SIOC yournewsiocfile.txt
    If I recall correctly, the .ini key definitions are there for when you want to send a character to the "live" window. However, if you want to send something to an offset then you only need to look for the "key" value you want. For example if you have a switch joing row 5 and column 7 then simplistically you want to know when key 35 has been pressed. If you are unsure of the numbering of the "keys" within the matrix then use the IOCPCONSOLE feature within the main SIOC window - this will tell you the "key" press when you look for the variable value you have assigned to the incoming key presses. Here is a very simple coding example



    Var 0000, Value 0

    Var 0001, Link FSUIPC_INOUT, name Gear_status, Offset $????, Length 1 // Insert the correct FSUIPC offset in place of ????

    Var 0002, name key_in, Link USB_KEYS // this is your incoming "key press" value
    {
    if &key_in = 71 // 71 or whatever "keypress" value you are looking for
    {
    &Gear_status = 1 // sends a value of 1 to the gearstatus FSUIPC offset
    }
    }

  8. #8
    500+ This must be a daytime job mpl330's Avatar
    Join Date
    Mar 2007
    Location
    Yorkshire - UK
    Posts
    513
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Trying to get USBkeys to work with SIOC

    Ah so you can make it send FSUIPC values by coding round it, makes sense really!

    Cheers
    Mike

  9. #9
    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: Trying to get USBkeys to work with SIOC

    Thank you, Nico.
    Couple of questions, if you don't mind :
    So if I understand correctly : For the second option you don't have to assign keystrokes at all ? You just see which codes are generated ?
    : is there a reason for the "5" in this statement ?
    What does "static" do in the first line of the script ?
    I actually think I understand the rest of it. Wow.
    Thanks a lot, Nico, je bent een kanjer.

  10. #10
    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: Trying to get USBkeys to work with SIOC

    Quote Originally Posted by fordgt40 View Post
    Martin

    The USBKeys card is like a keyboard matrix and will return a value dependent on the row and column selected (joined) by your keypress. You have approx 88 "keys" ie that is the number of rows multiplied by the number of columns.

    SIOC knows that there is an USBkeys card because you have given it a device number in the sioc.ini file

    You now need to write a .txt file in notepad containing your SIOC instructions and also put the reference in the sioc.ini file for example CONFIG_FILE=.\SCRIPTS\SIOC yournewsiocfile.txt
    If I recall correctly, the .ini key definitions are there for when you want to send a character to the "live" window. However, if you want to send something to an offset then you only need to look for the "key" value you want. For example if you have a switch joing row 5 and column 7 then simplistically you want to know when key 35 has been pressed. If you are unsure of the numbering of the "keys" within the matrix then use the IOCPCONSOLE feature within the main SIOC window - this will tell you the "key" press when you look for the variable value you have assigned to the incoming key presses. Here is a very simple coding example



    Var 0000, Value 0

    Var 0001, Link FSUIPC_INOUT, name Gear_status, Offset $????, Length 1 // Insert the correct FSUIPC offset in place of ????

    Var 0002, name key_in, Link USB_KEYS // this is your incoming "key press" value
    {
    if &key_in = 71 // 71 or whatever "keypress" value you are looking for
    {
    &Gear_status = 1 // sends a value of 1 to the gearstatus FSUIPC offset
    }
    }
    David, thanks, it's getting clearer by the minute. Why does your script start with Var0000, value 0 ?
    I'm going to study your and Nico's examples exhaustively, looking forward to it all coming together.

Page 1 of 2 12 LastLast