Is it possible to program Android to act as physical USB keyboard?

前端 未结 13 879
暖寄归人
暖寄归人 2020-12-04 07:00

What I really want to know is whether it is a hardware problem, or a software problem. Could I plug my android phone into a computer via USB and have it act as a hardware ke

13条回答
  •  一整个雨季
    2020-12-04 07:40

    I believe that you can do it if you have a rooted device with a recent Android. For example, the Asus Eee Pad Transformer running Android 4 has the libraries /system/lib/libusb.so and /system/lib/libusbhost.so, so you can write a Java application that calls them using JNI to emulate a USB keyboard. This means that you must write some glue C code that emulates the way a USB keyboard is communicating with a PC (=you must study the way the USB protocol works).

    I say "rooted", because some permissions are usually needed to use these libraries.

    Edit: The above is true when programming an Android device to act as a USB host, in your case you need to be a "gadget". I don't know how much of the Linux gadget functionality is contained in the kernel of your Android device. See this for a similar question.

提交回复
热议问题