Panda3D
virtualMouse.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 virtualMouse.h
10  * @author drose
11  * @date 2002-03-12
12  */
13 
14 #ifndef VIRTUALMOUSE_H
15 #define VIRTUALMOUSE_H
16 
17 #include "pandabase.h"
18 #include "dataNode.h"
19 #include "buttonHandle.h"
20 #include "buttonEvent.h"
21 #include "pointerTo.h"
22 #include "luse.h"
23 #include "linmath_events.h"
24 #include "buttonEventList.h"
25 
26 /**
27  * Poses as a MouseAndKeyboard object in the datagraph, but accepts input from
28  * user calls, rather than reading the actual mouse and keyboard from an input
29  * device. The user can write high-level code to put the mouse wherever
30  * he/she wants, and to insert keypresses on demand.
31  */
32 class EXPCL_PANDA_DEVICE VirtualMouse : public DataNode {
33 PUBLISHED:
34  explicit VirtualMouse(const std::string &name);
35 
36  void set_mouse_pos(int x, int y);
37  void set_window_size(int width, int height);
38  void set_mouse_on(bool flag);
39 
40  void press_button(ButtonHandle button);
41  void release_button(ButtonHandle button);
42 
43 private:
44  int _mouse_x, _mouse_y;
45  int _win_width, _win_height;
46  bool _mouse_on;
47 
48 protected:
49  // Inherited from DataNode
50  virtual void do_transmit_data(DataGraphTraverser *trav,
51  const DataNodeTransmit &input,
52  DataNodeTransmit &output);
53 
54 private:
55  // outputs
56  int _pixel_xy_output;
57  int _pixel_size_output;
58  int _xy_output;
59  int _button_events_output;
60 
61  PT(EventStoreVec2) _pixel_xy;
62  PT(EventStoreVec2) _pixel_size;
63  PT(EventStoreVec2) _xy;
64  PT(ButtonEventList) _button_events;
65  PT(ButtonEventList) _next_button_events;
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, "VirtualMouse",
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.
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.
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.
Records a set of button events that happened recently.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Poses as a MouseAndKeyboard object in the datagraph, but accepts input from user calls,...
Definition: virtualMouse.h:32
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.
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...