1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Gamnit event support for iOS
18 intrude import ios
::glkit
22 # Pointer/touch event on iOS
23 class GamnitIOSPointerEvent
26 private var native
: UIEvent
28 private var native_touch
: UITouch
30 private var content_scale_factor
: Float
32 redef fun x
do return native_touch
.x
* content_scale_factor
34 redef fun y
do return native_touch
.y
* content_scale_factor
40 redef var pointer_id
= native_touch
.to_i
is lazy
43 redef class NitGLKView
45 redef var content_scale_factor
= super is lazy
47 redef fun touches_began
(touches
, event
)
48 do app
.accept_event
(new GamnitIOSPointerEvent(event
, touches
.any_object
, content_scale_factor
, true, false))
50 redef fun touches_moved
(touches
, event
)
51 do app
.accept_event
(new GamnitIOSPointerEvent(event
, touches
.any_object
, content_scale_factor
, true, true))
53 redef fun touches_ended
(touches
, event
)
54 do app
.accept_event
(new GamnitIOSPointerEvent(event
, touches
.any_object
, content_scale_factor
, false, false))
57 #redef fun touches_cancelled(touches_event) do
58 #do app.accept_event(new GamnitIOSPointerEvent(event, false, false))