'How do you emulate a game pad input to an Android device?

So I'm trying to create an application that can emulate a gamepad on device, kinda like how vjoy programs work for windows with a HID input emulator, but I can't figure out how, the best idea I've tried so far is to use a rubber ducky to emulate it physically. How can I simulate inputs to the android controller API otherwise?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source