Connect Joystick to play games on android

本文介绍如何为运行Android 4.0及以上版本的平板电脑编译内核模块,以便连接并使用廉价的USB游戏手柄进行游戏。文章详细记录了从验证设备到编译模块的过程,并提供了具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

Prerequisites
  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  https://github.com/christiantroy/linux-allwinner  and the Sourcery CodeBench Lite edition from  http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/  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 3.0.6.36+ and the keylayout file can be downloaded from
https://dl.dropboxusercontent.com/u/48560079/joystick_hid_dr.zip  contains hid-dr.ko and Vendor_0079_Product_0006.kl files.

Happy gaming!!! and enjoy :)


From: http://anilsoni85.blogspot.com/2013/05/connect-joystick-to-play-games-on-your.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值