30
30
QVREvent::QVREvent () :
31
31
type(QVR_Event_KeyPress),
32
32
context(),
33
- keyEvent(QEvent::None, 0 , Qt::NoModifier),
34
- mouseEvent(QEvent::None, QPointF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier),
35
- wheelEvent(QPointF(), QPointF(), QPoint(), QPoint(), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false),
36
- deviceEvent(QVRDevice(), -1, -1)
33
+ deviceEvent(QVRDevice(), -1, -1),
34
+ keyEventType(QEvent::None),
35
+ keyEventKey(0 ),
36
+ keyEventModifiers(Qt::NoModifier),
37
+ keyEventNativeScanCode(0 ),
38
+ keyEventNativeVirtualKey(0 ),
39
+ keyEventNativeModifiers(0 ),
40
+ keyEventText(),
41
+ keyEventAutorepeat(false ),
42
+ keyEventCount(0 )
43
+ {}
44
+
45
+ QVREvent::QVREvent (QVREventType t, const QVRDeviceEvent& e) :
46
+ type(t),
47
+ context(),
48
+ deviceEvent(e)
37
49
{}
38
50
39
51
QVREvent::QVREvent (QVREventType t, const QVRRenderContext& c, const QKeyEvent& e) :
40
52
type(t),
41
53
context(c),
42
- keyEvent(e),
43
- mouseEvent(QEvent::None, QPointF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier),
44
- wheelEvent(QPointF(), QPointF(), QPoint(), QPoint(), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false),
45
- deviceEvent(QVRDevice(), -1, -1)
54
+ deviceEvent(QVRDevice(), -1, -1),
55
+ keyEventType(e.type()),
56
+ keyEventKey(e.key()),
57
+ keyEventModifiers(e.modifiers()),
58
+ keyEventNativeScanCode(e.nativeScanCode()),
59
+ keyEventNativeVirtualKey(e.nativeVirtualKey()),
60
+ keyEventNativeModifiers(e.nativeModifiers()),
61
+ keyEventText(e.text()),
62
+ keyEventAutorepeat(e.isAutoRepeat()),
63
+ keyEventCount(e.count())
46
64
{}
47
65
48
66
QVREvent::QVREvent (QVREventType t, const QVRRenderContext& c, const QMouseEvent& e) :
49
67
type(t),
50
68
context(c),
51
- keyEvent(QEvent::None, 0 , Qt::NoModifier),
52
- mouseEvent(e),
53
- wheelEvent(QPointF(), QPointF(), QPoint(), QPoint(), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false),
54
- deviceEvent(QVRDevice(), -1, -1)
69
+ deviceEvent(QVRDevice(), -1, -1),
70
+ mouseEventType(e.type()),
71
+ mouseEventPosition(e.position()),
72
+ mouseEventScenePosition(e.scenePosition()),
73
+ mouseEventGlobalPosition(e.globalPosition()),
74
+ mouseEventButton(e.button()),
75
+ mouseEventButtons(e.buttons()),
76
+ mouseEventModifiers(e.modifiers())
55
77
{}
56
78
57
79
QVREvent::QVREvent (QVREventType t, const QVRRenderContext& c, const QWheelEvent& e) :
58
80
type(t),
59
81
context(c),
60
- keyEvent(QEvent::None, 0 , Qt::NoModifier),
61
- mouseEvent(QEvent::None, QPointF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier),
62
- wheelEvent(e),
63
- deviceEvent(QVRDevice(), -1, -1)
82
+ deviceEvent(QVRDevice(), -1, -1),
83
+ wheelEventPosition(e.position()),
84
+ wheelEventGlobalPosition(e.globalPosition()),
85
+ wheelEventPixelDelta(e.pixelDelta()),
86
+ wheelEventAngleDelta(e.angleDelta()),
87
+ wheelEventButtons(e.buttons()),
88
+ wheelEventModifiers(e.modifiers()),
89
+ wheelEventPhase(e.phase()),
90
+ wheelEventInverted(e.inverted())
64
91
{}
65
92
66
- QVREvent::QVREvent (QVREventType t, const QVRDeviceEvent& e) :
67
- type(t),
68
- context(),
69
- keyEvent(QEvent::None, 0 , Qt::NoModifier),
70
- mouseEvent(QEvent::None, QPointF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier),
71
- wheelEvent(QPointF(), QPointF(), QPoint(), QPoint(), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false),
72
- deviceEvent(e)
73
- {}
93
+ QKeyEvent* QVREvent::createKeyEvent () const
94
+ {
95
+ return new QKeyEvent (keyEventType, keyEventKey, keyEventModifiers,
96
+ keyEventNativeScanCode, keyEventNativeVirtualKey, keyEventNativeModifiers,
97
+ keyEventText, keyEventAutorepeat, keyEventCount);
98
+ }
99
+
100
+ QMouseEvent* QVREvent::createMouseEvent () const
101
+ {
102
+ return new QMouseEvent (mouseEventType, mouseEventPosition, mouseEventScenePosition,
103
+ mouseEventGlobalPosition, mouseEventButton, mouseEventButtons, mouseEventModifiers);
104
+ }
105
+
106
+ QWheelEvent* QVREvent::createWheelEvent () const
107
+ {
108
+ return new QWheelEvent (wheelEventPosition, wheelEventGlobalPosition, wheelEventPixelDelta,
109
+ wheelEventAngleDelta, wheelEventButtons, wheelEventModifiers, wheelEventPhase,
110
+ wheelEventInverted);
111
+ }
74
112
75
113
QDataStream &operator <<(QDataStream& ds, const QVREvent& e)
76
114
{
77
- ds << static_cast <int >(e.type );
115
+ ds << static_cast <int >(e.type ) << e. context ;
78
116
switch (e.type ) {
79
117
case QVR_Event_KeyPress:
80
118
case QVR_Event_KeyRelease:
81
- ds << e.context
82
- << static_cast <int >(e.keyEvent .type ())
83
- << e.keyEvent .key ()
84
- << static_cast <int >(e.keyEvent .modifiers ());
119
+ ds << static_cast <int >(e.keyEventType )
120
+ << e.keyEventKey
121
+ << static_cast <int >(e.keyEventModifiers )
122
+ << e.keyEventNativeScanCode
123
+ << e.keyEventNativeVirtualKey
124
+ << e.keyEventNativeModifiers
125
+ << e.keyEventText
126
+ << e.keyEventAutorepeat
127
+ << e.keyEventCount ;
85
128
break ;
86
129
case QVR_Event_MouseMove:
87
130
case QVR_Event_MousePress:
88
131
case QVR_Event_MouseRelease:
89
132
case QVR_Event_MouseDoubleClick:
90
- ds << e.context
91
- << static_cast <int >(e.mouseEvent .type ())
92
- << e.mouseEvent .localPos ()
93
- << static_cast <int >(e.mouseEvent .button ())
94
- << static_cast <int >(e.mouseEvent .buttons ())
95
- << static_cast <int >(e.mouseEvent .modifiers ());
133
+ ds << static_cast <int >(e.mouseEventType )
134
+ << e.mouseEventPosition
135
+ << e.mouseEventScenePosition
136
+ << e.mouseEventGlobalPosition
137
+ << static_cast <int >(e.mouseEventButton )
138
+ << static_cast <int >(e.mouseEventButtons )
139
+ << static_cast <int >(e.mouseEventModifiers );
96
140
break ;
97
141
case QVR_Event_Wheel:
98
- ds << e.context
99
- << e.wheelEvent .position ()
100
- << e.wheelEvent .globalPosition ()
101
- << e.wheelEvent .pixelDelta ()
102
- << e.wheelEvent .angleDelta ()
103
- << static_cast <int >(e.wheelEvent .buttons ())
104
- << static_cast <int >(e.wheelEvent .modifiers ())
105
- << static_cast <int >(e.wheelEvent .phase ())
106
- << static_cast <int >(e.wheelEvent .inverted ());
142
+ ds << e.wheelEventPosition
143
+ << e.wheelEventGlobalPosition
144
+ << e.wheelEventPixelDelta
145
+ << e.wheelEventAngleDelta
146
+ << static_cast <int >(e.wheelEventButtons )
147
+ << static_cast <int >(e.wheelEventModifiers )
148
+ << static_cast <int >(e.wheelEventPhase )
149
+ << e.wheelEventInverted ;
107
150
break ;
108
151
case QVR_Event_DeviceButtonPress:
109
152
case QVR_Event_DeviceButtonRelease:
@@ -120,60 +163,62 @@ QDataStream &operator>>(QDataStream& ds, QVREvent& e)
120
163
int type;
121
164
ds >> type;
122
165
e.type = static_cast <QVREventType>(type);
166
+ ds >> e.context ;
123
167
124
- int ke[3 ];
125
- int me[4 ];
126
- QPointF mepf;
127
- QPointF wepf[2 ];
128
- QPoint wep[2 ];
129
- int we[4 ];
130
- QVRDevice d;
131
- int de[2 ];
132
-
168
+ int intval;
133
169
switch (e.type ) {
134
170
case QVR_Event_KeyPress:
135
171
case QVR_Event_KeyRelease:
136
- ds >> e.context
137
- >> ke[0 ]
138
- >> ke[1 ]
139
- >> ke[2 ];
140
- e.keyEvent = QKeyEvent (static_cast <QEvent::Type>(ke[0 ]), ke[1 ], static_cast <Qt::KeyboardModifier>(ke[2 ]));
172
+ ds >> intval;
173
+ e.keyEventType = static_cast <QEvent::Type>(intval);
174
+ ds >> e.keyEventKey ;
175
+ ds >> intval;
176
+ e.keyEventModifiers = static_cast <Qt::KeyboardModifiers>(intval);
177
+ ds >> e.keyEventNativeScanCode
178
+ >> e.keyEventNativeVirtualKey
179
+ >> e.keyEventNativeModifiers
180
+ >> e.keyEventText
181
+ >> e.keyEventAutorepeat
182
+ >> e.keyEventCount ;
141
183
break ;
142
184
case QVR_Event_MouseMove:
143
185
case QVR_Event_MousePress:
144
186
case QVR_Event_MouseRelease:
145
187
case QVR_Event_MouseDoubleClick:
146
- ds >> e.context
147
- >> me[0 ]
148
- >> mepf
149
- >> me[1 ]
150
- >> me[2 ]
151
- >> me[3 ];
152
- e.mouseEvent = QMouseEvent (static_cast <QEvent::Type>(me[0 ]), mepf,
153
- static_cast <Qt::MouseButton>(me[1 ]), static_cast <Qt::MouseButtons>(me[2 ]),
154
- static_cast <Qt::KeyboardModifier>(me[3 ]));
188
+ ds >> intval;
189
+ e.mouseEventType = static_cast <QEvent::Type>(intval);
190
+ ds >> e.mouseEventPosition
191
+ >> e.mouseEventScenePosition
192
+ >> e.mouseEventGlobalPosition
193
+ >> intval;
194
+ e.mouseEventButton = static_cast <Qt::MouseButton>(intval);
195
+ ds >> intval;
196
+ e.mouseEventButtons = static_cast <Qt::MouseButtons>(intval);
197
+ ds >> intval;
198
+ e.mouseEventModifiers = static_cast <Qt::KeyboardModifiers>(intval);
155
199
break ;
156
200
case QVR_Event_Wheel:
157
- ds >> e.context
158
- >> wepf[0 ]
159
- >> wepf[1 ]
160
- >> wep[0 ]
161
- >> wep[1 ]
162
- >> we[0 ]
163
- >> we[1 ]
164
- >> we[2 ]
165
- >> we[3 ];
166
- e.wheelEvent = QWheelEvent (wepf[0 ], wepf[1 ], wep[0 ], wep[1 ],
167
- static_cast <Qt::MouseButtons>(we[0 ]), static_cast <Qt::KeyboardModifier>(we[1 ]),
168
- static_cast <Qt::ScrollPhase>(we[2 ]), static_cast <bool >(we[3 ]));
201
+ ds >> e.wheelEventPosition
202
+ >> e.wheelEventGlobalPosition
203
+ >> e.wheelEventPixelDelta
204
+ >> e.wheelEventAngleDelta
205
+ >> intval;
206
+ e.wheelEventButtons = static_cast <Qt::MouseButtons>(intval);
207
+ ds >> intval;
208
+ e.wheelEventModifiers = static_cast <Qt::KeyboardModifiers>(intval);
209
+ ds >> intval;
210
+ e.wheelEventPhase = static_cast <Qt::ScrollPhase>(intval);
211
+ ds >> e.wheelEventInverted ;
169
212
break ;
170
213
case QVR_Event_DeviceButtonPress:
171
214
case QVR_Event_DeviceButtonRelease:
172
215
case QVR_Event_DeviceAnalogChange:
173
- ds >> d
174
- >> de[0 ]
175
- >> de[1 ];
176
- e.deviceEvent = QVRDeviceEvent (d, de[0 ], de[1 ]);
216
+ {
217
+ QVRDevice d;
218
+ int de[2 ];
219
+ ds >> d >> de[0 ] >> de[1 ];
220
+ e.deviceEvent = QVRDeviceEvent (d, de[0 ], de[1 ]);
221
+ }
177
222
break ;
178
223
}
179
224
return ds;
0 commit comments