00001 /* 00002 $Id: input_joystick.h,v 1.1 2001/03/06 15:09:22 mbn Exp $ 00003 00004 ------------------------------------------------------------------------ 00005 ClanLib, the platform independent game SDK. 00006 00007 This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE 00008 version 2. See COPYING for details. 00009 00010 For a total list of contributers see CREDITS. 00011 00012 ------------------------------------------------------------------------ 00013 */ 00014 00015 #ifndef header_input_joystick 00016 #define header_input_joystick 00017 00018 #include "API/Display/Input/input.h" 00019 #include "API/Display/Input/inputbutton.h" 00020 #include "API/Display/Input/inputaxis.h" 00021 #include "API/Display/Input/inputhat.h" 00022 #include "API/Display/Input/inputdevice.h" 00023 #include "API/Core/System/keep_alive.h" 00024 00025 class CL_InputButton_Joystick : public CL_InputButton 00026 { 00027 protected: 00028 bool button_down; 00029 00030 public: 00031 CL_InputButton_Joystick() { button_down = false; } 00032 virtual bool is_pressed() { return button_down; } 00033 void set_state(bool new_state) { button_down = new_state; } 00034 }; 00035 00036 class CL_InputAxis_Joystick : public CL_InputAxis 00037 { 00038 protected: 00039 float pos; 00040 00041 public: 00042 CL_InputAxis_Joystick() { pos = 0; } 00043 virtual float get_pos() { return pos; } 00044 void set_pos(float new_pos) { pos = new_pos; } 00045 }; 00046 00047 class CL_InputHat_Joystick : public CL_InputHat 00048 { 00049 protected: 00050 float dir; 00051 00052 public: 00053 CL_InputHat_Joystick() { dir = -1; } 00054 virtual float get_direction() { return dir; } 00055 void set_dir(float new_dir) { dir = new_dir; } 00056 }; 00057 00058 class CL_Joystick_Win32 : public CL_InputDevice, public CL_KeepAlive 00059 { 00060 protected: 00061 int joystick_id; // Joystick identifier 00062 JOYCAPS joycaps; // Struct describing capabilities of the joystick 00063 00064 CL_InputAxis_Joystick axes[6]; 00065 CL_InputButton_Joystick buttons[32]; 00066 CL_InputHat_Joystick hat; 00067 00068 float calc_pos(int pos, int min, int max); 00069 00070 public: 00071 CL_Joystick_Win32(int joystick_id); 00072 virtual ~CL_Joystick_Win32(); 00073 00074 // from CL_InputDevice: 00075 virtual char *get_name() const; 00076 00077 virtual int get_num_buttons() const; 00078 virtual CL_InputButton *get_button(int button_num); 00079 00080 virtual int get_num_axes() const; 00081 virtual CL_InputAxis *get_axis(int axis_num); 00082 00083 virtual int get_num_hats() const; 00084 virtual CL_InputHat *get_hat(int hat_num); 00085 00086 virtual int get_num_cursors() const; 00087 virtual CL_InputCursor *get_cursor(int cursor_num); 00088 00089 virtual void keep_alive(); 00090 }; 00091 00092 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001