controller-detector

Detect and recognize input controllers (HID) and receive feedback based on connectivity changes.

License

License

Categories

Categories

IDE Development Tools
GroupId

GroupId

com.aptoide.pt
ArtifactId

ArtifactId

controller-detector
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

aar
Description

Description

controller-detector
Detect and recognize input controllers (HID) and receive feedback based on connectivity changes.
Project URL

Project URL

https://github.com/gmartinsribeiro/controller-detector
Source Code Management

Source Code Management

https://github.com/gmartinsribeiro/controller-detector

Download controller-detector

How to add to project

<!-- https://jarcasting.com/artifacts/com.aptoide.pt/controller-detector/ -->
<dependency>
    <groupId>com.aptoide.pt</groupId>
    <artifactId>controller-detector</artifactId>
    <version>1.0.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.aptoide.pt/controller-detector/
implementation 'com.aptoide.pt:controller-detector:1.0.0'
// https://jarcasting.com/artifacts/com.aptoide.pt/controller-detector/
implementation ("com.aptoide.pt:controller-detector:1.0.0")
'com.aptoide.pt:controller-detector:aar:1.0.0'
<dependency org="com.aptoide.pt" name="controller-detector" rev="1.0.0">
  <artifact name="controller-detector" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.aptoide.pt', module='controller-detector', version='1.0.0')
)
libraryDependencies += "com.aptoide.pt" % "controller-detector" % "1.0.0"
[com.aptoide.pt/controller-detector "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
com.android.support » appcompat-v7 jar 24.0.0

Project Modules

There are no modules declared in this project.

Controller Detector

alt tag

Detect and recognize input controllers (HID) and receive feedback based on connectivity changes.

Installation

You can easily install this module using JCenter or Maven, by adding the following dependency to your build.gradle file:

dependencies {
 compile 'com.aptoide.pt:controller-detector:1.0.0'
 //...
}

Usage

Apart from this section, a complete example can be downloaded from this repo.

You need to create a InputDeviceConnector object and implement ControllerListener interface. For InputDeviceConnector you also need to:

  • Implement startDetectingDevices() to start detecting controllers (e.g. onCreate).
  • Implement stopDetectingDevices() to stop detecting controllers (e.g. onDestroy).
public class MainActivity extends AppCompatActivity implements ControllerListener {
    private InputDeviceConnector connector;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // ...
        connector = new InputDeviceConnector(getApplicationContext(), this);
        connector.startDetectingDevices();
        // ...
    }

    @Override
    protected void onDestroy(){
        super.onDestroy();
        // ...
        connector.stopDetectingDevices();
        // ...
    }
    
    @Override
    public void onControllerChange(DeviceController controller) {
        // ...
    }

    @Override
    public void onControllerConnect(DeviceController controller) {
        // ...
    }

    @Override
    public void onControllerDisconnect(int id) {
        // ...
    }
}

Notice onControllerDisconnect only an id is passed since the Device has been disconnected. This is the same id that you retrieve from DeviceController.getDevice().getId().

DeviceController

DeviceController defines two useful attributes that you can retrieve: an InputDevice and a DeviceInputType (enum).

For InputDevice you can read further here.

For DeviceInputType, it defines the following values: DPAD, GAMEPAD, KEYBOARD, MOUSE, STYLUS, TOUCHPAD, TOUCHSCREEN, TRACKBALL, TVREMOTE, UNRECOGNIZED

Tested Devices

An analysis of several devices was made in order to check the correctness of the recognition algorithm. This analysis and the list of confirmed supported devices is here.

Versions

Version
1.0.0