Panda3D
mouseAndKeyboard.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 mouseAndKeyboard.h
10  * @author drose
11  * @date 2002-03-12
12  */
13 
14 #ifndef MOUSEANDKEYBOARD_H
15 #define MOUSEANDKEYBOARD_H
16 
17 #include "pandabase.h"
18 
19 #include "dataNode.h"
20 #include "buttonEventList.h"
21 #include "pointerEventList.h"
22 #include "linmath_events.h"
23 #include "pointerTo.h"
24 #include "graphicsWindow.h"
25 
26 /**
27  * Reads the mouse and/or keyboard data sent from a GraphicsWindow, and
28  * transmits it down the data graph.
29  *
30  * The mouse and keyboard devices are bundled together into one device here,
31  * because they interrelate so much. A mouse might be constrained by the
32  * holding down of the shift key, for instance, or the clicking of the mouse
33  * button might be handled in much the same way as a keyboard key.
34  *
35  * Mouse data is sent down the data graph as an x,y position as well as the
36  * set of buttons currently being held down; keyboard data is sent down as a
37  * set of keypress events in an EventDataTransition. To throw these events to
38  * the system, you must attach an EventThrower to the MouseAndKeyboard object;
39  * otherwise, the events will be discarded.
40  */
41 class EXPCL_PANDA_DISPLAY MouseAndKeyboard : public DataNode {
42 PUBLISHED:
43  explicit MouseAndKeyboard(GraphicsWindow *window, int device, const std::string &name);
44  void set_source(GraphicsWindow *window, int device);
45 
46 protected:
47  // Inherited from DataNode
48  virtual void do_transmit_data(DataGraphTraverser *trav,
49  const DataNodeTransmit &input,
50  DataNodeTransmit &output);
51 
52 private:
53  // outputs
54  int _pixel_xy_output;
55  int _pixel_size_output;
56  int _xy_output;
57  int _button_events_output;
58  int _pointer_events_output;
59 
60  PT(EventStoreVec2) _pixel_xy;
61  PT(EventStoreVec2) _pixel_size;
62  PT(EventStoreVec2) _xy;
63 
64  PT(GraphicsWindow) _window;
65  PT(InputDevice) _device;
66 
67 public:
68  static TypeHandle get_class_type() {
69  return _type_handle;
70  }
71  static void init_type() {
72  DataNode::init_type();
73  register_type(_type_handle, "MouseAndKeyboard",
74  DataNode::get_class_type());
75  }
76  virtual TypeHandle get_type() const {
77  return get_class_type();
78  }
79  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
80 
81 private:
82  static TypeHandle _type_handle;
83 };
84 
85 #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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Reads the mouse and/or keyboard data sent from a GraphicsWindow, and transmits it down the data graph...
A handy class object for storing simple values (like integers or strings) passed along with an Event ...
Definition: paramValue.h:103
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
This is a structure representing a single input device.
Definition: inputDevice.h:53
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Encapsulates the data generated from (or sent into) any particular DataNode.
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...