![]() |
Reading multiple joysticks on C# using SlimDX.
Hello,
I am currently working on a scouting system for the upcoming FRC Season and I am having trouble getting more than one joystick to be read. The program receives data from the joysticks (like how many balls were attempted and made) then saves it to notepad. From notepad it can be read using Excel. The program works fine with one controller. Is there a way to do the same thing but with 6 different USB connected joysticks? |
Re: Reading multiple joysticks on C# using SlimDX.
I'd be willing to look at your code. If you don't want to post it publicly, PM me.
This should give you a starting place. Code:
public static Joystick[] GetSticks() |
Re: Reading multiple joysticks on C# using SlimDX.
I will use that for the starting point thank you and here is the code if anyone is interested.
Code:
|
Re: Reading multiple joysticks on C# using SlimDX.
I tested the code that EHaskins provided me and it can read every USB gamepad. I developed code so it can show which buttons are being pressed, but it only works if each gamepad is under a timer. The timer is used to refresh the labels which each button is assigned to change. The problem that I get in the code is in this line:
Code:
SlimDX.DirectInput.Joystick stick = new SlimDX.DirectInput.Joystick(Input. device.InstanceGuild); |
Re: Reading multiple joysticks on C# using SlimDX.
First, shouldn't that be a comma after Input you the code you posted. If that's just a typo when copying to CD, there's probably a problem on the line before or after it.
Second, you should do that with a single timer. Something like: Code:
Joystick[] sticks; |
Re: Reading multiple joysticks on C# using SlimDX.
Thanks for the help EHaskins. Now I am able to use all 6 gamepads that I need. Right now, whenever I press a certain button a counter on an integer goes up by one and is displayed on a label like this:
Code:
if (buttons[0])Code:
if (buttons[4] & buttons[0]) |
Re: Reading multiple joysticks on C# using SlimDX.
Try this. Either one is functionally the same, but I think the second may be more concise.
Code:
if (buttons[4] && buttons[0]) |
Re: Reading multiple joysticks on C# using SlimDX.
Hey Eric Haskins,
i am trying to program the dance pad programmed for a Dancing Revolution Game, could any one tell how i can take the input from their button..?? because i tried using the serial port input but it didn't worked out. even i used this code but its not returning the data. JoystickState state = new JoystickState(); // JoystickState state = joystick.CurrentJoystickState; ( If i use this and delete the above command then i get a error for Object reference not set to an instance of an object. ( NULL Reference Exception ) //Capture Buttons. byte[] buttons = state.GetButtons(); for (int i = 0; i < buttons.Length; i++) { if (buttons[i] != 0) { info += "Button:" + i + " "; label1.Text = info; } } |
Re: Reading multiple joysticks on C# using SlimDX.
Hey Eric whats app..??
i am trying to program the dance pad programmed for a Dancing Revolution Game, could any one tell how i can take the input from their button..?? because i tried using the serial port input but it didn't worked out. even i used this code but its not returning the data. JoystickState state = new JoystickState(); // JoystickState state = joystick.CurrentJoystickState; ( If i use this and delete the above command then i get a error for Object reference not set to an instance of an object. ( NULL Reference Exception ) //Capture Buttons. byte[] buttons = state.GetButtons(); for (int i = 0; i < buttons.Length; i++) { if (buttons[i] != 0) { info += "Button:" + i + " "; label1.Text = info; } } |
| All times are GMT -5. The time now is 00:43. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi