born_to_eat's picture

Joystick doesn't rise Events

Project:The Open Toolkit library
Version:1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:need info
Description

Joystick is detected, ie Joysticks.Count>0 return true,

but then : joystick.ButtonDown += new EventHandler<JoystickButtonEventArgs>(Joystick_ButtonDown); for example doesn't rise an Event or

protected override void OnUpdateFrame(FrameEventArgs e)
		{
			base.OnUpdateFrame(e);
 
				if (Joystick[0].Button[0])
				{
					Console.WriteLine("Joystick button 1 pressed");
				}
}

doesn't work


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

#1

Status:open» need info

Please try updating to SVN trunk. The issue *should* be fixed there (if it isn't please post).

born_to_eat's picture

#2

I updated from svn, but it still doesn't work...

kuma's picture

#3

Version:1.0-2010-10-06» 1.x-dev

I have some issue with last version. I have a gamepad xbox for windows and os is windows 7 64 bit.

born_to_eat's picture

#4

I haven't try again since my last post, because now for the joystick part I use the Tao framework (only the joystick part, OpenTK is really better for the OpenGL part). Tao provide an SDL library and you can easily use it :
Something like that :

 
			if(Sdl.SDL_Init(Sdl.SDL_INIT_VIDEO | Sdl.SDL_INIT_JOYSTICK) < 0){
				Console.WriteLine("Couldn't initiate sdl");
			}
			if(Sdl.SDL_NumJoysticks() > 0){
				Console.WritLine("Joystick exist");
			}
 
			IntPtr joys = Sdl.SDL_JoystickOpen(0);
                        Sdl.SDL_Event sdlEvent;
 
                       while(Sdl.SDL_PollEvent(out sdlEvent)==1){
				switch(sdlEvent.type){
					case Sdl.SDL_JOYAXISMOTION:
						//Console.WriteLine("axe move");
						int axeX = Sdl.SDL_JoystickGetAxis(joys,0);
						int axeY = Sdl.SDL_JoystickGetAxis(joys,1);
						int axeZ = Sdl.SDL_JoystickGetAxis(joys,2);
						int axeW = Sdl.SDL_JoystickGetAxis(joys,3);
						break;
					case Sdl.SDL_JOYBUTTONDOWN:
						if(Sdl.SDL_JoystickGetButton(joys, 0) == 1){
							//button 0 press
						}
						if(Sdl.SDL_JoystickGetButton(joys, 1) == 1){
							//Button 1 press
						}
 
						break;
					case Sdl.SDL_JOYBUTTONUP:
 
						if(Sdl.SDL_JoystickGetButton(joys, 0) == 0 ){
							//button 0 up
						}
						break;
					case Sdl.SDL_JOYHATMOTION:
//						Console.WriteLine("Hat move");
						break;
				}
			}
kuma's picture

#5

ok, I just try it and work fine!

thank you

kuma

c2woody's picture

#6

Guess you simply forgot polling in the OpenTK sample.