mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 19:42:45 +00:00
Fix back button press on the soft UI buttons. Make back+start emulate the steam overlay button.
This commit is contained in:
parent
c9ad9ab407
commit
745da05ad3
@ -86,6 +86,10 @@ public class Game extends Activity implements OnGenericMotionListener, OnTouchLi
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
|
||||
// Skip keyboard and virtual button events
|
||||
if (event.getSource() == InputDevice.SOURCE_KEYBOARD)
|
||||
return super.onKeyDown(keyCode, event);
|
||||
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_BUTTON_START:
|
||||
case KeyEvent.KEYCODE_MENU:
|
||||
@ -134,6 +138,15 @@ public class Game extends Activity implements OnGenericMotionListener, OnTouchLi
|
||||
default:
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
// We detect back+start as the special button combo
|
||||
if ((inputMap & NvControllerPacket.BACK_FLAG) != 0 &&
|
||||
(inputMap & NvControllerPacket.PLAY_FLAG) != 0)
|
||||
{
|
||||
inputMap &= ~(NvControllerPacket.BACK_FLAG | NvControllerPacket.PLAY_FLAG);
|
||||
inputMap |= NvControllerPacket.SPECIAL_BUTTON_FLAG;
|
||||
}
|
||||
|
||||
sendControllerInputPacket();
|
||||
return true;
|
||||
}
|
||||
@ -141,6 +154,10 @@ public class Game extends Activity implements OnGenericMotionListener, OnTouchLi
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
|
||||
// Skip keyboard and virtual button events
|
||||
if (event.getSource() == InputDevice.SOURCE_KEYBOARD)
|
||||
return super.onKeyUp(keyCode, event);
|
||||
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_BUTTON_START:
|
||||
case KeyEvent.KEYCODE_MENU:
|
||||
@ -189,6 +206,14 @@ public class Game extends Activity implements OnGenericMotionListener, OnTouchLi
|
||||
default:
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
// If one of the two is up, the special button comes up too
|
||||
if ((inputMap & NvControllerPacket.BACK_FLAG) == 0 ||
|
||||
(inputMap & NvControllerPacket.PLAY_FLAG) == 0)
|
||||
{
|
||||
inputMap &= ~NvControllerPacket.SPECIAL_BUTTON_FLAG;
|
||||
}
|
||||
|
||||
sendControllerInputPacket();
|
||||
return true;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ public class NvControllerPacket extends NvInputPacket {
|
||||
public static final short BACK_FLAG = 0x0020;
|
||||
public static final short LS_CLK_FLAG = 0x0040;
|
||||
public static final short RS_CLK_FLAG = 0x0080;
|
||||
public static final short SPECIAL_BUTTON_FLAG = 0x0400;
|
||||
|
||||
public static final short PAYLOAD_LENGTH = 24;
|
||||
public static final short PACKET_LENGTH = PAYLOAD_LENGTH +
|
||||
|
Loading…
x
Reference in New Issue
Block a user