diff --git a/shell/android/src/com/reicast/emulator/periph/MOGAInput.java b/shell/android/src/com/reicast/emulator/periph/MOGAInput.java
index a587512ba..78f506488 100644
--- a/shell/android/src/com/reicast/emulator/periph/MOGAInput.java
+++ b/shell/android/src/com/reicast/emulator/periph/MOGAInput.java
@@ -90,7 +90,8 @@ public final class MOGAInput
.getDefaultSharedPreferences(act.getApplicationContext());
mController = Controller.getInstance(act);
- mController.init();
+// mController.init();
+ MogaHack.init(mController, this.act);
mListener = new ExampleControllerListener();
mController.setListener(mListener, new Handler());
}
diff --git a/shell/android/src/com/reicast/emulator/periph/MogaHack.java b/shell/android/src/com/reicast/emulator/periph/MogaHack.java
new file mode 100644
index 000000000..9e28f7331
--- /dev/null
+++ b/shell/android/src/com/reicast/emulator/periph/MogaHack.java
@@ -0,0 +1,118 @@
+/**
+ * Mupen64PlusAE, an N64 emulator for the Android platform
+ *
+ * Copyright (C) 2013 Paul Lamb
+ *
+ * This file is part of Mupen64PlusAE.
+ *
+ * Mupen64PlusAE is free software: you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Mupen64PlusAE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Mupen64PlusAE. If
+ * not, see
+ * {@code Service Intent must be explicit: Intent { act=com.bda.controller.IControllerService } } + *+ * + * @see MOGA developer site + * @see + * Discussion on explicit intents + */ +public class MogaHack +{ + public static void init( Controller controller, Context context ) + { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) + { + boolean mIsBound = false; + java.lang.reflect.Field fIsBound = null; + android.content.ServiceConnection mServiceConnection = null; + java.lang.reflect.Field fServiceConnection = null; + try + { + Class> cMogaController = controller.getClass(); + fIsBound = cMogaController.getDeclaredField( "mIsBound" ); + fIsBound.setAccessible( true ); + mIsBound = fIsBound.getBoolean( controller ); + fServiceConnection = cMogaController.getDeclaredField( "mServiceConnection" ); + fServiceConnection.setAccessible( true ); + mServiceConnection = ( android.content.ServiceConnection ) fServiceConnection.get( controller ); + } + catch( NoSuchFieldException e ) + { + Log.e( "MogaHack", "MOGA Lollipop Hack NoSuchFieldException (get)", e ); + } + catch( IllegalAccessException e ) + { + Log.e( "MogaHack", "MOGA Lollipop Hack IllegalAccessException (get)", e ); + } + catch( IllegalArgumentException e ) + { + Log.e( "MogaHack", "MOGA Lollipop Hack IllegalArgumentException (get)", e ); + } + if( ( !mIsBound ) && ( mServiceConnection != null ) ) + { + // Convert implicit intent to explicit intent, see http://stackoverflow.com/a/26318757 + Intent intent = new Intent( IControllerService.class.getName() ); + List