From 5626e9663b5fae61510768fbdef2ce7d7d417c99 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 31 May 2014 16:33:51 -0400 Subject: [PATCH] Fix Ouya controller combos and bump the version to 2.2.1.2 --- AndroidManifest.xml | 4 +- .../binding/input/ControllerHandler.java | 44 ++++++++++++++----- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 4e25bcbe..2b4a003e 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@  + android:versionCode="16" + android:versionName="2.2.1.2" > mappings = new HashMap(); private NvConnection conn; @@ -356,9 +368,11 @@ public class ControllerHandler { break; case KeyEvent.KEYCODE_BUTTON_L1: inputMap &= ~ControllerPacket.LB_FLAG; + lastLbUpTime = SystemClock.uptimeMillis(); break; case KeyEvent.KEYCODE_BUTTON_R1: inputMap &= ~ControllerPacket.RB_FLAG; + lastRbUpTime = SystemClock.uptimeMillis(); break; case KeyEvent.KEYCODE_BUTTON_THUMBL: inputMap &= ~ControllerPacket.LS_CLK_FLAG; @@ -386,19 +400,28 @@ public class ControllerHandler { inputMap &= ~ControllerPacket.BACK_FLAG; emulatingButtonFlags &= ~ControllerHandler.EMULATING_SELECT; + + try { + Thread.sleep(EMULATED_SELECT_UP_DELAY_MS); + } catch (InterruptedException e) {} } } // Check if we're emulating the special button if ((emulatingButtonFlags & ControllerHandler.EMULATING_SPECIAL) != 0) { - // If either start or select is up, the special button comes up too + // If either start or select and RB is up, the special button comes up too if ((inputMap & ControllerPacket.PLAY_FLAG) == 0 || - (inputMap & ControllerPacket.BACK_FLAG) == 0) + ((inputMap & ControllerPacket.BACK_FLAG) == 0 && + (inputMap & ControllerPacket.RB_FLAG) == 0)) { inputMap &= ~ControllerPacket.SPECIAL_BUTTON_FLAG; emulatingButtonFlags &= ~ControllerHandler.EMULATING_SPECIAL; + + try { + Thread.sleep(EMULATED_SPECIAL_UP_DELAY_MS); + } catch (InterruptedException e) {} } } @@ -478,25 +501,22 @@ public class ControllerHandler { // Start+LB acts like select for controllers with one button if ((inputMap & ControllerPacket.PLAY_FLAG) != 0 && - (inputMap & ControllerPacket.LB_FLAG) != 0) + ((inputMap & ControllerPacket.LB_FLAG) != 0 || + SystemClock.uptimeMillis() - lastLbUpTime <= MAXIMUM_BUMPER_UP_DELAY_MS)) { inputMap &= ~(ControllerPacket.PLAY_FLAG | ControllerPacket.LB_FLAG); inputMap |= ControllerPacket.BACK_FLAG; - // If RB is also pressed, keep the start button down - if ((inputMap & ControllerPacket.RB_FLAG) != 0) - { - inputMap |= ControllerPacket.PLAY_FLAG; - } - emulatingButtonFlags |= ControllerHandler.EMULATING_SELECT; } - // We detect select+start as the special button combo - if ((inputMap & ControllerPacket.BACK_FLAG) != 0 && + // We detect select+start or start+RB as the special button combo + if (((inputMap & ControllerPacket.RB_FLAG) != 0 || + (SystemClock.uptimeMillis() - lastRbUpTime <= MAXIMUM_BUMPER_UP_DELAY_MS) || + (inputMap & ControllerPacket.BACK_FLAG) != 0) && (inputMap & ControllerPacket.PLAY_FLAG) != 0) { - inputMap &= ~(ControllerPacket.BACK_FLAG | ControllerPacket.PLAY_FLAG); + inputMap &= ~(ControllerPacket.BACK_FLAG | ControllerPacket.PLAY_FLAG | ControllerPacket.RB_FLAG); inputMap |= ControllerPacket.SPECIAL_BUTTON_FLAG; emulatingButtonFlags |= ControllerHandler.EMULATING_SPECIAL;