Merge branch 'master' of https://github.com/jMonkeyEngine/jmonkeyengine.git
This commit is contained in:
commit
d399e0594b
@ -107,6 +107,10 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
||||
* JoyAxisTriggers.
|
||||
*/
|
||||
protected boolean joystickEventsEnabled = false;
|
||||
/**
|
||||
* If true KeyEvents are generated from TouchEvents
|
||||
*/
|
||||
protected boolean keyEventsEnabled = true;
|
||||
/**
|
||||
* If true MouseEvents are generated from TouchEvents
|
||||
*/
|
||||
@ -224,6 +228,7 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
||||
settings.setEmulateMouse(mouseEventsEnabled);
|
||||
settings.setEmulateMouseFlipAxis(mouseEventsInvertX, mouseEventsInvertY);
|
||||
settings.setUseJoysticks(joystickEventsEnabled);
|
||||
settings.setEmulateKeyboard(keyEventsEnabled);
|
||||
|
||||
settings.setBitsPerPixel(eglBitsPerPixel);
|
||||
settings.setAlphaBits(eglAlphaBits);
|
||||
|
@ -400,7 +400,7 @@ public class AndroidInput implements
|
||||
if(eventQueue.size()< MAX_EVENTS){
|
||||
eventQueue.push(event);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -679,8 +679,8 @@ public class AndroidInput implements
|
||||
return mouseEventsEnabled;
|
||||
}
|
||||
|
||||
public void showVirtualKeyboard(boolean visible) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
public boolean isSimulateKeyboard() {
|
||||
return keyboardEventsEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class AndroidInputHandler implements TouchInput {
|
||||
private static final Logger logger = Logger.getLogger(AndroidInputHandler.class.getName());
|
||||
|
||||
|
||||
// Custom settings
|
||||
private boolean mouseEventsEnabled = true;
|
||||
private boolean mouseEventsInvertX = false;
|
||||
@ -64,8 +64,8 @@ public class AndroidInputHandler implements TouchInput {
|
||||
private boolean keyboardEventsEnabled = false;
|
||||
private boolean joystickEventsEnabled = false;
|
||||
private boolean dontSendHistory = false;
|
||||
|
||||
|
||||
|
||||
|
||||
// Internal
|
||||
private GLSurfaceView view;
|
||||
private AndroidTouchHandler touchHandler;
|
||||
@ -78,8 +78,8 @@ public class AndroidInputHandler implements TouchInput {
|
||||
private final TouchEventPool touchEventPool = new TouchEventPool(MAX_TOUCH_EVENTS);
|
||||
private float scaleX = 1f;
|
||||
private float scaleY = 1f;
|
||||
|
||||
|
||||
|
||||
|
||||
public AndroidInputHandler() {
|
||||
int buildVersion = Build.VERSION.SDK_INT;
|
||||
logger.log(Level.INFO, "Android Build Version: {0}", buildVersion);
|
||||
@ -94,14 +94,14 @@ public class AndroidInputHandler implements TouchInput {
|
||||
keyHandler = new AndroidKeyHandler(this);
|
||||
}
|
||||
}
|
||||
|
||||
public AndroidInputHandler(AndroidTouchHandler touchInput,
|
||||
|
||||
public AndroidInputHandler(AndroidTouchHandler touchInput,
|
||||
AndroidKeyHandler keyInput, AndroidGestureHandler gestureHandler) {
|
||||
this.touchHandler = touchInput;
|
||||
this.keyHandler = keyInput;
|
||||
this.gestureHandler = gestureHandler;
|
||||
}
|
||||
|
||||
|
||||
public void setView(View view) {
|
||||
if (touchHandler != null) {
|
||||
touchHandler.setView(view);
|
||||
@ -114,43 +114,42 @@ public class AndroidInputHandler implements TouchInput {
|
||||
}
|
||||
this.view = (GLSurfaceView)view;
|
||||
}
|
||||
|
||||
|
||||
public View getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
public float invertX(float origX) {
|
||||
return getJmeX(view.getWidth()) - origX;
|
||||
}
|
||||
|
||||
|
||||
public float invertY(float origY) {
|
||||
return getJmeY(view.getHeight()) - origY;
|
||||
}
|
||||
|
||||
|
||||
public float getJmeX(float origX) {
|
||||
return origX * scaleX;
|
||||
}
|
||||
|
||||
|
||||
public float getJmeY(float origY) {
|
||||
return origY * scaleY;
|
||||
}
|
||||
|
||||
|
||||
public void loadSettings(AppSettings settings) {
|
||||
// TODO: add simulate keyboard to settings
|
||||
// keyboardEventsEnabled = true;
|
||||
keyboardEventsEnabled = settings.isEmulateKeyboard();
|
||||
mouseEventsEnabled = settings.isEmulateMouse();
|
||||
mouseEventsInvertX = settings.isEmulateMouseFlipX();
|
||||
mouseEventsInvertY = settings.isEmulateMouseFlipY();
|
||||
joystickEventsEnabled = settings.useJoysticks();
|
||||
|
||||
|
||||
// view width and height are 0 until the view is displayed on the screen
|
||||
if (view.getWidth() != 0 && view.getHeight() != 0) {
|
||||
scaleX = (float)settings.getWidth() / (float)view.getWidth();
|
||||
scaleY = (float)settings.getHeight() / (float)view.getHeight();
|
||||
}
|
||||
logger.log(Level.FINE, "Setting input scaling, scaleX: {0}, scaleY: {1}",
|
||||
logger.log(Level.FINE, "Setting input scaling, scaleX: {0}, scaleY: {1}",
|
||||
new Object[]{scaleX, scaleY});
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
@ -167,14 +166,14 @@ public class AndroidInputHandler implements TouchInput {
|
||||
if (gestureHandler != null) {
|
||||
gestureHandler.initialize();
|
||||
}
|
||||
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
initialized = false;
|
||||
|
||||
|
||||
touchEventPool.destroy();
|
||||
if (touchHandler != null) {
|
||||
touchHandler.destroy();
|
||||
@ -185,7 +184,7 @@ public class AndroidInputHandler implements TouchInput {
|
||||
if (gestureHandler != null) {
|
||||
gestureHandler.destroy();
|
||||
}
|
||||
|
||||
|
||||
setView(null);
|
||||
}
|
||||
|
||||
@ -203,11 +202,11 @@ public class AndroidInputHandler implements TouchInput {
|
||||
public long getInputTimeNanos() {
|
||||
return System.nanoTime();
|
||||
}
|
||||
|
||||
|
||||
public void update() {
|
||||
if (listener != null) {
|
||||
InputEvent inputEvent;
|
||||
|
||||
|
||||
while ((inputEvent = inputEventQueue.poll()) != null) {
|
||||
if (inputEvent instanceof TouchEvent) {
|
||||
listener.onTouchEvent((TouchEvent)inputEvent);
|
||||
@ -223,11 +222,11 @@ public class AndroidInputHandler implements TouchInput {
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
|
||||
public TouchEvent getFreeTouchEvent() {
|
||||
return touchEventPool.getNextFreeEvent();
|
||||
}
|
||||
|
||||
|
||||
public void addEvent(InputEvent event) {
|
||||
inputEventQueue.add(event);
|
||||
if (event instanceof TouchEvent) {
|
||||
@ -243,10 +242,6 @@ public class AndroidInputHandler implements TouchInput {
|
||||
return mouseEventsEnabled;
|
||||
}
|
||||
|
||||
public boolean getSimulateMouse() {
|
||||
return mouseEventsEnabled;
|
||||
}
|
||||
|
||||
public boolean isMouseEventsInvertX() {
|
||||
return mouseEventsInvertX;
|
||||
}
|
||||
@ -254,20 +249,17 @@ public class AndroidInputHandler implements TouchInput {
|
||||
public boolean isMouseEventsInvertY() {
|
||||
return mouseEventsInvertY;
|
||||
}
|
||||
|
||||
|
||||
public void setSimulateKeyboard(boolean simulate) {
|
||||
this.keyboardEventsEnabled = simulate;
|
||||
}
|
||||
|
||||
public boolean isSimulateKeyboard() {
|
||||
return keyboardEventsEnabled;
|
||||
}
|
||||
|
||||
public void setOmitHistoricEvents(boolean dontSendHistory) {
|
||||
this.dontSendHistory = dontSendHistory;
|
||||
}
|
||||
|
||||
public void showVirtualKeyboard(boolean visible) {
|
||||
if (keyHandler != null) {
|
||||
keyHandler.showVirtualKeyboard(visible);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -45,29 +45,29 @@ import java.util.logging.Logger;
|
||||
* the jME KeyEvents. onKey is used by Android to receive keys from the keyboard
|
||||
* or device buttons. All key events are consumed by jME except for the Volume
|
||||
* buttons and menu button.
|
||||
*
|
||||
*
|
||||
* This class also provides the functionality to display or hide the soft keyboard
|
||||
* for inputing single key events. Use OGLESContext to display an dialog to type
|
||||
* in complete strings.
|
||||
*
|
||||
*
|
||||
* @author iwgeric
|
||||
*/
|
||||
public class AndroidKeyHandler implements View.OnKeyListener {
|
||||
private static final Logger logger = Logger.getLogger(AndroidKeyHandler.class.getName());
|
||||
|
||||
|
||||
private AndroidInputHandler androidInput;
|
||||
private boolean sendKeyEvents = true;
|
||||
|
||||
|
||||
public AndroidKeyHandler(AndroidInputHandler androidInput) {
|
||||
this.androidInput = androidInput;
|
||||
}
|
||||
|
||||
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
||||
public void setView(View view) {
|
||||
if (view != null) {
|
||||
view.setOnKeyListener(this);
|
||||
@ -75,7 +75,7 @@ public class AndroidKeyHandler implements View.OnKeyListener {
|
||||
androidInput.getView().setOnKeyListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* onKey gets called from android thread on key events
|
||||
*/
|
||||
@ -83,7 +83,7 @@ public class AndroidKeyHandler implements View.OnKeyListener {
|
||||
if (androidInput.isInitialized() && view != androidInput.getView()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
TouchEvent evt;
|
||||
// TODO: get touch event from pool
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
@ -107,50 +107,34 @@ public class AndroidKeyHandler implements View.OnKeyListener {
|
||||
androidInput.addEvent(evt);
|
||||
|
||||
}
|
||||
|
||||
|
||||
KeyInputEvent kie;
|
||||
char unicodeChar = (char)event.getUnicodeChar();
|
||||
int jmeKeyCode = AndroidKeyMapping.getJmeKey(keyCode);
|
||||
|
||||
boolean pressed = event.getAction() == KeyEvent.ACTION_DOWN;
|
||||
boolean repeating = pressed && event.getRepeatCount() > 0;
|
||||
|
||||
kie = new KeyInputEvent(jmeKeyCode, unicodeChar, pressed, repeating);
|
||||
kie.setTime(event.getEventTime());
|
||||
androidInput.addEvent(kie);
|
||||
// logger.log(Level.FINE, "onKey keyCode: {0}, jmeKeyCode: {1}, pressed: {2}, repeating: {3}",
|
||||
// new Object[]{keyCode, jmeKeyCode, pressed, repeating});
|
||||
// logger.log(Level.FINE, "creating KeyInputEvent: {0}", kie);
|
||||
|
||||
if (androidInput.isSimulateKeyboard()) {
|
||||
KeyInputEvent kie;
|
||||
char unicodeChar = (char)event.getUnicodeChar();
|
||||
int jmeKeyCode = AndroidKeyMapping.getJmeKey(keyCode);
|
||||
|
||||
boolean pressed = event.getAction() == KeyEvent.ACTION_DOWN;
|
||||
boolean repeating = pressed && event.getRepeatCount() > 0;
|
||||
|
||||
kie = new KeyInputEvent(jmeKeyCode, unicodeChar, pressed, repeating);
|
||||
kie.setTime(event.getEventTime());
|
||||
androidInput.addEvent(kie);
|
||||
// logger.log(Level.FINE, "onKey keyCode: {0}, jmeKeyCode: {1}, pressed: {2}, repeating: {3}",
|
||||
// new Object[]{keyCode, jmeKeyCode, pressed, repeating});
|
||||
// logger.log(Level.FINE, "creating KeyInputEvent: {0}", kie);
|
||||
}
|
||||
|
||||
// consume all keys ourself except Volume Up/Down and Menu
|
||||
// Don't do Menu so that typical Android Menus can be created and used
|
||||
// by the user in MainActivity
|
||||
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) ||
|
||||
(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) ||
|
||||
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) ||
|
||||
(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) ||
|
||||
(keyCode == KeyEvent.KEYCODE_MENU)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void showVirtualKeyboard (final boolean visible) {
|
||||
androidInput.getView().getHandler().post(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
InputMethodManager manager =
|
||||
(InputMethodManager)androidInput.getView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
if (visible) {
|
||||
manager.showSoftInput(androidInput.getView(), 0);
|
||||
sendKeyEvents = true;
|
||||
} else {
|
||||
manager.hideSoftInputFromWindow(androidInput.getView().getWindowToken(), 0);
|
||||
sendKeyEvents = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -764,12 +764,25 @@ public class InputManager implements RawInputListener {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @deprecated Use isSimulateMouse
|
||||
* Returns state of simulation of mouse events. Used for touchscreen input only.
|
||||
*
|
||||
*/
|
||||
public boolean getSimulateMouse() {
|
||||
if (touch != null) {
|
||||
return touch.getSimulateMouse();
|
||||
return touch.isSimulateMouse();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns state of simulation of mouse events. Used for touchscreen input only.
|
||||
*
|
||||
*/
|
||||
public boolean isSimulateMouse() {
|
||||
if (touch != null) {
|
||||
return touch.isSimulateMouse();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -786,6 +799,18 @@ public class InputManager implements RawInputListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns state of simulation of key events. Used for touchscreen input only.
|
||||
*
|
||||
*/
|
||||
public boolean isSimulateKeyboard() {
|
||||
if (touch != null) {
|
||||
return touch.isSimulateKeyboard();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void processQueue() {
|
||||
int queueSize = inputQueue.size();
|
||||
RawInputListener[] array = getRawListenerArray();
|
||||
|
@ -59,27 +59,20 @@ public interface TouchInput extends Input {
|
||||
/**
|
||||
* Volume up key.
|
||||
*/
|
||||
public static final int KEYCODE_VOLUME_UP = 0x18;
|
||||
public static final int KEYCODE_VOLUME_UP = 0x18;
|
||||
/**
|
||||
* Volume down key.
|
||||
*/
|
||||
public static final int KEYCODE_VOLUME_DOWN = 0x19;
|
||||
public static final int KEYCODE_VOLUME_DOWN = 0x19;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set if mouse events should be generated
|
||||
*
|
||||
*
|
||||
* @param simulate if mouse events should be generated
|
||||
*/
|
||||
public void setSimulateMouse(boolean simulate);
|
||||
|
||||
/**
|
||||
* Get if mouse events are generated
|
||||
* @deprecated Use {@link #isSimulateMouse() }.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean getSimulateMouse();
|
||||
|
||||
|
||||
/**
|
||||
* @return true if mouse event simulation is enabled, false otherwise.
|
||||
*/
|
||||
@ -87,11 +80,16 @@ public interface TouchInput extends Input {
|
||||
|
||||
/**
|
||||
* Set if keyboard events should be generated
|
||||
*
|
||||
*
|
||||
* @param simulate if keyboard events should be generated
|
||||
*/
|
||||
public void setSimulateKeyboard(boolean simulate);
|
||||
|
||||
|
||||
/**
|
||||
* @return true if key event simulation is enabled, false otherwise.
|
||||
*/
|
||||
public boolean isSimulateKeyboard();
|
||||
|
||||
/**
|
||||
* Set if historic android events should be transmitted, can be used to get better performance and less mem
|
||||
* @see <a href="http://developer.android.com/reference/android/view/MotionEvent.html#getHistoricalX%28int,%20int%29">
|
||||
@ -99,11 +97,5 @@ public interface TouchInput extends Input {
|
||||
* @param dontSendHistory turn of historic events if true, false else and default
|
||||
*/
|
||||
public void setOmitHistoricEvents(boolean dontSendHistory);
|
||||
|
||||
/**
|
||||
* Displays or hides the onscreen soft keyboard
|
||||
* @param visible
|
||||
*/
|
||||
public void showVirtualKeyboard (final boolean visible);
|
||||
|
||||
|
||||
}
|
@ -90,10 +90,10 @@ public final class AppSettings extends HashMap<String, Object> {
|
||||
/**
|
||||
* Use the Android MediaPlayer / SoundPool based renderer for Android audio capabilities.
|
||||
* <p>
|
||||
* NOTE: Supports Android 2.2+ platforms.
|
||||
* NOTE: Supports Android 2.2+ platforms.
|
||||
*
|
||||
* @see AppSettings#setAudioRenderer(java.lang.String)
|
||||
* @deprecated This audio renderer has too many limitations.
|
||||
* @deprecated This audio renderer has too many limitations.
|
||||
* use {@link #ANDROID_OPENAL_SOFT} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ -455,6 +455,26 @@ public final class AppSettings extends HashMap<String, Object> {
|
||||
return getBoolean("TouchEmulateMouseFlipY");
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable keyboard emulation on touchscreen based devices.
|
||||
* This will convert soft keyboard key presses on the touchscreen
|
||||
* into the appropriate key events.
|
||||
*
|
||||
* @param emulateKeyboard If soft keyboard emulation should be enabled.
|
||||
*/
|
||||
public void setEmulateKeyboard(boolean emulateKeyboard) {
|
||||
putBoolean("TouchEmulateKeyboard", emulateKeyboard);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if keyboard emulation is enabled, false otherwise.
|
||||
*
|
||||
* @return Soft keyboard emulation mode.
|
||||
*/
|
||||
public boolean isEmulateKeyboard() {
|
||||
return getBoolean("TouchEmulateKeyboard");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param frameRate The frame-rate is the upper limit on how high
|
||||
* the application's frames-per-second can go.
|
||||
@ -731,12 +751,12 @@ public final class AppSettings extends HashMap<String, Object> {
|
||||
public void setSettingsDialogImage(String path) {
|
||||
putString("SettingsDialogImage", path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enables Gamma Correction
|
||||
* This requires that the GPU supports GL_ARB_framebuffer_sRGB and will
|
||||
* This requires that the GPU supports GL_ARB_framebuffer_sRGB and will
|
||||
* disabled otherwise.
|
||||
* @param gammaCorrection
|
||||
* @param gammaCorrection
|
||||
* (Default : true)
|
||||
*/
|
||||
public void setGammaCorrection(boolean gammaCorrection) {
|
||||
@ -911,7 +931,7 @@ public final class AppSettings extends HashMap<String, Object> {
|
||||
public String getSettingsDialogImage() {
|
||||
return getString("SettingsDialogImage");
|
||||
}
|
||||
|
||||
|
||||
public boolean getGammaCorrection() {
|
||||
return getBoolean("GammaCorrection");
|
||||
}
|
||||
|
@ -103,6 +103,10 @@ public class JmeSystem {
|
||||
systemDelegate.setSoftTextDialogInput(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays or hides the onscreen soft keyboard
|
||||
* @param show If true, the keyboard is displayed, if false, the screen is hidden.
|
||||
*/
|
||||
public static void showSoftKeyboard(boolean show) {
|
||||
checkDelegate();
|
||||
systemDelegate.showSoftKeyboard(show);
|
||||
|
@ -49,11 +49,11 @@ public class IosInputHandler implements TouchInput {
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
logger.log(Level.FINE, "InputEvent update : {0}",
|
||||
logger.log(Level.FINE, "InputEvent update : {0}",
|
||||
new Object[]{listener});
|
||||
if (listener != null) {
|
||||
InputEvent inputEvent;
|
||||
|
||||
|
||||
while ((inputEvent = inputEventQueue.poll()) != null) {
|
||||
if (inputEvent instanceof TouchEvent) {
|
||||
listener.onTouchEvent((TouchEvent)inputEvent);
|
||||
@ -97,11 +97,6 @@ public class IosInputHandler implements TouchInput {
|
||||
this.mouseEventsEnabled = simulate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSimulateMouse() {
|
||||
return mouseEventsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSimulateMouse() {
|
||||
return mouseEventsEnabled;
|
||||
@ -112,25 +107,24 @@ public class IosInputHandler implements TouchInput {
|
||||
this.keyboardEventsEnabled = simulate;
|
||||
}
|
||||
|
||||
public boolean isSimulateKeyboard() {
|
||||
return keyboardEventsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOmitHistoricEvents(boolean dontSendHistory) {
|
||||
this.dontSendHistory = dontSendHistory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showVirtualKeyboard(boolean visible) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
// ----------------
|
||||
|
||||
|
||||
public void loadSettings(AppSettings settings) {
|
||||
// TODO: add simulate keyboard to settings
|
||||
// keyboardEventsEnabled = true;
|
||||
mouseEventsEnabled = true;//settings.isEmulateMouse();
|
||||
mouseEventsInvertX = settings.isEmulateMouseFlipX();
|
||||
mouseEventsInvertY = settings.isEmulateMouseFlipY();
|
||||
|
||||
|
||||
// view width and height are 0 until the view is displayed on the screen
|
||||
//if (view.getWidth() != 0 && view.getHeight() != 0) {
|
||||
// scaleX = (float)settings.getWidth() / (float)view.getWidth();
|
||||
@ -140,10 +134,10 @@ public class IosInputHandler implements TouchInput {
|
||||
scaleY = 1.0f;
|
||||
width = settings.getWidth();
|
||||
height = settings.getHeight();
|
||||
logger.log(Level.FINE, "Setting input scaling, scaleX: {0}, scaleY: {1}, width: {2}, height: {3}",
|
||||
logger.log(Level.FINE, "Setting input scaling, scaleX: {0}, scaleY: {1}, width: {2}, height: {3}",
|
||||
new Object[]{scaleX, scaleY, width, height});
|
||||
}
|
||||
|
||||
|
||||
public boolean isMouseEventsInvertX() {
|
||||
return mouseEventsInvertX;
|
||||
}
|
||||
@ -151,19 +145,19 @@ public class IosInputHandler implements TouchInput {
|
||||
public boolean isMouseEventsInvertY() {
|
||||
return mouseEventsInvertY;
|
||||
}
|
||||
|
||||
|
||||
public float invertX(float origX) {
|
||||
return getJmeX(width) - origX;
|
||||
}
|
||||
|
||||
|
||||
public float invertY(float origY) {
|
||||
return getJmeY(height) - origY;
|
||||
}
|
||||
|
||||
|
||||
public float getJmeX(float origX) {
|
||||
return origX * scaleX;
|
||||
}
|
||||
|
||||
|
||||
public float getJmeY(float origY) {
|
||||
return origY * scaleY;
|
||||
}
|
||||
@ -171,7 +165,7 @@ public class IosInputHandler implements TouchInput {
|
||||
public TouchEvent getFreeTouchEvent() {
|
||||
return touchEventPool.getNextFreeEvent();
|
||||
}
|
||||
|
||||
|
||||
public void addEvent(InputEvent event) {
|
||||
inputEventQueue.add(event);
|
||||
if (event instanceof TouchEvent) {
|
||||
@ -180,9 +174,9 @@ public class IosInputHandler implements TouchInput {
|
||||
}
|
||||
|
||||
// ----------------
|
||||
|
||||
|
||||
public void injectTouchDown(int pointerId, long time, float x, float y) {
|
||||
logger.log(Level.FINE, "Using input scaling, scaleX: {0}, scaleY: {1}, width: {2}, height: {3}",
|
||||
logger.log(Level.FINE, "Using input scaling, scaleX: {0}, scaleY: {1}, width: {2}, height: {3}",
|
||||
new Object[]{scaleX, scaleY, width, height});
|
||||
if (touchHandler != null) {
|
||||
touchHandler.actionDown(pointerId, time, x, y);
|
||||
|
Loading…
x
Reference in New Issue
Block a user