/* LICENSE:
  =========================================================================
    CMPack'04 Source Code Release for OPEN-R SDK 1.1.5-r2 for ERS7
    Copyright (C) 2004 Multirobot Lab [Project Head: Manuela Veloso]
    School of Computer Science, Carnegie Mellon University
    All rights reserved.
  ======================================================================== */

#ifndef INCLUDED_Joystick_h
#define INCLUDED_Joystick_h

#include <string.h>

class Joystick {
 private:
  static const int MAX_NAME_LEN = 128;
  static const int MAX_AXES    = 12;
  static const int MAX_BUTTONS = 12;
  
  int fd;

 public:
  int num_axes,num_buttons;
  char name[MAX_NAME_LEN];
  int axes[MAX_AXES];
  char buttons[MAX_BUTTONS];
  
  Joystick() {
    fd=-1;
    strcpy(name,"Unknown");
    num_axes = num_buttons = 0;
    for(int i=0; i<MAX_AXES; i++)
      axes[i] = 0;
    for(int i=0; i<MAX_BUTTONS; i++)
      buttons[i] = 0;
  }
  
  bool isOpen() {
    return(fd!=-1);
  }

  int open(const char *dev);
  // -1 means wait indefinitely
  int processEvents(int max_wait_time_ms);
  int close();
};

#endif
