Exemplo n.º 1
0
void emu_pause()
{
        emu_run = 0;
        vid_suspend();
        pcm_suspend();
        joy_close();
}
Exemplo n.º 2
0
int main()
{
   int x;    
   joy_t joy;
   
   if ( joy_init(&joy) != 0) {
      printf("cannot find joystick\n");
      return 1;
   }
   
   printf( " Joystick detected : %s \n \t %d axis \n\t %d buttons \n\n" ,joy.name, joy.num_of_axis , joy.num_of_buttons);
   
   //     fcntl( joy_fd, F_SETFL , O_NONBLOCK ); // use non - blocking methods
   
   while(1) // infinite loop
   {
      // read the joystick 
      joy_read(&joy);
      // print the results
      printf( " X:%6d y:%6d", joy.axis[0] , joy.axis[1]);
      if( joy.num_of_axis > 2)
         printf( " z:%6d" , joy.axis[2] );
      if( joy.num_of_axis > 3)
         printf( " R:%6d" , joy.axis [3]);
      for( x=0 ; x<joy.num_of_buttons ; ++x)
         printf( " B%d:%d" , x, joy.button [x]);
      printf("\n");
      fflush(stdout);
   }
   
   joy_close(&joy);
   
   return 0;
}
Exemplo n.º 3
0
void gp2x_usbjoy_deinit (void) {
	int i;
	for (i=0; i<num_of_joys; i++) {
		joy_close (joys[i]);
		joys[i] = NULL;
	}
	num_of_joys = 0;
}
Exemplo n.º 4
0
static void arch_close(void)
{
	songs_uninit();

	gr_close();

	if (!GameArg.CtlNoJoystick)
		joy_close();

	mouse_close();

	if (!GameArg.SndNoSound)
	{
		digi_close();
	}

	key_close();

	SDL_Quit();
}
Exemplo n.º 5
0
Arquivo: wgl.c Projeto: paud/d2x-xl
void OglDestroyWindow(void){
	if (gameStates.ogl.bInitialized){
		OglSmashTextureListInternal();
		if (mouse_hidden){
			ShowCursor(TRUE);
			mouse_hidden = 0;
		}
		if (g_hWnd){
			key_close();
			mouse_close();
			joy_close();
			if (!FindArg( "-nosound" ))
				DigiClose();
			OpenGL_Shutdown();
			DestroyWindow(g_hWnd);
		}else
			Error("OglDestroyWindow: no g_hWnd?\n");
		gameStates.ogl.bInitialized=0;
	}
	return;
}
Exemplo n.º 6
0
Arquivo: testj.c Projeto: btb/d2x
void main (void)
{
	unsigned int t1, t2;
	int i, start, stop, frames;
	short bd1, bd2, bu1, bu2, b, x, y, bt1, bt2;

	key_init();

	if (!joy_init())   {
		printf( "No joystick detected.\n" );
		key_close();
		exit(1);
	}

	timer_init( 0, NULL );

	printf( "Displaying joystick button transitions and time...any key leaves.\n" );

	i = 0;
	while( !key_inkey() )
	{
		i++;
		if (i>500000)    {
			i = 0;
			joy_get_btn_down_cnt( &bd1, &bd2 );
			joy_get_btn_up_cnt( &bu1, &bu2 );
			joy_get_btn_time( &bt1, &bt2 );
			printf( "%d  %d   %d   %d      T1:%d   T2:%d\n",bd1, bu1, bd2, bu2, bt1, bt2 );
		}
	}

	printf( "\nPress c to do a deluxe-full-fledged calibration.\n" );
	printf( "or any other key to just use the cheap method.\n" );

	if (key_getch() == 'c')    {
		printf( "Move stick to center and press any key.\n" );
		wait();
		joy_set_cen();

		printf( "Move stick to Upper Left corner and press any key.\n" );
		wait();
		joy_set_ul();

		printf( "Move stick to Lower Right corner and press any key.\n" );
		wait();
		joy_set_lr();
	}


	while( !keyd_pressed[KEY_ESC])
	{
		frames++;

		joy_get_pos( &x, &y );
		b = joy_get_btns();

		printf( "%d, %d   (%d %d)\n", x, y, b & 1, b & 2);

	}


	printf( "Testing joystick reading speed...\n" );
	t1 = timer_get_microseconds();
	joy_get_pos( &x, &y );
	t2 = timer_get_microseconds();

	printf( "~ %u æsec per reading using Timer Timing\n", t2 - t1 );

	joy_close();
	key_close();
	timer_close();

	frames = 1000;
	start = TICKER;
	for (i=0; i<frames; i++ )
		joy_get_pos( &x, &y );

	stop = TICKER;

	printf( "~ %d æsec per reading using BIOS ticker as a stopwatch.\n", USECS_PER_READING( start, stop, frames ) );


}
Exemplo n.º 7
0
JoystickButtons::~JoystickButtons() {
  joy_close(joy);
}