Subversion Repositories Projects

Rev

Rev 130 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 130 Rev 140
Line -... Line 1...
-
 
1
#include "joy_handler.h"
Line -... Line 2...
-
 
2
 
-
 
3
 
-
 
4
int connect_joy()
-
 
5
{
-
 
6
 
-
 
7
  axis = (int *) calloc( 100, sizeof( int ) );
-
 
8
  button = (char *)calloc( 100, sizeof( char ) );
-
 
9
  button_trigger = (char *) calloc( 100, sizeof( char ) );
-
 
10
 
-
 
11
 
-
 
12
  //  axis = (int *) calloc( num_of_axis, sizeof( int ) );
-
 
13
  // button = (char *)calloc( num_of_buttons, sizeof( char ) );
-
 
14
  // button_trigger = (char *) calloc( num_of_buttons, sizeof( char ) );
-
 
15
 
-
 
16
 
-
 
17
  if( ( joy_input_fd = open( input_joydev_name, O_RDONLY ) ) < 0 )
-
 
18
    {
-
 
19
      printf( "can't open %s !\nHint: try modprobe joydev\n",input_joydev_name  );
-
 
20
      return 0;
-
 
21
    }
-
 
22
 
-
 
23
  ioctl( joy_input_fd, JSIOCGAXES, &num_of_axis );
-
 
24
  ioctl( joy_input_fd, JSIOCGBUTTONS, &num_of_buttons );
-
 
25
  ioctl( joy_input_fd, JSIOCGNAME(80), &name_of_joystick );
-
 
26
 
-
 
27
  printf("Joystick detected: %s\n\t%d axis\n\t%d buttons\n\n"
-
 
28
         , name_of_joystick
-
 
29
         , num_of_axis
-
 
30
         , num_of_buttons );
-
 
31
 
-
 
32
  fcntl( joy_input_fd, F_SETFL, O_NONBLOCK );   /* use non-blocking mode */
-
 
33
 
-
 
34
  return 1;
-
 
35
}
-
 
36
 
1
 
37
/*
2
int connect_joy()
38
int connect_joy()
Line 3... Line 39...
3
{
39
{
4
 
40
 
Line 26... Line 62...
26
  printf("Joystick detected: %s\n\t%d axis\n\t%d buttons\n\n"
62
  printf("Joystick detected: %s\n\t%d axis\n\t%d buttons\n\n"
27
         , name_of_joystick
63
         , name_of_joystick
28
         , num_of_axis
64
         , num_of_axis
29
         , num_of_buttons );
65
         , num_of_buttons );
Line 30... Line 66...
30
 
66
 
Line 31... Line 67...
31
  fcntl( x52_input_fd, F_SETFL, O_NONBLOCK );   /* use non-blocking mode */
67
  fcntl( x52_input_fd, F_SETFL, O_NONBLOCK );  
32
 
68
 
-
 
69
  return 1;