Skip to content
Open
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
37 changes: 28 additions & 9 deletions app/src/main/java/com/limelight/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

Expand All @@ -96,7 +97,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,

// Only 2 touches are supported
private final TouchContext[] touchContextMap = new TouchContext[2];
private long threeFingerDownTime = 0;
private long keyboardToggleDownTime = 0;

private static final int REFERENCE_HORIZ_RES = 1280;
private static final int REFERENCE_VERT_RES = 720;
Expand All @@ -107,7 +108,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
private static final int STYLUS_UP_DEAD_ZONE_DELAY = 150;
private static final int STYLUS_UP_DEAD_ZONE_RADIUS = 50;

private static final int THREE_FINGER_TAP_THRESHOLD = 300;
private static final int KEYBOARD_TOGGLE_TAP_THRESHOLD = 300;

private ControllerHandler controllerHandler;
private KeyboardTranslator keyboardTranslator;
Expand Down Expand Up @@ -146,6 +147,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
private TextView notificationOverlayView;
private int requestedNotificationOverlayVisibility = View.GONE;
private TextView performanceOverlayView;
private ImageButton keyboardToggleButtonView;

private MediaCodecDecoderRenderer decoderRenderer;
private boolean reportedCrash;
Expand Down Expand Up @@ -272,6 +274,17 @@ else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {

performanceOverlayView = findViewById(R.id.performanceOverlay);

keyboardToggleButtonView = findViewById(R.id.keyboardToggleButton);
keyboardToggleButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toggleKeyboard();
}
});
if (prefConfig.showKeyboardToggleButton) {
keyboardToggleButtonView.setVisibility(View.VISIBLE);
}

inputCaptureProvider = InputCaptureManager.getInputCaptureProvider(this, this);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Expand Down Expand Up @@ -597,6 +610,7 @@ public void onConfigurationChanged(Configuration newConfig) {

performanceOverlayView.setVisibility(View.GONE);
notificationOverlayView.setVisibility(View.GONE);
keyboardToggleButtonView.setVisibility(View.GONE);

// Disable sensors while in PiP mode
controllerHandler.disableSensors();
Expand All @@ -619,6 +633,10 @@ public void onConfigurationChanged(Configuration newConfig) {

notificationOverlayView.setVisibility(requestedNotificationOverlayVisibility);

if (prefConfig.showKeyboardToggleButton) {
keyboardToggleButtonView.setVisibility(View.VISIBLE);
}

// Enable sensors again after exiting PiP
controllerHandler.enableSensors();

Expand Down Expand Up @@ -1998,11 +2016,12 @@ else if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMask
int eventX = (int)(event.getX(actionIndex) + xOffset);
int eventY = (int)(event.getY(actionIndex) + yOffset);

// Special handling for 3 finger gesture
if (event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN &&
event.getPointerCount() == 3) {
// Three fingers down
threeFingerDownTime = event.getEventTime();
// Special handling for the configurable keyboard-toggle tap gesture
if (prefConfig.keyboardToggleFingers != 0 &&
event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN &&
event.getPointerCount() == prefConfig.keyboardToggleFingers) {
// All configured fingers down
keyboardToggleDownTime = event.getEventTime();

// Cancel the first and second touches to avoid
// erroneous events
Expand Down Expand Up @@ -2041,8 +2060,8 @@ else if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMask
if (event.getPointerCount() == 1 &&
(Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || (event.getFlags() & MotionEvent.FLAG_CANCELED) == 0)) {
// All fingers up
if (event.getEventTime() - threeFingerDownTime < THREE_FINGER_TAP_THRESHOLD) {
// This is a 3 finger tap to bring up the keyboard
if (event.getEventTime() - keyboardToggleDownTime < KEYBOARD_TOGGLE_TAP_THRESHOLD) {
// This is a tap with the configured finger count to bring up the keyboard
toggleKeyboard();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public enum AnalogStickForScrolling {
private static final String VIBRATE_FALLBACK_STRENGTH_PREF_STRING = "seekbar_vibrate_fallback_strength";
private static final String FLIP_FACE_BUTTONS_PREF_STRING = "checkbox_flip_face_buttons";
private static final String TOUCHSCREEN_TRACKPAD_PREF_STRING = "checkbox_touchscreen_trackpad";
private static final String KEYBOARD_TOGGLE_FINGERS_PREF_STRING = "list_keyboard_toggle_fingers";
private static final String SHOW_KEYBOARD_BUTTON_PREF_STRING = "checkbox_show_keyboard_button";
private static final String LATENCY_TOAST_PREF_STRING = "checkbox_enable_post_stream_toast";
private static final String FRAME_PACING_PREF_STRING = "frame_pacing";
private static final String ABSOLUTE_MOUSE_MODE_PREF_STRING = "checkbox_absolute_mouse_mode";
Expand Down Expand Up @@ -98,6 +100,8 @@ public enum AnalogStickForScrolling {
private static final int DEFAULT_VIBRATE_FALLBACK_STRENGTH = 100;
private static final boolean DEFAULT_FLIP_FACE_BUTTONS = false;
private static final boolean DEFAULT_TOUCHSCREEN_TRACKPAD = true;
private static final String DEFAULT_KEYBOARD_TOGGLE_FINGERS = "3";
private static final boolean DEFAULT_SHOW_KEYBOARD_BUTTON = false;
private static final String DEFAULT_AUDIO_CONFIG = "2"; // Stereo
private static final boolean DEFAULT_LATENCY_TOAST = false;
private static final String DEFAULT_FRAME_PACING = "latency";
Expand Down Expand Up @@ -146,6 +150,8 @@ public enum AnalogStickForScrolling {
public boolean vibrateFallbackToDevice;
public int vibrateFallbackToDeviceStrength;
public boolean touchscreenTrackpad;
public int keyboardToggleFingers;
public boolean showKeyboardToggleButton;
public MoonBridge.AudioConfiguration audioConfiguration;
public int framePacing;
public boolean absoluteMouseMode;
Expand Down Expand Up @@ -593,6 +599,8 @@ else if (audioConfig.equals("51")) {
config.vibrateFallbackToDeviceStrength = prefs.getInt(VIBRATE_FALLBACK_STRENGTH_PREF_STRING, DEFAULT_VIBRATE_FALLBACK_STRENGTH);
config.flipFaceButtons = prefs.getBoolean(FLIP_FACE_BUTTONS_PREF_STRING, DEFAULT_FLIP_FACE_BUTTONS);
config.touchscreenTrackpad = prefs.getBoolean(TOUCHSCREEN_TRACKPAD_PREF_STRING, DEFAULT_TOUCHSCREEN_TRACKPAD);
config.keyboardToggleFingers = Integer.parseInt(prefs.getString(KEYBOARD_TOGGLE_FINGERS_PREF_STRING, DEFAULT_KEYBOARD_TOGGLE_FINGERS));
config.showKeyboardToggleButton = prefs.getBoolean(SHOW_KEYBOARD_BUTTON_PREF_STRING, DEFAULT_SHOW_KEYBOARD_BUTTON);
config.enableLatencyToast = prefs.getBoolean(LATENCY_TOAST_PREF_STRING, DEFAULT_LATENCY_TOAST);
config.absoluteMouseMode = prefs.getBoolean(ABSOLUTE_MOUSE_MODE_PREF_STRING, DEFAULT_ABSOLUTE_MOUSE_MODE);
config.enableAudioFx = prefs.getBoolean(ENABLE_AUDIO_FX_PREF_STRING, DEFAULT_ENABLE_AUDIO_FX);
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/bg_keyboard_toggle_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#80000000" />
</shape>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_keyboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="256dp"
android:height="256dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:pathData="M20,5H4C2.9,5,2,5.9,2,7v10c0,1.1,0.9,2,2,2h16c1.1,0,2,-0.9,2,-2V7C22,5.9,21.1,5,20,5z M4,7.5h16v1.5h-16V7.5z M4,10.5h16v1.5h-16V10.5z M6,13.5h12v2h-12V13.5z" />
</vector>
15 changes: 15 additions & 0 deletions app/src/main/res/layout/activity_game.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,19 @@
android:preferKeepClear="true"
android:visibility="gone" />

<ImageButton
android:id="@+id/keyboardToggleButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="bottom|right"
android:padding="10dp"
android:src="@drawable/ic_keyboard"
android:background="@drawable/bg_keyboard_toggle_button"
android:contentDescription="@string/title_checkbox_show_keyboard_button"
android:preferKeepClear="true"
android:visibility="gone" />

</merge>
11 changes: 11 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,15 @@
<item>right</item>
<item>left</item>
</string-array>

<string-array name="keyboard_toggle_fingers_names">
<item>@string/keyboard_toggle_fingers_disabled</item>
<item>@string/keyboard_toggle_fingers_3</item>
<item>@string/keyboard_toggle_fingers_4</item>
</string-array>
<string-array name="keyboard_toggle_fingers_values" translatable="false">
<item>0</item>
<item>3</item>
<item>4</item>
</string-array>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@
<string name="summary_checkbox_absolute_mouse_mode">This can make mouse acceleration behave more naturally for remote desktop usage, but it is incompatible with many games.</string>
<string name="title_checkbox_mouse_nav_buttons">Enable back and forward mouse buttons</string>
<string name="summary_checkbox_mouse_nav_buttons">Enabling this option may break right clicking on some buggy devices</string>
<string name="title_list_keyboard_toggle_fingers">On-screen keyboard gesture</string>
<string name="summary_list_keyboard_toggle_fingers">Number of fingers to tap with to show/hide the on-screen keyboard. Change this if your device intercepts the default gesture for a system action, or disable it entirely.</string>
<string name="keyboard_toggle_fingers_disabled">Disabled</string>
<string name="keyboard_toggle_fingers_3">3 fingers</string>
<string name="keyboard_toggle_fingers_4">4 fingers</string>
<string name="title_checkbox_show_keyboard_button">Show on-screen keyboard button</string>
<string name="summary_checkbox_show_keyboard_button">Shows a small button over the stream to show/hide the on-screen keyboard. Useful if your device doesn\'t support the tap gesture above.</string>

<string name="category_on_screen_controls_settings">On-screen Controls Settings</string>
<string name="title_checkbox_show_onscreen_controls">Show on-screen controls</string>
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@
android:title="@string/title_checkbox_absolute_mouse_mode"
android:summary="@string/summary_checkbox_absolute_mouse_mode"
android:defaultValue="false" />
<ListPreference
android:key="list_keyboard_toggle_fingers"
android:title="@string/title_list_keyboard_toggle_fingers"
android:summary="@string/summary_list_keyboard_toggle_fingers"
android:entries="@array/keyboard_toggle_fingers_names"
android:entryValues="@array/keyboard_toggle_fingers_values"
android:defaultValue="3" />
<CheckBoxPreference
android:key="checkbox_show_keyboard_button"
android:title="@string/title_checkbox_show_keyboard_button"
android:summary="@string/summary_checkbox_show_keyboard_button"
android:defaultValue="false" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/category_on_screen_controls_settings"
android:key="category_onscreen_controls">
Expand Down