forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvirtualMouse.h
More file actions
85 lines (73 loc) · 2.2 KB
/
virtualMouse.h
File metadata and controls
85 lines (73 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file virtualMouse.h
* @author drose
* @date 2002-03-12
*/
#ifndef VIRTUALMOUSE_H
#define VIRTUALMOUSE_H
#include "pandabase.h"
#include "dataNode.h"
#include "buttonHandle.h"
#include "buttonEvent.h"
#include "pointerTo.h"
#include "luse.h"
#include "linmath_events.h"
#include "buttonEventList.h"
/**
* 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. The user can write high-level code to put the mouse wherever
* he/she wants, and to insert keypresses on demand.
*/
class EXPCL_PANDA_DEVICE VirtualMouse : public DataNode {
PUBLISHED:
explicit VirtualMouse(const std::string &name);
void set_mouse_pos(int x, int y);
void set_window_size(int width, int height);
void set_mouse_on(bool flag);
void press_button(ButtonHandle button);
void release_button(ButtonHandle button);
private:
int _mouse_x, _mouse_y;
int _win_width, _win_height;
bool _mouse_on;
protected:
// Inherited from DataNode
virtual void do_transmit_data(DataGraphTraverser *trav,
const DataNodeTransmit &input,
DataNodeTransmit &output);
private:
// outputs
int _pixel_xy_output;
int _pixel_size_output;
int _xy_output;
int _button_events_output;
PT(EventStoreVec2) _pixel_xy;
PT(EventStoreVec2) _pixel_size;
PT(EventStoreVec2) _xy;
PT(ButtonEventList) _button_events;
PT(ButtonEventList) _next_button_events;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
DataNode::init_type();
register_type(_type_handle, "VirtualMouse",
DataNode::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
#endif