Panda3D
Loading...
Searching...
No Matches
graphicsWindowInputDevice.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 graphicsWindowInputDevice.h
10 * @author drose
11 * @date 2000-05-24
12 */
13
14#ifndef GRAPHICSWINDOWINPUTDEVICE_H
15#define GRAPHICSWINDOWINPUTDEVICE_H
16
17#include "pandabase.h"
18#include "inputDevice.h"
19
20// Forward declarations
21class GraphicsWindow;
22
23/**
24 * This is a virtual input device that represents the keyboard and mouse pair
25 * that is associated with a particular window. It collects mouse and
26 * keyboard events from the windowing system while the window is in focus.
27 */
28class EXPCL_PANDA_DISPLAY GraphicsWindowInputDevice : public InputDevice {
29private:
30 GraphicsWindowInputDevice(GraphicsWindow *host, const std::string &name,
31 bool pointer, bool keyboard);
32
33public:
34 static PT(GraphicsWindowInputDevice) pointer_only(GraphicsWindow *host, const std::string &name);
35 static PT(GraphicsWindowInputDevice) keyboard_only(GraphicsWindow *host, const std::string &name);
36 static PT(GraphicsWindowInputDevice) pointer_and_keyboard(GraphicsWindow *host, const std::string &name);
37
38 GraphicsWindowInputDevice() = default;
39
40PUBLISHED:
41 // The following interface is for the various kinds of GraphicsWindows to
42 // record the data incoming on the device.
43 void button_down(ButtonHandle button, double time = ClockObject::get_global_clock()->get_frame_time());
44 void button_resume_down(ButtonHandle button, double time = ClockObject::get_global_clock()->get_frame_time());
45 void button_up(ButtonHandle button, double time = ClockObject::get_global_clock()->get_frame_time());
46
47 void keystroke(int keycode, double time = ClockObject::get_global_clock()->get_frame_time());
48 void candidate(const std::wstring &candidate_string, size_t highlight_start,
49 size_t highlight_end, size_t cursor_pos);
50
51 void focus_lost(double time = ClockObject::get_global_clock()->get_frame_time());
52
53 void raw_button_down(ButtonHandle button, double time = ClockObject::get_global_clock()->get_frame_time());
54 void raw_button_up(ButtonHandle button, double time = ClockObject::get_global_clock()->get_frame_time());
55
56 INLINE PointerData get_pointer() const;
57 void set_pointer_in_window(double x, double y, double time = ClockObject::get_global_clock()->get_frame_time());
58 void set_pointer_out_of_window(double time = ClockObject::get_global_clock()->get_frame_time());
59 INLINE void update_pointer(PointerData data, double time = ClockObject::get_global_clock()->get_frame_time());
60 INLINE void pointer_moved(double x, double y, double time = ClockObject::get_global_clock()->get_frame_time());
61 INLINE void remove_pointer(int id);
62
63private:
65 ButtonsHeld _buttons_held;
66
67public:
68 static TypeHandle get_class_type() {
69 return _type_handle;
70 }
71 static void init_type() {
72 InputDevice::init_type();
73 register_type(_type_handle, "GraphicsWindowInputDevice",
74 InputDevice::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
81private:
82 static TypeHandle _type_handle;
83};
84
86
87#endif
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
This is a virtual input device that represents the keyboard and mouse pair that is associated with a ...
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
Holds the data that might be generated by a 2-d pointer input device, such as the mouse in the Graphi...
Definition pointerData.h:38
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
This is our own Panda specialization on the default STL set.
Definition pset.h:49
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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(),...