Giter Club home page Giter Club logo

Comments (4)

pelya avatar pelya commented on July 2, 2024

First, there is a kernel patch - this is dark magic, without which nothing
will work. This patch adds two new devices to your Android system,
/dev/hidg0 for keyboard, and /dev/hidg1 for mouse.
If you want to add HID joystick for example, you need to modify
hid_function_bind_config() and hid_function_init(), and another struct
ghid_device_android_joystick, with proper USB descriptor.
The best way to get USB descriptor is to buy USB analyzer, and copy data
from existing USB joystick. You can also read USB specification:
http://en.wikipedia.org/wiki/USB_human_interface_device_class

Then you need Android application, which will write data to these devices.
It doesn't matter if it's written in C or Java, as long as it writes valid
data to these files.
Keyboard/mouse protocol description is here:
https://github.com/pelya/android-keyboard-gadget#how-it-works
My Android app is written in C++ and uses SDL library. gfx.cpp contains
low-level graphics functions, gui.cpp is a GUI widgets implementation,
flash-kernel.cpp is for flashing kernel on Nexus 7, input.cpp is for
opening device files and writing data to them, main.cpp is, well, main(),
touchpad.cpp is the touchpad implementation, and scancodes.cpp contains
keyboard scancode table.

On Mon, Nov 10, 2014 at 12:45 PM, the-st0rm [email protected]
wrote:

What should I read exactly to understand what you have coded entirely. I
need something like a walkthough of your code to understand what is this
function and why it is used etc etc, so that I can develop on top of that.

Best Regards


Reply to this email directly or view it on GitHub
#12.

from android-keyboard-gadget.

the-st0rm avatar the-st0rm commented on July 2, 2024

I understand this big picture and I am ok with the Android application that writes the data to the devices. My only problem is with the kernel patch. Understanding what is happening actually.
what happened when I just connect my phone to the PC what function gets called first and how the data is sent to the USB ... and what is the difference between the hid_function_bind_config() and hid_function_init() .. I don't want you to answer all these stuff, I just want you to direct me to the source you read so that you managed to write all that code. Got me ?
BTW, Thank you so much for your effor and your quick respones. You are amazing dude
I really appreciate it everything you do.

from android-keyboard-gadget.

pelya avatar pelya commented on July 2, 2024

I do not know all details myself, because the kernel is huge, I only know
how my code works.

First, I've read this documemt, it contains half-baked example of what I
needed:

https://github.com/torvalds/linux/blob/master/Documentation/usb/gadget_hid.txt

Then I've scanbed through Android USB gadget implementation, where
functions are added and removed dynamically:

https://android.googlesource.com/kernel/tegra/+/android-tegra3-grouper-3.1-jb-mr2/drivers/usb/gadget/f_adb.c

https://android.googlesource.com/kernel/tegra/+/android-tegra3-grouper-3.1-jb-mr2/drivers/usb/gadget/android.c

HID gadget already has it's own driver, I needed only to provide USB HID
descriptor:

https://android.googlesource.com/kernel/tegra/+/android-tegra3-grouper-3.1-jb-mr2/drivers/usb/gadget/f_hid.c

Then I fixed compilation errors, run, debugged crashes, usual stuff.
On Nov 10, 2014 2:51 PM, "the-st0rm" [email protected] wrote:

I understand this big picture and I am ok with the Android application
that writes the data to the devices. My only problem is with the kernel
patch. Understanding what is happening actually.
what happened when I just connect my phone to the PC what function gets
called first and how the data is sent to the USB ... and what is the
difference between the hid_function_bind_config() and hid_function_init()
.. I don't want you to answer all these stuff, I just want you to direct me
to the source you read so that you managed to write all that code. Got me ?
BTW, Thank you so much for your effor and your quick respones. You are
amazing dude
I really appreciate it everything you do.


Reply to this email directly or view it on GitHub
#12 (comment)
.

from android-keyboard-gadget.

conrad-heimbold avatar conrad-heimbold commented on July 2, 2024

Question has been answered, therefore closing.

from android-keyboard-gadget.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.