Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
moemzn
Old
#1  
Senior Member - OP
Thanks Meter 18
Posts: 117
Join Date: Mar 2012
Location: Egypt
Default Mapping/Linking Hardware bottons to android device via USB port

I'm an engineering student, and im working on a graduation project, and i just had an idea and need to ask this question.
Lets say we have 3 bottons, (X,Y,Z) 4 others UP,DOWN,LEFT,RIGHT, ANALOG(All directions)
If i press X, is it possible to associate it to specific area on the screen?
Is it possible to move a specific character in any game up/down/left and right using a hardware device?
Also moving the camera in all directions using the analog stick?
If i sent a signal from the device lets say X, will it communicate with the game it self or the device? Is it possible to make it communicate with the device a if i pressed X it press a specific are on the screen?
Sorry for the long post but i just had the thoughts and i want to know the possibilities of it.
 
Renate NST
Old
#2  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Thanks Meter 465
Posts: 1,212
Join Date: Feb 2012
Location: Boston
Internal or external devices generate scan codes.
These are converted in /system/usr/keylayout/identifier.kl to keycodes.
Different devices (as long as they have different USB VID/PIDs) can have different maps.
Ultimately, you are dealing with keycodes.
The app would have to know that F1-6 deal with goblins on the left side of the screen
and that F7-12 deal with unicorns on the right side of the screen.

A short answer: The app would have to be aware.

 
moemzn
Old
#3  
Senior Member - OP
Thanks Meter 18
Posts: 117
Join Date: Mar 2012
Location: Egypt
So the hardware must speak to the app files im dealing with, would an emulator solve the problem?

Sent from my GT-I9100 using Tapatalk 2
Phone module: Samsung Galaxy SII - I9100
ROM: P.A.C Man 4.2.2 v21
Kernel: Stock Kernel
 
Renate NST
Old
#4  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Thanks Meter 465
Posts: 1,212
Join Date: Feb 2012
Location: Boston
It's not a question of hardware vs. emulator.

You can have anything send any keycode that you want.
Code:
adb shell input keyevent 4
Will send a "Back" key.
Something has to interpret that.
Applications are written with a fixed understanding of keycodes.

Ok, if you want you can hack something to turn keycodes into touch events.
So "F1" would generate a touch down then up at the coordinates of 234, 132.
You'd need to do some low-level hacking or else hack the application.
If you were going to hack the application, it would be just easier to modify it so "F1" does what you want already.

The Following 2 Users Say Thank You to Renate NST For This Useful Post: [ Click to Expand ]
 
moemzn
Old
#5  
Senior Member - OP
Thanks Meter 18
Posts: 117
Join Date: Mar 2012
Location: Egypt
I appreciate ur awesome reply sir you saved alot of time, ill get a developer to do that time to move fpr the next step, thanks again!

Sent from my GT-I9100 using Tapatalk 2
Phone module: Samsung Galaxy SII - I9100
ROM: P.A.C Man 4.2.2 v21
Kernel: Stock Kernel
 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...