moonlight-stream / moonlight-android

GameStream client for Android
GNU General Public License v3.0
3.16k stars 503 forks source link

[Feature request]: how to send the keyboard Button signal "ESC" to PC in the game? #1332

Open daxue2017 opened 2 months ago

daxue2017 commented 2 months ago

when open the remote connection for a game, then press the keyboard button "ESC" to quit the game, but the remote connection is broked and moonlight back to the other window.

so how to send the keyboard Button signal "ESC" to PC in the game?

should i modify some code in the file "game.java"?

i add the callback function in the game.java, but it seems can not send the signal to the pc, is it right ?, as follows

@Override
public void onBackPressed() {
    if(!prefConfig.touchscreenTrackpad){
        byte modifier = 0;
        short translated = keyboardTranslator.translate(KeyEvent.KEYCODE_ESCAPE, KeyCharacterMap.VIRTUAL_KEYBOARD);
        conn.sendKeyboardInput(translated, KeyboardPacket.KEY_UP, modifier, keyboardTranslator.hasNormalizedMapping(KeyEvent.KEYCODE_ESCAPE, KeyCharacterMap.FULL) ? 0 : MoonBridge.SS_KBE_FLAG_NON_NORMALIZED);
        return;
    }
    super.onBackPressed();
}

i think may be should provide some interface or funtion to send the keyboard key signals

StanLindsey commented 2 weeks ago

There's a pr for adding an interface which looks to be on the agenda to being merged in the future

If you're still able to open a stream I use Hackers keyboard to get the ESC key to be pass through.