JoystickInterface.h
00001 00002 /*************************************************************************** 00003 * JoystickInterface.h - Fawkes BlackBoard Interface - JoystickInterface 00004 * 00005 * Templated created: Thu Oct 12 10:49:19 2006 00006 * Copyright 2008 Tim Niemueller 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __INTERFACES_JOYSTICKINTERFACE_H_ 00025 #define __INTERFACES_JOYSTICKINTERFACE_H_ 00026 00027 #include <interface/interface.h> 00028 #include <interface/message.h> 00029 #include <interface/field_iterator.h> 00030 00031 namespace fawkes { 00032 00033 class JoystickInterface : public Interface 00034 { 00035 /// @cond INTERNALS 00036 INTERFACE_MGMT_FRIENDS(JoystickInterface) 00037 /// @endcond 00038 public: 00039 /* constants */ 00040 static const unsigned int BUTTON_1; 00041 static const unsigned int BUTTON_2; 00042 static const unsigned int BUTTON_3; 00043 static const unsigned int BUTTON_4; 00044 static const unsigned int BUTTON_5; 00045 static const unsigned int BUTTON_6; 00046 static const unsigned int BUTTON_7; 00047 static const unsigned int BUTTON_8; 00048 static const unsigned int BUTTON_9; 00049 static const unsigned int BUTTON_10; 00050 static const unsigned int BUTTON_11; 00051 static const unsigned int BUTTON_12; 00052 static const unsigned int BUTTON_13; 00053 static const unsigned int BUTTON_14; 00054 static const unsigned int BUTTON_15; 00055 static const unsigned int BUTTON_16; 00056 static const unsigned int BUTTON_17; 00057 static const unsigned int BUTTON_18; 00058 static const unsigned int BUTTON_19; 00059 static const unsigned int BUTTON_20; 00060 static const unsigned int BUTTON_21; 00061 static const unsigned int BUTTON_22; 00062 static const unsigned int BUTTON_23; 00063 static const unsigned int BUTTON_24; 00064 static const unsigned int BUTTON_25; 00065 static const unsigned int BUTTON_26; 00066 static const unsigned int BUTTON_27; 00067 static const unsigned int BUTTON_28; 00068 static const unsigned int BUTTON_29; 00069 static const unsigned int BUTTON_30; 00070 static const unsigned int BUTTON_31; 00071 static const unsigned int BUTTON_32; 00072 00073 private: 00074 /** Internal data storage, do NOT modify! */ 00075 typedef struct { 00076 unsigned int pressed_buttons; /**< 00077 A bit field of enabled buttons. For each currently clicked button the 00078 corresponding bit is set to 1. Use the BUTTON_* constants for bit-wise 00079 comparisons. 00080 */ 00081 float axis_x[4]; /**< X values of axes */ 00082 float axis_y[4]; /**< Y values of axes */ 00083 unsigned char num_axes; /**< 00084 The number of axes of this joystick 00085 */ 00086 unsigned char num_buttons; /**< 00087 The number of buttons of this joystick. 00088 */ 00089 } JoystickInterface_data_t; 00090 00091 JoystickInterface_data_t *data; 00092 00093 public: 00094 /* messages */ 00095 virtual bool message_valid(const Message *message) const; 00096 private: 00097 JoystickInterface(); 00098 ~JoystickInterface(); 00099 00100 public: 00101 /* Methods */ 00102 unsigned char num_axes() const; 00103 void set_num_axes(const unsigned char new_num_axes); 00104 size_t maxlenof_num_axes() const; 00105 unsigned char num_buttons() const; 00106 void set_num_buttons(const unsigned char new_num_buttons); 00107 size_t maxlenof_num_buttons() const; 00108 unsigned int pressed_buttons() const; 00109 void set_pressed_buttons(const unsigned int new_pressed_buttons); 00110 size_t maxlenof_pressed_buttons() const; 00111 float * axis_x() const; 00112 float axis_x(unsigned int index) const; 00113 void set_axis_x(unsigned int index, const float new_axis_x); 00114 void set_axis_x(const float * new_axis_x); 00115 size_t maxlenof_axis_x() const; 00116 float * axis_y() const; 00117 float axis_y(unsigned int index) const; 00118 void set_axis_y(unsigned int index, const float new_axis_y); 00119 void set_axis_y(const float * new_axis_y); 00120 size_t maxlenof_axis_y() const; 00121 virtual Message * create_message(const char *type) const; 00122 00123 virtual void copy_values(const Interface *other); 00124 00125 }; 00126 00127 } // end namespace fawkes 00128 00129 #endif

