Panda3D
rocketInputHandler.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file rocketInputHandler.h
10  * @author rdb
11  * @date 2011-12-20
12  */
13 
14 #ifndef ROCKETINPUTHANDLER_H
15 #define ROCKETINPUTHANDLER_H
16 
17 #include "config_rocket.h"
18 #include "dataNode.h"
19 #include "buttonHandle.h"
20 
21 namespace Rocket {
22  namespace Core {
23  class Context;
24  }
25 }
26 
27 /**
28  * DataNode that listens for keyboard and mouse events and passes them to
29  * libRocket.
30  */
31 class EXPCL_ROCKET RocketInputHandler : public DataNode {
32 PUBLISHED:
33  RocketInputHandler(const std::string &name = std::string());
34  virtual ~RocketInputHandler();
35 
36  static int get_rocket_key(const ButtonHandle handle);
37 
38 public:
39  void update_context(Rocket::Core::Context *context, int xoffs, int yoffs);
40 
41 protected:
42  // Inherited from DataNode
43  virtual void do_transmit_data(DataGraphTraverser *trav,
44  const DataNodeTransmit &input,
45  DataNodeTransmit &output);
46 
47 private:
48  Mutex _lock;
49 
50  // inputs
51  int _pixel_xy_input;
52  int _button_events_input;
53 
54  LVecBase2 _mouse_xy;
55  bool _mouse_xy_changed;
56  int _modifiers;
57  int _wheel_delta;
59  ButtonActivityMap _mouse_buttons;
60  ButtonActivityMap _keys;
61  pvector<int> _repeated_keys;
62  pvector<short> _text_input;
63 
64 public:
65  static TypeHandle get_class_type() {
66  return _type_handle;
67  }
68  static void init_type() {
69  DataNode::init_type();
70  register_type(_type_handle, "RocketInputHandler",
71  DataNode::get_class_type());
72  }
73  virtual TypeHandle get_type() const {
74  return get_class_type();
75  }
76  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
77 
78 private:
79  static TypeHandle _type_handle;
80 };
81 
82 #endif
The fundamental type of node for the data graph.
Definition: dataNode.h:52
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
A standard mutex, or mutual exclusion lock.
Definition: pmutex.h:38
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition: buttonHandle.h:26
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
DataNode that listens for keyboard and mouse events and passes them to libRocket.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Encapsulates the data generated from (or sent into) any particular DataNode.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...