Difference for arch/linux/joystick.c from version 1.2 to 1.3


version 1.2 version 1.3
Line 13
 
Line 13
 char joy_installed = 0;  char joy_installed = 0;
 char joy_present = 0;  char joy_present = 0;
   
 joystick_device j_joystick[4];  joystick_device j_joystick[MAX_JOY_DEVS];
 joystick_axis j_axis[MAX_AXES];  joystick_axis j_axis[MAX_AXES];
 joystick_button j_button[MAX_BUTTONS];  joystick_button j_button[MAX_BUTTONS];
   
 int j_num_axes = 0, j_num_buttons = 0;  int j_num_axes = 0, j_num_buttons = 0;
 int timer_rate;  int timer_rate;
   
 int j_axes_in_sticks[4]; /* number of axes in the first [x] sticks */  int j_axes_in_sticks[MAX_JOY_DEVS]; /* number of axes in the first [x] sticks */
 int j_buttons_in_sticks[4];     /* number of buttons in the first [x] sticks */  int j_buttons_in_sticks[MAX_JOY_DEVS];     /* number of buttons in the first [x] sticks */
   
 int joy_deadzone = 0;  int joy_deadzone = 0;
   
Line 64
 
Line 64
  j_button[i].last_state = j_button[i].state;   j_button[i].last_state = j_button[i].state;
  }   }
   
  for (i = 0; i < 4; i++) {   for (i = 0; i < MAX_JOY_DEVS; i++) {
  if (j_joystick[i].buffer >= 0) {   if (j_joystick[i].buffer >= 0) {
  if (j_joystick[i].version) {   if (j_joystick[i].version) {
  while (read (j_joystick[i].buffer, &current_event, sizeof (struct js_event)) > 0) {   while (read (j_joystick[i].buffer, &current_event, sizeof (struct js_event)) > 0) {
Line 177
 
Line 177
   
 int joy_init () {  int joy_init () {
  int i, j;   int i, j;
    int joystick_found;
   
  if (joy_installed) return 0;   if (joy_installed) return 0;
  joy_flush ();   joy_flush ();
Line 189
 
Line 190
  j_joystick[1].buffer = open ("/dev/js1", O_NONBLOCK);   j_joystick[1].buffer = open ("/dev/js1", O_NONBLOCK);
  j_joystick[2].buffer = open ("/dev/js2", O_NONBLOCK);   j_joystick[2].buffer = open ("/dev/js2", O_NONBLOCK);
  j_joystick[3].buffer = open ("/dev/js3", O_NONBLOCK);   j_joystick[3].buffer = open ("/dev/js3", O_NONBLOCK);
     j_joystick[4].buffer = open ("/dev/input/js0", O_NONBLOCK);
  if (j_joystick[0].buffer >= 0 || j_joystick[1].buffer >= 0 || j_joystick[2].buffer >= 0 || j_joystick[3].buffer >= 0) {   j_joystick[5].buffer = open ("/dev/input/js1", O_NONBLOCK);
    j_joystick[6].buffer = open ("/dev/input/js2", O_NONBLOCK);
    j_joystick[7].buffer = open ("/dev/input/js3", O_NONBLOCK);
   
    // Determine whether any sticks were found
    joystick_found = 0;
    for (i = 0; i < MAX_JOY_DEVS; i++) {
        if (j_joystick[i].buffer >= 0) {
    joystick_found = 1;
    break;
        }
    }
    if (joystick_found) {
 // printf ("found: ");  // printf ("found: ");
   
  for (i = 0; i < 4; i++) {   for (i = 0; i < MAX_JOY_DEVS; i++) {
  if (j_joystick[i].buffer >= 0) {   if (j_joystick[i].buffer >= 0) {
  ioctl (j_joystick[i].buffer, JSIOCGAXES, &j_joystick[i].num_axes);   ioctl (j_joystick[i].buffer, JSIOCGAXES, &j_joystick[i].num_axes);
  ioctl (j_joystick[i].buffer, JSIOCGBUTTONS, &j_joystick[i].num_buttons);   ioctl (j_joystick[i].buffer, JSIOCGBUTTONS, &j_joystick[i].num_buttons);
Line 258
 
Line 271
   
  if (!joy_installed) return;   if (!joy_installed) return;
   
  for (i = 0; i < 4; i++) {   for (i = 0; i < MAX_JOY_DEVS; i++) {
  if (j_joystick[i].buffer>=0) {   if (j_joystick[i].buffer>=0) {
  printf ("closing js%d\n", i);   printf ("closing js%d\n", i);
  close (j_joystick[i].buffer);   close (j_joystick[i].buffer);

Legend:
line(s) removed in v.1.2 
line(s) changed
 line(s) added in v.1.3