I developer a APP Android which can detect the type of device (smartphone normal or gamepad). I've done a test in HTC ONE M7 without the connection with a gamepad. But my code tell me that it's a gamePad.
This is my code:
InputDevice dev = InputDevice.getDevice(deviceId);
int sources = dev.getSources();
// Verify that the device has gamepad buttons, control sticks, or both.
if (((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) || ((sources & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK))
{
Log.d(TAG, "device detected : Game Pad");
}
And for HTC ONE M7's deviceID = 2, I found that the ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) is true. That's why HTC is considered as a GamePad.
Anyone knows Why ?