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

前端 未结 13 871
暖寄归人
暖寄归人 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:25

    Some others figured out that this is wrong. In the meantime i share their opinion. I'm sorry.

    Old WRONG answer:

    In my opinion this is barely possible.

    Your Computer identifies any USB device with the USB device descriptor or the usb interface descriptor. To be able to use your android device as a keyboard, you would have to change these. Actually i think these are saved on a ROM in the device, so you would have to change hardware. The device needs to identifiy itself with the host even if its only charging in turned off state (has to tell usb host about the power consumption, otherwise only a few mA max). For me this points into the direction, that you would have to change hardware

    "Easiest" way would proabably be assemble an adapter containing a usb host chip with a µC that converts the received data (which you still had to send via usb) to ps/2 or usb-client signals that u send to the computer.

    In my opinion the easiest way would be: Buy one of these Keyboards you can roll and put them in your bag too.

    0 讨论(0)
  • 2020-12-04 07:28

    Most USB keyboards need drivers to run. Any keyboard functionality (non-standard buttons) beyond the capabilities of the standard HID drivers will need to install some software on the computer.

    That being said, It may be possible to use Android's USB capabilities, as well as writing a custom driver if default HID is not sufficient, to achieve your goal. It is likely a very non-trivial undertaking.

    Edit: I think KristopherMicinski is right that the level of control you get with the stock Android USB API is inadequate for this purpose. His two solutions of modifying the firmware to communicate using HID standards, as well as a hardware middleman that translates from the Android Accessory protocol to HID both seem valid to me. If installing drivers on the computer is out of the question, these may be the only two options.

    However, if you're open to installing a driver for this behavior, It should be possible to write a custom driver that can handle Android USB protocol, and correctly translate to the correct calls/interrupts for keyboard functionality. If memory serves, every peripheral keyboard I've used in the last 10 years has needed to install a driver for full functionality, so this may not be considered non-standard behavior. (The though just occurs that this approach will only allow the device to function as a keyboard inside windows, not during the boot process)

    0 讨论(0)
  • 2020-12-04 07:33

    The only way I could see this being possible is if you:

    • modified the Android firmware to give you usb level access at a low enough level that you could operate using the necessary protocol

    or

    • Made some sort of special hardware level converter that you attached to the device.

    (So I suppose, depending on how much work you want to do, it could be a hardware or software problem.)

    0 讨论(0)
  • 2020-12-04 07:33

    This is possible, without any additional drivers needed.

    You can emulate PC's USB keyboard with small USB dongle-sized device and then use your Android device to send keyboard (and/or mouse) data over Bluetooth.

    Take a look on descriptive video in Indiegogo campaign: http://igg.me/at/hiDBLUE/x/3400885

    BTW: The product technical documents is available here: http://www.flyfish-tech.com/hiDBLUE

    0 讨论(0)
  • 2020-12-04 07:34

    Your Android already identifies with a VID/PID when plugged into a host. It already has an interface for Mass Storage. You would need to hack the driver at a low level to support a 2nd interface for 03:01 HID. Then it would just be a question of pushing scancodes to the modified driver. This wouldn't be simple, but it would be a neat hack. One use would be for typing long random passwords for logins.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题