00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CLIENTBUTTONDEVICE_H
00016 #define CLIENTBUTTONDEVICE_H
00017
00018 #include "pandabase.h"
00019
00020 #include "clientDevice.h"
00021
00022 #include "buttonHandle.h"
00023 #include "buttonEvent.h"
00024 #include "buttonEventList.h"
00025 #include "pointerTo.h"
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 class EXPCL_PANDA_DEVICE ClientButtonDevice : public ClientDevice {
00038 protected:
00039 ClientButtonDevice(ClientBase *client, const string &device_name);
00040
00041 public:
00042 INLINE int get_num_buttons() const;
00043
00044 INLINE void set_button_map(int index, ButtonHandle button);
00045 INLINE ButtonHandle get_button_map(int index) const;
00046
00047 void set_button_state(int index, bool down);
00048 INLINE bool get_button_state(int index) const;
00049 INLINE bool is_button_known(int index) const;
00050
00051 INLINE ButtonEventList *get_button_events() const;
00052
00053 virtual void output(ostream &out) const;
00054 virtual void write(ostream &out, int indent_level = 0) const;
00055
00056 void output_buttons(ostream &out) const;
00057 void write_buttons(ostream &out, int indent_level) const;
00058
00059 private:
00060 void ensure_button_index(int index);
00061
00062 protected:
00063 enum State {
00064 S_unknown,
00065 S_up,
00066 S_down
00067 };
00068
00069 class ButtonState {
00070 public:
00071 INLINE ButtonState();
00072
00073 ButtonHandle _handle;
00074 State _state;
00075 };
00076
00077 typedef pvector<ButtonState> Buttons;
00078 Buttons _buttons;
00079
00080 PT(ButtonEventList) _button_events;
00081
00082 public:
00083 static TypeHandle get_class_type() {
00084 return _type_handle;
00085 }
00086 static void init_type() {
00087 ClientDevice::init_type();
00088 register_type(_type_handle, "ClientButtonDevice",
00089 ClientDevice::get_class_type());
00090 }
00091 virtual TypeHandle get_type() const {
00092 return get_class_type();
00093 }
00094 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00095
00096 private:
00097 static TypeHandle _type_handle;
00098 friend class ButtonState;
00099 };
00100
00101 #include "clientButtonDevice.I"
00102
00103 #endif