@@ -206,17 +206,29 @@ - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
206206 ev.EventType = irr::EET_TOUCH_INPUT_EVENT;
207207 ev.TouchInput .Event = irr::ETIE_PRESSED_DOWN;
208208
209+ irr::core::position2d<irr::s32> mouse_pos = irr::core::position2d<irr::s32>(0 , 0 );
210+ bool simulate_mouse = false ;
211+ size_t id = 0 ;
212+
209213 for (UITouch* touch in touches)
210214 {
211- ev.TouchInput .ID = ( size_t )touch ;
215+ ev.TouchInput .ID = id ++ ;
212216
213217 CGPoint touchPoint = [touch locationInView: self ];
214218
215219 ev.TouchInput .X = touchPoint.x *Scale;
216220 ev.TouchInput .Y = touchPoint.y *Scale;
217221
218222 Device->postEventFromUser (ev);
223+ if (ev.TouchInput .ID == 0 )
224+ {
225+ simulate_mouse = true ;
226+ mouse_pos.X = ev.TouchInput .X ;
227+ mouse_pos.Y = ev.TouchInput .Y ;
228+ }
219229 }
230+ if (simulate_mouse)
231+ Device->simulateMouse (ev, mouse_pos);
220232}
221233
222234- (void )touchesMoved : (NSSet *)touches withEvent : (UIEvent*)event
@@ -225,17 +237,29 @@ - (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
225237 ev.EventType = irr::EET_TOUCH_INPUT_EVENT;
226238 ev.TouchInput .Event = irr::ETIE_MOVED;
227239
240+ irr::core::position2d<irr::s32> mouse_pos = irr::core::position2d<irr::s32>(0 , 0 );
241+ bool simulate_mouse = false ;
242+ size_t id = 0 ;
243+
228244 for (UITouch* touch in touches)
229245 {
230- ev.TouchInput .ID = ( size_t )touch ;
246+ ev.TouchInput .ID = id ++ ;
231247
232248 CGPoint touchPoint = [touch locationInView: self ];
233249
234250 ev.TouchInput .X = touchPoint.x *Scale;
235251 ev.TouchInput .Y = touchPoint.y *Scale;
236252
237253 Device->postEventFromUser (ev);
254+ if (ev.TouchInput .ID == 0 )
255+ {
256+ simulate_mouse = true ;
257+ mouse_pos.X = ev.TouchInput .X ;
258+ mouse_pos.Y = ev.TouchInput .Y ;
259+ }
238260 }
261+ if (simulate_mouse)
262+ Device->simulateMouse (ev, mouse_pos);
239263}
240264
241265- (void )touchesEnded : (NSSet *)touches withEvent : (UIEvent*)event
@@ -244,17 +268,29 @@ - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
244268 ev.EventType = irr::EET_TOUCH_INPUT_EVENT;
245269 ev.TouchInput .Event = irr::ETIE_LEFT_UP;
246270
271+ irr::core::position2d<irr::s32> mouse_pos = irr::core::position2d<irr::s32>(0 , 0 );
272+ bool simulate_mouse = false ;
273+ size_t id = 0 ;
274+
247275 for (UITouch* touch in touches)
248276 {
249- ev.TouchInput .ID = ( size_t )touch ;
277+ ev.TouchInput .ID = id ++ ;
250278
251279 CGPoint touchPoint = [touch locationInView: self ];
252280
253281 ev.TouchInput .X = touchPoint.x *Scale;
254282 ev.TouchInput .Y = touchPoint.y *Scale;
255283
256284 Device->postEventFromUser (ev);
285+ if (ev.TouchInput .ID == 0 )
286+ {
287+ simulate_mouse = true ;
288+ mouse_pos.X = ev.TouchInput .X ;
289+ mouse_pos.Y = ev.TouchInput .Y ;
290+ }
257291 }
292+ if (simulate_mouse)
293+ Device->simulateMouse (ev, mouse_pos);
258294}
259295
260296- (void )touchesCancelled : (NSSet *)touches withEvent : (UIEvent*)event
@@ -263,17 +299,29 @@ - (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event
263299 ev.EventType = irr::EET_TOUCH_INPUT_EVENT;
264300 ev.TouchInput .Event = irr::ETIE_LEFT_UP;
265301
302+ irr::core::position2d<irr::s32> mouse_pos = irr::core::position2d<irr::s32>(0 , 0 );
303+ bool simulate_mouse = false ;
304+ size_t id = 0 ;
305+
266306 for (UITouch* touch in touches)
267307 {
268- ev.TouchInput .ID = ( size_t )touch ;
308+ ev.TouchInput .ID = id ++ ;
269309
270310 CGPoint touchPoint = [touch locationInView: self ];
271311
272312 ev.TouchInput .X = touchPoint.x *Scale;
273313 ev.TouchInput .Y = touchPoint.y *Scale;
274314
275315 Device->postEventFromUser (ev);
316+ if (ev.TouchInput .ID == 0 )
317+ {
318+ simulate_mouse = true ;
319+ mouse_pos.X = ev.TouchInput .X ;
320+ mouse_pos.Y = ev.TouchInput .Y ;
321+ }
276322 }
323+ if (simulate_mouse)
324+ Device->simulateMouse (ev, mouse_pos);
277325}
278326
279327@end
0 commit comments