Subversion Repositories Projects

Rev

Rev 130 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
140 ligi 1
#include "joy_handler.h"
130 ligi 2
 
140 ligi 3
 
130 ligi 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
 
140 ligi 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
 
37
/*
38
int connect_joy()
39
{
40
 
41
  axis = (int *) calloc( 100, sizeof( int ) );
42
  button = (char *)calloc( 100, sizeof( char ) );
43
  button_trigger = (char *) calloc( 100, sizeof( char ) );
44
 
45
 
46
  //  axis = (int *) calloc( num_of_axis, sizeof( int ) );
47
  // button = (char *)calloc( num_of_buttons, sizeof( char ) );
48
  // button_trigger = (char *) calloc( num_of_buttons, sizeof( char ) );
49
 
50
 
130 ligi 51
  if( ( x52_input_fd = open( JOY_DEV, O_RDONLY ) ) < 0 )
52
    {
53
      printf( "Couldn't open joystick device %s\n", JOY_DEV );
54
      printf( "try modprobe joydev\n"  );
55
      return 0;
56
    }
57
 
58
  ioctl( x52_input_fd, JSIOCGAXES, &num_of_axis );
59
  ioctl( x52_input_fd, JSIOCGBUTTONS, &num_of_buttons );
60
  ioctl( x52_input_fd, JSIOCGNAME(80), &name_of_joystick );
61
 
62
  printf("Joystick detected: %s\n\t%d axis\n\t%d buttons\n\n"
63
         , name_of_joystick
64
         , num_of_axis
65
         , num_of_buttons );
66
 
140 ligi 67
  fcntl( x52_input_fd, F_SETFL, O_NONBLOCK );  
130 ligi 68
 
69
  return 1;
70
}
140 ligi 71
*/