android: update style of `input_events`
[nit.git] / lib / mnit_android / android_app.nit
1 # This file is part of NIT (http://www.nitlanguage.org).
2 #
3 # Copyright 2012-2014 Alexis Laferrière <alexis.laf@xymus.net>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Impements the services of `mnit:app` using the API from the Android ndk
18 module android_app is
19 android_manifest_activity """
20 android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
21 android:configChanges="orientation|keyboardHidden"
22 android:screenOrientation="portrait""""
23 end
24
25 import mnit
26 import android
27 import mnit::opengles1
28 intrude import ::android::input_events
29
30 in "C" `{
31 #include <EGL/egl.h>
32
33 extern EGLDisplay mnit_display;
34 extern EGLSurface mnit_surface;
35 extern EGLContext mnit_context;
36 extern EGLConfig mnit_config;
37 extern int32_t mnit_width;
38 extern int32_t mnit_height;
39 extern float mnit_zoom;
40
41 //int mnit_orientation_changed;
42 float mnit_zoom;
43 `}
44
45 redef class App
46 redef type D: Opengles1Display
47
48 redef fun init_window
49 do
50 display = new Opengles1Display
51
52 super
53 end
54
55 redef fun full_frame do if not paused then super
56
57 redef fun generate_input do poll_looper 0
58
59 redef fun native_input_key(event)
60 do
61 return input(event)
62 end
63
64 redef fun native_input_motion(event)
65 do
66 var ie = new AndroidMotionEvent(event)
67 var handled = input(ie)
68
69 if not handled then
70 for pe in ie.pointers do
71 input(pe)
72 end
73 end
74
75 return handled
76 end
77 end