Panda3D
|
00001 // Filename: mouseInterfaceNode.h 00002 // Created by: drose (11Jun04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef MOUSEINTERFACENODE_H 00016 #define MOUSEINTERFACENODE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "dataNode.h" 00021 #include "modifierButtons.h" 00022 00023 class ButtonEventList; 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : MouseInterfaceNode 00027 // Description : This is the base class for some classes that monitor 00028 // the mouse and keyboard input and perform some action 00029 // due to their state. 00030 // 00031 // It collects together some common interface; in 00032 // particular, the require_button() and related methods. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_PANDA_TFORM MouseInterfaceNode : public DataNode { 00035 public: 00036 MouseInterfaceNode(const string &name); 00037 virtual ~MouseInterfaceNode(); 00038 00039 PUBLISHED: 00040 void require_button(const ButtonHandle &button, bool is_down); 00041 void clear_button(const ButtonHandle &button); 00042 void clear_all_buttons(); 00043 00044 protected: 00045 void watch_button(const ButtonHandle &button); 00046 const ButtonEventList *check_button_events(const DataNodeTransmit &input, 00047 bool &required_buttons_match); 00048 00049 INLINE bool is_down(ButtonHandle button) const; 00050 00051 private: 00052 ModifierButtons _current_button_state; 00053 ModifierButtons _watched_buttons; 00054 ModifierButtons _required_buttons_mask; 00055 ModifierButtons _required_buttons_state; 00056 00057 private: 00058 int _button_events_input; 00059 00060 public: 00061 static TypeHandle get_class_type() { 00062 return _type_handle; 00063 } 00064 static void init_type() { 00065 DataNode::init_type(); 00066 register_type(_type_handle, "MouseInterfaceNode", 00067 DataNode::get_class_type()); 00068 } 00069 virtual TypeHandle get_type() const { 00070 return get_class_type(); 00071 } 00072 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00073 00074 private: 00075 static TypeHandle _type_handle; 00076 }; 00077 00078 #include "mouseInterfaceNode.I" 00079 00080 #endif