Panda3D
|
00001 // Filename: rocketInputHandler.h 00002 // Created by: rdb (20Dec11) 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 ROCKETINPUTHANDLER_H 00016 #define ROCKETINPUTHANDLER_H 00017 00018 #include "config_rocket.h" 00019 #include "dataNode.h" 00020 #include "buttonHandle.h" 00021 00022 namespace Rocket { 00023 namespace Core { 00024 class Context; 00025 } 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Class : RocketInputHandler 00030 // Description : DataNode that listens for keyboard and mouse 00031 // events and passes them to libRocket. 00032 //////////////////////////////////////////////////////////////////// 00033 class EXPCL_ROCKET RocketInputHandler : public DataNode { 00034 PUBLISHED: 00035 RocketInputHandler(const string &name = string()); 00036 virtual ~RocketInputHandler(); 00037 00038 static int get_rocket_key(const ButtonHandle handle); 00039 00040 public: 00041 void update_context(Rocket::Core::Context *context, int xoffs, int yoffs); 00042 00043 protected: 00044 // Inherited from DataNode 00045 virtual void do_transmit_data(DataGraphTraverser *trav, 00046 const DataNodeTransmit &input, 00047 DataNodeTransmit &output); 00048 00049 private: 00050 Mutex _lock; 00051 00052 // inputs 00053 int _pixel_xy_input; 00054 int _button_events_input; 00055 00056 LVecBase2 _mouse_xy; 00057 bool _mouse_xy_changed; 00058 int _modifiers; 00059 int _wheel_delta; 00060 typedef pmap<int, bool> ButtonActivityMap; 00061 ButtonActivityMap _mouse_buttons; 00062 ButtonActivityMap _keys; 00063 pvector<int> _repeated_keys; 00064 pvector<short> _text_input; 00065 00066 public: 00067 static TypeHandle get_class_type() { 00068 return _type_handle; 00069 } 00070 static void init_type() { 00071 DataNode::init_type(); 00072 register_type(_type_handle, "RocketInputHandler", 00073 DataNode::get_class_type()); 00074 } 00075 virtual TypeHandle get_type() const { 00076 return get_class_type(); 00077 } 00078 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00079 00080 private: 00081 static TypeHandle _type_handle; 00082 }; 00083 00084 #endif