Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use this app as a library? #6

Open
TheBricktop opened this issue Oct 11, 2020 · 6 comments
Open

Is it possible to use this app as a library? #6

TheBricktop opened this issue Oct 11, 2020 · 6 comments

Comments

@TheBricktop
Copy link

I want to prototype a device that acts as a mouse and control it from opencv app , for my purpose i need to build it as a aar lib, is it possible to build such binary or there is an easier way to it?

@tejado
Copy link
Owner

tejado commented Nov 15, 2020

You can get all the details from the source. So you can use it partly as a lib but there is no documentation on it except my source code.
But android-usb-gadget just enables you to use your Android phone as a mouse/keyboard. You can still implement the device logic, so acting like a mouse/keyboard by writing to /dev/hidg* by any other code, e.g. your aar lib. This code is provided here:
https://github.com/tejado/Authorizer/tree/master/authorizer/src/main/java/net/tjado/authorizer

I'm curious: what is the use-case of your app? :-)

@TheBricktop
Copy link
Author

TheBricktop commented Nov 16, 2020

I'm trying to convert opencv processed image to hid mouse, and then go for bluetooth hid. Idea is to create some sort of a new peripheral.

@tejado
Copy link
Owner

tejado commented Nov 16, 2020

This sounds interesting. For keyboard, you need to convert from the images to characters and then you can get the respective HID scancodes by mapping them (e.g. https://github.com/tejado/Authorizer-PoC/blob/master/app/src/main/java/net/tjado/authorizer/UsbHidKbd_en_US.java). These scancodes can then be used in USB and Bluetooth.

@TheBricktop
Copy link
Author

Yea I have an idea how to get the parameters (x y and button click) but the boilerplate code without any ui dependency for bluetoothhidprofile gets me confused as there is no official documentation on this or im not googly enough to find it.
Basically my library should need at least two functions one for starting the bluetooth client with hid profile and then one for sending the report with params (int x int y bool clicked).

@tejado
Copy link
Owner

tejado commented Nov 19, 2020

Look up BluetoothHidDevice and how it is used in my code or other sample apps, e.g. https://github.com/ralismark/bluehid.
You have to check how to use it without any UI because you will need some way of pairing and so on (which is done by Android but you have to approve it and so on).

@TheBricktop
Copy link
Author

Yea im currently hacking ralismark's approach but got stuck on the mBtHidDevice.registerApp cause it needs a executor and Im not sure if i should somehow get the executor from the unitymainActivity (cause my intetntion is to use this lib in unity) or create it on the android side with context provided from the unity. Its largely convoluted and im kinda stuck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants