• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Filtering Joystick Input

Messages
95
Country
malta
Hi all,

I need a simple filter to filter joystick input. I came across some in the internet but since I lack filter theory, it makes it a bit difficult to understand what's going on and hence to implement.

Is there anybody that can help me here please?

Thanks a lot
 
Hi all,

I need a simple filter to filter joystick input. I came across some in the internet but since I lack filter theory, it makes it a bit difficult to understand what's going on and hence to implement.

Is there anybody that can help me here please?

Thanks a lot

You are not specifying the programmer language you are using.

Here is a complete example with VB.Net 2008

- first of all you need to implement the Joystick environment in order to read Data

'ON TOP
Declare Function joyGetPosEx Lib "winmm.dll" (ByVal uJoyID As Integer, ByRef pji As JOYINFOEX) As Integer


<StructLayout(LayoutKind.Sequential)> _
Public Structure JOYINFOEX
Public dwSize As Integer
Public dwFlags As Integer
Public dwXpos As Integer
Public dwYpos As Integer
Public dwZpos As Integer
Public dwRpos As Integer
Public dwUpos As Integer
Public dwVpos As Integer
Public dwButton As Integer
Public dwButtonsNumber As Integer
Public dwPOV As Integer
Public dwReserved1 As Integer
Public dwReserved2 As Integer
End Structure


' WITHIN YOUR TIMER SECTION
' READ THE JOYSTICK VALUE

Call joyGetPosEx(0, myjoyEX)

Dim btnnumbers As Integer = 0
Dim DummyInt As Integer = 0

With myjoyEX
'you can read the Data declared with the Structure JOYINFOEX
'Label1 = .dwXpos.ToString
'etc. etc...

'Joystick Button number value
DummyInt = .dwButton
'show value as reference
Me.TextBox1.Text = .dwButton.ToString("0")

'Number of Joystick Buttons pressed together
btnnumbers = .dwButtonsNumber
F2.TextBox2.Text = btnnumbers.ToString("0")

End With


'read joystick then delay in any Sub, avoid too fast reading within this Timer
'YOU MUST FIRST READ THE SINGLE JOYSTICK BUTTON VALUES
'EXAMPLE: the 'Shift State' lever with the SAITEK X52 should return value 32
' the Button 'FIRE A' could return value 4
' The combination of 'Fire A' + Shift state would be then vale 36
' You read all buttons and POV values
' you read the X, Y values as declard


'FILTER OUT
'btn_1, btn_2 include the values assigned when you start your program
'you could use a ?.ini Text-File where you write your joystick values
'Use the 2 TextBox1 + TextBox2 for a visual data reading and create your 'ini.file'
'on program start read the '?.ini' data into the btn_1 ...... variables

Select Case UCase(DummyInt)

Case btn_1 'shift + Fire A
'in base of the total Value call your Sub-Function to do something.....
ApHdgClick()

Case btn_2 'shift + Fire B
Panel2Open()

Case btn_3 '32800
Panel3Open()

End Select



Private Sub ApHdgClick()

On Error Resume Next

'Example of Transmit Event with FSX Simconnect
fsx_simconnect.TransmitClientEvent(DEFINITIONS.Struct1, EVENT_ID.EVENT_HEADINGOnOff, 0, hSimconnect.group1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY)

''''''''''' Delay - This is very important ''''''''''''''
System.Threading.Thread.Sleep(300)

End Sub

regards,
 
Last edited:
Back
Top