
Joystick doesn't rise Events
Posted Wednesday, 21 September, 2011 - 17:23 by born_to_eat inHi everyone,
I try to work with the Joystick, but it doesn't work. The problem seems to be that Events aren't rise when I click on buttons, but the joystick is detect. here is a litle test code : does anybody has an idea what is wrong?
using System; using System.Drawing; using System.Drawing.Imaging; using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; using OpenTK.Input; namespace Project { public class Rend : GameWindow { private JoystickDevice joystick; private bool isJoystickExist = false; public Rend() : base(1200, 800) { InitEvent(); } private void InitEvent() { if(Joysticks.Count>0){ Console.WriteLine("Joystick exist = true"); joystick = Joysticks[0]; joystick.ButtonDown += new EventHandler<JoystickButtonEventArgs>(Joystick_ButtonDown); joystick.ButtonUp += new EventHandler<JoystickButtonEventArgs>(Joystick_ButtonUp); joystick.Move += new EventHandler<JoystickMoveEventArgs>(Joystick_Move); isJoystickExist = true; } } private void Joystick_Move(object sender, JoystickMoveEventArgs e) { Console.WriteLine("Joystick move"); } private void Joystick_ButtonUp(object sender, JoystickButtonEventArgs e) { Console.WriteLine("Joystick button up"); } private void Joystick_ButtonDown(object sender, JoystickButtonEventArgs e) { Console.WriteLine("Joystick button down"); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); VSync = VSyncMode.On; } protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); } protected override void OnUpdateFrame(FrameEventArgs e) { base.OnUpdateFrame(e); if(isJoystickExist){ if (joystick.Button[0]) { Console.WriteLine("Joystick button 1 pressed"); } if (joystick.Button[1]) { Console.WriteLine("Joystick button 2 pressed"); } if (joystick.Button[2]) { Console.WriteLine("Joystick button 3 pressed"); } if (joystick.Button[3]) { Console.WriteLine("Joystick button 4 pressed"); } } } protected override void OnResize(EventArgs e) { } } }
and the Main :
using System; namespace Project { class MainClass { [STAThread] public static void Main(string[] args) { using (Rend rend = new Rend()) { rend.Run(60,60); } } } }
The output is : Joystick exist = true
but then, nothing else.....So the joystick is detect, but after it's doesn't work. I know that the joystick is working, I tried it with a game.
any idea?
Thank you and sorry for my bad english :)
Cheers,
Born to Eat


Comments
Re: Joystick doesn't rise Events
Does anybody have an idea? or a link to a solution?
Thanks