[Q] Assigning a hardware button to a touchscreen press? - Android Q&A, Help & Troubleshooting

Hello, I do hope I'm in the correct section. There doesn't seem to be an explicit "Dumb Non-Programmer Questions" area, so if I'm somehow in the bad, my apologies.
Anyway, I was wondering if it it was possible to have an app which reassigned hardware buttons to presses on the touchscreen. So that, whenever you pressed, say, Search, the phone would act as if you pressed area XYZ on the touchscreen.
It originally came to me when I was reading about the Nook Touch, and everyone trying to get support for hardware buttons added. Well, considering most of the ebook readers seem to support taping the side of the page to turn, why not just assign the hardware buttons to one of those areas?
I began researching and found there isn't really anything which does that on Android, or on much anything, really. So I'm more curious then anything now; is it something that just isn't really feasible or possible with the Android SDK, or it is more of a solution in search of a problem that no one's found a reason for?

Lets say you have a button and you want that button to simulate a menu key press you can send key presses via adb and the shell
Runtime.getRuntime().exec(
"adb shell input keyevent 82")
Where 82 is the keycode for the menu key. So i suppose that any hardware key that has a code associated with it could be mapped to a screen press
From something awesome

Er, lemme rephrase the question.
I mean, is it possible to make a hardware button replace a press on the touchscreen? For instance, in the Kindle app, tapping the right third of the screen turns the page. Can I assign the search button, for instance, to replicate my finger tapping the right side of the screen to turn the page?

You can't. But the developers of the application should be able to do this by overriding onKeyDown method (except for the home button which I believe can't be overridden).

Oh bother.
Well, thanks for the replies. I was hoping there might be some method, since it'd make developing for the nook touch easier, but I'm guessing it's not something that's needed more then rarely.

I can't understand why it is so hard or impossible, it is very easy to do on almost every other os. Can't one just assign a button to a mouse click on screen coordinates?
I am asking because it would be awesome, to assign a wii remote button to a mouse click and then play games like Asphalt 6 or so, that don't support hardware keyboard, with a remote controller.

yup, i have the sae question as well. My intention was to play android games which doesn't require accelerometer using wiimote/classic controller.

If you get the app source code or if you are good at smali, you can

Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums
Moving to Q&A

Related

[Q] Mapping volume keys to HOME, BACK and possibly more

My HD2 "Frankenphone" (it's built from no less than 3 other HD2's) has no working hardware keys on the front of the phone. The volume keys, however, do still work. I therefore want to cook a rom based on an existing one that has Volume up/down mapped to HOME/Back.
Furthermore, I was wondering if I could somehow get the MENU button implemented as well. I understand that this is not possible through the SDK, but perhaps it can be done by writing native C code. E.g. a longpress Volume-up could be menu, a long-press Volume-down could be search.
I'm not asking for someone to do this for me, I'd like to do this myself. What I'm looking for are a few quick pointers to how to start this endeavor. I have previous experience cooking custom roms using toolchains under linux, and also experience writing C (non-gui) code under linux. So useful pointers would be :
* Where can I find the key mappings? I suppose this is part of the kernel/user space?
* How would I go about implementing the long-press feature? Or can you hint towards another possible solution that does not involve the front hardware keys (touchscreen snooping for gestures? accellerometer? Any other sensor?)
Take a look here:
http://source.android.com/porting/keymaps_keyboard_input.html
Hope that helps.
One thing I do in most builds is change my call key to a search key.
Hi!
Take a look at the following thread! http://forum.xda-developers.com/showthread.php?t=740629
paalkr said:
Hi!
Take a look at the following thread! http://forum.xda-developers.com/showthread.php?t=740629
Click to expand...
Click to collapse
Awesome, thanks! That worked like a charm. Mounted the system.ext2 loopback, patched the keys, and tadaah, working home + back. That at least makes the phone usable again.
Can anyone recommend a solution to get a working MENU action? It looks like long-press back is handled by apps individually (e.g. in the browser it will show a history), while long-press home displays a task switcher. I could live with long-press back being handled by android itself to implement the menu function.
(edit) looks like this is possible, e.g. here it mentions "including some special features to support the virtual hard keys that are appearing on recent devices such as Droid." Now how did they do that?

[Q] nook "n" mapper

Does anyone know if it would be possible to write an app that would re-map the nook "n" (home) to open up a small popup, that would give access to all four of the main android buttons? i.e., home, back, menu, search. (similar popup to the long press home to 'recent programs' list that android has), maybe even adding the recent programs too?
That way we could still get home, but it wouldn't be impossible to use standard android programs because of the lack of hardware keys.
I loaded "Alidko," which works great, but once I open a book, I have to read the whole thing to get back to the main app screen since there is no 'back' button.
EDIT:
Someone made it
http://forum.xda-developers.com/showthread.php?t=860153
I am an iOS coder, but, looking at the docs, not only does this appear possible, it doesn't look like it would be too difficult for an android coder that knows their way around.
I believe the right thing to do would be, in order of preference/elegance:
1. Have a "long press" on the nook/home key expose the status bar via a "service" that listens for and captures this even
2. Have a "long press" on the nook key display a window that shows a set of "soft keys"
kaicherry said:
I am an iOS coder, but, looking at the docs, not only does this appear possible, it doesn't look like it would be too difficult for an android coder that knows their way around.
I believe the right thing to do would be, in order of preference/elegance:
1. Have a "long press" on the nook/home key expose the status bar via a "service" that listens for and captures this even
2. Have a "long press" on the nook key display a window that shows a set of "soft keys"
Click to expand...
Click to collapse
A solution was posted here:
http://forum.xda-developers.com/showpost.php?p=9556837&postcount=1 to remap the volume keys. Although not as elegant as an app would be, it works great. I have my volume up key remapped to "MENU" and volume down as "BACK".
In Aldiko it works perfectly.
That is a good temporary solution, but I would personally not like to loose the volume functionality.
Anyone think they could make a pop-up like that? I am not sure how hard it would be to make the pop-up send the 'softkey' to the other app and not just close itself (i.e., back)...
Answered!
http://forum.xda-developers.com/showthread.php?t=860153

X2 Captive touch home buttons?

I love everything about my X2...except for the physical buttons. How hard do you guys think it would be to replace them with captive touch buttons? Would it be as simple as finding some buttons, connecting the wires and making them fit or would software be involved? Any feedback would be appreciated.
TransX2 said:
I love everything about my X2...except for the physical buttons. How hard do you guys think it would be to replace them with captive touch buttons? Would it be as simple as finding some buttons, connecting the wires and making them fit or would software be involved? Any feedback would be appreciated.
Click to expand...
Click to collapse
I had the same question regarding this. My reason being the buttons are too loud at night. All you hear is "clickity click click click". I was looking to see if the Honeycomb style onscreen buttons were available to install (they have them in Cyanogenmod on tablets running Gingerbread). Didn't find them.
BUT I did find a program called "Soft Keys" in the market. It's free and has on screen buttons that can be hidden or shown with a little floating movable button. You can do everything with it without using the hard keys. I strongly suggest it, and it will probably prolong the life of the hard keys.
Make sure to set it to not autohide after clicking on the buttons (it defaults to hide when pressing home).
the amount of physical modding needed would make this entirely too much work. re-wiring, taking a capacitive button section from another phone, etc, maybe even software stuff, that much i don't know.
you're better off finding a way to quiet the buttons
one of the best features of this phone is the fact that it still has some real buttons. itd be nice if it had a d-pad or trackball too just so one could not have to always use the touchscreen to interact with it
ralphwiggum1 said:
I had the same question regarding this. My reason being the buttons are too loud at night. All you hear is "clickity click click click". I was looking to see if the Honeycomb style onscreen buttons were available to install (they have them in Cyanogenmod on tablets running Gingerbread). Didn't find them.
BUT I did find a program called "Soft Keys" in the market. It's free and has on screen buttons that can be hidden or shown with a little floating movable button. You can do everything with it without using the hard keys. I strongly suggest it, and it will probably prolong the life of the hard keys.
Make sure to set it to not autohide after clicking on the buttons (it defaults to hide when pressing home).
Click to expand...
Click to collapse
Try button savior. I like it much more than soft keys.

[Q] Button Remap i9100

Hi, so I was lurking the interwebz for something that would let me remap the keys on my S2 in a specific way, specifically the same way the Galaxy Nexus has them, back, home & recents.
I found something that got me a little up to target, and that's the abandoned Button Remapper project. I remapped my keys and inversed the meny and search key (I never have the backlight on, it's unsightly, so their reposition doesn't bother me) unfortunately, Button Remapper doesn't feature a "Recents" function to map (probably because it was last updated January last year, before this multitasking sh** got serious on Android).
So I was wondering if someone knows someone or some tricks to get the buttons working in that order.
Oh and of course manipulating Android into providing an on-screen menu key where applicable is probably a must for the solution to go big time.
I'd look into creating something myself as I found a thread that talks about remapping keys by editing Android code (can't find the link in history) but I have to study for end of year exams at the moment.
So my question is, anyone know of or can create a solution? Maybe we can get the Button Remapper dev to update the app? Maybe you're looking at this right now? PEOPLE NEED YOU HERO!
Thanks.

[Q] Possibility of remapping Mouse buttons?

So I've done a search on Google and Xda about this topic and so far there doesn't seem to be much information on this except to find a thread about the inability of the android system in remapping of keys (or maybe the thread just went out of topic)
Thread; http://forum.xda-developers.com/showthread.php?t=1244702
So I'm wondering whether the remapping of the right click button to give a command 'Open Context Menu' is possible to immitate the function of a real computer (All these taking into consideration that it is also possible to remap buttons of the dock)
If you were to have it mimic the behavior of a real computer it wouldn't work. Android uses a right mouse button as if you were touching and holding on an object.
The only thing i would be interested in is remapping the second button the same as the primary button. Effectively having left click and left click.
Now it shouldn't be *that* hard to make a simple program to accomplish this, simply an extension to remap the buttons to whatever android specific task you want, this is already semi possible with the remapping of soft keys in CM 10.1/AOKP builds, so something like that should be possible.
Unfortunately i have no coding experience. I would love to see this done though
Nexus 4. Paranoid edition.
No, today I search & found a solution - http://forum.xda-developers.com/showpost.php?p=55848773&postcount=7

Categories

Resources