Sunday, May 12, 2013

Connect Joystick to play games on android

All most all of the android v4.0 and higher tablets are USB host enabled and comes with kernel modules of  ps3/xbox joystick etc but i had a cheap chinese made USB joystick (DragonRise gamepad) which i wanted to connect and play games with on my momo9 tablet with CM10 and there was no kernel module available for my requirement so here is my story how i compiled kernel module.

  1. Requires a root access.
  2. Joystick and micro USB OTG cable.
  3. Android Terminal emulator and busybox.
First i verified that the joystick is being detected as a USB device using the lsusb command. I connected the joystick to the tablet using a micro USB OTG cable and run lsusb.

Then i started searching for the kernel module of my joystick and found many versions of generic joydev.ko but none of them were compatible for my device. When i used dmesg command to determine the cause for one of such module i found that the mismatch of vermagic which means that an android (linux) kernel module can be loaded only if it is compiled for the same linux version and if it is compiled for the CPU. Using uname -a command i found the linux kernel version and CPU which powers my android.

Once the kernel version is determined i again google for kernel module of my joystick which are build for my kernel and CPU but i was not able to find joystick kernel module for my momo9c with CM10 so i downloaded allwinner kernel source from and the Sourcery CodeBench Lite edition from and then compiled the kernel module. I compiled the kernel module on Backtrack5 virtual machine using following commands

make ARCH=arm sun4i_crane_defconfig
make menuconfig ARCH=arm 
make modules ARCH=arm CROSS_COMPILE=/sourcery-arm-toolchain/bin/arm-none-eabi

Then i moved the compiled module hid-dr.ko to the tablet to /system/modules/lib and loaded the module using insmod command and verified the new input joystick device using ls -l /dev/js? command. At last i downloaded a generic USB joystick android keylayout file for the joystick and moved it into the /system/usr/keylayout directoy.

Then i configured input devices and key mappings in nesoid emulator and started playing my favorite game on tablet with joystick. Though i have not tested but i am sure that if two joysticks are connected using USB OTG cable and USB Hub then multi-player games can also be played.


My compiled hid-dr.ko kernel module for Linux and the keylayout file can be downloaded from contains hid-dr.ko and Vendor_0079_Product_0006.kl files.

Happy gaming!!! and enjoy :)


Anonymous said...

hi sir

i have swipe 3d tablet ... will your files work in my tablet or will i have to do same step like you ? because these was very hard step for me ..please guide me to use gamepad in my tablet because it is quantum usb gamepad and tablet is not email id is

alvin aguilar said...

heY! you're great man! actually i tried to follow the same procedure for my kata t1 tablet rk29 but i was lost in the middle.sorry, because i don't know much about scipts.i don't know much about programmings.please help me out on how to create my custom kernel so i can play games using generic gamepad too.thanks!i hope yuo'll respond to my message.

umesh said...

How can i connect ordinary(Chinese) gamepad into my xperia C mobile..........

I can connect it but cannot use fire buttons like button 1,2,3,4,......

Anonymous said...

Did you get your solution? I'm also having the same gamepad... want help.

newone said...

Some phones and tablets do not support this function so it is wise to search the web to find if your device is compatible with this function. I explained a little as to why I was looking for an alternative to buying one online and let me go a little more in depth as to why I chose the DIY route. The top two reasons are, it would be cheaper and I wouldn't have to wait for it, You can make one for under 2 dollars with stuff you more than likely have lying around your house! USB OTG (USB On The Go) is a standard that enables mobile devices to talk to one another. Traditionally mobile devices could only connect to a Mac/PC by USB, but USB OTG makes it possible for devices to connect directly to each other.And that's not all USB OTG can do. By enabling your device to act as a USB host – that is, to be the boss of other devices that you connect to it – you can use additional hardware such as storage, keyboards or even musical instruments together with your handset.