Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/show keyboard android tv #1170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions app/src/main/java/com/limelight/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ protected void onCreate(Bundle savedInstanceState) {
// Inflate the content
setContentView(R.layout.activity_game);

// Hack: allows use keyboard by dpad or controller
getWindow().getDecorView().findViewById(android.R.id.content).setFocusable(true);

// Start the spinner
spinner = SpinnerDialog.displayDialog(this, getResources().getString(R.string.conn_establishing_title),
getResources().getString(R.string.conn_establishing_msg), true);
Expand Down Expand Up @@ -1413,6 +1416,10 @@ private TouchContext getTouchContext(int actionIndex)
@Override
public void toggleKeyboard() {
LimeLog.info("Toggling keyboard overlay");

// Hack: allows use keyboard by dpad or controller
streamView.clearFocus();

InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.toggleSoftInput(0, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
private static final int MAXIMUM_BUMPER_UP_DELAY_MS = 100;

private static final int START_DOWN_TIME_MOUSE_MODE_MS = 750;
private static final int SELECT_DOWN_TIME_SHOW_KEYBOARD_MS = 750;

private static final int MINIMUM_BUTTON_DOWN_TIME_MS = 25;

Expand Down Expand Up @@ -1517,6 +1518,10 @@ public boolean handleButtonUp(KeyEvent event) {
break;
case KeyEvent.KEYCODE_BACK:
case KeyEvent.KEYCODE_BUTTON_SELECT:
if ((context.inputMap & ControllerPacket.PLAY_FLAG) != 0 &&
event.getEventTime() - context.selectDownTime > ControllerHandler.SELECT_DOWN_TIME_SHOW_KEYBOARD_MS) {
gestures.toggleKeyboard();
}
context.inputMap &= ~ControllerPacket.BACK_FLAG;
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
Expand Down Expand Up @@ -1660,6 +1665,9 @@ public boolean handleButtonDown(KeyEvent event) {
case KeyEvent.KEYCODE_BACK:
case KeyEvent.KEYCODE_BUTTON_SELECT:
context.hasSelect = true;
if (event.getRepeatCount() == 0) {
context.selectDownTime = event.getEventTime();
}
context.inputMap |= ControllerPacket.BACK_FLAG;
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
Expand Down Expand Up @@ -1962,6 +1970,7 @@ class InputDeviceContext extends GenericControllerContext {
public long lastRbUpTime = 0;

public long startDownTime = 0;
public long selectDownTime = 0;

@Override
public void destroy() {
Expand Down