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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -136,8 +136,7 @@ public class AndroidInputHandler implements TouchInput {
|
||||
}
|
||||
|
||||
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();
|
||||
@ -243,10 +242,6 @@ public class AndroidInputHandler implements TouchInput {
|
||||
return mouseEventsEnabled;
|
||||
}
|
||||
|
||||
public boolean getSimulateMouse() {
|
||||
return mouseEventsEnabled;
|
||||
}
|
||||
|
||||
public boolean isMouseEventsInvertX() {
|
||||
return mouseEventsInvertX;
|
||||
}
|
||||
@ -259,15 +254,12 @@ public class AndroidInputHandler implements TouchInput {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class AndroidKeyHandler implements View.OnKeyListener {
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (androidInput.isSimulateKeyboard()) {
|
||||
KeyInputEvent kie;
|
||||
char unicodeChar = (char)event.getUnicodeChar();
|
||||
int jmeKeyCode = AndroidKeyMapping.getJmeKey(keyCode);
|
||||
@ -122,6 +122,7 @@ public class AndroidKeyHandler implements View.OnKeyListener {
|
||||
// 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
|
||||
@ -133,24 +134,7 @@ public class AndroidKeyHandler implements View.OnKeyListener {
|
||||
} 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();
|
||||
|
@ -73,13 +73,6 @@ public interface TouchInput extends Input {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -92,6 +85,11 @@ public interface TouchInput extends Input {
|
||||
*/
|
||||
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">
|
||||
@ -100,10 +98,4 @@ public interface TouchInput extends Input {
|
||||
*/
|
||||
public void setOmitHistoricEvents(boolean dontSendHistory);
|
||||
|
||||
/**
|
||||
* Displays or hides the onscreen soft keyboard
|
||||
* @param visible
|
||||
*/
|
||||
public void showVirtualKeyboard (final boolean visible);
|
||||
|
||||
}
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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,14 +107,13 @@ public class IosInputHandler implements TouchInput {
|
||||
this.keyboardEventsEnabled = simulate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOmitHistoricEvents(boolean dontSendHistory) {
|
||||
this.dontSendHistory = dontSendHistory;
|
||||
public boolean isSimulateKeyboard() {
|
||||
return keyboardEventsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showVirtualKeyboard(boolean visible) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
public void setOmitHistoricEvents(boolean dontSendHistory) {
|
||||
this.dontSendHistory = dontSendHistory;
|
||||
}
|
||||
|
||||
// ----------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user