Some rudimentary support for hardware mouse
This commit is contained in:
@@ -33,7 +33,6 @@ import android.media.AudioTrack;
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioFormat;
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import android.util.Log;
|
||||
import java.lang.Thread;
|
||||
|
||||
|
||||
@@ -471,7 +471,7 @@ class DataDownloader extends Thread
|
||||
|
||||
try {
|
||||
CheckedInputStream check = new CheckedInputStream( new FileInputStream(path), new CRC32() );
|
||||
while( check.read(buf, 0, buf.length) > 0 ) {};
|
||||
while( check.read(buf, 0, buf.length) >= 0 ) {};
|
||||
check.close();
|
||||
if( check.getChecksum().getValue() != entry.getCrc() )
|
||||
{
|
||||
@@ -525,19 +525,26 @@ class DataDownloader extends Thread
|
||||
}
|
||||
|
||||
try {
|
||||
long count = 0, ret = 0;
|
||||
CheckedInputStream check = new CheckedInputStream( new FileInputStream(path), new CRC32() );
|
||||
while( check.read(buf, 0, buf.length) > 0 ) {};
|
||||
while( ret >= 0 )
|
||||
{
|
||||
count += ret;
|
||||
ret = check.read(buf, 0, buf.length);
|
||||
}
|
||||
check.close();
|
||||
if( check.getChecksum().getValue() != entry.getCrc() )
|
||||
if( check.getChecksum().getValue() != entry.getCrc() || count != entry.getSize() )
|
||||
{
|
||||
File ff = new File(path);
|
||||
ff.delete();
|
||||
System.out.println("Saving file '" + path + "' - CRC check failed, ZIP: " +
|
||||
String.format("%x", entry.getCrc()) + " actual file: " + String.format("%x", check.getChecksum().getValue()) +
|
||||
" file size in ZIP: " + entry.getSize() + " actual size " + count );
|
||||
throw new Exception();
|
||||
}
|
||||
} catch( Exception e )
|
||||
{
|
||||
Status.setText( res.getString(R.string.error_write, path) );
|
||||
System.out.println("Saving file '" + path + "' - CRC check failed");
|
||||
return false;
|
||||
}
|
||||
System.out.println("Saving file '" + path + "' done");
|
||||
|
||||
@@ -70,6 +70,7 @@ public class MainActivity extends Activity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
instance = this;
|
||||
// fullscreen mode
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
@@ -697,5 +698,5 @@ public class MainActivity extends Activity {
|
||||
private InputMethodManager _inputManager = null;
|
||||
|
||||
public LinkedList<Integer> textInput = new LinkedList<Integer> ();
|
||||
|
||||
public static MainActivity instance = null;
|
||||
}
|
||||
|
||||
@@ -2553,6 +2553,7 @@ class Settings
|
||||
int leftClickTimeout, int rightClickTimeout,
|
||||
int relativeMovement, int relativeMovementSpeed,
|
||||
int relativeMovementAccel, int showMouseCursor);
|
||||
public static native void nativeSetExternalMouseDetected();
|
||||
private static native void nativeSetJoystickUsed();
|
||||
private static native void nativeSetMultitouchUsed();
|
||||
private static native void nativeSetTouchscreenKeyboardUsed();
|
||||
|
||||
@@ -45,6 +45,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.AssetManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import android.widget.TextView;
|
||||
import java.lang.Thread;
|
||||
@@ -87,6 +88,8 @@ class Mouse
|
||||
|
||||
abstract class DifferentTouchInput
|
||||
{
|
||||
public static boolean ExternalMouseDetected = true;
|
||||
|
||||
public static DifferentTouchInput getInstance()
|
||||
{
|
||||
boolean multiTouchAvailable1 = false;
|
||||
@@ -223,8 +226,8 @@ abstract class DifferentTouchInput
|
||||
if( touchEvents[id].down )
|
||||
action = Mouse.SDL_FINGER_MOVE;
|
||||
else
|
||||
action = Mouse.SDL_FINGER_DOWN;
|
||||
touchEvents[id].down = true;
|
||||
action = Mouse.SDL_FINGER_HOVER; //action = Mouse.SDL_FINGER_DOWN;
|
||||
//touchEvents[id].down = true;
|
||||
touchEvents[id].x = (int)event.getX(ii);
|
||||
touchEvents[id].y = (int)event.getY(ii);
|
||||
touchEvents[id].pressure = (int)(event.getPressure(ii) * 1000.0);
|
||||
@@ -247,6 +250,12 @@ abstract class DifferentTouchInput
|
||||
touchEvents[0].size = 0;
|
||||
DemoGLSurfaceView.nativeMouse( touchEvents[0].x, touchEvents[0].y, action, 0, touchEvents[0].pressure, touchEvents[0].size );
|
||||
}
|
||||
if( action == Mouse.SDL_FINGER_HOVER && !ExternalMouseDetected )
|
||||
{
|
||||
ExternalMouseDetected = true;
|
||||
Settings.nativeSetExternalMouseDetected();
|
||||
Toast.makeText(MainActivity.instance, R.string.hardware_mouse_detected, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -325,6 +334,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
}
|
||||
|
||||
Settings.Apply(context);
|
||||
DifferentTouchInput.ExternalMouseDetected = false;
|
||||
accelerometer = new AccelerometerReader(context);
|
||||
// Tweak video thread priority, if user selected big audio buffer
|
||||
if(Globals.AudioBufferConfig >= 2)
|
||||
@@ -400,7 +410,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
int width = bmp.getBitmap().getWidth();
|
||||
int height = bmp.getBitmap().getHeight();
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 * width * height);
|
||||
byteBuffer.order(ByteOrder.BIG_ENDIAN);
|
||||
//byteBuffer.order(ByteOrder.BIG_ENDIAN);
|
||||
bmp.getBitmap().copyPixelsToBuffer(byteBuffer);
|
||||
byteBuffer.position(0);
|
||||
|
||||
|
||||
@@ -131,4 +131,6 @@
|
||||
<string name="controls_screenkb_drawsize">Размер изображения кнопок</string>
|
||||
<string name="display_size_small_touchpad">Маленький, режим тачпада</string>
|
||||
<string name="display_size_tiny_touchpad">Крохотный, режим тачпада</string>
|
||||
<string name="hardware_mouse_detected">Обнаружена внешняя мышь, эмуляция мыши выключена</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -129,4 +129,6 @@
|
||||
<string name="controls_screenkb_drawsize">Розмір зображення кнопок</string>
|
||||
<string name="display_size_small_touchpad">Маленький, режим тачпаду</string>
|
||||
<string name="display_size_tiny_touchpad">Крихiтний, режим тачпаду</string>
|
||||
<string name="hardware_mouse_detected">Виявлена зовнiшня миша, емуляція миші вимкнена</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -159,4 +159,6 @@
|
||||
<string name="broken_libc_title">Broken OS detected</string>
|
||||
<string name="broken_libc_text">Your device has broken system libraries, this application will most probably crash. Please install a system update, or flash a custom ROM, or copy file /system/lib/libc.so from another device (experts only!)</string>
|
||||
|
||||
<string name="hardware_mouse_detected">Hardware mouse detected, disabling mouse emulation</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -22,7 +22,7 @@ AppNeedsArrowKeys=n
|
||||
AppNeedsTextInput=y
|
||||
AppUsesJoystick=n
|
||||
AppHandlesJoystickSensitivity=n
|
||||
AppUsesMultitouch=n
|
||||
AppUsesMultitouch=y
|
||||
NonBlockingSwapBuffers=n
|
||||
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
|
||||
AppTouchscreenKeyboardKeysAmount=0
|
||||
|
||||
@@ -32,9 +32,9 @@ StartupMenuButtonTimeout=3000
|
||||
HiddenMenuOptions='KeyboardConfigMainMenu ScreenKeyboardThemeConfig ScreenKeyboardTransparencyConfig'
|
||||
FirstStartMenuOptions=''
|
||||
MultiABI=n
|
||||
AppVersionCode=272018
|
||||
AppVersionName="2720.18"
|
||||
ResetSdlConfigForThisVersion=y
|
||||
AppVersionCode=273918
|
||||
AppVersionName="2739.18"
|
||||
ResetSdlConfigForThisVersion=n
|
||||
CompiledLibraries="sdl_net sdl_mixer sdl_image sdl_ttf png intl"
|
||||
CustomBuildScript=n
|
||||
AppCflags='-finline-functions -O2 -DWITH_ZLIB -DWITH_MIXER -DWITH_XML -DWITH_IMAGE -DWITH_TTF -DWITH_AI=simple -DWITH_NET'
|
||||
|
||||
@@ -6,12 +6,18 @@ AppFullName=com.grafx2
|
||||
ScreenOrientation=h
|
||||
InhibitSuspend=y
|
||||
AppDataDownloadUrl="!Data|data.zip"
|
||||
VideoDepthBpp=16
|
||||
NeedDepthBuffer=n
|
||||
NeedStencilBuffer=n
|
||||
NeedGles2=n
|
||||
SwVideoMode=y
|
||||
SdlVideoResize=y
|
||||
SdlVideoResizeKeepAspect=n
|
||||
NeedDepthBuffer=n
|
||||
SwVideoMode=y
|
||||
CompatibilityHacks=n
|
||||
AppUsesMouse=y
|
||||
AppNeedsTwoButtonMouse=y
|
||||
ShowMouseCursor=y
|
||||
ForceRelativeMouseMode=n
|
||||
AppNeedsArrowKeys=n
|
||||
AppNeedsTextInput=n
|
||||
AppUsesJoystick=n
|
||||
@@ -24,9 +30,11 @@ AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
RedefinedKeysScreenKb="SPACE TAB PLUS MINUS RETURN ESCAPE DELETE"
|
||||
StartupMenuButtonTimeout=3000
|
||||
HiddenMenuOptions='OptionalDownloadConfig'
|
||||
FirstStartMenuOptions=''
|
||||
MultiABI=n
|
||||
AppVersionCode=23178101
|
||||
AppVersionName="2.3.1781.01"
|
||||
AppVersionCode=23178102
|
||||
AppVersionName="2.3.1781.02"
|
||||
ResetSdlConfigForThisVersion=y
|
||||
CompiledLibraries="jpeg png sdl_image sdl_ttf lua"
|
||||
CustomBuildScript=n
|
||||
AppCflags='-DVIRT_KEY -D__ENABLE_LUA__ -std=c99'
|
||||
|
||||
@@ -30,14 +30,15 @@ AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
RedefinedKeysScreenKb="SPACE TAB PLUS MINUS RETURN ESCAPE DELETE"
|
||||
StartupMenuButtonTimeout=3000
|
||||
HiddenMenuOptions='OptionalDownloadConfig'
|
||||
FirstStartMenuOptions='new Settings.CalibrateTouchscreenMenu(), new Settings.DisplaySizeConfig(true)'
|
||||
FirstStartMenuOptions=''
|
||||
MultiABI=n
|
||||
AppVersionCode=0908503
|
||||
AppVersionName="0.90.85.03"
|
||||
CompiledLibraries="jpeg png"
|
||||
AppVersionCode=0908504
|
||||
AppVersionName="0.90.85.04"
|
||||
ResetSdlConfigForThisVersion=y
|
||||
CompiledLibraries="jpeg png zzip"
|
||||
CustomBuildScript=y
|
||||
AppCflags=''
|
||||
AppLdflags=''
|
||||
AppSubdirsBuild=''
|
||||
AppCmdline='milkytracker -fullscreen'
|
||||
AppCmdline='milkytracker -fullscreen -nonstdkb -nosplash'
|
||||
ReadmeText='^You may press "Home" now - the data will be downloaded in background'
|
||||
|
||||
@@ -11,7 +11,7 @@ if [ \! -f milkytracker-0.90.85/configure ] ; then
|
||||
fi
|
||||
|
||||
if [ \! -f milkytracker-0.90.85/Makefile ] ; then
|
||||
../setEnvironment.sh sh -c "cd milkytracker-0.90.85 && ZZIP_CFLAGS='-I$LOCAL_PATH/../../zzip/include' ZZIP_LIBS='-L$LOCAL_PATH/../../../obj/local/armeabi -lzzip' ./configure --host=arm-linux-androideabi "
|
||||
../setEnvironment.sh sh -c "cd milkytracker-0.90.85 && ZZIP_CFLAGS='-I$LOCAL_PATH/../../zzip/include' ZZIP_LIBS='-L$LOCAL_PATH/../../../obj/local/armeabi -lzzip' LIBS=-lgnustl_static ./configure --host=arm-linux-androideabi"
|
||||
fi
|
||||
|
||||
make -C milkytracker-0.90.85 && mv -f milkytracker-0.90.85/src/tracker/milkytracker libapplication.so
|
||||
|
||||
@@ -1 +1 @@
|
||||
alienblaster
|
||||
ballfield
|
||||
@@ -16,6 +16,7 @@ SdlVideoResizeKeepAspect=n
|
||||
CompatibilityHacks=n
|
||||
AppUsesMouse=y
|
||||
AppNeedsTwoButtonMouse=y
|
||||
ShowMouseCursor=n
|
||||
ForceRelativeMouseMode=y
|
||||
AppNeedsArrowKeys=y
|
||||
AppNeedsTextInput=y
|
||||
@@ -33,6 +34,7 @@ FirstStartMenuOptions=''
|
||||
MultiABI=y
|
||||
AppVersionCode=5207
|
||||
AppVersionName="0.5.2.07"
|
||||
ResetSdlConfigForThisVersion=n
|
||||
CompiledLibraries="sdl_image freetype"
|
||||
CustomBuildScript=n
|
||||
AppCflags='-O3'
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#ifdef ANDROID
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#else
|
||||
|
||||
@@ -844,7 +844,7 @@ static int getClickTimeout(int v)
|
||||
|
||||
// Mwahaha overkill!
|
||||
JNIEXPORT void JNICALL
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz,
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) (JNIEnv* env, jobject thiz,
|
||||
jint RightClickMethod, jint ShowScreenUnderFinger, jint LeftClickMethod,
|
||||
jint MoveMouseWithJoystick, jint ClickMouseWithDpad,
|
||||
jint MaxForce, jint MaxRadius,
|
||||
@@ -876,7 +876,20 @@ JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz,
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetJoystickUsed) ( JNIEnv* env, jobject thiz)
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetExternalMouseDetected) (JNIEnv* env, jobject thiz)
|
||||
{
|
||||
if( !isMouseUsed )
|
||||
return;
|
||||
|
||||
leftClickMethod = LEFT_CLICK_NORMAL;
|
||||
SDL_ANDROID_ShowScreenUnderFinger = 0;
|
||||
leftClickTimeout = 0;
|
||||
relativeMovement = 0;
|
||||
SDL_ANDROID_ShowMouseCursor = 0;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetJoystickUsed) (JNIEnv* env, jobject thiz)
|
||||
{
|
||||
SDL_ANDROID_isJoystickUsed = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user