author | Xeli |
Sun, 21 Aug 2011 22:18:54 +0200 | |
branch | hedgeroid |
changeset 5641 | 06558ee35f51 |
parent 5623 | df23b477609d |
child 5934 | 9f05a0f43003 |
permissions | -rw-r--r-- |
5389
b3cc5b4099f1
Changed package name from org.hedgewars to org.hedgewars.mobile
Xeli
parents:
5387
diff
changeset
|
1 |
package org.hedgewars.mobile; |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
2 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
3 |
import javax.microedition.khronos.egl.EGL10; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
4 |
import javax.microedition.khronos.egl.EGLConfig; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
5 |
import javax.microedition.khronos.egl.EGLContext; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
6 |
import javax.microedition.khronos.egl.EGLDisplay; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
7 |
import javax.microedition.khronos.egl.EGLSurface; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
8 |
|
5469 | 9 |
import org.hedgewars.mobile.EngineProtocol.EngineProtocolNetwork; |
10 |
import org.hedgewars.mobile.EngineProtocol.GameConfig; |
|
5540 | 11 |
import org.hedgewars.mobile.TouchInterface.TouchInterface; |
5469 | 12 |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
13 |
import android.app.Activity; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
14 |
import android.content.Context; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
15 |
import android.graphics.Canvas; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
16 |
import android.graphics.PixelFormat; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
17 |
import android.hardware.Sensor; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
18 |
import android.hardware.SensorEvent; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
19 |
import android.hardware.SensorEventListener; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
20 |
import android.hardware.SensorManager; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
21 |
import android.media.AudioFormat; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
22 |
import android.media.AudioManager; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
23 |
import android.media.AudioTrack; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
24 |
import android.os.Bundle; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
25 |
import android.os.Handler; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
26 |
import android.os.Message; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
27 |
import android.util.Log; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
28 |
import android.view.KeyEvent; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
29 |
import android.view.SurfaceHolder; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
30 |
import android.view.SurfaceView; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
31 |
import android.view.View; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
32 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
33 |
/** |
5469 | 34 |
* SDL Activity |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
35 |
*/ |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
36 |
public class SDLActivity extends Activity { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
37 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
38 |
// Main components |
5406 | 39 |
public static SDLActivity mSingleton; |
5363
7f7800581012
Using the correct resolution rahter than a hardcoded one
Xeli
parents:
5347
diff
changeset
|
40 |
public static SDLSurface mSurface; |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
41 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
42 |
// Audio |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
43 |
private static Thread mAudioThread; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
44 |
private static AudioTrack mAudioTrack; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
45 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
46 |
// Load the .so |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
47 |
static { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
48 |
System.loadLibrary("SDL"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
49 |
System.loadLibrary("SDL_image"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
50 |
System.loadLibrary("mikmod"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
51 |
System.loadLibrary("SDL_net"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
52 |
System.loadLibrary("SDL_mixer"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
53 |
System.loadLibrary("SDL_ttf"); |
5469 | 54 |
System.loadLibrary("lua5.1"); |
5371
bb809cd50781
Preloaded libhwengine.so and added an argument to nativeInit()
Xeli
parents:
5363
diff
changeset
|
55 |
System.loadLibrary("hwengine"); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
56 |
System.loadLibrary("main"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
57 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
58 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
59 |
// Setup |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
60 |
protected void onCreate(Bundle savedInstanceState) { |
5469 | 61 |
// Log.v("SDL", "onCreate()"); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
62 |
super.onCreate(savedInstanceState); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
63 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
64 |
// So we can call stuff from static callbacks |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
65 |
mSingleton = this; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
66 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
67 |
// Set up the surface |
5469 | 68 |
GameConfig config = getIntent().getParcelableExtra("config"); |
69 |
mSurface = new SDLSurface(getApplication(), config); |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
70 |
setContentView(mSurface); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
71 |
SurfaceHolder holder = mSurface.getHolder(); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
72 |
holder.setType(SurfaceHolder.SURFACE_TYPE_GPU); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
73 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
74 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
75 |
// Events |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
76 |
protected void onPause() { |
5469 | 77 |
// Log.v("SDL", "onPause()"); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
78 |
super.onPause(); |
5469 | 79 |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
80 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
81 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
82 |
protected void onResume() { |
5469 | 83 |
// Log.v("SDL", "onResume()"); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
84 |
super.onResume(); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
85 |
} |
5538 | 86 |
|
87 |
public void onBackPressed(){ |
|
88 |
nativeQuit(); |
|
89 |
super.onBackPressed(); |
|
90 |
} |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
91 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
92 |
// Messages from the SDLMain thread |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
93 |
static int COMMAND_CHANGE_TITLE = 1; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
94 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
95 |
// Handler for the messages |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
96 |
Handler commandHandler = new Handler() { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
97 |
public void handleMessage(Message msg) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
98 |
if (msg.arg1 == COMMAND_CHANGE_TITLE) { |
5469 | 99 |
setTitle((String) msg.obj); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
100 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
101 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
102 |
}; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
103 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
104 |
// Send a message from the SDLMain thread |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
105 |
void sendCommand(int command, Object data) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
106 |
Message msg = commandHandler.obtainMessage(); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
107 |
msg.arg1 = command; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
108 |
msg.obj = data; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
109 |
commandHandler.sendMessage(msg); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
110 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
111 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
112 |
// C functions we call |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
113 |
public static native void nativeInit(String[] argv); |
5469 | 114 |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
115 |
public static native void nativeQuit(); |
5469 | 116 |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
117 |
public static native void onNativeResize(int x, int y, int format); |
5469 | 118 |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
119 |
public static native void onNativeKeyDown(int keycode); |
5469 | 120 |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
121 |
public static native void onNativeKeyUp(int keycode); |
5469 | 122 |
|
5540 | 123 |
public static native void onNativeTouch(int action, int pointer, float x, float y, |
5469 | 124 |
float p); |
125 |
||
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
126 |
public static native void onNativeAccel(float x, float y, float z); |
5469 | 127 |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
128 |
public static native void nativeRunAudioThread(); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
129 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
130 |
// Java functions called from C |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
131 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
132 |
public static boolean createGLContext(int majorVersion, int minorVersion) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
133 |
return mSurface.initEGL(majorVersion, minorVersion); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
134 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
135 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
136 |
public static void flipBuffers() { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
137 |
mSurface.flipEGL(); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
138 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
139 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
140 |
public static void setActivityTitle(String title) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
141 |
// Called from SDLMain() thread and can't directly affect the view |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
142 |
mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
143 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
144 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
145 |
// Audio |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
146 |
private static Object buf; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
147 |
|
5469 | 148 |
public static Object audioInit(int sampleRate, boolean is16Bit, |
149 |
boolean isStereo, int desiredFrames) { |
|
150 |
int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO |
|
151 |
: AudioFormat.CHANNEL_CONFIGURATION_MONO; |
|
152 |
int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT |
|
153 |
: AudioFormat.ENCODING_PCM_8BIT; |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
154 |
int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
155 |
|
5469 | 156 |
Log.v("SDL", "SDL audio: wanted " + (isStereo ? "stereo" : "mono") |
157 |
+ " " + (is16Bit ? "16-bit" : "8-bit") + " " |
|
158 |
+ ((float) sampleRate / 1000f) + "kHz, " + desiredFrames |
|
159 |
+ " frames buffer"); |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
160 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
161 |
// Let the user pick a larger buffer if they really want -- but ye |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
162 |
// gods they probably shouldn't, the minimums are horrifyingly high |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
163 |
// latency already |
5469 | 164 |
desiredFrames = Math.max( |
165 |
desiredFrames, |
|
166 |
(AudioTrack.getMinBufferSize(sampleRate, channelConfig, |
|
167 |
audioFormat) + frameSize - 1) |
|
168 |
/ frameSize); |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
169 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
170 |
mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, |
5469 | 171 |
channelConfig, audioFormat, desiredFrames * frameSize, |
172 |
AudioTrack.MODE_STREAM); |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
173 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
174 |
audioStartThread(); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
175 |
|
5469 | 176 |
Log.v("SDL", |
177 |
"SDL audio: got " |
|
178 |
+ ((mAudioTrack.getChannelCount() >= 2) ? "stereo" |
|
179 |
: "mono") |
|
180 |
+ " " |
|
181 |
+ ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" |
|
182 |
: "8-bit") + " " |
|
183 |
+ ((float) mAudioTrack.getSampleRate() / 1000f) |
|
184 |
+ "kHz, " + desiredFrames + " frames buffer"); |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
185 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
186 |
if (is16Bit) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
187 |
buf = new short[desiredFrames * (isStereo ? 2 : 1)]; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
188 |
} else { |
5469 | 189 |
buf = new byte[desiredFrames * (isStereo ? 2 : 1)]; |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
190 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
191 |
return buf; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
192 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
193 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
194 |
public static void audioStartThread() { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
195 |
mAudioThread = new Thread(new Runnable() { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
196 |
public void run() { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
197 |
mAudioTrack.play(); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
198 |
nativeRunAudioThread(); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
199 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
200 |
}); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
201 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
202 |
// I'd take REALTIME if I could get it! |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
203 |
mAudioThread.setPriority(Thread.MAX_PRIORITY); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
204 |
mAudioThread.start(); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
205 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
206 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
207 |
public static void audioWriteShortBuffer(short[] buffer) { |
5469 | 208 |
for (int i = 0; i < buffer.length;) { |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
209 |
int result = mAudioTrack.write(buffer, i, buffer.length - i); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
210 |
if (result > 0) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
211 |
i += result; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
212 |
} else if (result == 0) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
213 |
try { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
214 |
Thread.sleep(1); |
5469 | 215 |
} catch (InterruptedException e) { |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
216 |
// Nom nom |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
217 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
218 |
} else { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
219 |
Log.w("SDL", "SDL audio: error return from write(short)"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
220 |
return; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
221 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
222 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
223 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
224 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
225 |
public static void audioWriteByteBuffer(byte[] buffer) { |
5469 | 226 |
for (int i = 0; i < buffer.length;) { |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
227 |
int result = mAudioTrack.write(buffer, i, buffer.length - i); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
228 |
if (result > 0) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
229 |
i += result; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
230 |
} else if (result == 0) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
231 |
try { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
232 |
Thread.sleep(1); |
5469 | 233 |
} catch (InterruptedException e) { |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
234 |
// Nom nom |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
235 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
236 |
} else { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
237 |
Log.w("SDL", "SDL audio: error return from write(short)"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
238 |
return; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
239 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
240 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
241 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
242 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
243 |
public static void audioQuit() { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
244 |
if (mAudioThread != null) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
245 |
try { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
246 |
mAudioThread.join(); |
5469 | 247 |
} catch (Exception e) { |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
248 |
Log.v("SDL", "Problem stopping audio thread: " + e); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
249 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
250 |
mAudioThread = null; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
251 |
|
5469 | 252 |
// Log.v("SDL", "Finished waiting for audio thread"); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
253 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
254 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
255 |
if (mAudioTrack != null) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
256 |
mAudioTrack.stop(); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
257 |
mAudioTrack = null; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
258 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
259 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
260 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
261 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
262 |
/** |
5469 | 263 |
* Simple nativeInit() runnable |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
264 |
*/ |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
265 |
class SDLMain implements Runnable { |
5363
7f7800581012
Using the correct resolution rahter than a hardcoded one
Xeli
parents:
5347
diff
changeset
|
266 |
private int surfaceWidth, surfaceHeight; |
5469 | 267 |
private GameConfig config; |
268 |
||
269 |
public SDLMain(int width, int height, GameConfig _config) { |
|
270 |
config = _config; |
|
5363
7f7800581012
Using the correct resolution rahter than a hardcoded one
Xeli
parents:
5347
diff
changeset
|
271 |
surfaceWidth = width; |
7f7800581012
Using the correct resolution rahter than a hardcoded one
Xeli
parents:
5347
diff
changeset
|
272 |
surfaceHeight = height; |
7f7800581012
Using the correct resolution rahter than a hardcoded one
Xeli
parents:
5347
diff
changeset
|
273 |
} |
5469 | 274 |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
275 |
public void run() { |
5623 | 276 |
//Set up the IPC socket server to communicate with the engine |
5469 | 277 |
EngineProtocolNetwork ipc = new EngineProtocolNetwork(config); |
278 |
||
5623 | 279 |
String path = Utils.getDownloadPath(SDLActivity.mSingleton);//This represents the data directory |
280 |
path = path.substring(0, path.length()-1);//remove the trailing '/' |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
281 |
|
5623 | 282 |
|
283 |
// Runs SDL_main() with added parameters |
|
5469 | 284 |
SDLActivity.nativeInit(new String[] { String.valueOf(ipc.port), |
285 |
String.valueOf(surfaceWidth), String.valueOf(surfaceHeight), |
|
286 |
"0", "null", "xeli", "1", "1", "1", "0", "", path }); |
|
287 |
||
288 |
// Log.v("SDL", "SDL thread terminated"); |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
289 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
290 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
291 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
292 |
/** |
5469 | 293 |
* SDLSurface. This is what we draw on, so we need to know when it's created in |
294 |
* order to do anything useful. |
|
295 |
* |
|
296 |
* Because of this, that's where we set up the SDL thread |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
297 |
*/ |
5469 | 298 |
class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, |
5540 | 299 |
View.OnKeyListener, SensorEventListener { |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
300 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
301 |
// This is what SDL runs in. It invokes SDL_main(), eventually |
5469 | 302 |
private Thread mSDLThread; |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
303 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
304 |
// EGL private objects |
5469 | 305 |
private EGLContext mEGLContext; |
306 |
private EGLSurface mEGLSurface; |
|
307 |
private EGLDisplay mEGLDisplay; |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
308 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
309 |
// Sensors |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
310 |
private static SensorManager mSensorManager; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
311 |
|
5469 | 312 |
private GameConfig config; |
313 |
||
314 |
// Startup |
|
315 |
public SDLSurface(Context context, GameConfig _config) { |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
316 |
super(context); |
5469 | 317 |
getHolder().addCallback(this); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
318 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
319 |
setFocusable(true); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
320 |
setFocusableInTouchMode(true); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
321 |
requestFocus(); |
5469 | 322 |
setOnKeyListener(this); |
5540 | 323 |
setOnTouchListener(TouchInterface.getTouchInterface()); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
324 |
|
5469 | 325 |
mSensorManager = (SensorManager) context.getSystemService("sensor"); |
326 |
||
327 |
config = _config; |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
328 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
329 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
330 |
// Called when we have a valid drawing surface |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
331 |
public void surfaceCreated(SurfaceHolder holder) { |
5641 | 332 |
Log.v("SDL", "surfaceCreated()"); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
333 |
|
5641 | 334 |
//enableSensor(Sensor.TYPE_ACCELEROMETER, true); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
335 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
336 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
337 |
// Called when we lose the surface |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
338 |
public void surfaceDestroyed(SurfaceHolder holder) { |
5641 | 339 |
Log.v("SDL", "surfaceDestroyed()"); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
340 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
341 |
// Send a quit message to the application |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
342 |
SDLActivity.nativeQuit(); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
343 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
344 |
// Now wait for the SDL thread to quit |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
345 |
if (mSDLThread != null) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
346 |
try { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
347 |
mSDLThread.join(); |
5469 | 348 |
} catch (Exception e) { |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
349 |
Log.v("SDL", "Problem stopping thread: " + e); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
350 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
351 |
mSDLThread = null; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
352 |
|
5469 | 353 |
// Log.v("SDL", "Finished waiting for SDL thread"); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
354 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
355 |
|
5641 | 356 |
//enableSensor(Sensor.TYPE_ACCELEROMETER, false); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
357 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
358 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
359 |
// Called when the surface is resized |
5469 | 360 |
public void surfaceChanged(SurfaceHolder holder, int format, int width, |
361 |
int height) { |
|
362 |
Log.d("SDL", "surfaceChanged()" + width + " + " + height); |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
363 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
364 |
int sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565 by default |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
365 |
switch (format) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
366 |
case PixelFormat.A_8: |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
367 |
Log.v("SDL", "pixel format A_8"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
368 |
break; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
369 |
case PixelFormat.LA_88: |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
370 |
Log.v("SDL", "pixel format LA_88"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
371 |
break; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
372 |
case PixelFormat.L_8: |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
373 |
Log.v("SDL", "pixel format L_8"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
374 |
break; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
375 |
case PixelFormat.RGBA_4444: |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
376 |
Log.v("SDL", "pixel format RGBA_4444"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
377 |
sdlFormat = 0x85421002; // SDL_PIXELFORMAT_RGBA4444 |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
378 |
break; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
379 |
case PixelFormat.RGBA_5551: |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
380 |
Log.v("SDL", "pixel format RGBA_5551"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
381 |
sdlFormat = 0x85441002; // SDL_PIXELFORMAT_RGBA5551 |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
382 |
break; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
383 |
case PixelFormat.RGBA_8888: |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
384 |
Log.v("SDL", "pixel format RGBA_8888"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
385 |
sdlFormat = 0x86462004; // SDL_PIXELFORMAT_RGBA8888 |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
386 |
break; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
387 |
case PixelFormat.RGBX_8888: |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
388 |
Log.v("SDL", "pixel format RGBX_8888"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
389 |
sdlFormat = 0x86262004; // SDL_PIXELFORMAT_RGBX8888 |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
390 |
break; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
391 |
case PixelFormat.RGB_332: |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
392 |
Log.v("SDL", "pixel format RGB_332"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
393 |
sdlFormat = 0x84110801; // SDL_PIXELFORMAT_RGB332 |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
394 |
break; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
395 |
case PixelFormat.RGB_565: |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
396 |
Log.v("SDL", "pixel format RGB_565"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
397 |
sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565 |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
398 |
break; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
399 |
case PixelFormat.RGB_888: |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
400 |
Log.v("SDL", "pixel format RGB_888"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
401 |
// Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead? |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
402 |
sdlFormat = 0x86161804; // SDL_PIXELFORMAT_RGB888 |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
403 |
break; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
404 |
default: |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
405 |
Log.v("SDL", "pixel format unknown " + format); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
406 |
break; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
407 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
408 |
SDLActivity.onNativeResize(width, height, sdlFormat); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
409 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
410 |
// Now start up the C app thread |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
411 |
if (mSDLThread == null) { |
5469 | 412 |
mSDLThread = new Thread(new SDLMain(width, height, config), |
413 |
"SDLThread"); |
|
414 |
mSDLThread.start(); |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
415 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
416 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
417 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
418 |
// unused |
5469 | 419 |
public void onDraw(Canvas canvas) { |
420 |
} |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
421 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
422 |
// EGL functions |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
423 |
public boolean initEGL(int majorVersion, int minorVersion) { |
5469 | 424 |
Log.v("SDL", "Starting up OpenGL ES " + majorVersion + "." |
425 |
+ minorVersion); |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
426 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
427 |
try { |
5469 | 428 |
EGL10 egl = (EGL10) EGLContext.getEGL(); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
429 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
430 |
EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
431 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
432 |
int[] version = new int[2]; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
433 |
egl.eglInitialize(dpy, version); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
434 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
435 |
int EGL_OPENGL_ES_BIT = 1; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
436 |
int EGL_OPENGL_ES2_BIT = 4; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
437 |
int renderableType = 0; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
438 |
if (majorVersion == 2) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
439 |
renderableType = EGL_OPENGL_ES2_BIT; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
440 |
} else if (majorVersion == 1) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
441 |
renderableType = EGL_OPENGL_ES_BIT; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
442 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
443 |
int[] configSpec = { |
5469 | 444 |
// EGL10.EGL_DEPTH_SIZE, 16, |
445 |
EGL10.EGL_RENDERABLE_TYPE, renderableType, EGL10.EGL_NONE }; |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
446 |
EGLConfig[] configs = new EGLConfig[1]; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
447 |
int[] num_config = new int[1]; |
5469 | 448 |
if (!egl.eglChooseConfig(dpy, configSpec, configs, 1, num_config) |
449 |
|| num_config[0] == 0) { |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
450 |
Log.e("SDL", "No EGL config available"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
451 |
return false; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
452 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
453 |
EGLConfig config = configs[0]; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
454 |
|
5469 | 455 |
EGLContext ctx = egl.eglCreateContext(dpy, config, |
456 |
EGL10.EGL_NO_CONTEXT, null); |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
457 |
if (ctx == EGL10.EGL_NO_CONTEXT) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
458 |
Log.e("SDL", "Couldn't create context"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
459 |
return false; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
460 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
461 |
|
5469 | 462 |
EGLSurface surface = egl.eglCreateWindowSurface(dpy, config, this, |
463 |
null); |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
464 |
if (surface == EGL10.EGL_NO_SURFACE) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
465 |
Log.e("SDL", "Couldn't create surface"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
466 |
return false; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
467 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
468 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
469 |
if (!egl.eglMakeCurrent(dpy, surface, surface, ctx)) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
470 |
Log.e("SDL", "Couldn't make context current"); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
471 |
return false; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
472 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
473 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
474 |
mEGLContext = ctx; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
475 |
mEGLDisplay = dpy; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
476 |
mEGLSurface = surface; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
477 |
|
5469 | 478 |
} catch (Exception e) { |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
479 |
Log.v("SDL", e + ""); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
480 |
for (StackTraceElement s : e.getStackTrace()) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
481 |
Log.v("SDL", s.toString()); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
482 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
483 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
484 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
485 |
return true; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
486 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
487 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
488 |
// EGL buffer flip |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
489 |
public void flipEGL() { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
490 |
try { |
5469 | 491 |
EGL10 egl = (EGL10) EGLContext.getEGL(); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
492 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
493 |
egl.eglWaitNative(EGL10.EGL_NATIVE_RENDERABLE, null); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
494 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
495 |
// drawing here |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
496 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
497 |
egl.eglWaitGL(); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
498 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
499 |
egl.eglSwapBuffers(mEGLDisplay, mEGLSurface); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
500 |
|
5469 | 501 |
} catch (Exception e) { |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
502 |
Log.v("SDL", "flipEGL(): " + e); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
503 |
for (StackTraceElement s : e.getStackTrace()) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
504 |
Log.v("SDL", s.toString()); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
505 |
} |
5538 | 506 |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
507 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
508 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
509 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
510 |
// Key events |
5469 | 511 |
public boolean onKey(View v, int keyCode, KeyEvent event) { |
5597 | 512 |
if(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) return false; |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
513 |
if (event.getAction() == KeyEvent.ACTION_DOWN) { |
5538 | 514 |
Log.v("SDL", "key down: " + keyCode); |
515 |
if(keyCode == KeyEvent.KEYCODE_BACK){//TODO ask user to quit or not |
|
516 |
SDLActivity.nativeQuit(); |
|
517 |
SDLActivity.mSingleton.finish(); |
|
518 |
}else{ |
|
519 |
SDLActivity.onNativeKeyDown(keyCode); |
|
520 |
} |
|
521 |
||
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
522 |
return true; |
5469 | 523 |
} else if (event.getAction() == KeyEvent.ACTION_UP) { |
5538 | 524 |
Log.v("SDL", "key up: " + keyCode); |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
525 |
SDLActivity.onNativeKeyUp(keyCode); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
526 |
return true; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
527 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
528 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
529 |
return false; |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
530 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
531 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
532 |
// Sensor events |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
533 |
public void enableSensor(int sensortype, boolean enabled) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
534 |
// TODO: This uses getDefaultSensor - what if we have >1 accels? |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
535 |
if (enabled) { |
5469 | 536 |
mSensorManager.registerListener(this, |
537 |
mSensorManager.getDefaultSensor(sensortype), |
|
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
538 |
SensorManager.SENSOR_DELAY_GAME, null); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
539 |
} else { |
5469 | 540 |
mSensorManager.unregisterListener(this, |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
541 |
mSensorManager.getDefaultSensor(sensortype)); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
542 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
543 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
544 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
545 |
public void onAccuracyChanged(Sensor sensor, int accuracy) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
546 |
// TODO |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
547 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
548 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
549 |
public void onSensorChanged(SensorEvent event) { |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
550 |
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { |
5469 | 551 |
SDLActivity.onNativeAccel(event.values[0], event.values[1], |
5331
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
552 |
event.values[2]); |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
553 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
554 |
} |
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
555 |
|
3f93e036ca94
Changed the package path from org.libsdl.app to org.hedgewars
Xeli
parents:
diff
changeset
|
556 |
} |