diff --git a/CHANGES b/CHANGES index c60b856a1b6..ee39977965f 100755 --- a/CHANGES +++ b/CHANGES @@ -1,10 +1,11 @@ [1.9.13] - [BREAKING CHANGE] TexturePacker writes using a new format (TextureAtlas can still read old format). See #6316. +- [BREAKING CHANGE] Fixed keycode representations for ESCAPE, END, INSERT and F1 to F12. These keys are working on Android now, but if you hardcoded or saved the values you might need to migrate. - GWT: Key codes set with Gdx.input.setCatchKey prevent default browser behaviour - Added Scaling.contain mode: Scales the source to fit the target while keeping the same aspect ratio, but the source is not scaled at all if smaller in both directions. - API Addition: Added hasContents() to Clipboard interface, to reduce clipboard notifications on iOS 14 - TOOLS Features: Blending mode can be changed in Flame particle 3D editor. -- Input Keycodes added: CAPS_LOCK, PAUSE (aka Break), PRINT_SCREEN, SCROLL_LOCK, F13 to F24, NUMPAD_DIVIDE, NUMPAD_MULTIPLY, NUMPAD_SUBTRACT, NUMPAD_ADD, NUMPAD_DOT, NUMPAD_COMMA, NUMPAD_ENTER, NUMPAD_EQUALS, NUMPAD_LEFT_PAREN, NUMPAD_RIGHT_PAREN, NUM_LOCK. +- Input Keycodes added: CAPS_LOCK, PAUSE (aka Break), PRINT_SCREEN, SCROLL_LOCK, F13 to F24, NUMPAD_DIVIDE, NUMPAD_MULTIPLY, NUMPAD_SUBTRACT, NUMPAD_ADD, NUMPAD_DOT, NUMPAD_COMMA, NUMPAD_ENTER, NUMPAD_EQUALS, NUMPAD_LEFT_PAREN, NUMPAD_RIGHT_PAREN, NUM_LOCK. Following changes might be done depending on platform: Keys.STAR to Keys.NUMPAD_MULTIPLY, Keys.SLASH to Keys.NUMPAD_DIVIDE, Keys.NUM to Keys.NUM_LOCK, Keys.COMMA to Keys.NUMPAD_COMMA, Keys.PERIOD to Keys.NUMPAD_DOT, Keys.COMMA to Keys.NUMPAD_COMMA, Keys.ENTER to Keys.NUMPAD_ENTER, Keys.PLUS to Keys.NUMPAD_ADD, Keys.MINUS to Keys.NUMPAD_SUBTRACT - Added a QuadFloatTree class. - Desktop: Cubemap Seamless feature is now enabled by default when supported, can be changed via backend specific methods, see supportsCubeMapSeamless and enableCubeMapSeamless in both LwjglGraphics and Lwjgl3Graphics. diff --git a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidOnscreenKeyboard.java b/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidOnscreenKeyboard.java deleted file mode 100644 index 22cd7d46d31..00000000000 --- a/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidOnscreenKeyboard.java +++ /dev/null @@ -1,313 +0,0 @@ -/******************************************************************************* - * Copyright 2011 See AUTHORS file. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -package com.badlogic.gdx.backends.android; - -import android.app.Dialog; -import android.content.Context; -import android.os.Handler; -import android.text.Editable; -import android.text.InputFilter; -import android.text.method.ArrowKeyMovementMethod; -import android.text.method.MovementMethod; -import android.util.Log; -import android.view.Gravity; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.view.View; -import android.view.View.OnKeyListener; -import android.view.View.OnTouchListener; -import android.view.ViewGroup; -import android.view.ViewTreeObserver.OnPreDrawListener; -import android.view.Window; -import android.view.WindowManager; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodManager; -import android.widget.FrameLayout; -import android.widget.TextView; - -import com.badlogic.gdx.Input.Peripheral; - -/** Responsible for showing and hiding the Android onscreen keyboard (aka softkeyboard). Uses a dialog with an invisible TextView - * and injects key down/up and typed events into AndroidInput. Only the delete and back keys will trigger key down/up events. - * Alphanumeric keys will be directly injected as key typed events which is sufficient to implement things like text fields. - * - * Since the input mechanism for softkeyboards is a bit complex, we don't directly get key events from the softkeyboard. Instead - * we intercept calls to the Editable of the invisible TextView which we translate into delete key events and key typed events. - * - * @author mzechner */ -class AndroidOnscreenKeyboard implements OnKeyListener, OnTouchListener { - final Context context; - final Handler handler; - final AndroidInput input; - Dialog dialog; - TextView textView; - - public AndroidOnscreenKeyboard (Context context, Handler handler, AndroidInput input) { - this.context = context; - this.handler = handler; - this.input = input; - } - - Dialog createDialog () { - textView = createView(context); - textView.setOnKeyListener(this); - FrameLayout.LayoutParams textBoxLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, - FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM); - textView.setLayoutParams(textBoxLayoutParams); - textView.setFocusable(true); - textView.setFocusableInTouchMode(true); - textView.setImeOptions(textView.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI); - - final FrameLayout layout = new FrameLayout(context); - ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0); - layout.setLayoutParams(layoutParams); - layout.addView(textView); - layout.setOnTouchListener(this); - - dialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); - dialog.setContentView(layout); - return dialog; - } - - public static TextView createView (Context context) { - final TextView view = new TextView(context) { - Editable editable = new PassThroughEditable(); - - @Override - protected boolean getDefaultEditable () { - return true; - } - - @Override - public Editable getEditableText () { - return editable; - } - - @Override - protected MovementMethod getDefaultMovementMethod () { - return ArrowKeyMovementMethod.getInstance(); - } - - @Override - public boolean onKeyDown (int keyCode, KeyEvent event) { - Log.d("Test", "down keycode: " + event.getKeyCode()); - return super.onKeyDown(keyCode, event); - } - - @Override - public boolean onKeyUp (int keyCode, KeyEvent event) { - Log.d("Test", "up keycode: " + event.getKeyCode()); - return super.onKeyUp(keyCode, event); - } - }; -// view.setCursorVisible(false); - return view; - } - - public void setVisible (boolean visible) { - if (visible && dialog != null) { - dialog.dismiss(); - dialog = null; - } - if (visible && dialog == null && !input.isPeripheralAvailable(Peripheral.HardwareKeyboard)) { - handler.post(new Runnable() { - @Override - public void run () { - dialog = createDialog(); - dialog.show(); - - handler.post(new Runnable() { - @Override - public void run () { - dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); - InputMethodManager input = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); - if (input != null) input.showSoftInput(textView, InputMethodManager.SHOW_FORCED); - } - }); - - final View content = dialog.getWindow().findViewById(Window.ID_ANDROID_CONTENT); - content.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() { - int[] screenloc = new int[2]; - private int keyboardHeight; - private boolean keyboardShowing; - - @Override - public boolean onPreDraw () { - content.getLocationOnScreen(screenloc); - keyboardHeight = Math.abs(screenloc[1]); - if (keyboardHeight > 0) keyboardShowing = true; - if (keyboardHeight == 0 && keyboardShowing) { - dialog.dismiss(); - dialog = null; - } - return true; - } - }); - } - }); - } else { - if (!visible && dialog != null) { - dialog.dismiss(); - } - } - } - - public static class PassThroughEditable implements Editable { - - @Override - public char charAt (int index) { - Log.d("Editable", "charAt"); - return 0; - } - - @Override - public int length () { - Log.d("Editable", "length"); - return 0; - } - - @Override - public CharSequence subSequence (int start, int end) { - Log.d("Editable", "subSequence"); - return null; - } - - @Override - public void getChars (int start, int end, char[] dest, int destoff) { - Log.d("Editable", "getChars"); - } - - @Override - public void removeSpan (Object what) { - Log.d("Editable", "removeSpan"); - } - - @Override - public void setSpan (Object what, int start, int end, int flags) { - Log.d("Editable", "setSpan"); - } - - @Override - public int getSpanEnd (Object tag) { - Log.d("Editable", "getSpanEnd"); - return 0; - } - - @Override - public int getSpanFlags (Object tag) { - Log.d("Editable", "getSpanFlags"); - return 0; - } - - @Override - public int getSpanStart (Object tag) { - Log.d("Editable", "getSpanStart"); - return 0; - } - - @Override - public T[] getSpans (int arg0, int arg1, Class arg2) { - Log.d("Editable", "getSpans"); - return null; - } - - @Override - public int nextSpanTransition (int start, int limit, Class type) { - Log.d("Editable", "nextSpanTransition"); - return 0; - } - - @Override - public Editable append (CharSequence text) { - Log.d("Editable", "append: " + text); - return this; - } - - @Override - public Editable append (char text) { - Log.d("Editable", "append: " + text); - return this; - } - - @Override - public Editable append (CharSequence text, int start, int end) { - Log.d("Editable", "append: " + text); - return this; - } - - @Override - public void clear () { - Log.d("Editable", "clear"); - } - - @Override - public void clearSpans () { - Log.d("Editable", "clearSpanes"); - } - - @Override - public Editable delete (int st, int en) { - Log.d("Editable", "delete, " + st + ", " + en); - return this; - } - - @Override - public InputFilter[] getFilters () { - Log.d("Editable", "getFilters"); - return new InputFilter[0]; - } - - @Override - public Editable insert (int where, CharSequence text) { - Log.d("Editable", "insert: " + text); - return this; - } - - @Override - public Editable insert (int where, CharSequence text, int start, int end) { - Log.d("Editable", "insert: " + text); - return this; - } - - @Override - public Editable replace (int st, int en, CharSequence text) { - Log.d("Editable", "replace: " + text); - return this; - } - - @Override - public Editable replace (int st, int en, CharSequence source, int start, int end) { - Log.d("Editable", "replace: " + source); - return this; - } - - @Override - public void setFilters (InputFilter[] filters) { - Log.d("Editable", "setFilters"); - } - } - - @Override - public boolean onTouch (View view, MotionEvent e) { - return false; - } - - @Override - public boolean onKey (View view, int keycode, KeyEvent e) { - return false; - } -} diff --git a/gdx/src/com/badlogic/gdx/Input.java b/gdx/src/com/badlogic/gdx/Input.java index 7a1e5493c72..02ab7933274 100644 --- a/gdx/src/com/badlogic/gdx/Input.java +++ b/gdx/src/com/badlogic/gdx/Input.java @@ -178,9 +178,9 @@ static public class Keys { public static final int META_SYM_ON = 4; public static final int CONTROL_LEFT = 129; public static final int CONTROL_RIGHT = 130; - public static final int ESCAPE = 131; - public static final int END = 132; - public static final int INSERT = 133; + public static final int ESCAPE = 111; + public static final int END = 123; + public static final int INSERT = 124; public static final int PAGE_UP = 92; public static final int PAGE_DOWN = 93; public static final int PICTSYMBOLS = 94; @@ -244,18 +244,18 @@ static public class Keys { // ! | VK_EXCLAMATION // ? | VK_QUESTION public static final int COLON = 243; - public static final int F1 = 244; - public static final int F2 = 245; - public static final int F3 = 246; - public static final int F4 = 247; - public static final int F5 = 248; - public static final int F6 = 249; - public static final int F7 = 250; - public static final int F8 = 251; - public static final int F9 = 252; - public static final int F10 = 253; - public static final int F11 = 254; - public static final int F12 = 255; + public static final int F1 = 131; + public static final int F2 = 132; + public static final int F3 = 133; + public static final int F4 = 134; + public static final int F5 = 135; + public static final int F6 = 136; + public static final int F7 = 137; + public static final int F8 = 138; + public static final int F9 = 139; + public static final int F10 = 140; + public static final int F11 = 141; + public static final int F12 = 142; public static final int F13 = 183; public static final int F14 = 184; public static final int F15 = 185;