Line data Source code
1 :
2 : /* Copyright (c) 2016-2017, Stefan.Eilemann@epfl.ch
3 : *
4 : * This library is free software; you can redistribute it and/or modify it under
5 : * the terms of the GNU Lesser General Public License version 2.1 as published
6 : * by the Free Software Foundation.
7 : *
8 : * This library is distributed in the hope that it will be useful, but WITHOUT
9 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 : * details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this library; if not, write to the Free Software Foundation, Inc.,
15 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 : */
17 :
18 : #ifndef EQFABRIC_POINTEREVENT_H
19 : #define EQFABRIC_POINTEREVENT_H
20 :
21 : #include <eq/fabric/event.h>
22 : #include <eq/fabric/renderContext.h> // member
23 :
24 : namespace eq
25 : {
26 : namespace fabric
27 : {
28 : /** Event for a pointer (mouse) motion or click. */
29 2 : struct PointerEvent : public Event
30 : {
31 2 : PointerEvent()
32 2 : : x(0)
33 : , y(0)
34 : , dx(0)
35 : , dy(0)
36 : , buttons(0)
37 : , button(0)
38 : , xAxis(0)
39 2 : , yAxis(0)
40 : {
41 2 : }
42 :
43 : int32_t x; //!< X position relative to entity
44 : int32_t y; //!< Y position relative to entity (0 is on top)
45 : int32_t dx; //!< X position change since last event
46 : int32_t dy; //!< Y position change since last event
47 : uint32_t buttons; //!< current state of all buttons
48 : uint32_t button; //!< fired button
49 : KeyModifier modifiers; //!< state of modifier keys
50 : float xAxis; //!< x wheel rotation in clicks
51 : float yAxis; //!< y wheel rotation in clicks
52 : RenderContext context; //!< The last rendering context at position
53 : };
54 :
55 : /** Print the pointer event to the given output stream. @version 1.0 */
56 : inline std::ostream& operator<<(std::ostream& os, const PointerEvent& event)
57 : {
58 : os << static_cast<const Event&>(event) << " [" << event.x << "], ["
59 : << event.y << "] d(" << event.dx << ", " << event.dy << ')' << " wheel "
60 : << '[' << event.xAxis << ", " << event.yAxis << "] buttons ";
61 :
62 : if (event.buttons == PTR_BUTTON_NONE)
63 : os << "none";
64 : if (event.buttons & PTR_BUTTON1)
65 : os << "1";
66 : if (event.buttons & PTR_BUTTON2)
67 : os << "2";
68 : if (event.buttons & PTR_BUTTON3)
69 : os << "3";
70 : if (event.buttons & PTR_BUTTON4)
71 : os << "4";
72 : if (event.buttons & PTR_BUTTON5)
73 : os << "5";
74 :
75 : os << event.modifiers << " fired ";
76 : if (event.button == PTR_BUTTON_NONE)
77 : os << "none";
78 : if (event.button & PTR_BUTTON1)
79 : os << "1";
80 : if (event.button & PTR_BUTTON2)
81 : os << "2";
82 : if (event.button & PTR_BUTTON3)
83 : os << "3";
84 : if (event.button & PTR_BUTTON4)
85 : os << "4";
86 : if (event.button & PTR_BUTTON5)
87 : os << "5";
88 :
89 : return os << " context " << event.context;
90 : }
91 : }
92 : }
93 :
94 : #endif // EQFABRIC_EVENT_H
|