Merge branch 'sdl_android' of github.com:pelya/commandergenius into sdl_android

Conflicts:
	project/jni/application/vcmi/AndroidAppSettings.cfg
	project/jni/application/vcmi/Makefile
This commit is contained in:
Gerhard Stein
2013-02-11 17:43:54 +01:00
55 changed files with 2704 additions and 2279 deletions

View File

@@ -20,6 +20,7 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="tv.ouya.intent.category.GAME" />
</intent-filter>
</activity>
<!-- ==ADMOB== --> <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

View File

@@ -41,57 +41,89 @@ class AccelerometerReader implements SensorEventListener
{
private SensorManager _manager = null;
public boolean openedBySDL = false;
public static final GyroscopeListener gyro = new GyroscopeListener();
public AccelerometerReader(Activity context)
{
_manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
start();
}
public synchronized void stop()
{
if( _manager != null )
{
System.out.println("libSDL: stopping accelerometer/gyroscope");
_manager.unregisterListener(this);
_manager.unregisterListener(gyro);
}
}
public synchronized void start()
{
if( Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer )
if( (Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) &&
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null )
{
if( _manager != null )
{
System.out.println("libSDL: starting accelerometer");
// TODO: orientation allows for 3rd axis - azimuth, but it will be way too hard to the user
// if( ! _manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_GAME) )
_manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
}
System.out.println("libSDL: starting accelerometer");
_manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
}
if( Globals.AppUsesGyroscope && _manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null )
{
System.out.println("libSDL: starting gyroscope");
_manager.registerListener(gyro, _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
}
}
public synchronized void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
{
if( Globals.HorizontalOrientation )
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
else
nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
}
public void onSensorChanged(SensorEvent event)
{
if( Globals.HorizontalOrientation )
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
else
nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
}
public void onAccuracyChanged(Sensor s, int a)
{
}
static class GyroscopeListener implements SensorEventListener
{
public float x1, x2, xc, y1, y2, yc, z1, z2, zc;
public GyroscopeListener()
{
if( Globals.HorizontalOrientation )
nativeOrientation(event.values[1], -event.values[2], event.values[0]);
else
nativeOrientation(event.values[2], event.values[1], event.values[0]);
}
public void onSensorChanged(SensorEvent event)
{
// TODO: vertical orientation
//if( Globals.HorizontalOrientation )
if( event.values[0] < x1 || event.values[0] > x2 ||
event.values[1] < y1 || event.values[1] > y2 ||
event.values[2] < z1 || event.values[2] > z2 )
nativeGyroscope(event.values[0] - xc, event.values[1] - yc, event.values[2] - zc);
}
public void onAccuracyChanged(Sensor s, int a)
{
}
public boolean available(Activity context)
{
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
return ( manager != null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null );
}
public void registerListener(Activity context, SensorEventListener l)
{
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
if ( manager == null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) == null )
return;
manager.registerListener(l, manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
}
public void unregisterListener(Activity context,SensorEventListener l)
{
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
if ( manager == null )
return;
manager.unregisterListener(l);
}
}
public synchronized void onAccuracyChanged(Sensor s, int a) {
}
private native void nativeAccelerometer(float accX, float accY, float accZ);
private native void nativeOrientation(float accX, float accY, float accZ);
private static native void nativeAccelerometer(float accX, float accY, float accZ);
private static native void nativeGyroscope(float X, float Y, float Z);
}

View File

@@ -42,6 +42,7 @@ class Globals
public static boolean CompatibilityHacksStaticInit = false;
public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = false;
public static boolean HorizontalOrientation = true;
public static boolean KeepAspectRatioDefaultSetting = false;
public static boolean InhibitSuspend = false;
public static String ReadmeText = "^You may press \"Home\" now - the data will be downloaded in background".replace("^","\n");
public static String CommandLine = "";
@@ -53,6 +54,7 @@ class Globals
public static boolean AppNeedsTextInput = true;
public static boolean AppUsesJoystick = false;
public static boolean AppUsesAccelerometer = false;
public static boolean AppUsesGyroscope = false;
public static boolean AppUsesMultitouch = false;
public static boolean NonBlockingSwapBuffers = false;
public static boolean ResetSdlConfigForThisVersion = false;
@@ -62,7 +64,7 @@ class Globals
public static int StartupMenuButtonTimeout = 3000;
public static int AppMinimumRAM = 0;
public static Settings.Menu HiddenMenuOptions [] = {};
public static Settings.Menu FirstStartMenuOptions [] = { (AppUsesMouse && ! ForceRelativeMouseMode ? new Settings.DisplaySizeConfig(true) : new Settings.DummyMenu()), new Settings.OptionalDownloadConfig(true) };
public static Settings.Menu FirstStartMenuOptions [] = { (AppUsesMouse && ! ForceRelativeMouseMode ? new Settings.DisplaySizeConfig(true) : new Settings.DummyMenu()), new Settings.OptionalDownloadConfig(true), new Settings.GyroscopeCalibration() };
public static String AdmobPublisherId = "";
public static String AdmobTestDeviceId = "";
public static String AdmobBannerSize = "";
@@ -96,7 +98,7 @@ class Globals
public static int RelativeMouseMovementSpeed = 2;
public static int RelativeMouseMovementAccel = 0;
public static int ShowScreenUnderFinger = Mouse.ZOOM_NONE;
public static boolean KeepAspectRatio = false;
public static boolean KeepAspectRatio = KeepAspectRatioDefaultSetting;
public static int ClickScreenPressure = 0;
public static int ClickScreenTouchspotSize = 0;
public static int RemapHwKeycode[] = new int[SDL_Keys.JAVA_KEYCODE_LAST];
@@ -111,4 +113,6 @@ class Globals
public static boolean VideoLinearFilter = true;
public static boolean MultiThreadedVideo = false;
public static boolean BrokenLibCMessageShown = false;
// Gyroscope calibration
public static float gyro_x1, gyro_x2, gyro_xc, gyro_y1, gyro_y2, gyro_yc, gyro_z1, gyro_z2, gyro_zc;
}

View File

@@ -60,6 +60,7 @@ import java.io.FileInputStream;
import java.util.zip.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.Set;
import android.text.SpannedString;
import java.io.BufferedReader;
import java.io.BufferedInputStream;

View File

@@ -66,6 +66,10 @@ import android.app.AlarmManager;
import android.util.DisplayMetrics;
import android.net.Uri;
import java.util.concurrent.Semaphore;
import android.graphics.Color;
import android.hardware.SensorEventListener;
import android.hardware.SensorEvent;
import android.hardware.Sensor;
// TODO: too much code here, split into multiple files, possibly auto-generated menus?
class Settings
@@ -153,6 +157,15 @@ class Settings
out.writeBoolean(Globals.BrokenLibCMessageShown);
out.writeInt(Globals.TouchscreenKeyboardDrawSize);
out.writeInt(p.getApplicationVersion());
out.writeFloat(Globals.gyro_x1);
out.writeFloat(Globals.gyro_x2);
out.writeFloat(Globals.gyro_xc);
out.writeFloat(Globals.gyro_y1);
out.writeFloat(Globals.gyro_y2);
out.writeFloat(Globals.gyro_yc);
out.writeFloat(Globals.gyro_z1);
out.writeFloat(Globals.gyro_z2);
out.writeFloat(Globals.gyro_zc);
out.close();
settingsLoaded = true;
@@ -299,6 +312,15 @@ class Settings
Globals.BrokenLibCMessageShown = settingsFile.readBoolean();
Globals.TouchscreenKeyboardDrawSize = settingsFile.readInt();
int cfgVersion = settingsFile.readInt();
Globals.gyro_x1 = settingsFile.readFloat();
Globals.gyro_x2 = settingsFile.readFloat();
Globals.gyro_xc = settingsFile.readFloat();
Globals.gyro_y1 = settingsFile.readFloat();
Globals.gyro_y2 = settingsFile.readFloat();
Globals.gyro_yc = settingsFile.readFloat();
Globals.gyro_z1 = settingsFile.readFloat();
Globals.gyro_z2 = settingsFile.readFloat();
Globals.gyro_zc = settingsFile.readFloat();
settingsLoaded = true;
@@ -530,6 +552,7 @@ class Settings
new MouseConfigMainMenu(),
new ArrowKeysConfig(),
new AccelerometerConfig(),
new GyroscopeCalibration(),
new AudioConfig(),
new RemapHwKeysConfig(),
new ScreenGesturesConfig(),
@@ -2194,8 +2217,10 @@ class Settings
{
MainActivity p;
FrameLayout layout = null;
ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length];
ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length];
Bitmap bmps[] = new Bitmap[Globals.ScreenKbControlsLayout.length];
ImageView boundary = null;
Bitmap boundaryBmp = null;
int currentButton = 0;
int buttons[] = {
R.drawable.dpad,
@@ -2213,7 +2238,27 @@ class Settings
p = _p;
layout = new FrameLayout(p);
p.getVideoLayout().addView(layout);
boundary = new ImageView(p);
boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
boundary.setScaleType(ImageView.ScaleType.MATRIX);
boundaryBmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.rectangle );
boundary.setImageBitmap(boundaryBmp);
layout.addView(boundary);
currentButton = 0;
if( Globals.TouchscreenKeyboardTheme == 2 )
{
int buttons2[] = {
R.drawable.sun_dpad,
R.drawable.sun_keyboard,
R.drawable.sun_b1,
R.drawable.sun_b2,
R.drawable.sun_b3,
R.drawable.sun_b4,
R.drawable.sun_b5,
R.drawable.sun_b6
};
buttons = buttons2;
}
setupButton(true);
}
@@ -2240,11 +2285,28 @@ class Settings
if( imgs[currentButton] == null )
{
imgs[currentButton] = new ImageView(p);
imgs[currentButton].setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
imgs[currentButton].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
imgs[currentButton].setScaleType(ImageView.ScaleType.MATRIX);
bmps[currentButton] = BitmapFactory.decodeResource( p.getResources(), buttons[currentButton] );
imgs[currentButton].setImageBitmap(bmps[currentButton]);
layout.addView(imgs[currentButton]);
boundary.bringToFront();
}
if( Globals.ScreenKbControlsLayout[currentButton][0] == Globals.ScreenKbControlsLayout[currentButton][2] ||
Globals.ScreenKbControlsLayout[currentButton][1] == Globals.ScreenKbControlsLayout[currentButton][3] )
{
int displayX = 800;
int displayY = 480;
try {
DisplayMetrics dm = new DisplayMetrics();
p.getWindowManager().getDefaultDisplay().getMetrics(dm);
displayX = dm.widthPixels;
displayY = dm.heightPixels;
} catch (Exception eeeee) {}
Globals.ScreenKbControlsLayout[currentButton][0] = displayX / 2 - displayX / 6;
Globals.ScreenKbControlsLayout[currentButton][2] = displayX / 2 + displayX / 6;
Globals.ScreenKbControlsLayout[currentButton][1] = displayY / 2 - displayY / 4;
Globals.ScreenKbControlsLayout[currentButton][3] = displayY / 2 + displayY / 4;
}
Matrix m = new Matrix();
RectF src = new RectF(0, 0, bmps[currentButton].getWidth(), bmps[currentButton].getHeight());
@@ -2252,6 +2314,10 @@ class Settings
Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]);
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
imgs[currentButton].setImageMatrix(m);
m = new Matrix();
src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight());
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
boundary.setImageMatrix(m);
}
public void onTouchEvent(final MotionEvent ev)
@@ -2286,6 +2352,10 @@ class Settings
Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]);
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
imgs[currentButton].setImageMatrix(m);
m = new Matrix();
src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight());
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
boundary.setImageMatrix(m);
if( ev.getAction() == MotionEvent.ACTION_UP )
setupButton(false);
@@ -2438,6 +2508,149 @@ class Settings
}
}
static class GyroscopeCalibration extends Menu implements SensorEventListener
{
String title(final MainActivity p)
{
return p.getResources().getString(R.string.calibrate_gyroscope);
}
boolean enabled()
{
return Globals.AppUsesGyroscope;
}
void run (final MainActivity p)
{
if( !Globals.AppUsesGyroscope || !AccelerometerReader.gyro.available(p) )
{
goBack(p);
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.calibrate_gyroscope));
builder.setMessage(p.getResources().getString(R.string.calibrate_gyroscope_text));
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss();
startCalibration(p);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
goBack(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
}
ImageView img;
Bitmap bmp;
int numEvents;
MainActivity p;
void startCalibration(final MainActivity _p)
{
p = _p;
img = new ImageView(p);
img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
img.setScaleType(ImageView.ScaleType.MATRIX);
bmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.calibrate );
img.setImageBitmap(bmp);
Matrix m = new Matrix();
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
RectF dst = new RectF( p.getVideoLayout().getWidth()/2 - 50, p.getVideoLayout().getHeight()/2 - 50,
p.getVideoLayout().getWidth()/2 + 50, p.getVideoLayout().getHeight()/2 + 50);
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
img.setImageMatrix(m);
p.getVideoLayout().addView(img);
numEvents = 0;
AccelerometerReader.gyro.x1 = 100;
AccelerometerReader.gyro.x2 = -100;
AccelerometerReader.gyro.xc = 0;
AccelerometerReader.gyro.y1 = 100;
AccelerometerReader.gyro.y2 = -100;
AccelerometerReader.gyro.yc = 0;
AccelerometerReader.gyro.z1 = 100;
AccelerometerReader.gyro.z2 = -100;
AccelerometerReader.gyro.zc = 0;
AccelerometerReader.gyro.registerListener(p, this);
(new Thread(new Runnable()
{
public void run()
{
for(int count = 1; count < 10; count++)
{
p.setText("" + count + "0% ...");
try {
Thread.sleep(500);
} catch( Exception e ) {}
}
finishCalibration(p);
}
}
)).start();
}
public void onSensorChanged(SensorEvent event)
{
gyroscopeEvent(event.values[0], event.values[1], event.values[2]);
}
public void onAccuracyChanged(Sensor s, int a)
{
}
void gyroscopeEvent(float x, float y, float z)
{
numEvents++;
AccelerometerReader.gyro.xc += x;
AccelerometerReader.gyro.yc += y;
AccelerometerReader.gyro.zc += z;
AccelerometerReader.gyro.x1 = Math.min(AccelerometerReader.gyro.x1, x * 1.1f); // Small safety bound coefficient
AccelerometerReader.gyro.x2 = Math.max(AccelerometerReader.gyro.x2, x * 1.1f);
AccelerometerReader.gyro.y1 = Math.min(AccelerometerReader.gyro.y1, y * 1.1f);
AccelerometerReader.gyro.y2 = Math.max(AccelerometerReader.gyro.y2, y * 1.1f);
AccelerometerReader.gyro.z1 = Math.min(AccelerometerReader.gyro.z1, z * 1.1f);
AccelerometerReader.gyro.z2 = Math.max(AccelerometerReader.gyro.z2, z * 1.1f);
final Matrix m = new Matrix();
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
RectF dst = new RectF( x * 5000 + p.getVideoLayout().getWidth()/2 - 50, y * 5000 + p.getVideoLayout().getHeight()/2 - 50,
x * 5000 + p.getVideoLayout().getWidth()/2 + 50, y * 5000 + p.getVideoLayout().getHeight()/2 + 50);
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
p.runOnUiThread(new Runnable()
{
public void run()
{
img.setImageMatrix(m);
}
});
}
void finishCalibration(final MainActivity p)
{
AccelerometerReader.gyro.unregisterListener(p, this);
try {
Thread.sleep(200); // Just in case we have pending events
} catch( Exception e ) {}
if( numEvents > 5 )
{
AccelerometerReader.gyro.xc /= (float)numEvents;
AccelerometerReader.gyro.yc /= (float)numEvents;
AccelerometerReader.gyro.zc /= (float)numEvents;
}
p.runOnUiThread(new Runnable()
{
public void run()
{
p.getVideoLayout().removeView(img);
goBack(p);
}
});
}
}
// ===============================================================================================
public static boolean deleteRecursively(File dir)

View File

@@ -108,14 +108,13 @@ abstract class DifferentTouchInput
multiTouchAvailable2 = true;
}
try {
System.out.println("Device model: " + android.os.Build.MODEL);
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH )
{
if(android.os.Build.MODEL.equals("GT-N7000") || android.os.Build.MODEL.equals("SGH-I717"))
return GalaxyNoteIcsTouchInput.Holder.sInstance;
return IcsTouchInput.Holder.sInstance;
}
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD )
return XperiaPlayTouchpadTouchInput.Holder.sInstance;
return GingerbreadTouchInput.Holder.sInstance;
if (multiTouchAvailable1 && multiTouchAvailable2)
return MultiTouchInput.Holder.sInstance;
else
@@ -296,57 +295,21 @@ abstract class DifferentTouchInput
}
}
}
private static class XperiaPlayTouchpadTouchInput extends MultiTouchInput
private static class GingerbreadTouchInput extends MultiTouchInput
{
private static class Holder
{
private static final XperiaPlayTouchpadTouchInput sInstance = new XperiaPlayTouchpadTouchInput();
private static final GingerbreadTouchInput sInstance = new GingerbreadTouchInput();
}
float xmin = 0.0f;
float xmax = 1.0f;
float ymin = 0.0f;
float ymax = 1.0f;
float minRange = 1.0f;
float xshift = 0.0f;
XperiaPlayTouchpadTouchInput()
GingerbreadTouchInput()
{
super();
int[] devIds = InputDevice.getDeviceIds();
for( int id : devIds )
{
InputDevice device = InputDevice.getDevice(id);
if( device == null )
continue;
System.out.println("libSDL: input device ID " + id + " type " + device.getSources() + " name " + device.getName() );
if( (device.getSources() & InputDevice.SOURCE_TOUCHPAD) != InputDevice.SOURCE_TOUCHPAD )
continue;
System.out.println("libSDL: input device ID " + id + " type " + device.getSources() + " name " + device.getName() + " is a touchpad" );
InputDevice.MotionRange range = device.getMotionRange(MotionEvent.AXIS_X /*, InputDevice.SOURCE_TOUCHPAD*/);
if(range != null)
{
xmin = range.getMin();
xmax = range.getMax() - range.getMin();
System.out.println("libSDL: touch pad X range " + xmin + ":" + xmax );
}
range = device.getMotionRange(MotionEvent.AXIS_Y /*, InputDevice.SOURCE_TOUCHPAD*/);
if(range != null)
{
ymin = range.getMin();
ymax = range.getMax() - range.getMin();
System.out.println("libSDL: touch pad Y range " + ymin + ":" + ymax );
}
// Xperia Play has long wide touchpad with joystick-like embossing on the sides, so we'll leave only a left joystick to function
// I don't know how to use the second joystick, so I'll just ignore it for now
minRange = Math.min( Math.abs(ymax - ymin), Math.abs(xmax - xmin) );
xshift = xmax - minRange;
}
}
public void process(final MotionEvent event)
{
boolean hwMouseEvent = ( event.getSource() == InputDevice.SOURCE_MOUSE ||
event.getSource() == InputDevice.SOURCE_STYLUS ||
boolean hwMouseEvent = ( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE ||
(event.getSource() & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS ||
(event.getMetaState() & KeyEvent.FLAG_TRACKING) != 0 ); // Hack to recognize Galaxy Note Gingerbread stylus
if( ExternalMouseDetected != hwMouseEvent )
{
@@ -357,37 +320,10 @@ abstract class DifferentTouchInput
}
public void processGenericEvent(final MotionEvent event)
{
if( event.getSource() != InputDevice.SOURCE_TOUCHPAD )
{
process(event);
return;
}
/*
int x = (int)((event.getX() - xmin) / xmax * 65535.0f);
int y = (int)((event.getY() - ymin) / ymax * 65535.0f);
*/
// Use only right square part of a touch surface - I've heard reports that it breaks functionality, feel free to uncomment and test it.
int x = (int)((event.getX() - xshift) / minRange * 65535.0f);
int y = (int)((event.getY() - ymin) / minRange * 65535.0f);
if( x > 65535 )
x = 65535;
if( x < 0 )
x = 0;
if( y > 65535 )
y = 65535;
if( y < 0 )
y = 0;
int down = 1;
int multitouch = event.getPointerCount() - 1;
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP ||
(event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_CANCEL )
down = 0;
// TODO: we're processing only one touch pointer, touchpad will most probably support multitouch
//System.out.println("libSDL: touch pad event: " + x + ":" + y + " action " + event.getAction() + " down " + down + " multitouch " + multitouch );
DemoGLSurfaceView.nativeTouchpad( x, 65535 - y, down, multitouch ); // Y axis is inverted, as you may have guessed
process(event);
}
}
private static class IcsTouchInput extends XperiaPlayTouchpadTouchInput
private static class IcsTouchInput extends GingerbreadTouchInput
{
private static class Holder
{
@@ -411,6 +347,16 @@ abstract class DifferentTouchInput
}
public void processGenericEvent(final MotionEvent event)
{
// Joysticks are supported since Honeycomb, but I don't care about it, because very little devices have it
if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK )
{
// event.getAxisValue(AXIS_HAT_X) and event.getAxisValue(AXIS_HAT_Y) are joystick arrow keys, they also send keyboard events
DemoGLSurfaceView.nativeGamepadAnalogJoystickInput(
event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y),
event.getAxisValue(MotionEvent.AXIS_Z), event.getAxisValue(MotionEvent.AXIS_RZ),
event.getAxisValue(MotionEvent.AXIS_RTRIGGER), event.getAxisValue(MotionEvent.AXIS_LTRIGGER) );
return;
}
// Process mousewheel
if( event.getAction() == MotionEvent.ACTION_SCROLL )
{
@@ -422,20 +368,6 @@ abstract class DifferentTouchInput
super.processGenericEvent(event);
}
}
private static class GalaxyNoteIcsTouchInput extends IcsTouchInput
{
private static class Holder
{
private static final GalaxyNoteIcsTouchInput sInstance = new GalaxyNoteIcsTouchInput();
}
public void process(final MotionEvent event)
{
// HACK for Galaxy Note stylus, which pushes the cursor to the lower-right part of the screen, when you lift the stylus.
// Also it reports the stylus as the mouse
if(! (event.getSource() == InputDevice.SOURCE_MOUSE && (int)event.getX() == 0 && (int)event.getY() == 799))
super.process(event);
}
}
}
@@ -585,6 +517,15 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
return context.isScreenKeyboardShown() ? 1 : 0;
}
public void startAccelerometerGyroscope(int started)
{
accelerometer.openedBySDL = (started != 0);
if( accelerometer.openedBySDL && !mPaused )
accelerometer.start();
else
accelerometer.stop();
}
public void exitApp()
{
nativeDone();
@@ -774,7 +715,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
System.out.println("libSDL: DemoGLSurfaceView.onResume(): mRenderer.mGlSurfaceCreated " + mRenderer.mGlSurfaceCreated + " mRenderer.mPaused " + mRenderer.mPaused);
if( mRenderer.mGlSurfaceCreated && ! mRenderer.mPaused || Globals.NonBlockingSwapBuffers )
mRenderer.nativeGlContextRecreated();
if( mRenderer.accelerometer != null ) // For some reason it crashes here often - are we getting this event before initialization?
if( mRenderer.accelerometer != null && mRenderer.accelerometer.openedBySDL ) // For some reason it crashes here often - are we getting this event before initialization?
mRenderer.accelerometer.start();
};
@@ -805,8 +746,8 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
public static native void initJavaCallbacks();
public static native void nativeHardwareMouseDetected( int detected );
public static native void nativeMouseButtonsPressed( int buttonId, int pressedState );
public static native void nativeMouseWheel(int scrollX, int scrollY);
public static native void nativeMouseWheel( int scrollX, int scrollY );
public static native void nativeGamepadAnalogJoystickInput( float stick1x, float stick1y, float stick2x, float stick2y, float rtrigger, float ltrigger );
}

View File

@@ -165,4 +165,7 @@
<string name="not_enough_ram_size">This app needs %1$d Mb RAM, your device has %2$d Mb</string>
<string name="ignore">Ignore</string>
<string name="calibrate_gyroscope">Calibrate gyroscope</string>
<string name="calibrate_gyroscope_text">Put your phone on a flat surface</string>
</resources>

View File

@@ -28,16 +28,18 @@ SDL_TRACKBALL_KEYUP_DELAY := 1
# resized in HW-accelerated way, however it eats a tiny bit of CPU
SDL_VIDEO_RENDER_RESIZE := 1
SDL_VIDEO_RENDER_RESIZE_KEEP_ASPECT := 0
COMPILED_LIBRARIES := tremor ogg
APPLICATION_ADDITIONAL_CFLAGS := -finline-functions -O2 -DTREMOR=1 -DBUILD_TYPE=LINUX32 -DTARGET_LNX=1 -Werror=strict-aliasing -Werror=cast-align -Werror=pointer-arith -Werror=address
APPLICATION_ADDITIONAL_LDFLAGS := -ltremor
APPLICATION_OVERLAPS_SYSTEM_HEADERS := n
APPLICATION_SUBDIRS_BUILD := src/*
APPLICATION_BUILD_EXCLUDE :=
APPLICATION_CUSTOM_BUILD_SCRIPT :=
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=LCTRL -DSDL_ANDROID_KEYCODE_1=LALT -DSDL_ANDROID_KEYCODE_2=SPACE -DSDL_ANDROID_KEYCODE_3=RETURN -DSDL_ANDROID_KEYCODE_4=RETURN

View File

@@ -18,17 +18,22 @@ LOCAL_SRC_FILES := $(filter %.c %.cpp, $(APP_SUBDIRS))
APP_SUBDIRS := $(filter-out %.c %.cpp, $(APP_SUBDIRS))
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.cpp))))
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.c))))
LOCAL_SRC_FILES := $(filter-out $(addprefix $(APPDIR)/, $(APPLICATION_BUILD_EXCLUDE)), $(LOCAL_SRC_FILES))
# Disabled because they give slight overhead, add "-frtti -fexceptions" to the AppCflags inside AndroidAppSettings.cfg if you need them
# If you use setEnvironment.sh you may write "env CXXFLAGS='-frtti -fexceptions' ../setEnvironment.sh ./configure".
#LOCAL_CPP_FEATURES := exceptions rtti
LOCAL_CFLAGS :=
LOCAL_C_INCLUDES :=
LOCAL_C_INCLUDES := $(foreach D, $(APP_SUBDIRS), $(LOCAL_PATH)/$(D))
LOCAL_C_INCLUDES += $(foreach D, $(APP_SUBDIRS), $(LOCAL_PATH)/$(D)) \
$(LOCAL_PATH)/../sdl-$(SDL_VERSION)/include \
$(foreach L, $(COMPILED_LIBRARIES), $(LOCAL_PATH)/../$(L)/include) \
ifeq ($(APPLICATION_OVERLAPS_SYSTEM_HEADERS),y)
LOCAL_CFLAGS += $(foreach D, $(LOCAL_C_INCLUDES), -iquote$(D))
LOCAL_C_INCLUDES :=
endif
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../sdl-$(SDL_VERSION)/include
LOCAL_C_INCLUDES += $(foreach L, $(COMPILED_LIBRARIES), $(LOCAL_PATH)/../$(L)/include)
LOCAL_CFLAGS += $(APPLICATION_ADDITIONAL_CFLAGS)

View File

@@ -18,6 +18,7 @@ CompatibilityHacksStaticInit=n
CompatibilityHacksTextInputEmulatesHwKeyboard=n
CompatibilityHacksPreventAudioChopping=n
CompatibilityHacksAppIgnoresAudioBufferSize=n
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
AppUsesMouse=y
AppNeedsTwoButtonMouse=y
ShowMouseCursor=n
@@ -26,6 +27,7 @@ AppNeedsArrowKeys=y
AppNeedsTextInput=y
AppUsesJoystick=y
AppUsesAccelerometer=y
AppUsesGyroscope=y
AppUsesMultitouch=y
NonBlockingSwapBuffers=n
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
@@ -45,7 +47,9 @@ CompiledLibraries="sdl_mixer sdl_image"
CustomBuildScript=n
AppCflags='-O2 -finline-functions'
AppLdflags=''
AppOverlapsSystemHeaders=
AppSubdirsBuild=''
AppBuildExclude=''
AppCmdline=''
ReadmeText='^Readme text'
MinimumScreenSize=s

View File

@@ -25,7 +25,7 @@
Definitions...
----------------------------------------------------------*/
#define SCREEN_W 640
#define SCREEN_W 800
#define SCREEN_H 480
@@ -437,13 +437,16 @@ int main(int argc, char* argv[])
// some random colors
int colors[MAX_POINTERS] = { 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee, 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee };
struct TouchPointer_t { int x; int y; int pressure; int pressed; } touchPointers[MAX_POINTERS];
int accel[2], screenjoy[2];
int accel[5], screenjoy[4], gamepads[4][8];
SDL_Surface *mouse[4];
int screenKeyboardShown = 0;
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
SDL_EnableUNICODE(1);
SDL_Joystick * joysticks[6];
for( i = 0; i < 6; i++ )
joysticks[i] = SDL_JoystickOpen(i);
atexit(SDL_Quit);
@@ -548,7 +551,7 @@ int main(int argc, char* argv[])
memset(touchPointers, 0, sizeof(touchPointers));
memset(accel, 0, sizeof(accel));
memset(screenjoy, 0, sizeof(screenjoy));
SDL_Joystick * joystick = SDL_JoystickOpen(0);
memset(gamepads, 0, sizeof(gamepads));
while(1)
{
@@ -596,22 +599,33 @@ int main(int argc, char* argv[])
r.y -= r.h/2;
SDL_FillRect(screen, &r, colors[i]);
}
r.x = SCREEN_W/2 + accel[0] * SCREEN_H / 65536;
r.y = SCREEN_H/2 + accel[1] * SCREEN_H / 65536;
//__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Accel: %d %d screen %d %d", accel[0], accel[1], r.x, r.y);
r.w = 10;
r.h = 10;
r.x -= r.w/2;
r.y -= r.h/2;
SDL_FillRect(screen, &r, 0xffffff);
r.x = SCREEN_W/2 + screenjoy[0] * SCREEN_H / 65536;
r.y = SCREEN_H/2 + screenjoy[1] * SCREEN_H / 65536;
//__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Screen joystick: %d %d screen %d %d", screenjoy[0], screenjoy[1], r.x, r.y);
r.w = 10;
r.h = 10;
r.x -= r.w/2;
r.y -= r.h/2;
SDL_FillRect(screen, &r, 0x000000);
int joyInput[][3] = {
{accel[0], accel[1], 10},
{accel[2], accel[3], 10 + abs(accel[4]) * 100 / 32767},
{screenjoy[0], screenjoy[1], 10},
{screenjoy[2], screenjoy[3], 10},
{gamepads[0][0], gamepads[0][1], 10 + gamepads[0][4] * 100 / 32767},
{gamepads[0][2], gamepads[0][3], 10 + gamepads[0][5] * 100 / 32767},
{gamepads[0][6], gamepads[0][7], 10},
{gamepads[1][0], gamepads[1][1], 10 + gamepads[1][4] * 100 / 32767},
{gamepads[1][2], gamepads[1][3], 10 + gamepads[1][5] * 100 / 32767},
{gamepads[1][6], gamepads[1][7], 10},
{gamepads[2][0], gamepads[2][1], 10 + gamepads[2][4] * 100 / 32767},
{gamepads[2][2], gamepads[2][3], 10 + gamepads[2][5] * 100 / 32767},
{gamepads[2][6], gamepads[2][7], 10},
{gamepads[3][0], gamepads[3][1], 10 + gamepads[3][4] * 100 / 32767},
{gamepads[3][2], gamepads[3][3], 10 + gamepads[3][5] * 100 / 32767},
{gamepads[3][6], gamepads[3][7], 10},
};
for( i = 0; i < 15; i++ )
{
r.w = joyInput[i][2];
r.h = joyInput[i][2];
r.x = SCREEN_W/2 + joyInput[i][0] * SCREEN_H / 65536 - r.w/2;
r.y = SCREEN_H/2 + joyInput[i][1] * SCREEN_H / 65536 - r.w/2;
//__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Joy input %d: %d %d %d", i, joyInput[i][0], joyInput[i][1], joyInput[i][2] );
SDL_FillRect(screen, &r, i * 123);
}
int mx, my;
int b = SDL_GetMouseState(&mx, &my);
@@ -652,26 +666,35 @@ int main(int argc, char* argv[])
// Android-specific events - accelerometer, multitoush, and on-screen joystick
if( evt.type == SDL_JOYAXISMOTION )
{
if(evt.jaxis.axis < 4)
if(evt.jaxis.which == 0) // Multitouch and on-screen joysticks
{
if(evt.jaxis.axis < 2)
if(evt.jaxis.axis < 4)
screenjoy[evt.jaxis.axis] = evt.jaxis.value;
else
accel[evt.jaxis.axis - 2] = evt.jaxis.value;
touchPointers[evt.jaxis.axis - 4].pressure = evt.jaxis.value;
}
else
if(evt.jaxis.which == 1)
{
touchPointers[evt.jaxis.axis - 4].pressure = evt.jaxis.value;
accel[evt.jaxis.axis] = evt.jaxis.value; // accelerometer and gyroscope
}
if(evt.jaxis.which >= 2)
{
// Each gamepad has 8 axes - two joystick hats, two triggers, and Ouya touchpad
gamepads[evt.jaxis.which - 2][evt.jaxis.axis] = evt.jaxis.value;
}
}
if( evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP )
{
touchPointers[evt.jbutton.button].pressed = (evt.jbutton.state == SDL_PRESSED);
if(evt.jbutton.which == 0) // Multitouch and on-screen joystick
touchPointers[evt.jbutton.button].pressed = (evt.jbutton.state == SDL_PRESSED);
}
if( evt.type == SDL_JOYBALLMOTION )
{
touchPointers[evt.jball.ball].x = evt.jball.xrel;
touchPointers[evt.jball.ball].y = evt.jball.yrel;
if(evt.jball.which == 0) // Multitouch and on-screen joystick
{
touchPointers[evt.jball.ball].x = evt.jball.xrel;
touchPointers[evt.jball.ball].y = evt.jball.yrel;
}
}
}
if( screenKeyboardShown != SDL_IsScreenKeyboardShown(NULL))

View File

@@ -5,7 +5,7 @@ AppName="Commander Genius"
AppFullName=net.sourceforge.clonekeenplus
ScreenOrientation=h
InhibitSuspend=n
AppDataDownloadUrl="!Keen 1|keen1.zip^Keen 4|keen4.zip^Keen 7|keen7.zip^High-quality GFX and music - 50 Mb|http://sourceforge.net/projects/clonekeenplus/files/High%20Quality%20Packs/Version%201.x/hqp19.zip/download"
AppDataDownloadUrl="!Keen1|keen1.zip^!Keen4|keen4.zip^!Keen7|keen7.zip^High-quality GFX and music - 50 Mb|http://sourceforge.net/projects/clonekeenplus/files/High%20Quality%20Packs/Version%201.x/hqpv19.zip/download"
VideoDepthBpp=24
NeedDepthBuffer=n
NeedStencilBuffer=n

View File

@@ -18,6 +18,9 @@ CompatibilityHacksStaticInit=n
CompatibilityHacksTextInputEmulatesHwKeyboard=n
CompatibilityHacksPreventAudioChopping=n
CompatibilityHacksAppIgnoresAudioBufferSize=n
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
CompatibilityHacksSlowCompatibleEventQueue=n
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=n
AppUsesMouse=n
AppNeedsTwoButtonMouse=n
ShowMouseCursor=n
@@ -26,9 +29,10 @@ AppNeedsArrowKeys=y
AppNeedsTextInput=y
AppUsesJoystick=y
AppUsesAccelerometer=n
AppUsesGyroscope=y
AppUsesMultitouch=y
NonBlockingSwapBuffers=n
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
RedefinedKeys="SPACE SPACE NO_REMAP NO_REMAP RETURN ESCAPE LCTRL"
AppTouchscreenKeyboardKeysAmount=5
AppTouchscreenKeyboardKeysAmountAutoFire=0
RedefinedKeysScreenKb="SLASH BACKSPACE TAB END LCTRL SPACE UNKNOWN UNKNOWN UNKNOWN UNKNOWN"
@@ -37,15 +41,17 @@ HiddenMenuOptions='OptionalDownloadConfig DisplaySizeConfig'
FirstStartMenuOptions=''
MultiABI=y
AppMinimumRAM=300
AppVersionCode=08817
AppVersionName="0.8.8.17"
ResetSdlConfigForThisVersion=y
DeleteFilesOnUpgrade="libsdl-DownloadFinished-10.flag .openarena/baseoa/q3config.cfg"
AppVersionCode=08819
AppVersionName="0.8.8.19"
ResetSdlConfigForThisVersion=n
DeleteFilesOnUpgrade="libsdl-DownloadFinished-10.flag"
CompiledLibraries="sdl_mixer sdl_image freetype curl vorbis ogg"
CustomBuildScript=y
AppCflags='-O2 -finline-functions'
AppLdflags=''
AppOverlapsSystemHeaders=
AppSubdirsBuild=''
AppBuildExclude=''
AppCmdline=''
ReadmeText='^Readme text'
MinimumScreenSize=n

View File

@@ -1,3 +1,3 @@
#!/bin/sh
adb shell rm /sdcard/Android/data/ws.openarena.sdl/files/libsdl-DownloadFinished-10.flag
adb shell rm -r /sdcard/Android/data/ws.openarena.sdl/files/.openarena
[ -n "$1" ] && adb shell rm -r /sdcard/Android/data/ws.openarena.sdl/files/.openarena

View File

@@ -37,9 +37,9 @@ HiddenMenuOptions='OptionalDownloadConfig'
FirstStartMenuOptions=''
MultiABI=n
AppMinimumRAM=0
AppVersionCode=12324
AppVersionName="1.2.3.24"
ResetSdlConfigForThisVersion=y
AppVersionCode=12325
AppVersionName="1.2.3.25"
ResetSdlConfigForThisVersion=n
DeleteFilesOnUpgrade="%"
CompiledLibraries="jpeg png freetype timidity lzma lzo2"
CustomBuildScript=y

View File

@@ -1,5 +1,7 @@
Quick compilation guide:
Download my GIT repo from https://github.com/pelya/commandergenius,
Install liblzma-dev, it's needed for configure script
sudo apt-get install liblzma-dev
Download my Git repo from https://github.com/pelya/commandergenius,
then install Android SDK, Android NDK, and "ant" tool, then launch commands
rm project/jni/application/src
ln -s openttd project/jni/application/src

View File

@@ -0,0 +1 @@
src

View File

@@ -5,7 +5,7 @@ AppName="Ur-Quan Masters"
AppFullName=com.sourceforge.sc2
ScreenOrientation=h
InhibitSuspend=n
AppDataDownloadUrl="!Game data (15 Mb)|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/sc2-data-5.zip/download^3DO remixed music (19 Mb) - enable it in Setup->Sound Options->3DO Remixes|:addons/3domusic/3domusic.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3domusic.zip/download^UQM music remix pack (150 Mb) - enable it in Setup->Sound Options->UQM Remixes|:addons/remix/remix.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/remix.zip/download^3DO voice (115 Mb) - go to Setup->Sound Options and increase Voice volume from zero|:addons/3dovoice/3dovoice.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovoice.zip/download^Russian translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/russian.zip/download^Deutsch translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/deutsch.zip/download^Spanish translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/spanish.zip/download^Slovak translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/slovak.zip/download^Finnish translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/finnish.zip/download^3DO video support - after installing this pack copy all files from|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^your 3DO Star Control II game CD from 'duckart' dir to the SD card to dir|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'app-data/com.sourceforge.sc2/addons/3dovideo', to extract files from 3DO disk use|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'3DO Commander' or 'uncd-rom' apps from http://madroms.free.fr/3do/|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^Then from the game change 'Setup->PC/3DO compat->Cutscenes' to Movies, and restart game|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download"
AppDataDownloadUrl="!!Game data (15 Mb)|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/sc2-data-5.zip/download^3DO remixed music (19 Mb) - enable it in Setup->Sound Options->3DO Remixes|:addons/3domusic/3domusic.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3domusic.zip/download^UQM music remix pack (150 Mb) - enable it in Setup->Sound Options->UQM Remixes|:addons/remix/remix.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/remix.zip/download^3DO voice (115 Mb) - go to Setup->Sound Options and increase Voice volume from zero|:addons/3dovoice/3dovoice.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovoice.zip/download^Russian translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/russian.zip/download^Deutsch translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/deutsch.zip/download^Spanish translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/spanish.zip/download^Slovak translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/slovak.zip/download^Finnish translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/finnish.zip/download^3DO video support - after installing this pack copy all files from|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^your 3DO Star Control II game CD from 'duckart' dir to the SD card to dir|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'app-data/com.sourceforge.sc2/addons/3dovideo', to extract files from 3DO disk use|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'3DO Commander' or 'uncd-rom' apps from http://madroms.free.fr/3do/|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^Then from the game change 'Setup->PC/3DO compat->Cutscenes' to Movies, and restart game|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download"
VideoDepthBpp=16
NeedDepthBuffer=n
NeedStencilBuffer=n
@@ -15,6 +15,10 @@ SdlVideoResize=y
SdlVideoResizeKeepAspect=n
CompatibilityHacks=n
CompatibilityHacksStaticInit=n
CompatibilityHacksTextInputEmulatesHwKeyboard=n
CompatibilityHacksPreventAudioChopping=n
CompatibilityHacksAppIgnoresAudioBufferSize=n
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
AppUsesMouse=n
AppNeedsTwoButtonMouse=n
ShowMouseCursor=n
@@ -22,7 +26,7 @@ ForceRelativeMouseMode=n
AppNeedsArrowKeys=y
AppNeedsTextInput=y
AppUsesJoystick=y
AppHandlesJoystickSensitivity=n
AppUsesAccelerometer=n
AppUsesMultitouch=n
NonBlockingSwapBuffers=n
RedefinedKeys="RETURN RSHIFT NO_REMAP NO_REMAP RCTRL F10"
@@ -33,14 +37,21 @@ StartupMenuButtonTimeout=3000
HiddenMenuOptions=''
FirstStartMenuOptions=''
MultiABI=n
AppVersionCode=07022
AppVersionName="0.7.0.22"
AppMinimumRAM=0
AppVersionCode=07023
AppVersionName="0.7.0.23"
ResetSdlConfigForThisVersion=y
DeleteFilesOnUpgrade="%"
CompiledLibraries="sdl_image tremor ogg"
CustomBuildScript=n
AppCflags='-O3 -DTHREADLIB_SDL=1 -DTIMELIB=SDL -DOVCODEC_TREMOR=1 -DNETPLAY=1 -DHAVE_GETOPT_LONG=1 -DHAVE_ZIP=1 -DHAVE_JOYSTICK=1'
AppCflags='-O3 -DGFXMODULE_SDL -DOVCODEC_TREMOR -DNETPLAY=NETPLAY_FULL -DHAVE_JOYSTICK -DHAVE_ZIP=1 -DTHREADLIB_SDL -DUSE_INTERNAL_MIKMOD'
AppLdflags=''
AppSubdirsBuild='src src/regex src/libs/* src/uqm/*'
AppOverlapsSystemHeaders=y
AppSubdirsBuild='src src/libs/* src/uqm/*'
AppBuildExclude='src/libs/uio/hashtable.c src/libs/uio/memdebug.c'
AppCmdline='uqm --addon lang'
ReadmeText='^You may press "Home" now - the data will be downloaded in background'
MinimumScreenSize=s
AdmobPublisherId=n
AdmobTestDeviceId=
AdmobBannerSize=

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

View File

@@ -0,0 +1,10 @@
#!/bin/sh
LOCAL_PATH=`dirname $0`
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
if [ -e src/patched.successfully ]; then
exit 0
else
svn co https://sc2.svn.sourceforge.net/svnroot/sc2/trunk/sc2/src && patch -p0 -d src < android.diff && touch src/patched.successfully || exit 1
fi

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@
../../../../../sc2/sc2/src/

View File

@@ -1,8 +1,15 @@
$(shell mkdir -p AI debug/AI Scripting debug/Scripting \
<<<<<<< HEAD
out/vcmi/lib out/vcmi/lib/Filesystem out/vcmi/lib/Mapping \
out/vcmi/lib/RMG out/vcmi/server out/vcmi/AI/StupidAI \
out/vcmi/AI/GeniusAI out/vcmi/client out/vcmi/Scripting/ERM)
=======
out/vcmi/lib out/vcmi/lib/Filesystem out/vcmi/server out/vcmi/AI/StupidAI \
out/vcmi/AI/BattleAI out/vcmi/AI/EmptyAI \
out/vcmi/AI/Fuzzylite out/vcmi/AI/VCAI \
out/vcmi/client out/vcmi/Scripting/ERM)
>>>>>>> 2986a60b94e08c9946f3b29f2598b4eb0a53a8b0
$(shell rm -f ../../../obj/local/armeabi/libvcmi.so)
LOCAL_PATH=$(shell dirname $0)
@@ -10,7 +17,7 @@ LOCAL_PATH=`cd $LOCAL_PATH && pwd`
GCC_PREFIX=$(if $(shell which ndk-build | grep 'android-ndk-r8'),arm-linux-androideabi,arm-eabi)
SOURCES_LIB=$(wildcard vcmi/lib/*.cpp vcmi/CConsoleHandler.cpp vcmi/CThreadHelper.cpp)
SOURCES_LIB=$(wildcard vcmi/lib/*.cpp vcmi/lib/Filesystem/*.cpp vcmi/CConsoleHandler.cpp vcmi/CThreadHelper.cpp)
OBJS_LIB=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB))
SOURCES_LIB_FILESYSTEM=$(wildcard vcmi/lib/Filesystem/*.cpp)
@@ -25,11 +32,26 @@ OBJS_LIB_RMG=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB_RMG))
SOURCES_SERVER=$(wildcard vcmi/server/*.cpp)
OBJS_SERVER=$(patsubst %.cpp, out/%.o, $(SOURCES_SERVER))
SOURCES_CLIENT=$(wildcard vcmi/client/*.cpp vcmi/client/BattleInterface/*.cpp vcmi/client/UIFramework/*.cpp)
OBJS_CLIENT=$(patsubst %.cpp, out/%.o, $(SOURCES_CLIENT))
#SOURCES_GENIUSAI=$(filter-out %/ExpertSystem.cpp, $(wildcard vcmi/AI/GeniusAI/*.cpp))
#OBJS_GENIUSAI=$(patsubst %.cpp, out/%.o, $(SOURCES_GENIUSAI))
SOURCES_BATTLEAI=$(wildcard vcmi/AI/BattleAI/*.cpp)
OBJS_BATTLEAI=$(patsubst %.cpp, out/%.o, $(SOURCES_BATTLEAI))
SOURCES_EMPTYAI=$(wildcard vcmi/AI/EmptyAI/*.cpp)
OBJS_BATTLEAI=$(patsubst %.cpp, out/%.o, $(SOURCES_EMPTYAI))
SOURCES_FUZZYLITE=$(wildcard vcmi/AI/FuzzyLite/*.cpp)
OBJS_FUZZYLITE=$(patsubst %.cpp, out/%.o, $(SOURCES_FUZZYLITE))
SOURCES_STUPIDAI=$(wildcard vcmi/AI/StupidAI/*.cpp)
OBJS_STUPIDAI=$(patsubst %.cpp, out/%.o, $(SOURCES_STUPIDAI))
SOURCES_GENIUSAI=$(filter-out %/ExpertSystem.cpp, $(wildcard vcmi/AI/GeniusAI/*.cpp))
OBJS_GENIUSAI=$(patsubst %.cpp, out/%.o, $(SOURCES_GENIUSAI))
SOURCES_VCAI=$(wildcard vcmi/AI/VCAI/*.cpp)
OBJS_VCAI=$(patsubst %.cpp, out/%.o, $(SOURCES_VCAI))
SOURCES_ERM=$(wildcard vcmi/Scripting/ERM/*.cpp)
OBJS_ERM=$(patsubst %.cpp, out/%.o, $(SOURCES_ERM))
@@ -39,11 +61,15 @@ OBJS_CLIENT=$(patsubst %.cpp, out/%.o, $(SOURCES_CLIENT))
all: AndroidData/binaries.zip libapplication.so
AndroidData/binaries.zip: vcmiserver AI/libGeniusAI.so AI/libStupidAI.so Scripting/libvcmiERM.so
AndroidData/binaries.zip: vcmiserver AI/libAI.so Scripting/libvcmiERM.so
rm -f $@
zip -r $@ $^
<<<<<<< HEAD
$(OBJS_SERVER) $(OBJS_LIB) $(OBJS_LIB_FILESYSTEM) $(OBJS_LIB_MAPPING) $(OBJS_LIB_RMG) $(OBJS_GENIUSAI) $(OBJS_STUPIDAI) $(OBJS_CLIENT) $(OBJS_ERM): out/%.o: %.cpp
=======
$(OBJS_SERVER) $(OBJS_LIB) $(OBJS_BATTLEAI) $(OBJS_EMPTYAI) $(OBJS_FUZZYLITE) $(OBJS_STUPIDAI) $(OBJS_VCAI) $(OBJS_CLIENT) $(OBJS_ERM): out/%.o: %.cpp
>>>>>>> 2986a60b94e08c9946f3b29f2598b4eb0a53a8b0
../setEnvironment.sh sh -c \
"$(GCC_PREFIX)-g++ \
-c \$$CXXFLAGS -Ivcmi -std=c++11 -Ivcmi/lib \
@@ -59,8 +85,13 @@ vcmiserver: $(OBJS_SERVER) $(OBJS_LIB) $(OBJS_LIB_FILESYSTEM) $(OBJS_LIB_MAPPING
env BUILD_EXECUTABLE=1 NO_SHARED_LIBS=1 ../setEnvironment.sh sh -c \
"$(GCC_PREFIX)-g++ \
$^ -o $@ \
<<<<<<< HEAD
\$$LDFLAGS -L. -L../../boost/lib/arm-linux-androideabi-4.6 \
-lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread -lgnustl_static" && \
=======
\$$LDFLAGS -L. \
-lboost_system -lboost_filesystem -lboost_iostreams -lboost_thread" && \
>>>>>>> 2986a60b94e08c9946f3b29f2598b4eb0a53a8b0
cp $@ debug/$@ && \
$(GCC_PREFIX)-strip $@
@@ -76,10 +107,7 @@ LINK_LIB= \
.PHONY: -lvcmi
-lvcmi: libvcmi.so
AI/libGeniusAI.so: $(OBJS_GENIUSAI) -lvcmi
$(LINK_LIB)
AI/libStupidAI.so: $(OBJS_STUPIDAI) -lvcmi
AI/libAI.so: $(OBJS_BATTLEAI) $(OBJS_EMPTYAI) $(OBJS_FUZZYLITE) $(OBJS_STUPIDAI) $(OBJS_VCAI) -lvcmi
$(LINK_LIB)
Scripting/libvcmiERM.so: $(OBJS_ERM) -lvcmi

View File

@@ -0,0 +1,592 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include <jni.h>
#include <android/log.h>
#include <sys/time.h>
#include <time.h>
#include <stdint.h>
#include <math.h>
#include <string.h> // for memset()
#include "SDL_config.h"
#include "SDL_version.h"
#include "SDL_mutex.h"
#include "SDL_events.h"
#if SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_touch.h"
#include "../../events/SDL_touch_c.h"
#endif
#include "../SDL_sysvideo.h"
#include "SDL_androidvideo.h"
#include "SDL_androidinput.h"
#include "unicodestuff.h"
#include "atan2i.h"
#ifdef SDL_COMPATIBILITY_HACKS_SLOW_COMPATIBLE_EVENT_QUEUE
// This code is left here to rot - it's bad, complicated and needed by only one applicaiton
#if SDL_VERSION_ATLEAST(1,3,0)
#define SDL_SendKeyboardKey(state, keysym) SDL_SendKeyboardKey(state, (keysym)->sym)
extern SDL_Window * ANDROID_CurrentWindow;
#else
#define SDL_SendMouseMotion(A,B,X,Y) SDL_PrivateMouseMotion(0, 0, X, Y)
#define SDL_SendMouseButton(N, A, B) SDL_PrivateMouseButton( A, B, 0, 0 )
#define SDL_SendKeyboardKey(state, keysym) SDL_PrivateKeyboard(state, keysym)
#endif
enum { MAX_BUFFERED_EVENTS = 64 };
static SDL_Event BufferedEvents[MAX_BUFFERED_EVENTS];
static int BufferedEventsStart = 0, BufferedEventsEnd = 0;
static SDL_mutex * BufferedEventsMutex = NULL;
/* We need our own event queue, because Free Heroes 2 game uses
* SDL_SetEventFilter(), and it calls SDL_Flip() from inside
* it's custom filter function, and SDL_Flip() does not work
* when it's not called from the main() thread.
* So we, like, push the events into our own queue,
* read each event from that queue inside SDL_ANDROID_PumpEvents(),
* unlock the mutex, and push the event to SDL queue,
* which is then immediately read by SDL from the same thread,
* and then SDL invokes event filter function from FHeroes2.
* FHeroes2 call SDL_Flip() from inside that event filter function,
* and it works, because it is called from the main() thread.
*/
extern void SDL_ANDROID_PumpEvents()
{
static int oldMouseButtons = 0;
SDL_Event ev;
SDL_ANDROID_processAndroidTrackballDampening();
SDL_ANDROID_processMoveMouseWithKeyboard();
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_Window * window = SDL_GetFocusWindow();
if( !window )
return;
#endif
if( !BufferedEventsMutex )
BufferedEventsMutex = SDL_CreateMutex();
SDL_mutexP(BufferedEventsMutex);
while( BufferedEventsStart != BufferedEventsEnd )
{
ev = BufferedEvents[BufferedEventsStart];
BufferedEvents[BufferedEventsStart].type = 0;
BufferedEventsStart++;
if( BufferedEventsStart >= MAX_BUFFERED_EVENTS )
BufferedEventsStart = 0;
SDL_mutexV(BufferedEventsMutex);
switch( ev.type )
{
case SDL_MOUSEMOTION:
SDL_SendMouseMotion( ANDROID_CurrentWindow, 0, ev.motion.x, ev.motion.y );
break;
case SDL_MOUSEBUTTONDOWN:
if( ((oldMouseButtons & SDL_BUTTON(ev.button.button)) != 0) != ev.button.state )
{
oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(ev.button.button)) | (ev.button.state ? SDL_BUTTON(ev.button.button) : 0);
SDL_SendMouseButton( ANDROID_CurrentWindow, ev.button.state, ev.button.button );
}
break;
case SDL_KEYDOWN:
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_KEYDOWN: %i %i", ev->key.keysym.sym, ev->key.state);
SDL_SendKeyboardKey( ev.key.state, &ev.key.keysym );
break;
case SDL_JOYAXISMOTION:
if( ev.jaxis.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jaxis.which] )
SDL_PrivateJoystickAxis( SDL_ANDROID_CurrentJoysticks[ev.jaxis.which], ev.jaxis.axis, ev.jaxis.value );
break;
case SDL_JOYBUTTONDOWN:
if( ev.jbutton.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jbutton.which] )
SDL_PrivateJoystickButton( SDL_ANDROID_CurrentJoysticks[ev.jbutton.which], ev.jbutton.button, ev.jbutton.state );
break;
case SDL_JOYBALLMOTION:
if( ev.jball.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jbutton.which] )
SDL_PrivateJoystickBall( SDL_ANDROID_CurrentJoysticks[ev.jball.which], ev.jball.ball, ev.jball.xrel, ev.jball.yrel );
break;
#if SDL_VERSION_ATLEAST(1,3,0)
//if( ANDROID_CurrentWindow )
// SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
#else
case SDL_ACTIVEEVENT:
SDL_PrivateAppActive(ev.active.gain, ev.active.state);
break;
#endif
#if SDL_VERSION_ATLEAST(1,3,0)
case SDL_FINGERMOTION:
SDL_SendTouchMotion(0, ev.tfinger.fingerId, 0, (float)ev.tfinger.x / (float)window->w, (float)ev.tfinger.y / (float)window->h, ev.tfinger.pressure);
break;
case SDL_FINGERDOWN:
SDL_SendFingerDown(0, ev.tfinger.fingerId, ev.tfinger.state ? 1 : 0, (float)ev.tfinger.x / (float)window->w, (float)ev.tfinger.y / (float)window->h, ev.tfinger.pressure);
break;
case SDL_TEXTINPUT:
SDL_SendKeyboardText(ev.text.text);
break;
case SDL_MOUSEWHEEL:
SDL_SendMouseWheel( ANDROID_CurrentWindow, ev.wheel.x, ev.wheel.y );
break;
#endif
}
SDL_mutexP(BufferedEventsMutex);
}
SDL_mutexV(BufferedEventsMutex);
};
// Queue events to main thread
static int getNextEventAndLock()
{
int nextEvent;
if( !BufferedEventsMutex )
return -1;
SDL_mutexP(BufferedEventsMutex);
nextEvent = BufferedEventsEnd;
nextEvent++;
if( nextEvent >= MAX_BUFFERED_EVENTS )
nextEvent = 0;
while( nextEvent == BufferedEventsStart )
{
SDL_mutexV(BufferedEventsMutex);
if( SDL_ANDROID_InsideVideoThread() )
SDL_ANDROID_PumpEvents();
else
SDL_Delay(100);
SDL_mutexP(BufferedEventsMutex);
nextEvent = BufferedEventsEnd;
nextEvent++;
if( nextEvent >= MAX_BUFFERED_EVENTS )
nextEvent = 0;
}
return nextEvent;
}
static int getPrevEventNoLock()
{
int prevEvent;
if(BufferedEventsStart == BufferedEventsEnd)
return -1;
prevEvent = BufferedEventsEnd;
prevEvent--;
if( prevEvent < 0 )
prevEvent = MAX_BUFFERED_EVENTS - 1;
return prevEvent;
}
extern void SDL_ANDROID_MainThreadPushMouseMotion(int x, int y)
{
int nextEvent = getNextEventAndLock();
if( nextEvent == -1 )
return;
int prevEvent = getPrevEventNoLock();
if( prevEvent > 0 && BufferedEvents[prevEvent].type == SDL_MOUSEMOTION )
{
// Reuse previous mouse motion event, to prevent mouse movement lag
BufferedEvents[prevEvent].motion.x = x;
BufferedEvents[prevEvent].motion.y = y;
}
else
{
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
ev->type = SDL_MOUSEMOTION;
ev->motion.x = x;
ev->motion.y = y;
}
SDL_ANDROID_currentMouseX = x;
SDL_ANDROID_currentMouseY = y;
BufferedEventsEnd = nextEvent;
SDL_mutexV(BufferedEventsMutex);
};
extern void SDL_ANDROID_MainThreadPushMouseButton(int pressed, int button)
{
int nextEvent = getNextEventAndLock();
if( nextEvent == -1 )
return;
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
ev->type = SDL_MOUSEBUTTONDOWN;
ev->button.state = pressed;
ev->button.button = button;
if(pressed)
SDL_ANDROID_currentMouseButtons |= SDL_BUTTON(button);
else
SDL_ANDROID_currentMouseButtons &= ~(SDL_BUTTON(button));
BufferedEventsEnd = nextEvent;
SDL_mutexV(BufferedEventsMutex);
};
extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key)
{
int nextEvent = getNextEventAndLock();
if( nextEvent == -1 )
return;
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
if( SDL_ANDROID_moveMouseWithArrowKeys && (
key == SDL_KEY(UP) || key == SDL_KEY(DOWN) ||
key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) ) )
{
if( SDL_ANDROID_moveMouseWithKbX < 0 )
{
SDL_ANDROID_moveMouseWithKbX = SDL_ANDROID_currentMouseX;
SDL_ANDROID_moveMouseWithKbY = SDL_ANDROID_currentMouseY;
}
if( pressed )
{
if( key == SDL_KEY(LEFT) )
{
if( SDL_ANDROID_moveMouseWithKbSpeedX > 0 )
SDL_ANDROID_moveMouseWithKbSpeedX = 0;
SDL_ANDROID_moveMouseWithKbSpeedX -= SDL_ANDROID_moveMouseWithKbSpeed;
SDL_ANDROID_moveMouseWithKbAccelX = -SDL_ANDROID_moveMouseWithKbAccel;
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 1;
}
else if( key == SDL_KEY(RIGHT) )
{
if( SDL_ANDROID_moveMouseWithKbSpeedX < 0 )
SDL_ANDROID_moveMouseWithKbSpeedX = 0;
SDL_ANDROID_moveMouseWithKbSpeedX += SDL_ANDROID_moveMouseWithKbSpeed;
SDL_ANDROID_moveMouseWithKbAccelX = SDL_ANDROID_moveMouseWithKbAccel;
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 1;
}
if( key == SDL_KEY(UP) )
{
if( SDL_ANDROID_moveMouseWithKbSpeedY > 0 )
SDL_ANDROID_moveMouseWithKbSpeedY = 0;
SDL_ANDROID_moveMouseWithKbSpeedY -= SDL_ANDROID_moveMouseWithKbSpeed;
SDL_ANDROID_moveMouseWithKbAccelY = -SDL_ANDROID_moveMouseWithKbAccel;
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 2;
}
else if( key == SDL_KEY(DOWN) )
{
if( SDL_ANDROID_moveMouseWithKbSpeedY < 0 )
SDL_ANDROID_moveMouseWithKbSpeedY = 0;
SDL_ANDROID_moveMouseWithKbSpeedY += SDL_ANDROID_moveMouseWithKbSpeed;
SDL_ANDROID_moveMouseWithKbAccelY = SDL_ANDROID_moveMouseWithKbAccel;
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 2;
}
}
else
{
if( key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) )
{
SDL_ANDROID_moveMouseWithKbSpeedX = 0;
SDL_ANDROID_moveMouseWithKbAccelX = 0;
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded &= ~1;
}
if( key == SDL_KEY(UP) || key == SDL_KEY(DOWN) )
{
SDL_ANDROID_moveMouseWithKbSpeedY = 0;
SDL_ANDROID_moveMouseWithKbAccelY = 0;
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded &= ~2;
}
}
SDL_ANDROID_moveMouseWithKbX += SDL_ANDROID_moveMouseWithKbSpeedX;
SDL_ANDROID_moveMouseWithKbY += SDL_ANDROID_moveMouseWithKbSpeedY;
SDL_mutexV(BufferedEventsMutex);
SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY);
return;
}
ev->type = SDL_KEYDOWN;
ev->key.state = pressed;
ev->key.keysym.scancode = key;
ev->key.keysym.sym = key;
ev->key.keysym.mod = KMOD_NONE;
ev->key.keysym.unicode = 0;
#if SDL_VERSION_ATLEAST(1,3,0)
#else
if ( SDL_TranslateUNICODE )
#endif
ev->key.keysym.unicode = key;
BufferedEventsEnd = nextEvent;
SDL_mutexV(BufferedEventsMutex);
};
extern void SDL_ANDROID_MainThreadPushJoystickAxis(int joy, int axis, int value)
{
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
return;
int nextEvent = getNextEventAndLock();
if( nextEvent == -1 )
return;
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
ev->type = SDL_JOYAXISMOTION;
ev->jaxis.which = joy;
ev->jaxis.axis = axis;
ev->jaxis.value = MAX( -32768, MIN( 32767, value ) );
BufferedEventsEnd = nextEvent;
SDL_mutexV(BufferedEventsMutex);
};
extern void SDL_ANDROID_MainThreadPushJoystickButton(int joy, int button, int pressed)
{
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
return;
int nextEvent = getNextEventAndLock();
if( nextEvent == -1 )
return;
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
ev->type = SDL_JOYBUTTONDOWN;
ev->jbutton.which = joy;
ev->jbutton.button = button;
ev->jbutton.state = pressed;
BufferedEventsEnd = nextEvent;
SDL_mutexV(BufferedEventsMutex);
};
extern void SDL_ANDROID_MainThreadPushJoystickBall(int joy, int ball, int x, int y)
{
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
return;
int nextEvent = getNextEventAndLock();
if( nextEvent == -1 )
return;
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
ev->type = SDL_JOYBALLMOTION;
ev->jball.which = joy;
ev->jball.ball = ball;
ev->jball.xrel = x;
ev->jball.yrel = y;
BufferedEventsEnd = nextEvent;
SDL_mutexV(BufferedEventsMutex);
}
extern void SDL_ANDROID_MainThreadPushMultitouchButton(int id, int pressed, int x, int y, int force)
{
#if SDL_VERSION_ATLEAST(1,3,0)
int nextEvent = getNextEventAndLock();
if( nextEvent == -1 )
return;
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
ev->type = SDL_FINGERDOWN;
ev->tfinger.fingerId = id;
ev->tfinger.state = pressed;
ev->tfinger.x = x;
ev->tfinger.y = y;
ev->tfinger.pressure = force;
BufferedEventsEnd = nextEvent;
SDL_mutexV(BufferedEventsMutex);
#endif
};
extern void SDL_ANDROID_MainThreadPushMultitouchMotion(int id, int x, int y, int force)
{
#if SDL_VERSION_ATLEAST(1,3,0)
int nextEvent = getNextEventAndLock();
if( nextEvent == -1 )
return;
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
ev->type = SDL_FINGERMOTION;
ev->tfinger.fingerId = id;
ev->tfinger.x = x;
ev->tfinger.y = y;
ev->tfinger.pressure = force;
BufferedEventsEnd = nextEvent;
SDL_mutexV(BufferedEventsMutex);
#endif
};
extern void SDL_ANDROID_MainThreadPushMouseWheel(int x, int y)
{
#if SDL_VERSION_ATLEAST(1,3,0)
int nextEvent = getNextEventAndLock();
if( nextEvent == -1 )
return;
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
ev->type = SDL_MOUSEWHEEL;
ev->wheel.x = x;
ev->wheel.y = y;
BufferedEventsEnd = nextEvent;
SDL_mutexV(BufferedEventsMutex);
#endif
}
extern void SDL_ANDROID_MainThreadPushAppActive(int active)
{
#if SDL_VERSION_ATLEAST(1,3,0)
//if( ANDROID_CurrentWindow )
// SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
#else
int nextEvent = getNextEventAndLock();
if( nextEvent == -1 )
return;
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
ev->type = SDL_ACTIVEEVENT;
ev->active.gain = active;
ev->active.state = SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS;
BufferedEventsEnd = nextEvent;
SDL_mutexV(BufferedEventsMutex);
#endif
}
enum { DEFERRED_TEXT_COUNT = 256 };
static struct { int scancode; int unicode; int down; } deferredText[DEFERRED_TEXT_COUNT];
static int deferredTextIdx1 = 0;
static int deferredTextIdx2 = 0;
static SDL_mutex * deferredTextMutex = NULL;
void SDL_ANDROID_DeferredTextInput()
{
if( !deferredTextMutex )
deferredTextMutex = SDL_CreateMutex();
SDL_mutexP(deferredTextMutex);
if( deferredTextIdx1 != deferredTextIdx2 )
{
int nextEvent = getNextEventAndLock();
if( nextEvent == -1 )
{
SDL_mutexV(deferredTextMutex);
return;
}
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
deferredTextIdx1++;
if( deferredTextIdx1 >= DEFERRED_TEXT_COUNT )
deferredTextIdx1 = 0;
ev->type = SDL_KEYDOWN;
ev->key.state = deferredText[deferredTextIdx1].down;
ev->key.keysym = asciiToKeysym( deferredText[deferredTextIdx1].scancode, deferredText[deferredTextIdx1].unicode );
BufferedEventsEnd = nextEvent;
SDL_mutexV(BufferedEventsMutex);
if( SDL_ANDROID_isMouseUsed )
SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_currentMouseX + (SDL_ANDROID_currentMouseX % 2 ? -1 : 1), SDL_ANDROID_currentMouseY); // Force screen redraw
}
else
{
if( SDL_ANDROID_TextInputFinished )
{
SDL_ANDROID_TextInputFinished = 0;
SDL_ANDROID_IsScreenKeyboardShownFlag = 0;
}
}
SDL_mutexV(deferredTextMutex);
};
extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode )
{
int shiftRequired;
int nextEvent = getNextEventAndLock();
if( nextEvent == -1 )
return;
SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
#if SDL_VERSION_ATLEAST(1,3,0)
ev->type = SDL_TEXTINPUT;
UnicodeToUtf8(unicode, ev->text.text);
#endif
if( !deferredTextMutex )
deferredTextMutex = SDL_CreateMutex();
SDL_mutexP(deferredTextMutex);
ev->type = 0;
shiftRequired = checkShiftRequired(&ascii);
if( shiftRequired )
{
deferredTextIdx2++;
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
deferredTextIdx2 = 0;
deferredText[deferredTextIdx2].down = SDL_PRESSED;
deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
deferredText[deferredTextIdx2].unicode = 0;
}
deferredTextIdx2++;
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
deferredTextIdx2 = 0;
deferredText[deferredTextIdx2].down = SDL_PRESSED;
deferredText[deferredTextIdx2].scancode = ascii;
deferredText[deferredTextIdx2].unicode = unicode;
deferredTextIdx2++;
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
deferredTextIdx2 = 0;
deferredText[deferredTextIdx2].down = SDL_RELEASED;
deferredText[deferredTextIdx2].scancode = ascii;
deferredText[deferredTextIdx2].unicode = 0;
if( shiftRequired )
{
deferredTextIdx2++;
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
deferredTextIdx2 = 0;
deferredText[deferredTextIdx2].down = SDL_RELEASED;
deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
deferredText[deferredTextIdx2].unicode = 0;
}
SDL_mutexV(deferredTextMutex);
BufferedEventsEnd = nextEvent;
SDL_mutexV(BufferedEventsMutex);
};
#endif

View File

@@ -0,0 +1,342 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include <jni.h>
#include <android/log.h>
#include <sys/time.h>
#include <time.h>
#include <stdint.h>
#include <math.h>
#include <string.h> // for memset()
#include "SDL_config.h"
#include "SDL_version.h"
#include "SDL_mutex.h"
#include "SDL_events.h"
#if SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_touch.h"
#include "../../events/SDL_touch_c.h"
#endif
#include "../SDL_sysvideo.h"
#include "SDL_androidvideo.h"
#include "SDL_androidinput.h"
#include "unicodestuff.h"
#include "atan2i.h"
#ifndef SDL_COMPATIBILITY_HACKS_SLOW_COMPATIBLE_EVENT_QUEUE
#if SDL_VERSION_ATLEAST(1,3,0)
#define SDL_SendKeyboardKey(state, keysym) SDL_SendKeyboardKey(state, (keysym)->sym)
extern SDL_Window * ANDROID_CurrentWindow;
#else
#define SDL_SendMouseMotion(A,B,X,Y) SDL_PrivateMouseMotion(0, 0, X, Y)
#define SDL_SendMouseButton(N, A, B) SDL_PrivateMouseButton( A, B, 0, 0 )
#define SDL_SendKeyboardKey(state, keysym) SDL_PrivateKeyboard(state, keysym)
#endif
static volatile int joystickEventsCount;
static int oldMouseButtons = 0;
extern void SDL_ANDROID_PumpEvents()
{
joystickEventsCount = 0;
SDL_ANDROID_processAndroidTrackballDampening();
SDL_ANDROID_processMoveMouseWithKeyboard();
};
extern void SDL_ANDROID_MainThreadPushMouseMotion(int x, int y)
{
SDL_SendMouseMotion( ANDROID_CurrentWindow, 0, x, y );
SDL_ANDROID_currentMouseX = x;
SDL_ANDROID_currentMouseY = y;
}
extern void SDL_ANDROID_MainThreadPushMouseButton(int pressed, int button)
{
if( ((oldMouseButtons & SDL_BUTTON(button)) != 0) != pressed )
{
oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(button)) | (pressed ? SDL_BUTTON(button) : 0);
SDL_SendMouseButton( ANDROID_CurrentWindow, pressed, button );
}
if(pressed)
SDL_ANDROID_currentMouseButtons |= SDL_BUTTON(button);
else
SDL_ANDROID_currentMouseButtons &= ~(SDL_BUTTON(button));
}
extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key)
{
SDL_keysym keysym;
if( SDL_ANDROID_moveMouseWithArrowKeys && (
key == SDL_KEY(UP) || key == SDL_KEY(DOWN) ||
key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) ) )
{
if( SDL_ANDROID_moveMouseWithKbX < 0 )
{
SDL_ANDROID_moveMouseWithKbX = SDL_ANDROID_currentMouseX;
SDL_ANDROID_moveMouseWithKbY = SDL_ANDROID_currentMouseY;
}
if( pressed )
{
if( key == SDL_KEY(LEFT) )
{
if( SDL_ANDROID_moveMouseWithKbSpeedX > 0 )
SDL_ANDROID_moveMouseWithKbSpeedX = 0;
SDL_ANDROID_moveMouseWithKbSpeedX -= SDL_ANDROID_moveMouseWithKbSpeed;
SDL_ANDROID_moveMouseWithKbAccelX = -SDL_ANDROID_moveMouseWithKbAccel;
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 1;
}
else if( key == SDL_KEY(RIGHT) )
{
if( SDL_ANDROID_moveMouseWithKbSpeedX < 0 )
SDL_ANDROID_moveMouseWithKbSpeedX = 0;
SDL_ANDROID_moveMouseWithKbSpeedX += SDL_ANDROID_moveMouseWithKbSpeed;
SDL_ANDROID_moveMouseWithKbAccelX = SDL_ANDROID_moveMouseWithKbAccel;
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 1;
}
if( key == SDL_KEY(UP) )
{
if( SDL_ANDROID_moveMouseWithKbSpeedY > 0 )
SDL_ANDROID_moveMouseWithKbSpeedY = 0;
SDL_ANDROID_moveMouseWithKbSpeedY -= SDL_ANDROID_moveMouseWithKbSpeed;
SDL_ANDROID_moveMouseWithKbAccelY = -SDL_ANDROID_moveMouseWithKbAccel;
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 2;
}
else if( key == SDL_KEY(DOWN) )
{
if( SDL_ANDROID_moveMouseWithKbSpeedY < 0 )
SDL_ANDROID_moveMouseWithKbSpeedY = 0;
SDL_ANDROID_moveMouseWithKbSpeedY += SDL_ANDROID_moveMouseWithKbSpeed;
SDL_ANDROID_moveMouseWithKbAccelY = SDL_ANDROID_moveMouseWithKbAccel;
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 2;
}
}
else
{
if( key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) )
{
SDL_ANDROID_moveMouseWithKbSpeedX = 0;
SDL_ANDROID_moveMouseWithKbAccelX = 0;
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded &= ~1;
}
if( key == SDL_KEY(UP) || key == SDL_KEY(DOWN) )
{
SDL_ANDROID_moveMouseWithKbSpeedY = 0;
SDL_ANDROID_moveMouseWithKbAccelY = 0;
SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded &= ~2;
}
}
SDL_ANDROID_moveMouseWithKbX += SDL_ANDROID_moveMouseWithKbSpeedX;
SDL_ANDROID_moveMouseWithKbY += SDL_ANDROID_moveMouseWithKbSpeedY;
SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY);
return;
}
keysym.scancode = key;
keysym.sym = key;
keysym.mod = KMOD_NONE;
keysym.unicode = 0;
#if SDL_VERSION_ATLEAST(1,3,0)
#else
if ( SDL_TranslateUNICODE )
#endif
keysym.unicode = key;
if( pressed == SDL_RELEASED )
keysym.unicode = 0;
SDL_SendKeyboardKey( pressed, &keysym );
}
extern void SDL_ANDROID_MainThreadPushJoystickAxis(int joy, int axis, int value)
{
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
return;
if( joystickEventsCount > 64 )
{
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "Too many joystick events in the queue - dropping some events");
return;
}
joystickEventsCount++;
SDL_PrivateJoystickAxis( SDL_ANDROID_CurrentJoysticks[joy], axis, MAX( -32768, MIN( 32767, value ) ) );
}
extern void SDL_ANDROID_MainThreadPushJoystickButton(int joy, int button, int pressed)
{
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
return;
SDL_PrivateJoystickButton( SDL_ANDROID_CurrentJoysticks[joy], button, pressed );
}
extern void SDL_ANDROID_MainThreadPushJoystickBall(int joy, int ball, int x, int y)
{
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
return;
SDL_PrivateJoystickBall( SDL_ANDROID_CurrentJoysticks[joy], ball, x, y );
}
extern void SDL_ANDROID_MainThreadPushMultitouchButton(int id, int pressed, int x, int y, int force)
{
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_SendFingerDown(0, id, pressed ? 1 : 0, (float)x / (float)window->w, (float)y / (float)window->h, force);
#endif
}
extern void SDL_ANDROID_MainThreadPushMultitouchMotion(int id, int x, int y, int force)
{
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_SendTouchMotion(0, id, 0, (float)x / (float)window->w, (float)y / (float)window->h, force);
#endif
}
extern void SDL_ANDROID_MainThreadPushMouseWheel(int x, int y)
{
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_SendMouseWheel( ANDROID_CurrentWindow, x, y );
#endif
}
extern void SDL_ANDROID_MainThreadPushAppActive(int active)
{
#if SDL_VERSION_ATLEAST(1,3,0)
//if( ANDROID_CurrentWindow )
// SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
#else
SDL_PrivateAppActive(active, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
#endif
}
enum { DEFERRED_TEXT_COUNT = 256 };
static struct { int scancode; int unicode; int down; } deferredText[DEFERRED_TEXT_COUNT];
static int deferredTextIdx1 = 0;
static int deferredTextIdx2 = 0;
static SDL_mutex * deferredTextMutex = NULL;
void SDL_ANDROID_DeferredTextInput()
{
if( !deferredTextMutex )
deferredTextMutex = SDL_CreateMutex();
SDL_mutexP(deferredTextMutex);
if( deferredTextIdx1 != deferredTextIdx2 )
{
SDL_keysym keysym;
deferredTextIdx1++;
if( deferredTextIdx1 >= DEFERRED_TEXT_COUNT )
deferredTextIdx1 = 0;
keysym = asciiToKeysym( deferredText[deferredTextIdx1].scancode, deferredText[deferredTextIdx1].unicode );
if( deferredText[deferredTextIdx1].down == SDL_RELEASED )
keysym.unicode = 0;
SDL_SendKeyboardKey( deferredText[deferredTextIdx1].down, &keysym );
if( SDL_ANDROID_isMouseUsed )
SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_currentMouseX + (SDL_ANDROID_currentMouseX % 2 ? -1 : 1), SDL_ANDROID_currentMouseY); // Force screen redraw
}
else
{
if( SDL_ANDROID_TextInputFinished )
{
SDL_ANDROID_TextInputFinished = 0;
SDL_ANDROID_IsScreenKeyboardShownFlag = 0;
}
}
SDL_mutexV(deferredTextMutex);
}
extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode )
{
int shiftRequired;
#if SDL_VERSION_ATLEAST(1,3,0)
{
char text[32];
UnicodeToUtf8(unicode, text);
SDL_SendKeyboardText(text);
}
#endif
if( !deferredTextMutex )
deferredTextMutex = SDL_CreateMutex();
SDL_mutexP(deferredTextMutex);
shiftRequired = checkShiftRequired(&ascii);
if( shiftRequired )
{
deferredTextIdx2++;
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
deferredTextIdx2 = 0;
deferredText[deferredTextIdx2].down = SDL_PRESSED;
deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
deferredText[deferredTextIdx2].unicode = 0;
}
deferredTextIdx2++;
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
deferredTextIdx2 = 0;
deferredText[deferredTextIdx2].down = SDL_PRESSED;
deferredText[deferredTextIdx2].scancode = ascii;
deferredText[deferredTextIdx2].unicode = unicode;
deferredTextIdx2++;
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
deferredTextIdx2 = 0;
deferredText[deferredTextIdx2].down = SDL_RELEASED;
deferredText[deferredTextIdx2].scancode = ascii;
deferredText[deferredTextIdx2].unicode = 0;
if( shiftRequired )
{
deferredTextIdx2++;
if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
deferredTextIdx2 = 0;
deferredText[deferredTextIdx2].down = SDL_RELEASED;
deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
deferredText[deferredTextIdx2].unicode = 0;
}
SDL_mutexV(deferredTextMutex);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -203,4 +203,18 @@ extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode );
extern void SDL_android_init_keymap(SDLKey *SDL_android_keymap);
extern void SDL_ANDROID_MainThreadPushMouseWheel( int x, int y ); // SDL 1.3 only
extern void SDL_ANDROID_MainThreadPushAppActive(int active);
// Internal input queue stuff
extern SDLKey SDL_android_keymap[];
extern SDL_Joystick *SDL_ANDROID_CurrentJoysticks[];
extern int SDL_ANDROID_isMouseUsed;
extern int SDL_ANDROID_currentMouseX, SDL_ANDROID_currentMouseY, SDL_ANDROID_currentMouseButtons;
extern int SDL_ANDROID_moveMouseWithArrowKeys;
extern int SDL_ANDROID_moveMouseWithKbSpeed;
extern int SDL_ANDROID_moveMouseWithKbAccel;
extern int SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY;
extern int SDL_ANDROID_moveMouseWithKbSpeedX, SDL_ANDROID_moveMouseWithKbSpeedY;
extern int SDL_ANDROID_moveMouseWithKbAccelX, SDL_ANDROID_moveMouseWithKbAccelY;
extern int SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded;
#endif

View File

@@ -910,10 +910,9 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
// Do it old-fashioned way with direct GL calls
glPushMatrix();
glLoadIdentity();
glOrthox( 0, SDL_ANDROID_sFakeWindowWidth * 0x10000, SDL_ANDROID_sFakeWindowHeight * 0x10000, 0, 0, 1 * 0x10000 );
glColor4x(0, 0, 0, 0x10000);
glOrthof( 0.0f, SDL_ANDROID_sFakeWindowWidth, SDL_ANDROID_sFakeWindowHeight, 0.0f, 0.0f, 1.0f );
glEnableClientState(GL_VERTEX_ARRAY);
glColor4x(0, 0, 0, 0x10000);
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
GLshort vertices[] = { frame.x, frame.y,
frame.x + frame.w, frame.y,
frame.x + frame.w, frame.y + frame.h,
@@ -991,7 +990,7 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
SDL_GetMouseState(&x, &y);
x = x * SDL_ANDROID_sRealWindowWidth / SDL_ANDROID_sFakeWindowWidth;
y = y * SDL_ANDROID_sRealWindowHeight / SDL_ANDROID_sFakeWindowHeight;
SDL_ANDROID_DrawMouseCursor( x, y, 0, 255 );
SDL_ANDROID_DrawMouseCursor( x, y, 0, 1.0f );
}
if( SDL_ANDROID_ShowScreenUnderFinger != ZOOM_NONE )
{
@@ -1005,7 +1004,7 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
SDL_ANDROID_ShowScreenUnderFingerRect.h / SDL_ANDROID_ShowScreenUnderFingerRectSrc.h;
x = x * SDL_ANDROID_sRealWindowWidth / SDL_ANDROID_sFakeWindowWidth;
y = y * SDL_ANDROID_sRealWindowHeight / SDL_ANDROID_sFakeWindowHeight;
SDL_ANDROID_DrawMouseCursor( x, y, 16, 255 );
SDL_ANDROID_DrawMouseCursor( x, y, 16, 1.0f );
}
}
}

View File

@@ -65,6 +65,7 @@ static jmethodID JavaShowScreenKeyboard = NULL;
static jmethodID JavaToggleScreenKeyboardWithoutTextInput = NULL;
static jmethodID JavaHideScreenKeyboard = NULL;
static jmethodID JavaIsScreenKeyboardShown = NULL;
static jmethodID JavaStartAccelerometerGyroscope = NULL;
static jmethodID JavaGetAdvertisementParams = NULL;
static jmethodID JavaSetAdvertisementVisible = NULL;
static jmethodID JavaSetAdvertisementPosition = NULL;
@@ -110,8 +111,8 @@ int SDL_ANDROID_CallJavaSwapBuffers()
{
glPushMatrix();
glLoadIdentity();
glOrthox( 0, (SDL_ANDROID_sRealWindowWidth) * 0x10000, SDL_ANDROID_sRealWindowHeight * 0x10000, 0, 0, 1 * 0x10000 );
glColor4x(0, 0, 0, 0x10000);
glOrthof( 0.0f, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight, 0.0f, 0.0f, 1.0f );
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
GLshort vertices[] = { SDL_ANDROID_ForceClearScreenRect.x, SDL_ANDROID_ForceClearScreenRect.y,
@@ -297,6 +298,11 @@ int SDL_ANDROID_IsScreenKeyboardShown()
return SDL_ANDROID_IsScreenKeyboardShownFlag;
}
void SDL_ANDROID_CallJavaStartAccelerometerGyroscope(int start)
{
(*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaStartAccelerometerGyroscope, (jint) start );
}
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject thiz )
{
@@ -309,7 +315,8 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject t
JavaToggleScreenKeyboardWithoutTextInput = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboardWithoutTextInputField", "()V");
JavaHideScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "hideScreenKeyboard", "()V");
JavaIsScreenKeyboardShown = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "isScreenKeyboardShown", "()I");
// TODO: implement it
JavaStartAccelerometerGyroscope = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "startAccelerometerGyroscope", "(I)V");
JavaGetAdvertisementParams = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "getAdvertisementParams", "([I)V");
JavaSetAdvertisementVisible = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "setAdvertisementVisible", "(I)V");
JavaSetAdvertisementPosition = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "setAdvertisementPosition", "(II)V");

View File

@@ -69,10 +69,10 @@ extern void SDL_ANDROID_initFakeStdout();
extern SDL_VideoDevice *ANDROID_CreateDevice_1_3(int devindex);
extern void SDL_ANDROID_ProcessDeferredEvents();
extern void SDL_ANDROID_WarpMouse(int x, int y);
extern void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, int alpha);
extern void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, float alpha);
extern void SDL_ANDROID_DrawMouseCursorIfNeeded();
extern void SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput();
extern void SDL_ANDROID_CallJavaStartAccelerometerGyroscope(int start);
#if SDL_VERSION_ATLEAST(1,3,0)
extern SDL_Window * ANDROID_CurrentWindow;

View File

@@ -40,14 +40,10 @@
#include "SDL_androidvideo.h"
#include "SDL_androidinput.h"
#include "jniwrapperstuff.h"
// #include "touchscreentheme.h" // Not used yet
#include "atan2i.h"
// TODO: this code is a HUGE MESS
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
enum { MAX_BUTTONS = SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM-1, MAX_BUTTONS_AUTOFIRE = 2, BUTTON_TEXT_INPUT = SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT, BUTTON_ARROWS = MAX_BUTTONS } ; // Max amount of custom buttons
int SDL_ANDROID_isTouchscreenKeyboardUsed = 0;
@@ -56,7 +52,7 @@ static short touchscreenKeyboardShown = 1;
static short AutoFireButtonsNum = 0;
static short buttonsize = 1;
static short buttonDrawSize = 1;
static short transparency = 128;
static float transparency = 128.0f/255.0f;
static SDL_Rect arrows, arrowsExtended, buttons[MAX_BUTTONS], buttonsAutoFireRect[MAX_BUTTONS_AUTOFIRE];
static SDL_Rect arrowsDraw, buttonsDraw[MAX_BUTTONS];
@@ -118,16 +114,30 @@ oldGlState;
static inline void beginDrawingTex()
{
#ifndef SDL_TOUCHSCREEN_KEYBOARD_SAVE_RESTORE_OPENGL_STATE
// Make the video somehow work on emulator
oldGlState.texture2d = GL_TRUE;
oldGlState.texunitId = GL_TEXTURE0;
oldGlState.clientTexunitId = GL_TEXTURE0;
oldGlState.textureId = 0;
oldGlState.texEnvMode = GL_MODULATE;
oldGlState.blend = GL_TRUE;
oldGlState.blend1 = GL_SRC_ALPHA;
oldGlState.blend2 = GL_ONE_MINUS_SRC_ALPHA;
oldGlState.colorArray = GL_FALSE;
#else
// Save OpenGL state
glGetError(); // Clear error flag
// This code does not work on 1.6 emulator, and on some older devices
// However GLES 1.1 spec defines all theese values, so it's a device fault for not implementing them
oldGlState.texture2d = glIsEnabled(GL_TEXTURE_2D);
glGetIntegerv(GL_ACTIVE_TEXTURE, &oldGlState.texunitId);
glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &oldGlState.clientTexunitId);
#endif
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);
#ifdef SDL_TOUCHSCREEN_KEYBOARD_SAVE_RESTORE_OPENGL_STATE
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldGlState.textureId);
glGetFloatv(GL_CURRENT_COLOR, &(oldGlState.color[0]));
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &oldGlState.texEnvMode);
@@ -136,19 +146,7 @@ static inline void beginDrawingTex()
glGetIntegerv(GL_BLEND_DST, &oldGlState.blend2);
glGetBooleanv(GL_COLOR_ARRAY, &oldGlState.colorArray);
// It's very unlikely that some app will use GL_TEXTURE_CROP_RECT_OES, so just skip it
if( glGetError() != GL_NO_ERROR )
{
// Make the video somehow work on emulator
oldGlState.texture2d = GL_FALSE;
oldGlState.texunitId = GL_TEXTURE0;
oldGlState.clientTexunitId = GL_TEXTURE0;
oldGlState.textureId = 0;
oldGlState.texEnvMode = GL_MODULATE;
oldGlState.blend = GL_FALSE;
oldGlState.blend1 = GL_SRC_ALPHA;
oldGlState.blend2 = GL_ONE_MINUS_SRC_ALPHA;
oldGlState.colorArray = GL_FALSE;
}
#endif
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@@ -164,7 +162,7 @@ static inline void endDrawingTex()
glDisable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, oldGlState.textureId);
glColor4f(oldGlState.color[0], oldGlState.color[1], oldGlState.color[2], oldGlState.color[3]);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, oldGlState.texEnvMode);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, oldGlState.texEnvMode);
if( oldGlState.blend == GL_FALSE )
glDisable(GL_BLEND);
glBlendFunc(oldGlState.blend1, oldGlState.blend2);
@@ -174,7 +172,7 @@ static inline void endDrawingTex()
glEnableClientState(GL_COLOR_ARRAY);
}
static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, int flipX, int flipY, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, int flipX, int flipY, float r, float g, float b, float a)
{
GLint cropRect[4];
@@ -183,7 +181,7 @@ static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect *
glBindTexture(GL_TEXTURE_2D, tex->id);
glColor4x(r * 0x100, g * 0x100, b * 0x100, a * 0x100 );
glColor4f(r, g, b, a);
if(src)
{
@@ -213,7 +211,7 @@ static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect *
glDrawTexiOES(dest->x, SDL_ANDROID_sWindowHeight - dest->y - dest->h, 0, dest->w, dest->h);
}
static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, float r, float g, float b, float a)
{
drawCharTexFlip(tex, src, dest, 0, 0, r, g, b, a);
}
@@ -221,24 +219,24 @@ static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * des
static void drawTouchscreenKeyboardLegacy()
{
int i;
int blendFactor;
float blendFactor;
blendFactor = ( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ? 1 : 0 ) +
( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ? 1 : 0 ) +
( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ? 1 : 0 ) +
( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 1 : 0 );
if( blendFactor == 0 )
drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 255, 255, 255, transparency );
drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency );
else
{
if( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] )
drawCharTex( &arrowImages[1], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
drawCharTex( &arrowImages[1], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency / blendFactor );
if( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] )
drawCharTex( &arrowImages[2], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
drawCharTex( &arrowImages[2], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency / blendFactor );
if( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] )
drawCharTex( &arrowImages[3], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
drawCharTex( &arrowImages[3], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency / blendFactor );
if( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] )
drawCharTex( &arrowImages[4], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
drawCharTex( &arrowImages[4], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency / blendFactor );
}
for( i = 0; i < MAX_BUTTONS; i++ )
@@ -274,7 +272,7 @@ static void drawTouchscreenKeyboardLegacy()
autoFireDest.w = pos1dst;
drawCharTex( &buttonImages[i*2+1],
&autoFireCrop, &autoFireDest, 255, 255, 255, transparency );
&autoFireCrop, &autoFireDest, 1.0f, 1.0f, 1.0f, transparency );
autoFireCrop.x = pos2src;
autoFireCrop.w = buttonImages[i*2+1].w - pos2src;
@@ -282,7 +280,7 @@ static void drawTouchscreenKeyboardLegacy()
autoFireDest.w = buttonsDraw[i].w - pos2dst;
drawCharTex( &buttonImages[i*2+1],
&autoFireCrop, &autoFireDest, 255, 255, 255, transparency );
&autoFireCrop, &autoFireDest, 1.0f, 1.0f, 1.0f, transparency );
autoFireCrop.x = pos1src;
autoFireCrop.w = pos2src - pos1src;
@@ -290,13 +288,13 @@ static void drawTouchscreenKeyboardLegacy()
autoFireDest.w = pos2dst - pos1dst;
drawCharTex( &buttonAutoFireImages[i*2+1],
&autoFireCrop, &autoFireDest, 255, 255, 255, transparency );
&autoFireCrop, &autoFireDest, 1.0f, 1.0f, 1.0f, transparency );
}
else
{
drawCharTex( ( i < AutoFireButtonsNum && ButtonAutoFire[i] ) ? &buttonAutoFireImages[i*2] :
&buttonImages[ SDL_GetKeyboardState(NULL)[buttonKeysyms[i]] ? (i * 2 + 1) : (i * 2) ],
NULL, &buttonsDraw[i], 255, 255, 255, transparency );
NULL, &buttonsDraw[i], 1.0f, 1.0f, 1.0f, transparency );
}
}
}
@@ -305,7 +303,7 @@ static void drawTouchscreenKeyboardSun()
{
int i;
drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 255, 255, 255, transparency );
drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency );
if(pointerInButtonRect[BUTTON_ARROWS] != -1)
{
SDL_Rect touch = arrowsDraw;
@@ -313,7 +311,7 @@ static void drawTouchscreenKeyboardSun()
touch.h /= 2;
touch.x = joystickTouchPoints[0] - touch.w / 2;
touch.y = joystickTouchPoints[1] - touch.h / 2;
drawCharTex( &arrowImages[0], NULL, &touch, 255, 255, 255, transparency );
drawCharTex( &arrowImages[0], NULL, &touch, 1.0f, 1.0f, 1.0f, transparency );
}
for( i = 0; i < MAX_BUTTONS; i++ )
@@ -339,10 +337,10 @@ static void drawTouchscreenKeyboardSun()
if( i < AutoFireButtonsNum && ButtonAutoFire[i] )
drawCharTex( &buttonAutoFireImages[i*2+1],
NULL, &buttonsDraw[i], 255, 255, 255, transparency );
NULL, &buttonsDraw[i], 1.0f, 1.0f, 1.0f, transparency );
drawCharTexFlip( &buttonImages[ pressed ? (i * 2 + 1) : (i * 2) ],
NULL, &buttonsDraw[i], (i >= 2 && pressed), 0, 255, 255, 255, transparency );
NULL, &buttonsDraw[i], (i >= 2 && pressed), 0, 1.0f, 1.0f, 1.0f, transparency );
if( i < AutoFireButtonsNum && ! ButtonAutoFire[i] &&
( ButtonAutoFireX[i*2] > 0 || ButtonAutoFireX[i*2+1] > 0 ) )
@@ -359,7 +357,7 @@ static void drawTouchscreenKeyboardSun()
autoFireDest.y = buttonsDraw[i].y + buttonsDraw[i].h/2 - autoFireDest.h/2;
drawCharTex( &buttonAutoFireImages[i*2],
NULL, &autoFireDest, 255, 255, 255, transparency );
NULL, &autoFireDest, 1.0f, 1.0f, 1.0f, transparency );
}
}
}
@@ -700,12 +698,12 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi
buttonDrawSize = drawsize;
switch(_transparency)
{
case 0: transparency = 32; break;
case 1: transparency = 64; break;
case 2: transparency = 128; break;
case 3: transparency = 192; break;
case 4: transparency = 255; break;
default: transparency = 192; break;
case 0: transparency = 32.0f/255.0f; break;
case 1: transparency = 64.0f/255.0f; break;
case 2: transparency = 128.0f/255.0f; break;
case 3: transparency = 192.0f/255.0f; break;
case 4: transparency = 255.0f/255.0f; break;
default: transparency = 192.0f/255.0f; break;
}
// Arrows to the lower-left part of screen
@@ -778,16 +776,16 @@ JAVA_EXPORT_NAME(Settings_nativeSetTouchscreenKeyboardUsed) ( JNIEnv* env, jobj
SDL_ANDROID_isTouchscreenKeyboardUsed = 1;
}
void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, int alpha)
void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, float alpha)
{
SDL_Rect r;
// I've failed with size calcualtions, so leaving it as-is
// I've failed with size calculations, so leaving it as-is
r.x = x - MOUSE_POINTER_X;
r.y = y - MOUSE_POINTER_Y;
r.w = MOUSE_POINTER_W;
r.h = MOUSE_POINTER_H;
beginDrawingTex();
drawCharTex( &mousePointer, NULL, &r, 255, 255, 255, alpha );
drawCharTex( &mousePointer, NULL, &r, 1.0f, 1.0f, 1.0f, alpha );
endDrawingTex();
}

View File

@@ -30,4 +30,7 @@ static inline int atan2i(int y, int x)
return(angle);
};
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
#endif

View File

@@ -130,18 +130,18 @@ void SDL_android_init_keymap(SDLKey *SDL_android_keymap)
keymap[KEYCODE_PAGE_DOWN] = SDL_KEY(PAGEDOWN);
keymap[KEYCODE_PICTSYMBOLS] = SDL_KEY(LSHIFT);
keymap[KEYCODE_SWITCH_CHARSET] = SDL_KEY(LSHIFT);
keymap[KEYCODE_BUTTON_A] = SDL_KEY(A);
keymap[KEYCODE_BUTTON_B] = SDL_KEY(B);
keymap[KEYCODE_BUTTON_A] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_2));
keymap[KEYCODE_BUTTON_B] = SDL_KEY(ESCAPE); // SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_3)); // There's no Back key on Ouya
keymap[KEYCODE_BUTTON_C] = SDL_KEY(C);
keymap[KEYCODE_BUTTON_X] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_0));
keymap[KEYCODE_BUTTON_Y] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_1));
keymap[KEYCODE_BUTTON_Z] = SDL_KEY(Z);
keymap[KEYCODE_BUTTON_L1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_2));
keymap[KEYCODE_BUTTON_R1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_3));
keymap[KEYCODE_BUTTON_L2] = SDL_KEY(LCTRL);
keymap[KEYCODE_BUTTON_R2] = SDL_KEY(RCTRL);
keymap[KEYCODE_BUTTON_THUMBL] = SDL_KEY(LALT);
keymap[KEYCODE_BUTTON_THUMBR] = SDL_KEY(RALT);
keymap[KEYCODE_BUTTON_L1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_5));
keymap[KEYCODE_BUTTON_R1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_4));
keymap[KEYCODE_BUTTON_L2] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_0));
keymap[KEYCODE_BUTTON_R2] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_6));
keymap[KEYCODE_BUTTON_THUMBL] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_1));
keymap[KEYCODE_BUTTON_THUMBR] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_4));
keymap[KEYCODE_BUTTON_START] = SDL_KEY(RETURN);
keymap[KEYCODE_BUTTON_SELECT] = SDL_KEY(ESCAPE);
keymap[KEYCODE_BUTTON_MODE] = SDL_KEY(SPACE);

View File

@@ -0,0 +1,86 @@
#ifndef _UNICODE_STUFF_H_
#define _UNICODE_STUFF_H_
#include "SDL_androidinput.h"
// I'm too lazy to move code into .c file
static inline int UnicodeToUtf8(int src, char * dest)
{
int len = 0;
if ( src <= 0x007f) {
*dest++ = (char)src;
len = 1;
} else if (src <= 0x07ff) {
*dest++ = (char)0xc0 | (src >> 6);
*dest++ = (char)0x80 | (src & 0x003f);
len = 2;
} else if (src == 0xFEFF) {
// nop -- zap the BOM
} else if (src >= 0xD800 && src <= 0xDFFF) {
// surrogates not supported
} else if (src <= 0xffff) {
*dest++ = (char)0xe0 | (src >> 12);
*dest++ = (char)0x80 | ((src >> 6) & 0x003f);
*dest++ = (char)0x80 | (src & 0x003f);
len = 3;
} else if (src <= 0xffff) {
*dest++ = (char)0xf0 | (src >> 18);
*dest++ = (char)0x80 | ((src >> 12) & 0x3f);
*dest++ = (char)0x80 | ((src >> 6) & 0x3f);
*dest++ = (char)0x80 | (src & 0x3f);
len = 4;
} else {
// out of Unicode range
}
*dest = 0;
return len;
}
static inline SDL_keysym asciiToKeysym(int ascii, int unicode)
{
SDL_keysym keysym;
keysym.scancode = ascii;
keysym.sym = ascii;
keysym.mod = KMOD_NONE;
keysym.unicode = 0;
#if SDL_VERSION_ATLEAST(1,3,0)
keysym.sym = SDL_GetScancodeFromKey(ascii);
#else
if ( SDL_TranslateUNICODE )
#endif
keysym.unicode = unicode;
return keysym;
}
static inline int checkShiftRequired( int * sym )
{
switch( *sym )
{
case '!': *sym = '1'; return 1;
case '@': *sym = '2'; return 1;
case '#': *sym = '3'; return 1;
case '$': *sym = '4'; return 1;
case '%': *sym = '5'; return 1;
case '^': *sym = '6'; return 1;
case '&': *sym = '7'; return 1;
case '*': *sym = '8'; return 1;
case '(': *sym = '9'; return 1;
case ')': *sym = '0'; return 1;
case '_': *sym = '-'; return 1;
case '+': *sym = '='; return 1;
case '|': *sym = '\\';return 1;
case '<': *sym = ','; return 1;
case '>': *sym = '.'; return 1;
case '?': *sym = '/'; return 1;
case ':': *sym = ';'; return 1;
case '"': *sym = '\'';return 1;
case '{': *sym = '['; return 1;
case '}': *sym = ']'; return 1;
case '~': *sym = '`'; return 1;
default: if( *sym >= 'A' && *sym <= 'Z' ) { *sym += 'a' - 'A'; return 1; };
}
return 0;
}
#endif

View File

@@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-15
target=android-17

1
project/res/drawable-xhdpi/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
ouya_icon.png

View File

@@ -0,0 +1 @@
icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB