Results 1 to 8 of 8

Thread: Read gamepad input

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2007
    Posts
    27

    Read gamepad input

    Hello,

    I have this gamepad:

    http://www.speedlink.com/?p=2&cat=313&pid=3708&paus=1

    I want to write a small application that is able to read what button is pressed on the gamepad.

    I've seen this thread:

    http://www.vbforums.com/showthread.php?t=317362

    but this does not read the input of the controller, it only initialize it.

    Is there someone who can help me? I do not use XNA.

    Edit: I've seen this thread:

    http://blogs.msdn.com/coding4fun/arc...03/940908.aspx

    I think it describes basically what I need . But your advice is of course welcome.

    Thanks in advance.
    Last edited by 2005 user; Sep 13th, 2009 at 02:24 PM.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Nov 2007
    Posts
    27

    Re: Read gamepad input

    Do I really need to download the whole DirectX SDK to be able to add the reference:

    Microsoft.DirectX.DirectInput.dll

    Or can I download it somewhere separate?

    Answer: Yes you really need to download the whole SDK
    Last edited by 2005 user; Sep 16th, 2009 at 01:13 AM.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2007
    Posts
    27

    Re: Read gamepad input

    Ok I've found this great example:

    http://www.xtremevbtalk.com/showthread.php?t=246406

    but I have a problem with this code:

    Code:
    ' Fill up text with which buttons are pressed
            Dim buttons As Byte() = state.GetButtons()
    
            Dim _button As Integer = 0
            For Each b As Byte In buttons
                If Not ((b And &H80) = 0) Then
                    strText += _button.ToString("00 ")
                    _button += 1
                End If	
            Next
    
            labelButtons.Text = strText
    now only "00" (without the quotes is displayed instead of 01, 02, ect.....) is displayed with every button I press.

    Is there something wrong with this code? It has been updated (by Visual Studio) because I use Visual Studio 2008 Express Edition.

    Thanks in advance

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2007
    Posts
    27

    Re: Read gamepad input

    This looks like the C++ version but I have little experience with this language:

    Code:
     // Fill up text with which buttons are pressed
        StringCchCopy( strText, 512, TEXT( "" ) );
        for( int i = 0; i < 128; i++ )
        {
            if( js.rgbButtons[i] & 0x80 )
            {
                TCHAR sz[128];
                StringCchPrintf( sz, 128, TEXT( "&#37;02d " ), i );
                StringCchCat( strText, 512, sz );
            }
        }
    
        SetWindowText( GetDlgItem( hDlg, IDC_BUTTONS ), strText );
    
        return S_OK;
    What is the difference? Can anyone translate it into VB .NET?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2007
    Posts
    27

    Re: Read gamepad input

    Anyone who can help me out? I am really struggling with this one.....

    Thanks in advance.

  6. #6
    Member
    Join Date
    Sep 2007
    Posts
    48

    Re: Read gamepad input

    I'm afraid I cant answer your question but I have downloaded the code you are using and when I press 1 button at a time I get 00, when I press more than 1 button I get 01 02 etc.

    The number displayed seems to depend on the amount of buttons being pressed.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Nov 2007
    Posts
    27

    Re: Read gamepad input

    If you want to know which button is pressed check this thread:

    http://www.xtremevbtalk.com/showthre...76#post1341976

  8. #8
    Member
    Join Date
    Sep 2007
    Posts
    48

    Re: Read gamepad input

    I dont need to know which button, I justneed to know that a button has been pressed. I thought you were wanting to know which button was pressed.

    Sorry I misunderstood.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width