27MouseAndKeyboard(
GraphicsWindow *window,
int device,
const std::string &name) :
30 _device(window->get_input_device(device))
32 _pixel_xy_output = define_output(
"pixel_xy", EventStoreVec2::get_class_type());
33 _pixel_size_output = define_output(
"pixel_size", EventStoreVec2::get_class_type());
34 _xy_output = define_output(
"xy", EventStoreVec2::get_class_type());
35 _button_events_output = define_output(
"button_events", ButtonEventList::get_class_type());
36 _pointer_events_output = define_output(
"pointer_events", PointerEventList::get_class_type());
38 _pixel_xy =
new EventStoreVec2(LPoint2(0.0f, 0.0f));
39 _pixel_size =
new EventStoreVec2(LPoint2(0.0f, 0.0f));
40 _xy =
new EventStoreVec2(LPoint2(0.0f, 0.0f));
42 _device->enable_pointer_events();
65void MouseAndKeyboard::
76 PT(PointerEventList) pel = device->get_pointer_events();
77 output.set_data(_pointer_events_output, EventParameter(pel));
81 WindowProperties properties = _window->get_properties();
86 _pixel_size->set_value(LPoint2(w, h));
87 output.set_data(_pixel_size_output, EventParameter(_pixel_size));
92 if (mdata._in_window) {
94 _pixel_xy->set_value(LPoint2(mdata._xpos, mdata._ypos));
95 output.set_data(_pixel_xy_output, EventParameter(_pixel_xy));
98 PN_stdfloat xf = (PN_stdfloat)(2 * mdata._xpos) / (PN_stdfloat)w - 1.0f;
99 PN_stdfloat yf = 1.0f - (PN_stdfloat)(2 * mdata._ypos) / (PN_stdfloat)h;
101 _xy->set_value(LPoint2(xf, yf));
102 output.set_data(_xy_output, EventParameter(_xy));
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...
Encapsulates the data generated from (or sent into) any particular DataNode.
void set_data(int index, const EventParameter &data)
Sets the data for the indicated parameter.
The fundamental type of node for the data graph.
An optional parameter associated with an event.
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
get_input_device
Returns the nth input device associated with the window.
void set_source(GraphicsWindow *window, int device)
Redirects the class to get the data from the mouse and keyboard associated with a different window an...
void output(std::ostream &out) const
Outputs the Namable.
constexpr To * p() const noexcept
Returns an ordinary pointer instead of a PointerTo.
TypeHandle is the identifier used to differentiate C++ class types.
int get_y_size() const
Returns size in pixels in the y dimension of the useful part of the window, not including decorations...
int get_x_size() const
Returns size in pixels in the x dimension of the useful part of the window, not including decorations...
has_size
Returns true if the window size has been specified, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.