Compare commits

...

5 commits

Author SHA1 Message Date
downthecrop
5b72e87a89 Merge branch 'master' of https://github.com/2009scape/2009scape-mobile 2024-06-09 21:52:51 +09:00
downthecrop
cb9ffc52fb Update Jar to e8589 (Music + WorldMap), Set default resolution scale 2024-06-09 21:52:40 +09:00
downthecrop
5270adf48f regession in special character sending 2023-12-17 01:53:40 -08:00
downthecrop
fa697c6a75 Keycode 67 handling 2023-12-17 01:39:06 -08:00
downthecrop
6f969cb7d7 Longpress rc should only be active in touch mode 2023-11-30 02:00:34 -08:00
9 changed files with 64 additions and 105 deletions

View file

@ -141,7 +141,6 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouc
} }
} }
} }
longPressDetector.onTouchEvent(event);
prevY = y; prevY = y;
prevX = x; prevX = x;

View file

@ -3,6 +3,7 @@ package net.kdt.pojavlaunch;
import static net.kdt.pojavlaunch.GLFWGLSurface.FINGER_SCROLL_THRESHOLD; import static net.kdt.pojavlaunch.GLFWGLSurface.FINGER_SCROLL_THRESHOLD;
import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics; import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.DEFAULT_PREF; import static net.kdt.pojavlaunch.prefs.LauncherPreferences.DEFAULT_PREF;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_SCALE_FACTOR;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
@ -35,7 +36,7 @@ public class Touchpad extends FrameLayout implements GrabListener{
/* Detect a classic android Tap */ /* Detect a classic android Tap */
private final GestureDetector mSingleTapDetector = new GestureDetector(getContext(), new SingleTapConfirm()); private final GestureDetector mSingleTapDetector = new GestureDetector(getContext(), new SingleTapConfirm());
/* Resolution scaler option, allow downsizing a window */ /* Resolution scaler option, allow downsizing a window */
private final float mScaleFactor = DEFAULT_PREF.getInt("resolutionRatio",100)/100f; private final float mScaleFactor = PREF_SCALE_FACTOR/100f;
/* Current pointer ID to move the mouse */ /* Current pointer ID to move the mouse */
private int mCurrentPointerID = -1000; private int mCurrentPointerID = -1000;
/* Previous MotionEvent position, not scale */ /* Previous MotionEvent position, not scale */

View file

@ -42,6 +42,7 @@ import static net.kdt.pojavlaunch.customcontrols.gamepad.GamepadJoystick.DIRECTI
import static net.kdt.pojavlaunch.customcontrols.gamepad.GamepadJoystick.DIRECTION_SOUTH_WEST; import static net.kdt.pojavlaunch.customcontrols.gamepad.GamepadJoystick.DIRECTION_SOUTH_WEST;
import static net.kdt.pojavlaunch.customcontrols.gamepad.GamepadJoystick.DIRECTION_WEST; import static net.kdt.pojavlaunch.customcontrols.gamepad.GamepadJoystick.DIRECTION_WEST;
import static net.kdt.pojavlaunch.customcontrols.gamepad.GamepadJoystick.isJoystickEvent; import static net.kdt.pojavlaunch.customcontrols.gamepad.GamepadJoystick.isJoystickEvent;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_SCALE_FACTOR;
import static net.kdt.pojavlaunch.utils.MCOptionUtils.getMcScale; import static net.kdt.pojavlaunch.utils.MCOptionUtils.getMcScale;
import static org.lwjgl.glfw.CallbackBridge.sendKeyPress; import static org.lwjgl.glfw.CallbackBridge.sendKeyPress;
import static org.lwjgl.glfw.CallbackBridge.sendMouseButton; import static org.lwjgl.glfw.CallbackBridge.sendMouseButton;
@ -51,7 +52,7 @@ import fr.spse.gamepad_remapper.GamepadHandler;
public class Gamepad implements GrabListener, GamepadHandler { public class Gamepad implements GrabListener, GamepadHandler {
/* Resolution scaler option, allow downsizing a window */ /* Resolution scaler option, allow downsizing a window */
private final float mScaleFactor = LauncherPreferences.DEFAULT_PREF.getInt("resolutionRatio",100)/100f; private final float mScaleFactor = PREF_SCALE_FACTOR/100f;
/* Sensitivity, adjusted according to screen size */ /* Sensitivity, adjusted according to screen size */
private final double mSensitivityFactor = (1.4 * (1080f/ currentDisplayMetrics.heightPixels)); private final double mSensitivityFactor = (1.4 * (1080f/ currentDisplayMetrics.heightPixels));

View file

@ -23,6 +23,7 @@ import net.kdt.pojavlaunch.utils.KeyEncoder;
*/ */
public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText { public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText {
public static final String TEXT_FILLER = " "; public static final String TEXT_FILLER = " ";
public static boolean softKeyboardIsActive = false;
public TouchCharInput(@NonNull Context context) { public TouchCharInput(@NonNull Context context) {
this(context, null); this(context, null);
} }
@ -49,7 +50,7 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
Log.i("TouchCharInput","New Event (before/after)!: "+ lengthBefore + " : " + lengthAfter); Log.i("TouchCharInput","New Event (before/after)!: "+ lengthBefore + " : " + lengthAfter);
boolean isBackSpace = (lengthBefore > lengthAfter); boolean isBackSpace = (lengthBefore > lengthAfter);
if(isBackSpace) { if(isBackSpace) {
KeyEncoder.sendEncodedChar(KeyEncoder.backspaceUnicode,KeyEncoder.backspaceUnicode); KeyEncoder.sendUnicodeBackspace();
return; return;
} }
char c = text.charAt(text.length()-1); char c = text.charAt(text.length()-1);
@ -115,6 +116,7 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
/** Regain ability to exist, take focus and have some text being input */ /** Regain ability to exist, take focus and have some text being input */
public void enable(){ public void enable(){
softKeyboardIsActive = true;
setEnabled(true); setEnabled(true);
setFocusable(true); setFocusable(true);
setVisibility(VISIBLE); setVisibility(VISIBLE);
@ -123,6 +125,7 @@ public class TouchCharInput extends androidx.appcompat.widget.AppCompatEditText
/** Lose ability to exist, take focus and have some text being input */ /** Lose ability to exist, take focus and have some text being input */
public void disable(){ public void disable(){
softKeyboardIsActive = false;
clear(); clear();
setVisibility(GONE); setVisibility(GONE);
clearFocus(); clearFocus();

View file

@ -46,7 +46,7 @@ public class LauncherPreferences {
public static boolean PREF_ARC_CAPES = false; public static boolean PREF_ARC_CAPES = false;
public static boolean PREF_USE_ALTERNATE_SURFACE = true; public static boolean PREF_USE_ALTERNATE_SURFACE = true;
public static boolean PREF_JAVA_SANDBOX = true; public static boolean PREF_JAVA_SANDBOX = true;
public static int PREF_SCALE_FACTOR = 100; public static int PREF_SCALE_FACTOR = 60;
public static boolean PREF_ENABLE_GYRO = false; public static boolean PREF_ENABLE_GYRO = false;
public static float PREF_GYRO_SENSITIVITY = 1f; public static float PREF_GYRO_SENSITIVITY = 1f;
public static int PREF_GYRO_SAMPLE_RATE = 16; public static int PREF_GYRO_SAMPLE_RATE = 16;
@ -93,7 +93,7 @@ public class LauncherPreferences {
PREF_ARC_CAPES = DEFAULT_PREF.getBoolean("arc_capes",false); PREF_ARC_CAPES = DEFAULT_PREF.getBoolean("arc_capes",false);
PREF_USE_ALTERNATE_SURFACE = DEFAULT_PREF.getBoolean("alternate_surface", false); PREF_USE_ALTERNATE_SURFACE = DEFAULT_PREF.getBoolean("alternate_surface", false);
PREF_JAVA_SANDBOX = DEFAULT_PREF.getBoolean("java_sandbox", true); PREF_JAVA_SANDBOX = DEFAULT_PREF.getBoolean("java_sandbox", true);
PREF_SCALE_FACTOR = DEFAULT_PREF.getInt("resolutionRatio", 100); PREF_SCALE_FACTOR = DEFAULT_PREF.getInt("resolutionRatio", 60);
PREF_ENABLE_GYRO = DEFAULT_PREF.getBoolean("enableGyro", false); PREF_ENABLE_GYRO = DEFAULT_PREF.getBoolean("enableGyro", false);
PREF_GYRO_SENSITIVITY = ((float)DEFAULT_PREF.getInt("gyroSensitivity", 100))/100f; PREF_GYRO_SENSITIVITY = ((float)DEFAULT_PREF.getInt("gyroSensitivity", 100))/100f;
PREF_GYRO_SAMPLE_RATE = DEFAULT_PREF.getInt("gyroSampleRate", 16); PREF_GYRO_SAMPLE_RATE = DEFAULT_PREF.getInt("gyroSampleRate", 16);

View file

@ -1,6 +1,7 @@
package net.kdt.pojavlaunch.prefs.screens; package net.kdt.pojavlaunch.prefs.screens;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_NOTCH_SIZE; import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_NOTCH_SIZE;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_SCALE_FACTOR;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build; import android.os.Build;

View file

@ -1,110 +1,63 @@
package net.kdt.pojavlaunch.utils; package net.kdt.pojavlaunch.utils;
import net.kdt.pojavlaunch.AWTInputBridge; import net.kdt.pojavlaunch.AWTInputBridge;
import net.kdt.pojavlaunch.customcontrols.keyboard.TouchCharInput;
/* import java.util.HashMap;
About Key Events. Because the Android Spec doesn't require import java.util.Map;
soft keyboards to dispatch key events not all keyboard implementations
across Android will trigger these actions.
Currently we use the following function to translate keycodes for
special character, capital letters, and digits.
keycode 123 (F12) is used as a single digit capslock button which
when sent to the miniclient before a char will act accordingly.
*/
public class KeyEncoder { public class KeyEncoder {
static String specialChars = "/*!@#$%^&*()\"{}_[+:;=-_]'|\\?/<>,."; private static final Map<Character, Character> specialCharMap = createSpecialCharMap();
static char modifier = 123; private static final char MODIFIER = 123; // F12 key as a modifier for caps lock
static char backspaceAndroid = 67; private static final char BACKSPACE_ANDROID = 67;
public static char backspaceUnicode = 8; private static final char BACKSPACE_UNICODE = 8;
public static void sendEncodedChar(int keyCode, char iC){ // Initialize the mapping of special characters to their respective keys
System.out.println(keyCode); private static Map<Character, Character> createSpecialCharMap() {
if(keyCode == backspaceAndroid){ Map<Character, Character> map = new HashMap<>();
AWTInputBridge.sendKey(backspaceUnicode,backspaceUnicode); map.put('!', '1');
} else if(specialChars.contains(""+iC)){ map.put('@', '2');
// Send special character to client map.put('#', '3');
char c = iC; map.put('$', '4');
switch(c){ map.put('%', '5');
case '!': map.put('^', '6');
c = '1'; map.put('&', '7');
break; map.put('*', '8');
case '@': map.put('(', '9');
c = '2'; map.put(')', '0');
break; map.put('_', '-');
case '#': map.put('+', '=');
c = '3'; map.put('{', '[');
break; map.put('}', ']');
case '$': map.put(':', ';');
c = '4'; map.put('"', '\'');
break; map.put('<', ',');
case '%': map.put('>', '.');
c = '5'; map.put('?', '/');
break; map.put('|', '\\');
case '^': return map;
c = '6';
break;
case '&':
c = '7';
break;
case '*':
c = '8';
break;
case '(':
c = '9';
break;
case ')':
c = '0';
break;
case '_':
c = '-';
break;
case '+':
c = '=';
break;
case '{':
c = '[';
break;
case '}':
c = ']';
break;
case ':':
c = ';';
break;
case '"':
c = '\'';
break;
case '<':
c = ',';
break;
case '>':
c = '.';
break;
case '?':
c = '/';
break;
case '|':
c = '\\';
break;
} }
if(c != iC){
AWTInputBridge.sendKey(modifier,modifier); public static void sendUnicodeBackspace(){
AWTInputBridge.sendKey(BACKSPACE_UNICODE, BACKSPACE_UNICODE);
} }
AWTInputBridge.sendKey(c,c);
} else if(Character.isDigit(iC)){ public static void sendEncodedChar(int keyCode, char c) {
AWTInputBridge.sendKey(iC,iC); if (keyCode == BACKSPACE_ANDROID && !TouchCharInput.softKeyboardIsActive) {
} else if (iC == Character.toUpperCase(iC)){ sendUnicodeBackspace();
// We send F12 as a modifier to avoid needing to worry about shift. } else if (specialCharMap.containsKey(c)) {
// Client takes this modifier and does a toUpperCase(). AWTInputBridge.sendKey(MODIFIER, MODIFIER);
AWTInputBridge.sendKey(modifier,modifier); AWTInputBridge.sendKey(specialCharMap.get(c), specialCharMap.get(c));
AWTInputBridge.sendKey(Character.toUpperCase(iC),Character.toUpperCase(iC)); } else if (Character.isDigit(c)) {
} else if(iC == Character.toLowerCase(iC)){ AWTInputBridge.sendKey(c, c);
AWTInputBridge.sendKey(Character.toUpperCase(iC),Character.toUpperCase(iC)); } else if (Character.isLowerCase(c)){
AWTInputBridge.sendKey(Character.toUpperCase(c),Character.toUpperCase(c));
} else if (Character.isUpperCase(c)) {
AWTInputBridge.sendKey(MODIFIER, MODIFIER);
AWTInputBridge.sendKey(c, c);
} else { } else {
AWTInputBridge.sendKey(iC,keyCode); AWTInputBridge.sendKey(c, keyCode);
} }
} }
} }

View file

@ -29,6 +29,7 @@
app2:showSeekBarValue="true" app2:showSeekBarValue="true"
app2:selectable="false" app2:selectable="false"
app2:seekBarIncrement="5" app2:seekBarIncrement="5"
app2:defaultValue="60"
android:icon="@drawable/ic_setting_screen_resolution" android:icon="@drawable/ic_setting_screen_resolution"
/> />