Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
Expand Down Expand Up @@ -110,6 +111,13 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (LauncherPreferences.PREF_KEYBOARD_PANNING) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
} else {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
}

if (LauncherPreferences.PREF_GAMEPAD_SDL_PASSTHRU) {
// TODO: Use lower level HID capture that needs a dialogue box from the user for the
// app to fully take focus of the input devices. Might cause issues with older android
Expand Down Expand Up @@ -509,6 +517,15 @@ public void onResolutionChanged() {
mHotbarView.onResolutionChanged();
}

@Override
public void onKeyboardPanningChanged() {
if (LauncherPreferences.PREF_KEYBOARD_PANNING) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
} else {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
}
}

@Override
public void onGyroStateChanged() {
mGyroControl.updateOrientation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ public boolean getDisplayState() {

@Override
public void applyMotionVector(float x, float y) {
mMouseX = Math.max(0, Math.min(currentDisplayMetrics.widthPixels, mMouseX + x * LauncherPreferences.PREF_MOUSESPEED));
mMouseY = Math.max(0, Math.min(currentDisplayMetrics.heightPixels, mMouseY + y * LauncherPreferences.PREF_MOUSESPEED));
updateMousePosition();
if (mDisplayState) { // Make sure no motion leaks through when disabling a moving cursor
mMouseX = Math.max(0, Math.min(currentDisplayMetrics.widthPixels, mMouseX + x * LauncherPreferences.PREF_MOUSESPEED));
mMouseY = Math.max(0, Math.min(currentDisplayMetrics.heightPixels, mMouseY + y * LauncherPreferences.PREF_MOUSESPEED));
updateMousePosition();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class LauncherPreferences {
public static int PREF_TOUCHCONTROLLER_VIBRATE_LENGTH = 100;

public static boolean PREF_MOUSE_GRAB_FORCE = false;
public static boolean PREF_KEYBOARD_PANNING = true;


public static void loadPreferences(Context ctx) {
Expand Down Expand Up @@ -121,6 +122,7 @@ public static void loadPreferences(Context ctx) {
PREF_FORCE_ENABLE_TOUCHCONTROLLER = DEFAULT_PREF.getBoolean("forceEnableTouchController", false);
PREF_TOUCHCONTROLLER_VIBRATE_LENGTH = DEFAULT_PREF.getInt("touchControllerVibrateLength", 100);
PREF_MOUSE_GRAB_FORCE = DEFAULT_PREF.getBoolean("always_grab_mouse", false);
PREF_KEYBOARD_PANNING = DEFAULT_PREF.getBoolean("keyboardPanning", true);

String argLwjglLibname = "-Dorg.lwjgl.opengl.libname=";
for (String arg : JREUtils.parseJavaArguments(PREF_CUSTOM_JAVA_ARGS)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_GYRO_INVERT_X;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_GYRO_INVERT_Y;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_GYRO_SENSITIVITY;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_KEYBOARD_PANNING;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_LONGPRESS_TRIGGER;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_MOUSESPEED;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_MOUSE_GRAB_FORCE;
Expand Down Expand Up @@ -32,11 +33,11 @@ public abstract class QuickSettingSideDialog extends com.kdt.SideDialogView {

private SharedPreferences.Editor mEditor;
@SuppressLint("UseSwitchCompatOrMaterialCode")
private Switch mGyroSwitch, mGyroXSwitch, mGyroYSwitch, mGestureSwitch, mMouseGrabSwitch;
private Switch mGyroSwitch, mGyroXSwitch, mGyroYSwitch, mGestureSwitch, mMouseGrabSwitch, mKeyboardPanningSwitch;
private CustomSeekbar mGyroSensitivityBar, mMouseSpeedBar, mGestureDelayBar, mResolutionBar;
private TextView mGyroSensitivityText, mGyroSensitivityDisplayText, mMouseSpeedText, mGestureDelayText, mGestureDelayDisplayText, mResolutionText;

private boolean mOriginalGyroEnabled, mOriginalGyroXEnabled, mOriginalGyroYEnabled, mOriginalGestureDisabled, mOriginalMouseGrab;
private boolean mOriginalGyroEnabled, mOriginalGyroXEnabled, mOriginalGyroYEnabled, mOriginalGestureDisabled, mOriginalMouseGrab, mOriginalKeyboardPanning;
private float mOriginalGyroSensitivity, mOriginalMouseSpeed, mOriginalResolution;
private int mOriginalGestureDelay;

Expand Down Expand Up @@ -67,6 +68,7 @@ private void bindLayout() {
mGyroYSwitch = mDialogContent.findViewById(R.id.checkboxGyroY);
mGestureSwitch = mDialogContent.findViewById(R.id.checkboxGesture);
mMouseGrabSwitch = mDialogContent.findViewById(R.id.always_grab_mouse_side_dialog);
mKeyboardPanningSwitch = mDialogContent.findViewById(R.id.checkboxKeyboardPanning);

mGyroSensitivityBar = mDialogContent.findViewById(R.id.editGyro_seekbar);
mMouseSpeedBar = mDialogContent.findViewById(R.id.editMouseSpeed_seekbar);
Expand All @@ -89,6 +91,7 @@ private void setupListeners() {
mOriginalGyroYEnabled = PREF_GYRO_INVERT_Y;
mOriginalGestureDisabled = PREF_DISABLE_GESTURES;
mOriginalMouseGrab = PREF_MOUSE_GRAB_FORCE;
mOriginalKeyboardPanning = PREF_KEYBOARD_PANNING;

mOriginalGyroSensitivity = PREF_GYRO_SENSITIVITY;
mOriginalMouseSpeed = PREF_MOUSESPEED;
Expand All @@ -100,6 +103,7 @@ private void setupListeners() {
mGyroYSwitch.setChecked(mOriginalGyroYEnabled);
mGestureSwitch.setChecked(mOriginalGestureDisabled);
mMouseGrabSwitch.setChecked(mOriginalMouseGrab);
mKeyboardPanningSwitch.setChecked(mOriginalKeyboardPanning);

mGyroSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
PREF_ENABLE_GYRO = isChecked;
Expand Down Expand Up @@ -131,6 +135,12 @@ private void setupListeners() {
mEditor.putBoolean("always_grab_mouse", isChecked);
});

mKeyboardPanningSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
PREF_KEYBOARD_PANNING = isChecked;
onKeyboardPanningChanged();
mEditor.putBoolean("keyboardPanning", isChecked);
});

mGyroSensitivityBar.setOnSeekBarChangeListener((SimpleSeekBarListener) (seekBar, progress, fromUser) -> {
PREF_GYRO_SENSITIVITY = progress / 100f;
mEditor.putInt("gyroSensitivity", progress);
Expand Down Expand Up @@ -217,6 +227,7 @@ private void removeListeners() {
mGyroYSwitch.setOnCheckedChangeListener(null);
mGestureSwitch.setOnCheckedChangeListener(null);
mMouseGrabSwitch.setOnCheckedChangeListener(null);
mKeyboardPanningSwitch.setOnCheckedChangeListener(null);

mGyroSensitivityBar.setOnSeekBarChangeListener(null);
mMouseSpeedBar.setOnSeekBarChangeListener(null);
Expand All @@ -241,6 +252,7 @@ public void cancel() {
PREF_GYRO_INVERT_Y = mOriginalGyroYEnabled;
PREF_DISABLE_GESTURES = mOriginalGestureDisabled;
PREF_MOUSE_GRAB_FORCE = mOriginalMouseGrab;
PREF_KEYBOARD_PANNING = mOriginalKeyboardPanning;

PREF_GYRO_SENSITIVITY = mOriginalGyroSensitivity;
PREF_MOUSESPEED = mOriginalMouseSpeed;
Expand All @@ -249,6 +261,7 @@ public void cancel() {

onGyroStateChanged();
onResolutionChanged();
onKeyboardPanningChanged();
}

disappear(true);
Expand All @@ -257,6 +270,9 @@ public void cancel() {
/** Called when the resolution is changed. Use {@link LauncherPreferences#PREF_SCALE_FACTOR} */
public abstract void onResolutionChanged();

/** Called when the keyboard panning state is changed. Use {@link LauncherPreferences#PREF_KEYBOARD_PANNING} */
public abstract void onKeyboardPanningChanged();

/** Called when the gyro state is changed.
* Use {@link LauncherPreferences#PREF_ENABLE_GYRO}
* Use {@link LauncherPreferences#PREF_GYRO_INVERT_X}
Expand Down
16 changes: 15 additions & 1 deletion app_pojavlauncher/src/main/res/layout/activity_basemain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,24 @@
android:translationZ="1dp"
android:visibility="gone"/>

<!-- This is a horrible hack that forces android to properly redraw ControlLayout
when keyboard causes MainActivity to pan offscreen, which can cause the top part
of ControLayout to just be grpahically cut out. This stops that, somehow... -->
<View
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:focusable="false"
android:translationZ="1dp"
android:visibility="visible"
android:importantForAccessibility="no"
android:background="@android:color/transparent"/>

<net.kdt.pojavlaunch.customcontrols.keyboard.TouchCharInput
android:id="@+id/mainTouchCharInput"
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_gravity="bottom"
android:background="@android:color/darker_gray"
android:ems="10"
android:imeOptions="flagNoFullscreen|flagNoExtractUi|flagNoPersonalizedLearning|actionDone"
Expand All @@ -52,7 +65,8 @@
<net.kdt.pojavlaunch.utils.TouchControllerInputView
android:id="@+id/touch_controller_input"
android:layout_width="1dp"
android:layout_height="1dp" />
android:layout_height="1dp"
android:layout_gravity="bottom" />

<net.kdt.pojavlaunch.customcontrols.handleview.DrawerPullButton
android:id="@+id/drawer_button"
Expand Down
11 changes: 10 additions & 1 deletion app_pojavlauncher/src/main/res/layout/dialog_quick_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,17 @@
android:text="@string/mcl_setting_title_grab_mouse"


app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editGestureDelay_seekbar"
tools:ignore="UseSwitchCompatOrMaterialXml" />

<Switch
android:id="@+id/checkboxKeyboardPanning"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/mcl_setting_title_keyboard_panning"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/always_grab_mouse_side_dialog"
tools:ignore="UseSwitchCompatOrMaterialXml" />

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 2 additions & 0 deletions app_pojavlauncher/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@
<string name="mcl_setting_subtitle_mousespeed">Changes the speed of the virtual mouse.</string>
<string name="mcl_setting_title_grab_mouse">Use virtual cursor</string>
<string name="mcl_setting_subtitle_grab_mouse">Ensures the cursor stays inside the game. Prevents mouse from clicking touch control layout.</string>
<string name="mcl_setting_title_keyboard_panning">Keyboard panning</string>
<string name="mcl_setting_subtitle_keyboard_panning">Shift the screen upwards when the keyboard is open.</string>
<string name="customctrl_passthru">Mouse pass-thru</string>
<string name="customctrl_swipeable">Swipeable</string>
<string name="customctrl_forward_lock">Forward lock</string>
Expand Down
5 changes: 5 additions & 0 deletions app_pojavlauncher/src/main/res/xml/pref_control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
android:title="@string/mcl_setting_title_buttonallcaps"
android:summary="@string/mcl_setting_subtitle_buttonallcaps"
/>
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:key="keyboardPanning"
android:summary="@string/mcl_setting_subtitle_keyboard_panning"
android:title="@string/mcl_setting_title_keyboard_panning" />

</PreferenceCategory>

Expand Down
Loading