|
-
Sep 13th, 2009, 12:52 PM
#1
Thread Starter
Junior Member
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.
-
Sep 13th, 2009, 02:25 PM
#2
Thread Starter
Junior Member
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.
-
Sep 15th, 2009, 02:16 PM
#3
Thread Starter
Junior Member
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
-
Sep 15th, 2009, 03:01 PM
#4
Thread Starter
Junior Member
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( "%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?
-
Sep 16th, 2009, 01:12 AM
#5
Thread Starter
Junior Member
Re: Read gamepad input
Anyone who can help me out? I am really struggling with this one.....
Thanks in advance.
-
Sep 16th, 2009, 02:34 PM
#6
Member
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.
-
Sep 16th, 2009, 02:55 PM
#7
Thread Starter
Junior Member
Re: Read gamepad input
If you want to know which button is pressed check this thread:
http://www.xtremevbtalk.com/showthre...76#post1341976
-
Sep 16th, 2009, 02:59 PM
#8
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|