Developer Console

Migrate from Google Input SDK

The Amazon Input SDK helps your app surface keyboard and mouse input controls to your users on various devices. The Google Input SDK exclusively targets Google Play Games enabled devices and the service that handles the help invocation. The Amazon Input SDK supports all compatible Android devices and puts you in control of displaying the controls help screen.

What is Google Input SDK?

The Google Input SDK is for games that work on Google Play Games. With the Google Input SDK, a game can register its keyboard and mouse controls and Google Play Games displays the controls when requested. The Google Input SDK is only available on Google Play Games enabled devices and doesn't work on Amazon devices, Windows 11, or other Android devices.

Migrate to Amazon Input SDK

If your app is already integrated with the Google Input SDK, consider migrating to the Amazon Input SDK. The Amazon Input SDK uses similar interfaces to that of the Google Input SDK. Therefore, after updating the import statements, most of the code you wrote to support the Google Input SDK you can use for the Amazon Input SDK with minimal changes.

Steps to add support for Amazon Input SDK

To add support for the Amazon Input SDK, use the following steps.

  1. Add the Amazon Input SDK as a dependency to your project. For details, see Add the Input SDK to your project.
  2. Implement the InputMappingProvider interface. The following code shows how to create an input mapping provider in Java.
     public class CustomInputMapProvider implements InputMappingProvider {
    
         @Override
         public InputMap onProvideInputMap() {
             InputAction jumpAction = InputAction.create(
                 "Jump",
                 MyGameActions.JUMP, // MyGameActions here is an enumeration in the game
                 InputControls.create(
                         Collections.singletonList(KeyEvent.KEYCODE_SPACE),
                         Collections.emptyList()
                 )
             );
                
             InputAction moveAction = InputAction.create(
                 "Move",
                 MyGameActions.MOVE,
                 InputControls.create(
                         Collections.emptyList(),
                         Collections.singletonList(InputControls.MOUSE_MOVEMENT)
                 )
             );
                
             InputGroup movementInputGroup = InputGroup.create("Basic Movement",
                 Arrays.asList(moveAction, jumpAction));
                    
             return InputMap.create(Arrays.asList(movementInputGroup),
                 MouseSettings.create(true, true));
         }
     }
    
  3. Depending on the device environment, register an input map from the Amazon Input SDK or the Google Input SDK. For details, see Support both Amazon Input SDK and Google Input SDK.
  4. For the Amazon Input SDK, handle the help screen invocation from within the app. This isn't required for the Google Input SDK. Make sure to only enable this in scenarios where your app uses the Amazon Input SDK to register an input map.

For more details on the APIs, see Amazon Input SDK.

Support both Amazon Input SDK and Google Input SDK

The Google Input SDK works with the Google Play Games service. If you want to support both Amazon Input SDK and Google Input SDK in your app, the Appstore recommends that you enable the Amazon Input SDK on devices where Google Play Games service is unavailable. This includes Amazon Fire devices, Windows 11, and several Android devices.

To do this, determine if the Google Play Games API is available, as shown in the following example.

 

Copied to clipboard.

boolean isGPGEnabled = getPackageManager()
    .hasSystemFeature("com.google.android.play.feature.HPE_EXPERIENCE");

if (isGPGEnabled) {
    // initialize Google Input SDK input client
    com.google.android.libraries.play.games.inputmapping
        .InputMappingClient inputMappingClient = com.google.android.libraries.play
            .games.inputmapping.Input.getInputMappingClient(this);
inputMappingClient.setInputMappingProvider(new PayGamesInputMapProvider());
} else {
    // initialize Amazon Input SDK input client
    com.amazon.device.inputmapping.input.InputMappingClient inputMappingClient 
        = com.amazon.device.inputmapping.Input.getInputMappingClient(this)
    inputMappingClient.setInputMappingProvider(new CustomInputMapProvider());
}

 

Copied to clipboard.

val IsGooglePlayGamesEnabled = packageManager
    .hasSystemFeature("com.google.android.play.feature.HPE_EXPERIENCE");

if (IsGooglePlayGamesEnabled) {
    // initialize Google Input SDK input client
    val inputMappingClient = com.google.android.libraries.play
            .games.inputmapping.Input.getInputMappingClient(this);
    inputMappingClient.setInputMappingProvider(PayGamesInputMapProvider());
} else {
    // initialize Amazon Input SDK input client
    val inputMappingClient = com.amazon.device.inputmapping.input.Input
        .getInputMappingClient(this);
    inputMappingClient.inputMappingProvider = CustomInputMapProvider();
}

 

Copied to clipboard.

using AmazonInputSDK = Amazon.InputSDK.Input;
using GoogleInputSDK = Google.Play.InputMapping;

//inside the init method
public static bool IsGooglePlayGamesEnabled => PackageManager.Call<bool>("hasSystemFeature",
    "com.google.android.play.feature.HPE_EXPERIENCE");
if (isGooglePlayGamesEnabled){
    var inputMappingClient = GoogleInputSDK.GetInputMappingClient();
    inputMappingClient.SetInputMappingProvider(new MyInputMappingProvider());
else {
    var inputMappingClient = AmazonInputSDK.GetInputMappingClient();
    inputMappingClient.SetInputMappingProvider(new MyInputMappingProvider());
}

Help screen invocation

With the Google Input SDK, the Google Play Games service controls when to show the help screen. With the Amazon Input SDK, you control how to handle the help screen invocation.

To display the help screen, consider displaying a visual element to the user that opens the help screen when clicked. You can place the visual indicator either within the game window, or in a separate screen, such as a preferences or controls page.


Last updated: Mar 05, 2024