Skip to content

Commit

Permalink
game menu: clean-up open on back navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Karim Mreisi committed Feb 15, 2023
1 parent e195957 commit 48f521b
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions app/src/main/java/com/limelight/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,16 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {

@Override
public boolean handleKeyDown(KeyEvent event) {
// Pass-through virtual navigation keys
// Handle (virtual) Navigation Keys
if ((event.getFlags() & KeyEvent.FLAG_VIRTUAL_HARD_KEY) != 0) {
// Show Game Menu on back action instead of finishing the activity, the user has to
// select "Disconnect" within the game menu to actually disconnect
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
showGameMenu(null);
return true;
}

// Pass-through other navigation keys
return false;
}

Expand Down Expand Up @@ -2270,16 +2278,7 @@ public void showGameMenu(GameInputDevice device) {
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
switch (keyEvent.getAction()) {
case KeyEvent.ACTION_DOWN:
boolean handled = handleKeyDown(keyEvent);
if (handled)
return true;

// Intercept back key event before android handles it
// Always handle the request, the user has to select "Disconnect" within the game menu to actually disconnect
if (keyCode == keyEvent.KEYCODE_BACK) {
showGameMenu(null);
return true;
}
return handleKeyDown(keyEvent);
case KeyEvent.ACTION_UP:
return handleKeyUp(keyEvent);
default:
Expand Down

0 comments on commit 48f521b

Please sign in to comment.