SDL: refactoring of input event code
This commit is contained in:
@@ -29,6 +29,7 @@ import android.view.KeyEvent;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
@@ -186,7 +187,8 @@ class DataDownloader extends Thread
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
Parent.keyListener = new BackKeyListener(Parent);
|
Parent.getVideoLayout().setOnKeyListener(new BackKeyListener(Parent));
|
||||||
|
|
||||||
String [] downloadFiles = Globals.DataDownloadUrl;
|
String [] downloadFiles = Globals.DataDownloadUrl;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -217,7 +219,7 @@ class DataDownloader extends Thread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DownloadComplete = true;
|
DownloadComplete = true;
|
||||||
Parent.keyListener = null;
|
Parent.getVideoLayout().setOnKeyListener(null);
|
||||||
initParent();
|
initParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -803,7 +805,7 @@ class DataDownloader extends Thread
|
|||||||
Parent.getPackageName() + "/" + url.substring("obb:".length()) + "." + Parent.getPackageName() + ".obb";
|
Parent.getPackageName() + "/" + url.substring("obb:".length()) + "." + Parent.getPackageName() + ".obb";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BackKeyListener implements MainActivity.KeyEventsListener
|
public class BackKeyListener implements View.OnKeyListener
|
||||||
{
|
{
|
||||||
MainActivity p;
|
MainActivity p;
|
||||||
public BackKeyListener(MainActivity _p)
|
public BackKeyListener(MainActivity _p)
|
||||||
@@ -811,7 +813,8 @@ class DataDownloader extends Thread
|
|||||||
p = _p;
|
p = _p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onKeyEvent(final int keyCode)
|
@Override
|
||||||
|
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
if( DownloadFailed )
|
if( DownloadFailed )
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
@@ -844,6 +847,7 @@ class DataDownloader extends Thread
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
alert.setOwnerActivity(p);
|
alert.setOwnerActivity(p);
|
||||||
alert.show();
|
alert.show();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -205,7 +205,12 @@ public class MainActivity extends Activity
|
|||||||
loaded.release();
|
loaded.release();
|
||||||
loadedLibraries.release();
|
loadedLibraries.release();
|
||||||
if( _btn != null )
|
if( _btn != null )
|
||||||
|
{
|
||||||
_btn.setEnabled(true);
|
_btn.setEnabled(true);
|
||||||
|
_btn.setFocusable(true);
|
||||||
|
_btn.setFocusableInTouchMode(true);
|
||||||
|
_btn.requestFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Callback2 cb = new Callback2();
|
Callback2 cb = new Callback2();
|
||||||
@@ -850,18 +855,6 @@ public class MainActivity extends Activity
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
EditText screenKeyboard = new EditText(this);
|
EditText screenKeyboard = new EditText(this);
|
||||||
// This code does not work
|
|
||||||
/*
|
|
||||||
screenKeyboard.setMaxLines(100);
|
|
||||||
ViewGroup.LayoutParams layout = _screenKeyboard.getLayoutParams();
|
|
||||||
if( layout != null )
|
|
||||||
{
|
|
||||||
layout.width = ViewGroup.LayoutParams.FILL_PARENT;
|
|
||||||
layout.height = ViewGroup.LayoutParams.FILL_PARENT;
|
|
||||||
screenKeyboard.setLayoutParams(layout);
|
|
||||||
}
|
|
||||||
screenKeyboard.setGravity(android.view.Gravity.BOTTOM | android.view.Gravity.LEFT);
|
|
||||||
*/
|
|
||||||
String hint = _screenKeyboardHintMessage;
|
String hint = _screenKeyboardHintMessage;
|
||||||
screenKeyboard.setHint(hint != null ? hint : getString(R.string.text_edit_click_here));
|
screenKeyboard.setHint(hint != null ? hint : getString(R.string.text_edit_click_here));
|
||||||
screenKeyboard.setText(oldText);
|
screenKeyboard.setText(oldText);
|
||||||
@@ -1046,6 +1039,7 @@ public class MainActivity extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, final KeyEvent event)
|
public boolean onKeyDown(int keyCode, final KeyEvent event)
|
||||||
{
|
{
|
||||||
@@ -1116,99 +1110,14 @@ public class MainActivity extends Activity
|
|||||||
return _btn.onKeyUp(keyCode, event);
|
return _btn.onKeyUp(keyCode, event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@Override
|
|
||||||
public boolean onKeyMultiple(int keyCode, int repeatCount, final KeyEvent event)
|
|
||||||
{
|
|
||||||
if( _screenKeyboard != null )
|
|
||||||
{
|
|
||||||
_screenKeyboard.onKeyMultiple(keyCode, repeatCount, event);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if( mGLView != null && event.getCharacters() != null )
|
|
||||||
{
|
|
||||||
// International text input
|
|
||||||
for(int i = 0; i < event.getCharacters().length(); i++ )
|
|
||||||
{
|
|
||||||
mGLView.nativeKey( event.getKeyCode(), 1, event.getCharacters().codePointAt(i) );
|
|
||||||
mGLView.nativeKey( event.getKeyCode(), 0, event.getCharacters().codePointAt(i) );
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onKeyLongPress (int keyCode, KeyEvent event)
|
|
||||||
{
|
|
||||||
if( _screenKeyboard != null )
|
|
||||||
{
|
|
||||||
_screenKeyboard.onKeyLongPress(keyCode, event);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean dispatchTouchEvent(final MotionEvent ev)
|
|
||||||
{
|
|
||||||
//Log.i("SDL", "dispatchTouchEvent: " + ev.getAction() + " coords " + ev.getX() + ":" + ev.getY() );
|
|
||||||
if(_screenKeyboard != null && _screenKeyboard.dispatchTouchEvent(ev))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if( _ad.getView() != null && // User clicked the advertisement, ignore when user moved finger from game screen to advertisement or touches screen with several fingers
|
|
||||||
((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN ||
|
|
||||||
(ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) &&
|
|
||||||
_ad.getView().getLeft() <= (int)ev.getX() &&
|
|
||||||
_ad.getView().getRight() > (int)ev.getX() &&
|
|
||||||
_ad.getView().getTop() <= (int)ev.getY() &&
|
|
||||||
_ad.getView().getBottom() > (int)ev.getY() )
|
|
||||||
return super.dispatchTouchEvent(ev);
|
|
||||||
else
|
|
||||||
if(mGLView != null)
|
|
||||||
mGLView.onTouchEvent(ev);
|
|
||||||
else
|
|
||||||
if( _btn != null )
|
|
||||||
return _btn.dispatchTouchEvent(ev);
|
|
||||||
else
|
|
||||||
if( touchListener != null )
|
|
||||||
touchListener.onTouchEvent(ev);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean dispatchGenericMotionEvent (MotionEvent ev)
|
|
||||||
{
|
|
||||||
//Log.i("SDL", "dispatchGenericMotionEvent: " + ev.getAction() + " coords " + ev.getX() + ":" + ev.getY() );
|
|
||||||
// This code fails to run for Android 1.6, so there will be no generic motion event for Andorid screen keyboard
|
|
||||||
/*
|
|
||||||
if(_screenKeyboard != null)
|
|
||||||
_screenKeyboard.dispatchGenericMotionEvent(ev);
|
|
||||||
else
|
|
||||||
*/
|
|
||||||
if(mGLView != null)
|
|
||||||
mGLView.onGenericMotionEvent(ev);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//private Configuration oldConfig = null;
|
//private Configuration oldConfig = null;
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig)
|
public void onConfigurationChanged(Configuration newConfig)
|
||||||
{
|
{
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
updateScreenOrientation();
|
updateScreenOrientation();
|
||||||
/*
|
|
||||||
if (oldConfig != null)
|
|
||||||
{
|
|
||||||
int diff = newConfig.diff(oldConfig);
|
|
||||||
Log.i("SDL", "onConfigurationChanged(): " + " diff " + diff +
|
|
||||||
((diff & ActivityInfo.CONFIG_ORIENTATION) == ActivityInfo.CONFIG_ORIENTATION ? " orientation" : "") +
|
|
||||||
((diff & ActivityInfo.CONFIG_SCREEN_SIZE) == ActivityInfo.CONFIG_SCREEN_SIZE ? " screen size" : "") +
|
|
||||||
((diff & ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE) == ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE ? " smallest screen size" : "") +
|
|
||||||
" " + newConfig.toString());
|
|
||||||
}
|
|
||||||
oldConfig = new Configuration(newConfig);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateScreenOrientation()
|
public void updateScreenOrientation()
|
||||||
@@ -1644,18 +1553,6 @@ public class MainActivity extends Activity
|
|||||||
private boolean sdlInited = false;
|
private boolean sdlInited = false;
|
||||||
public static boolean ApplicationLibraryLoaded = false;
|
public static boolean ApplicationLibraryLoaded = false;
|
||||||
|
|
||||||
public interface TouchEventsListener
|
|
||||||
{
|
|
||||||
public void onTouchEvent(final MotionEvent ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface KeyEventsListener
|
|
||||||
{
|
|
||||||
public void onKeyEvent(final int keyCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TouchEventsListener touchListener = null;
|
|
||||||
public KeyEventsListener keyListener = null;
|
|
||||||
boolean _isPaused = false;
|
boolean _isPaused = false;
|
||||||
private InputMethodManager _inputManager = null;
|
private InputMethodManager _inputManager = null;
|
||||||
|
|
||||||
|
|||||||
@@ -276,10 +276,10 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
void run (final MainActivity p)
|
void run (final MainActivity p)
|
||||||
{
|
{
|
||||||
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
||||||
p.keyListener = new KeyRemapTool(p);
|
p.getVideoLayout().setOnKeyListener(new KeyRemapTool(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class KeyRemapTool implements MainActivity.KeyEventsListener
|
public static class KeyRemapTool implements View.OnKeyListener
|
||||||
{
|
{
|
||||||
MainActivity p;
|
MainActivity p;
|
||||||
public KeyRemapTool(MainActivity _p)
|
public KeyRemapTool(MainActivity _p)
|
||||||
@@ -287,9 +287,10 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
p = _p;
|
p = _p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onKeyEvent(final int keyCode)
|
@Override
|
||||||
|
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
p.keyListener = null;
|
p.getVideoLayout().setOnKeyListener(null);
|
||||||
int keyIndex = keyCode;
|
int keyIndex = keyCode;
|
||||||
if( keyIndex < 0 )
|
if( keyIndex < 0 )
|
||||||
keyIndex = 0;
|
keyIndex = 0;
|
||||||
@@ -336,6 +337,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
alert.setOwnerActivity(p);
|
alert.setOwnerActivity(p);
|
||||||
alert.show();
|
alert.show();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
public void ShowAllKeys(final int KeyIndex)
|
public void ShowAllKeys(final int KeyIndex)
|
||||||
{
|
{
|
||||||
@@ -624,12 +626,10 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
{
|
{
|
||||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help));
|
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help));
|
||||||
CustomizeScreenKbLayoutTool tool = new CustomizeScreenKbLayoutTool(p);
|
CustomizeScreenKbLayoutTool tool = new CustomizeScreenKbLayoutTool(p);
|
||||||
p.touchListener = tool;
|
|
||||||
p.keyListener = tool;
|
|
||||||
Globals.TouchscreenKeyboardSize = Globals.TOUCHSCREEN_KEYBOARD_CUSTOM;
|
Globals.TouchscreenKeyboardSize = Globals.TOUCHSCREEN_KEYBOARD_CUSTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CustomizeScreenKbLayoutTool implements MainActivity.TouchEventsListener, MainActivity.KeyEventsListener
|
static class CustomizeScreenKbLayoutTool implements View.OnTouchListener, View.OnKeyListener
|
||||||
{
|
{
|
||||||
MainActivity p;
|
MainActivity p;
|
||||||
FrameLayout layout = null;
|
FrameLayout layout = null;
|
||||||
@@ -658,6 +658,11 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
p = _p;
|
p = _p;
|
||||||
layout = new FrameLayout(p);
|
layout = new FrameLayout(p);
|
||||||
p.getVideoLayout().addView(layout);
|
p.getVideoLayout().addView(layout);
|
||||||
|
layout.setFocusable(true);
|
||||||
|
layout.setFocusableInTouchMode(true);
|
||||||
|
layout.requestFocus();
|
||||||
|
layout.setOnTouchListener(this);
|
||||||
|
layout.setOnKeyListener(this);
|
||||||
boundary = new ImageView(p);
|
boundary = new ImageView(p);
|
||||||
boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||||
boundary.setScaleType(ImageView.ScaleType.MATRIX);
|
boundary.setScaleType(ImageView.ScaleType.MATRIX);
|
||||||
@@ -744,7 +749,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
}
|
}
|
||||||
boundary.bringToFront();
|
boundary.bringToFront();
|
||||||
if( currentButton == -1 )
|
if( currentButton == -1 )
|
||||||
onKeyEvent( KeyEvent.KEYCODE_BACK ); // All buttons disabled - do not show anything
|
onKey( null, KeyEvent.KEYCODE_BACK, null ); // All buttons disabled - do not show anything
|
||||||
else
|
else
|
||||||
setupButton(currentButton);
|
setupButton(currentButton);
|
||||||
}
|
}
|
||||||
@@ -777,7 +782,8 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help) + "\n" + buttonText);
|
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help) + "\n" + buttonText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTouchEvent(final MotionEvent ev)
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent ev)
|
||||||
{
|
{
|
||||||
if( ev.getAction() == MotionEvent.ACTION_DOWN )
|
if( ev.getAction() == MotionEvent.ACTION_DOWN )
|
||||||
{
|
{
|
||||||
@@ -842,18 +848,19 @@ class SettingsMenuKeyboard extends SettingsMenu
|
|||||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||||
boundary.setImageMatrix(m);
|
boundary.setImageMatrix(m);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onKeyEvent(final int keyCode)
|
@Override
|
||||||
|
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
if( keyCode == KeyEvent.KEYCODE_BACK )
|
if( keyCode == KeyEvent.KEYCODE_BACK )
|
||||||
{
|
{
|
||||||
p.getVideoLayout().removeView(layout);
|
p.getVideoLayout().removeView(layout);
|
||||||
layout = null;
|
layout = null;
|
||||||
p.touchListener = null;
|
|
||||||
p.keyListener = null;
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
Globals.LeftClickMethod = item;
|
Globals.LeftClickMethod = item;
|
||||||
if( item == Mouse.LEFT_CLICK_WITH_KEY )
|
if( item == Mouse.LEFT_CLICK_WITH_KEY )
|
||||||
p.keyListener = new KeyRemapToolMouseClick(p, true);
|
p.getVideoLayout().setOnKeyListener(new KeyRemapToolMouseClick(p, true));
|
||||||
else if( item == Mouse.LEFT_CLICK_WITH_TIMEOUT || item == Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT )
|
else if( item == Mouse.LEFT_CLICK_WITH_TIMEOUT || item == Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT )
|
||||||
showLeftClickTimeoutConfig(p);
|
showLeftClickTimeoutConfig(p);
|
||||||
else
|
else
|
||||||
@@ -343,7 +343,7 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
Globals.RightClickMethod = item;
|
Globals.RightClickMethod = item;
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
if( item == Mouse.RIGHT_CLICK_WITH_KEY )
|
if( item == Mouse.RIGHT_CLICK_WITH_KEY )
|
||||||
p.keyListener = new KeyRemapToolMouseClick(p, false);
|
p.getVideoLayout().setOnKeyListener(new KeyRemapToolMouseClick(p, false));
|
||||||
else if( item == Mouse.RIGHT_CLICK_WITH_TIMEOUT )
|
else if( item == Mouse.RIGHT_CLICK_WITH_TIMEOUT )
|
||||||
showRightClickTimeoutConfig(p);
|
showRightClickTimeoutConfig(p);
|
||||||
else
|
else
|
||||||
@@ -393,7 +393,7 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class KeyRemapToolMouseClick implements MainActivity.KeyEventsListener
|
public static class KeyRemapToolMouseClick implements View.OnKeyListener
|
||||||
{
|
{
|
||||||
MainActivity p;
|
MainActivity p;
|
||||||
boolean leftClick;
|
boolean leftClick;
|
||||||
@@ -404,9 +404,10 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
this.leftClick = leftClick;
|
this.leftClick = leftClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onKeyEvent(final int keyCode)
|
@Override
|
||||||
|
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
p.keyListener = null;
|
p.getVideoLayout().setOnKeyListener(null);
|
||||||
int keyIndex = keyCode;
|
int keyIndex = keyCode;
|
||||||
if( keyIndex < 0 )
|
if( keyIndex < 0 )
|
||||||
keyIndex = 0;
|
keyIndex = 0;
|
||||||
@@ -419,6 +420,7 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
Globals.RightClickKey = keyIndex;
|
Globals.RightClickKey = keyIndex;
|
||||||
|
|
||||||
goBack(p);
|
goBack(p);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,10 +688,10 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
void run (final MainActivity p)
|
void run (final MainActivity p)
|
||||||
{
|
{
|
||||||
p.setText(p.getResources().getString(R.string.measurepressure_touchplease));
|
p.setText(p.getResources().getString(R.string.measurepressure_touchplease));
|
||||||
p.touchListener = new TouchMeasurementTool(p);
|
p.getVideoLayout().setOnTouchListener(new TouchMeasurementTool(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TouchMeasurementTool implements MainActivity.TouchEventsListener
|
public static class TouchMeasurementTool implements View.OnTouchListener
|
||||||
{
|
{
|
||||||
MainActivity p;
|
MainActivity p;
|
||||||
ArrayList<Integer> force = new ArrayList<Integer>();
|
ArrayList<Integer> force = new ArrayList<Integer>();
|
||||||
@@ -701,7 +703,8 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
p = _p;
|
p = _p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTouchEvent(final MotionEvent ev)
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent ev)
|
||||||
{
|
{
|
||||||
force.add(new Integer((int)(ev.getPressure() * 1000.0)));
|
force.add(new Integer((int)(ev.getPressure() * 1000.0)));
|
||||||
radius.add(new Integer((int)(ev.getSize() * 1000.0)));
|
radius.add(new Integer((int)(ev.getSize() * 1000.0)));
|
||||||
@@ -712,12 +715,13 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
|
|
||||||
if( force.size() >= maxEventAmount )
|
if( force.size() >= maxEventAmount )
|
||||||
{
|
{
|
||||||
p.touchListener = null;
|
p.getVideoLayout().setOnTouchListener(null);
|
||||||
Globals.ClickScreenPressure = getAverageForce();
|
Globals.ClickScreenPressure = getAverageForce();
|
||||||
Globals.ClickScreenTouchspotSize = getAverageRadius();
|
Globals.ClickScreenTouchspotSize = getAverageRadius();
|
||||||
Log.i("SDL", "SDL: measured average force " + Globals.ClickScreenPressure + " radius " + Globals.ClickScreenTouchspotSize);
|
Log.i("SDL", "SDL: measured average force " + Globals.ClickScreenPressure + " radius " + Globals.ClickScreenTouchspotSize);
|
||||||
goBack(p);
|
goBack(p);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getAverageForce()
|
int getAverageForce()
|
||||||
@@ -756,11 +760,11 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
Globals.TouchscreenCalibration[2] = 0;
|
Globals.TouchscreenCalibration[2] = 0;
|
||||||
Globals.TouchscreenCalibration[3] = 0;
|
Globals.TouchscreenCalibration[3] = 0;
|
||||||
ScreenEdgesCalibrationTool tool = new ScreenEdgesCalibrationTool(p);
|
ScreenEdgesCalibrationTool tool = new ScreenEdgesCalibrationTool(p);
|
||||||
p.touchListener = tool;
|
p.getVideoLayout().setOnTouchListener(tool);
|
||||||
p.keyListener = tool;
|
p.getVideoLayout().setOnKeyListener(tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ScreenEdgesCalibrationTool implements MainActivity.TouchEventsListener, MainActivity.KeyEventsListener
|
static class ScreenEdgesCalibrationTool implements View.OnTouchListener, View.OnKeyListener
|
||||||
{
|
{
|
||||||
MainActivity p;
|
MainActivity p;
|
||||||
ImageView img;
|
ImageView img;
|
||||||
@@ -783,7 +787,8 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
p.getVideoLayout().addView(img);
|
p.getVideoLayout().addView(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTouchEvent(final MotionEvent ev)
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent ev)
|
||||||
{
|
{
|
||||||
if( Globals.TouchscreenCalibration[0] == Globals.TouchscreenCalibration[1] &&
|
if( Globals.TouchscreenCalibration[0] == Globals.TouchscreenCalibration[1] &&
|
||||||
Globals.TouchscreenCalibration[1] == Globals.TouchscreenCalibration[2] &&
|
Globals.TouchscreenCalibration[1] == Globals.TouchscreenCalibration[2] &&
|
||||||
@@ -808,14 +813,17 @@ class SettingsMenuMouse extends SettingsMenu
|
|||||||
Globals.TouchscreenCalibration[2], Globals.TouchscreenCalibration[3]);
|
Globals.TouchscreenCalibration[2], Globals.TouchscreenCalibration[3]);
|
||||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||||
img.setImageMatrix(m);
|
img.setImageMatrix(m);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onKeyEvent(final int keyCode)
|
@Override
|
||||||
|
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
p.touchListener = null;
|
p.getVideoLayout().setOnTouchListener(null);
|
||||||
p.keyListener = null;
|
p.getVideoLayout().setOnKeyListener(null);
|
||||||
p.getVideoLayout().removeView(img);
|
p.getVideoLayout().removeView(img);
|
||||||
goBack(p);
|
goBack(p);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ abstract class DifferentTouchInput
|
|||||||
}
|
}
|
||||||
public void processGenericEvent(final MotionEvent event)
|
public void processGenericEvent(final MotionEvent event)
|
||||||
{
|
{
|
||||||
// Joysticks are supported since Honeycomb, but I don't care about it, because very little devices have it
|
// Joysticks are supported since Honeycomb, but I don't care about it, because very few devices have it
|
||||||
if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK )
|
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, on Nvidia Shield and some other joysticks
|
// event.getAxisValue(AXIS_HAT_X) and event.getAxisValue(AXIS_HAT_Y) are joystick arrow keys, on Nvidia Shield and some other joysticks
|
||||||
@@ -985,6 +985,75 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
|||||||
setRenderer(mRenderer);
|
setRenderer(mRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, final KeyEvent event)
|
||||||
|
{
|
||||||
|
if( keyCode == KeyEvent.KEYCODE_BACK )
|
||||||
|
{
|
||||||
|
if( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE )
|
||||||
|
{
|
||||||
|
// Stupid Samsung and stupid Acer remaps right mouse button to BACK key
|
||||||
|
nativeMouseButtonsPressed(2, 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if( mParent.keyboardWithoutTextInputShown )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//if( context._screenKeyboard != null && context._screenKeyboard.onKeyDown(keyCode, event) )
|
||||||
|
// return true;
|
||||||
|
|
||||||
|
if( nativeKey( keyCode, 1, event.getUnicodeChar() ) == 0 )
|
||||||
|
return super.onKeyDown(keyCode, event);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyUp(int keyCode, final KeyEvent event)
|
||||||
|
{
|
||||||
|
if( keyCode == KeyEvent.KEYCODE_BACK )
|
||||||
|
{
|
||||||
|
if( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE )
|
||||||
|
{
|
||||||
|
// Stupid Samsung and stupid Acer remaps right mouse button to BACK key
|
||||||
|
nativeMouseButtonsPressed(2, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if( mParent.keyboardWithoutTextInputShown )
|
||||||
|
{
|
||||||
|
mParent.showScreenKeyboardWithoutTextInputField(0); // Hide keyboard
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//if( _screenKeyboard != null && _screenKeyboard.onKeyUp(keyCode, event) )
|
||||||
|
// return true;
|
||||||
|
|
||||||
|
if( nativeKey( keyCode, 0, event.getUnicodeChar() ) == 0 )
|
||||||
|
return super.onKeyUp(keyCode, event);
|
||||||
|
|
||||||
|
if( keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU )
|
||||||
|
DimSystemStatusBar.get().dim(mParent._videoLayout);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyMultiple(int keyCode, int repeatCount, final KeyEvent event)
|
||||||
|
{
|
||||||
|
if( event.getCharacters() != null )
|
||||||
|
{
|
||||||
|
// International text input
|
||||||
|
for(int i = 0; i < event.getCharacters().length(); i++ )
|
||||||
|
{
|
||||||
|
nativeKey( event.getKeyCode(), 1, event.getCharacters().codePointAt(i) );
|
||||||
|
nativeKey( event.getKeyCode(), 0, event.getCharacters().codePointAt(i) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(final MotionEvent event)
|
public boolean onTouchEvent(final MotionEvent event)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ APP_PLATFORM=android-21
|
|||||||
|
|
||||||
# Specify architectures to compile, 'all' or 'y' to compile for all architectures.
|
# Specify architectures to compile, 'all' or 'y' to compile for all architectures.
|
||||||
# Available architectures: armeabi armeabi-v7a x86 mips arm64-v8a
|
# Available architectures: armeabi armeabi-v7a x86 mips arm64-v8a
|
||||||
MultiABI='armeabi-v7a x86 arm64-v8a'
|
MultiABI='armeabi-v7a' # x86 arm64-v8a'
|
||||||
|
|
||||||
# Optional shared libraries to compile - removing some of them will save space
|
# Optional shared libraries to compile - removing some of them will save space
|
||||||
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
|
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
|
||||||
|
|||||||
Reference in New Issue
Block a user