Enable touch controls
This commit is contained in:
parent
94f416ec20
commit
ec977e1307
1 changed files with 25 additions and 6 deletions
|
@ -20,6 +20,10 @@ import android.content.*;
|
||||||
|
|
||||||
import java.lang.*;
|
import java.lang.*;
|
||||||
|
|
||||||
|
import com.beloko.games.hl.NativeLib;
|
||||||
|
import com.beloko.touchcontrols.ControlInterpreter;
|
||||||
|
import com.beloko.touchcontrols.Settings;
|
||||||
|
import com.beloko.touchcontrols.TouchControlsSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
SDL Activity
|
SDL Activity
|
||||||
|
@ -27,7 +31,7 @@ import java.lang.*;
|
||||||
public class XashActivity extends Activity {
|
public class XashActivity extends Activity {
|
||||||
|
|
||||||
// Main components
|
// Main components
|
||||||
private static XashActivity mSingleton;
|
protected static XashActivity mSingleton;
|
||||||
private static EngineSurface mSurface;
|
private static EngineSurface mSurface;
|
||||||
private static String mArgv;
|
private static String mArgv;
|
||||||
|
|
||||||
|
@ -35,6 +39,7 @@ public class XashActivity extends Activity {
|
||||||
private static Thread mAudioThread;
|
private static Thread mAudioThread;
|
||||||
private static AudioTrack mAudioTrack;
|
private static AudioTrack mAudioTrack;
|
||||||
|
|
||||||
|
public static ControlInterpreter controlInterp;
|
||||||
// Load the .so
|
// Load the .so
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("touchcontrols");
|
System.loadLibrary("touchcontrols");
|
||||||
|
@ -230,6 +235,7 @@ class XashMain implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
// Runs SDL_main()
|
// Runs SDL_main()
|
||||||
XashActivity.createGLContext();
|
XashActivity.createGLContext();
|
||||||
|
|
||||||
XashActivity.nativeInit(XashActivity.getArguments());
|
XashActivity.nativeInit(XashActivity.getArguments());
|
||||||
|
|
||||||
//Log.v("SDL", "SDL thread terminated");
|
//Log.v("SDL", "SDL thread terminated");
|
||||||
|
@ -342,9 +348,22 @@ View.OnKeyListener, View.OnTouchListener {
|
||||||
Log.v("SDL", "pixel format unknown " + format);
|
Log.v("SDL", "pixel format unknown " + format);
|
||||||
break;
|
break;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
XashActivity.onNativeResize(width, height);
|
XashActivity.onNativeResize(width, height);
|
||||||
// Now start up the C app thread
|
// Now start up the C app thread
|
||||||
if (mEngThread == null) {
|
if (mEngThread == null) {
|
||||||
|
NativeLib engine = new NativeLib();
|
||||||
|
engine.initTouchControls_if(XashActivity.mSingleton.getFilesDir().toString() + "/",
|
||||||
|
width, height);
|
||||||
|
XashActivity.controlInterp = new ControlInterpreter(engine,Settings.IDGame.Doom,Settings.gamePadControlsFile,Settings.gamePadEnabled);
|
||||||
|
XashActivity.controlInterp.setScreenSize(width, height);
|
||||||
|
|
||||||
|
TouchControlsSettings.setup(XashActivity.mSingleton, engine);
|
||||||
|
TouchControlsSettings.loadSettings(XashActivity.mSingleton);
|
||||||
|
TouchControlsSettings.sendToQuake();
|
||||||
|
|
||||||
|
Settings.copyPNGAssets(XashActivity.mSingleton,XashActivity.mSingleton.getFilesDir().toString() + "/",null);
|
||||||
mEngThread = new Thread(new XashMain(), "EngineThread");
|
mEngThread = new Thread(new XashMain(), "EngineThread");
|
||||||
mEngThread.start();
|
mEngThread.start();
|
||||||
}
|
}
|
||||||
|
@ -445,21 +464,20 @@ View.OnKeyListener, View.OnTouchListener {
|
||||||
|
|
||||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
//Log.v("SDL", "key down: " + keyCode);
|
//Log.v("SDL", "key down: " + keyCode);
|
||||||
XashActivity.onNativeKeyDown(keyCode);
|
XashActivity.controlInterp.onKeyDown(keyCode, event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (event.getAction() == KeyEvent.ACTION_UP) {
|
else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||||
//Log.v("SDL", "key up: " + keyCode);
|
//Log.v("SDL", "key up: " + keyCode);
|
||||||
XashActivity.onNativeKeyUp(keyCode);
|
XashActivity.controlInterp.onKeyUp(keyCode, event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Touch events
|
// Touch events
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
{
|
/*
|
||||||
final int touchDevId = event.getDeviceId();
|
final int touchDevId = event.getDeviceId();
|
||||||
final int pointerCount = event.getPointerCount();
|
final int pointerCount = event.getPointerCount();
|
||||||
// touchId, pointerId, action, x, y, pressure
|
// touchId, pointerId, action, x, y, pressure
|
||||||
|
@ -484,7 +502,8 @@ View.OnKeyListener, View.OnTouchListener {
|
||||||
} else {
|
} else {
|
||||||
XashActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
|
XashActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
XashActivity.controlInterp.onTouchEvent(event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue