Panda3D
 All Classes Functions Variables Enumerations
virtualMouse.h
1 // Filename: virtualMouse.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 VIRTUALMOUSE_H
16 #define VIRTUALMOUSE_H
17 
18 #include "pandabase.h"
19 #include "dataNode.h"
20 #include "buttonHandle.h"
21 #include "buttonEvent.h"
22 #include "pointerTo.h"
23 #include "luse.h"
24 #include "linmath_events.h"
25 #include "buttonEventList.h"
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : VirtualMouse
29 // Description : Poses as a MouseAndKeyboard object in the datagraph,
30 // but accepts input from user calls, rather than
31 // reading the actual mouse and keyboard from an input
32 // device. The user can write high-level code to put
33 // the mouse wherever he/she wants, and to insert
34 // keypresses on demand.
35 ////////////////////////////////////////////////////////////////////
36 class EXPCL_PANDA_DEVICE VirtualMouse : public DataNode {
37 PUBLISHED:
38  VirtualMouse(const string &name);
39 
40  void set_mouse_pos(int x, int y);
41  void set_window_size(int width, int height);
42  void set_mouse_on(bool flag);
43 
44  void press_button(ButtonHandle button);
45  void release_button(ButtonHandle button);
46 
47 private:
48  int _mouse_x, _mouse_y;
49  int _win_width, _win_height;
50  bool _mouse_on;
51 
52 protected:
53  // Inherited from DataNode
54  virtual void do_transmit_data(DataGraphTraverser *trav,
55  const DataNodeTransmit &input,
56  DataNodeTransmit &output);
57 
58 private:
59  // outputs
60  int _pixel_xy_output;
61  int _pixel_size_output;
62  int _xy_output;
63  int _button_events_output;
64 
65  PT(EventStoreVec2) _pixel_xy;
66  PT(EventStoreVec2) _pixel_size;
67  PT(EventStoreVec2) _xy;
68  PT(ButtonEventList) _button_events;
69  PT(ButtonEventList) _next_button_events;
70 
71 public:
72  static TypeHandle get_class_type() {
73  return _type_handle;
74  }
75  static void init_type() {
76  DataNode::init_type();
77  register_type(_type_handle, "VirtualMouse",
78  DataNode::get_class_type());
79  }
80  virtual TypeHandle get_type() const {
81  return get_class_type();
82  }
83  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
84 
85 private:
86  static TypeHandle _type_handle;
87 };
88 
89 #endif
90 
The fundamental type of node for the data graph.
Definition: dataNode.h:64
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 ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition: buttonHandle.h:28
Poses as a MouseAndKeyboard object in the datagraph, but accepts input from user calls, rather than reading the actual mouse and keyboard from an input device.
Definition: virtualMouse.h:36
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...