![]() |
Reading one Joystick (PS1/PS2) using slimDX and C#
Hello everybody. I've a problem. I've connected to the computer a joystick (PS1) to an adapter called "Konig electronic" which is connected to the pc through a usb cable. I want to control it with a c# program. I've used slimDX dll but it doesn't work. When i use a PSX simulation software the joystick works, but when i try to control it with a c# code it doesn't work. please help me.
I want to get the pressed buttons, from PS1 joystick, and display it into label2. PS: Sorry for my bad english but i'm italian! :) My C# project is: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using SlimDX.DirectInput; namespace JoyStick { public partial class Form1 : Form { List<DeviceInstance> directInputList = new List<DeviceInstance>(); DirectInput directInput = new DirectInput(); SlimDX.DirectInput.Joystick gamepad; SlimDX.DirectInput.JoystickState state; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { directInputList.AddRange(directInput.GetDevices(De viceClass.GameController, DeviceEnumerationFlags.AttachedOnly)); gamepad = new SlimDX.DirectInput.Joystick(directInput, directInputList[0].InstanceGuid); } private void button1_Click(object sender, EventArgs e) { timer1.Start(); } private void button2_Click(object sender, EventArgs e) { //gamepad.Unacquire(); timer1.Stop(); } private void timer1_Tick(object sender, EventArgs e) { if (gamepad.Acquire().IsFailure) return; if (gamepad.Poll().IsFailure) return; if (SlimDX.Result.Last.IsFailure) return; state = gamepad.GetCurrentState(); bool[] buttons = state.GetButtons(); for (int i = 0; i < buttons.Length; i++) if (buttons[i]) label2.Text = i.ToString(); lbl_np.Text = Convert.ToString(buttons.Length); gamepad.Unacquire(); } } } |
Re: Reading one Joystick (PS1/PS2) using slimDX and C#
Welcome to the Chief Delphi forum!
This is a community dedicated to various robotics competitions for high school students and their adult mentors. The community here doesn't use slimDX, in general, though you may find somebody who uses it for their day job or for side projects. You'd probably have better luck posting on a forum with an active slimDX community: slimdx-devel mailing list: https://groups.google.com/forum/#!forum/slimdx-devel Stack Overflow: http://stackoverflow.com/questions/tagged/slimdx Since slimDX is a managed wrapper around DirectX, you may find some help on the DirectX forums as well: http://xboxforums.create.msdn.com/fo...aspx?GroupID=7 Also, if you suspect that it's a device problem, you may want to contact the manufacturer: http://www.konigelectronic.com/en_us/service-support |
Re: Reading one Joystick (PS1/PS2) using slimDX and C#
Here is a similar thread for more insight on using slimDX:
http://www.chiefdelphi.com/forums/sh...d.php?t=108111 I'll get our programmer to take a look at your problem and see if he comes up with anything. |
Re: Reading one Joystick (PS1/PS2) using slimDX and C#
thank you anyway!! :)
|
Re: Reading one Joystick (PS1/PS2) using slimDX and C#
Hello,
I used Slim DX and C# to create a scouting system that used ps3 controllers to change several different numbers. Here is the part of my code that gets all the usb joysticks connected to the computer. Code:
namespace FalconScoutingSoftwareCode:
void StickHandlingLogic(Joystick stick, int id) |
Re: Reading one Joystick (PS1/PS2) using slimDX and C#
Thank you! but it doesn't work! I've tryed also with:
for(int i = 0; i < buttons.length; i++) if(buttons[i]) label2.Text = "pressed"; ... on every id ... but nothing... it's like the program can't read data from joystick.. :/ |
Re: Reading one Joystick (PS1/PS2) using slimDX and C#
oooh yeeeesss!! :)
I've solved the problem!! i've connected the adapter to the pc, debugged the program and after i've connected the joystick to the adapter.. and it works! :D now, i've a long programming night ;) thank you! |
Re: Reading one Joystick (PS1/PS2) using slimDX and C#
Quote:
|
Re: Reading one Joystick (PS1/PS2) using slimDX and C#
Quote:
|
| All times are GMT -5. The time now is 03:04. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi