00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __JOYSTICK__
00023 #define __JOYSTICK__
00024
00025 #include "jed_defs.h"
00026
00027
00028 #if PLATAFORMA == i386_LINUX_GCC || PLATAFORMA == SPARC64_LINUX_GCC
00029 #ifdef JOYSTICK_ENABLED
00030 #include <linux/joystick.h>
00031 #endif
00032 #include <fcntl.h>
00033 #include <unistd.h>
00034 #include <sys/ioctl.h>
00035 #include <errno.h>
00036 #define JS1 "/dev/js0"
00037 #define JS2 "/dev/js1"
00038 #endif
00039
00040 #if PLATAFORMA == i386_WIN32_VC
00041 #include <dinput.h>
00042 #define JS1 "1"
00043 #define JS2 "2"
00044 #endif
00045
00046 #ifndef JS1
00047 #define JS1 "0"
00048 #endif
00049
00050 #ifndef JS2
00051 #define JS2 "0"
00052 #endif
00053
00054 #include <stdio.h>
00055
00056 #include "toolkits/media/dispositivo.h"
00057
00058 class JOYSTICK : public DISPOSITIVO {
00059 private:
00060 #ifdef JOYSTICK_ENABLED
00061 #if PLATAFORMA == i386_LINUX_GCC || PLATAFORMA == SPARC64_LINUX_GCC
00062 int fd;
00063 int status;
00064 char *archivo;
00065 struct JS_DATA_TYPE lowlevel_data;
00066 #endif
00067
00068 #if PLATAFORMA == i386_WIN32_VC
00069 LPDIRECTINPUT direct_input_object;
00070 GUID guid;
00071 BOOLEAN gui_valido;
00072 LPDIRECTINPUTDEVICE2 fd_device;
00073
00074 static BOOLEAN CALLBACK
00075 device_callback(LPDIDEVICEINSTANCE pdidi, LPVOID pv);
00076 BOOLEAN set_gain(int gain);
00077 #endif
00078 #endif
00079
00080 double fx;
00081 double fy;
00082 int fbotones;
00083 public:
00084 JOYSTICK(char *filename);
00085 virtual ~JOYSTICK();
00086 BOOLEAN abrir(void);
00087 void cerrar(void);
00088 void consultar(double *x, double *y, int *botones);
00089 void calibrar(void);
00090 void actualizar(void);
00091 BOOLEAN
00092 consultar_variable(const char *nombre_variable, int &tipo, void **ref);
00093
00094
00095 #ifdef JOYSTICK_ENABLED
00096 #if PLATAFORMA == i386_WIN32_VC
00097 LPDIRECTINPUTDEVICE2 device() { return fd_device; }
00098 #endif
00099 #endif
00100 };
00101
00102 #endif // __JOYSTICK__
00103
00104
00105
00106
00107