Steps:
-Open Es file explorer go to /system/usr/keylayout/ make a copy of Generic.kl
-Open Terminal enter the command cat /proc/bus/input/devices now you will see the vendor id and product id codes rename the Generic.kl file like Vendor_[VendorID]_Product_[ProductID].kl of your gamepad vendor and product
Ex:
I: Bus=0003 Vendor=0c45 Product=7403 Version=0100 N: Name="SONiX USB Device" P: Phys=usb-usb20_host-1.1.1/input0 S: Sysfs=/devices/platform/usb20_host/usb2/2-1/2-1.1/2-1.1.1/2-1.1.1:1.0/input/input9 U: Uniq= H: Handlers=sysrq kbd event1 keychord |
-install keytest.apk open it now press ex A button you will get the scanCode ex: (scanCode=290)
you will need to do this to all your keys write them down to a paper it is easy like this :
BUTTON_A 290
BUTTON_B 289
BUTTON_X 291
BUTTON_Y 288
BUTTON_L1 292
BUTTON_R1 293
BUTTON_L2 294
BUTTON_R2 295
BUTTON_SELECT 296
BUTTON_START 297
if your gamepad does not have A B X Y and it is with number or ps style etc here is and ex photo for the keys order

-now open the Vendor_Product.kl file you have created with es text editor or any other editor
find every scanCode line and edit it like this :
scanCode / Android function key
key 290 BUTTON_A
key 289 BUTTON_B
key 291 BUTTON_X
key 288 BUTTON_Y
key 292 BUTTON_L1
key 293 BUTTON_R1
key 294 BUTTON_L2
key 295 BUTTON_R2
key 296 BUTTON_SELECT
key 297 BUTTON_START
-now save the file copy it to /system/usr/keylayout/ set permissions to (-rw-r–r–)
-reboot device now you will have a compatible gamepad for the D-pad and sticks they work from default
-Tested on Leo's Fortune , Prince of Persia Shadow & Flame ,Beach Buggy Racing, GTA III
NOTE this is for games that support gamepads
Comment