Panda3D
mouseAndKeyboard.h
1 // Filename: mouseAndKeyboard.h
2 // Created by: drose (12Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef MOUSEANDKEYBOARD_H
16 #define MOUSEANDKEYBOARD_H
17 
18 #include "pandabase.h"
19 
20 #include "dataNode.h"
21 #include "buttonEventList.h"
22 #include "pointerEventList.h"
23 #include "linmath_events.h"
24 #include "pointerTo.h"
25 #include "graphicsWindow.h"
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : MouseAndKeyboard
29 // Description : Reads the mouse and/or keyboard data sent from a
30 // GraphicsWindow, and transmits it down the data graph.
31 //
32 // The mouse and keyboard devices are bundled together
33 // into one device here, because they interrelate so
34 // much. A mouse might be constrained by the holding
35 // down of the shift key, for instance, or the clicking
36 // of the mouse button might be handled in much the same
37 // way as a keyboard key.
38 //
39 // Mouse data is sent down the data graph as an x,y
40 // position as well as the set of buttons currently
41 // being held down; keyboard data is sent down as a set
42 // of keypress events in an EventDataTransition. To
43 // throw these events to the system, you must attach an
44 // EventThrower to the MouseAndKeyboard object;
45 // otherwise, the events will be discarded.
46 ////////////////////////////////////////////////////////////////////
47 class EXPCL_PANDA_DEVICE MouseAndKeyboard : public DataNode {
48 PUBLISHED:
49  MouseAndKeyboard(GraphicsWindow *window, int device, const string &name);
50  void set_source(GraphicsWindow *window, int device);
51 
52  PT(GraphicsWindow) get_source_window() const;
53  int get_source_device() const;
54 
55 protected:
56  // Inherited from DataNode
57  virtual void do_transmit_data(DataGraphTraverser *trav,
58  const DataNodeTransmit &input,
59  DataNodeTransmit &output);
60 
61 private:
62  // outputs
63  int _pixel_xy_output;
64  int _pixel_size_output;
65  int _xy_output;
66  int _button_events_output;
67  int _pointer_events_output;
68 
69  PT(EventStoreVec2) _pixel_xy;
70  PT(EventStoreVec2) _pixel_size;
71  PT(EventStoreVec2) _xy;
72  PT(ButtonEventList) _button_events;
73 
74  PT(GraphicsWindow) _window;
75  int _device;
76 
77 public:
78  static TypeHandle get_class_type() {
79  return _type_handle;
80  }
81  static void init_type() {
82  DataNode::init_type();
83  register_type(_type_handle, "MouseAndKeyboard",
84  DataNode::get_class_type());
85  }
86  virtual TypeHandle get_type() const {
87  return get_class_type();
88  }
89  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
90 
91 private:
92  static TypeHandle _type_handle;
93 };
94 
95 #endif
The fundamental type of node for the data graph.
Definition: dataNode.h:64
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:109
Records a set of button events that happened recently.
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
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...