[N2E] Nook Touch - App Support for Hardware Buttons

Search This thread

pcm2a

Senior Member
May 22, 2007
472
23
I don't know about everyone else but I would love to see apps that support our Nook's hardware buttons for scrolling and turning pages. I created an small app just to find out exactly what these buttons were. I have attached the test apk and the source for it.

The buttons generate a KeyEvent that can be captured in the normal manner for handling key presses.
Left top button - 92
Left bottom button - 93
Right top button - 94
Right bottom button - 95

All the developer has to do is test for those in addition to whatever they are already monitoring for. I am going to begin emailing developers with this information and see if I get any "takers". I have emailed the following and will post a status here if I hear back:

Kindle - 5/16: Received an email saying the suggestion would be forwarded on to the appropriate development group
NewsRob (via google group) - 5/16: The developer is going to add page up/down and article up/down support!
FeedR - 5/16: Email sent
Aldiko - 5/16: Email sent
FBReader - 5/16: Email sent

In addition I am going to add hardware button support to some open source apps. I have located a number of open source RSS apps:
http://code.google.com/p/feedgoal/
http://code.google.com/p/feeddroid/
http://code.google.com/p/reader/

As an example of what we can do I have attached an updated FeedGoal where I have added support for the hardware buttons to scroll up and down on a feed article.

Update 5/17/2011:
I have modified the Browser from the stock Eclair to support page buttons and compiled it. When I try to start it on the Nook it comes up and then shuts down. One of the times I saw a "signing in" box. My thoughts is that it is trying to do something that requires gapps on the phone? If anyone has any ideas I'd be glad to try them.
 

Attachments

  • FeedGoal.apk
    408.1 KB · Views: 104
  • TouchTest.txt
    893 bytes · Views: 185
  • TouchTest.apk
    13.7 KB · Views: 140
Last edited:

pcm2a

Senior Member
May 22, 2007
472
23
Keys are actually

key 407 RIGHT_NEXTPAGE
key 412 LEFT_NEXTPAGE
key 139 LEFT_PREVPAGE
key 158 RIGHT_PREVPAGE
Those numbers are the scancodes from the keymap file TWL4030_Keypad.kl. If you are wanting to watch for key inputs in an Android application you override the "onKeyDown(int keyCode, KeyEvent event)" method and the "int keycode" that get's printed out is 92-95.

The format of the keymap file (TWL4030_Keypad.kl) is "key SCANCODE KEYCODE [FLAGS...]". In your example 407 is the SCANCODE and "RIGHT_NEXTPAGE" is the KEYCODE. The numerical value of "RIGHT_NEXTPAGE" is either 94 or 95 depending on how you set your Nook up.

If someone wants give the two attached apk's and test and verify (I've already ran them myself) that they do work as intended that would be great.
- The TouchTest should print out 92-95 (keycode) on the screen when you press them.
- The FeedGoal should page up and down when you press the right or left side keys. I may go back and change the left side to be page up/down and the right side to be article back/forward.
 
Last edited:

aruangra

Senior Member
Dec 11, 2010
66
28
If you remaps two keys to VOLUME_UP and VOLUME_DOWN, almost all reading-centric programs work will hardware buttons. I have tested:

Read It Later
Kindle
Aldiko
FBreader
CoolReader
Moon+Reader
RSSdaemon
NewsRob
BuzzBox RSS reader


They all works with remapped buttons.
 
Last edited:
  • Like
Reactions: cymoze and rev0l

rev0l

Senior Member
Sep 3, 2008
70
33
Sony Xperia Z3 Compact
If you remaps two keys to VOLUME_UP and VOLUME_DOWN, almost all reading-centric programs work will hardware buttons.

yes, of course.
but this is just a workaround and i already recognized that there are situations where i have to take the nook in the other hand to turn a page...
for example: i use the left keys remapped to volume for readitlater, so i can only use the right keys on the default reader app (which i prefer).

i think for some apps you will always have to do this remapping, especially for the kindle app in my thougts.
and it seems to me that the devs will easily can integrate this buttons in their apps.

a lot of other apps are already working with the default mapping:
e-mail
twicca
titanium backup
root explorer
alogcat
autostarts
moon+
...
 
Last edited:

apeine

Senior Member
Mar 9, 2011
268
31
Sao Paulo
Is there no way to remap the hardware buttons using like a driver software (sorry, completely noob regarding android software). Remapped buttons would help on repligo and ezpdf, my preferred readers.
 

nopnopnop

Member
May 1, 2011
24
10
I liked seeing the NewsRob support in the change log. But it only scrolls half a page down so you have to hit it twice.

I found that my old technique of remapping the key to SPACE worked better; SPACE is a page-down shortcut for most WebView apps. Unfortunately my SHIFT SPACE mapping in the layout file seemed to ignore the shift part. :-(

Android 3.0 adds real page up/down keys finally, so more apps should support the keycodes then. This isn't just a Nook issue; I've been trying to fix this on my Galaxy Tab too.

I blame Apple for not including a page down function because it's so "cool" to flick the screen around. Hope you have good timing.
 
Jan 19, 2011
9
5
Good news, everyone!

This weekend I received reply from FBReader authors. Here is the translation:

Since version 1.1.3 FBReader is able to read external file with actions mapped to keys. One can put keymap.xml file into main directory, which is /sdcard/Books by default.
File format can be seen in example:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<keymap>
	<binding key="4" action="cancelMenu"/>
	<binding key="23" action="processHyperlink"/>
	<binding key="24" action="volumeKeyScrollBackward"/>
	<binding key="25" action="volumeKeyScrollForward"/>
	<binding key="66" action="processHyperlink"/>
</keymap>

All possible actions are here:
Code:
	String SHOW_LIBRARY = "library";
	String SHOW_PREFERENCES = "preferences";
	String SHOW_BOOK_INFO = "bookInfo";
	String SHOW_TOC = "toc";
	String SHOW_BOOKMARKS = "bookmarks";
	String SHOW_NETWORK_LIBRARY = "networkLibrary";

	String SWITCH_TO_NIGHT_PROFILE = "night";
	String SWITCH_TO_DAY_PROFILE = "day";

	String SEARCH = "search";
	String FIND_PREVIOUS = "findPrevious";
	String FIND_NEXT = "findNext";
	String CLEAR_FIND_RESULTS = "clearFindResults";

	String SET_TEXT_VIEW_MODE_VISIT_HYPERLINKS = "hyperlinksOnlyMode";
	String SET_TEXT_VIEW_MODE_VISIT_ALL_WORDS = "dictionaryMode";

	String TURN_PAGE_BACK = "previousPage";
	String TURN_PAGE_FORWARD = "nextPage";

	String VOLUME_KEY_SCROLL_FORWARD = "volumeKeyScrollForward";
	String VOLUME_KEY_SCROLL_BACK = "volumeKeyScrollBackward";
	String SHOW_MENU = "menu";
	String SHOW_NAVIGATION = "navigate";

	String GO_BACK = "goBack";
	String EXIT = "exit";
	String SHOW_CANCEL_MENU = "cancelMenu";

	String ROTATE = "rotate";
	String INCREASE_FONT = "increaseFont";
	String DECREASE_FONT = "decreaseFont";

	String PROCESS_HYPERLINK = "processHyperlink";

	String SELECTION_SHOW_PANEL = "selectionShowPanel";
	String SELECTION_HIDE_PANEL = "selectionHidePanel";
	String SELECTION_CLEAR = "selectionClear";
	String SELECTION_COPY_TO_CLIPBOARD = "selectionCopyToClipboard";
	String SELECTION_SHARE = "selectionShare";
	String SELECTION_TRANSLATE = "selectionTranslate";
	String SELECTION_BOOKMARK = "selectionBookmark";
Program must be restarted in order to pick up changes in config file.

Can anyone test if this really works? I can't test it right now.

And, I suggest to make a donation to this wonderful program authors.

Cheers.
 
  • Like
Reactions: rev0l

apeine

Senior Member
Mar 9, 2011
268
31
Sao Paulo
Great news!
If other developers would do the same, we'd be in heaven.
I'll only be able to try it tomorrow, but I'll inform as soon as I do it.
 

seinkon

New member
Jan 1, 2011
1
0
Good news, everyone!
This weekend I received reply from FBReader authors. Here is the translation:
Since version 1.1.3 FBReader is able to read external file with actions mapped to keys. One can put keymap.xml file into main directory, which is /sdcard/Books by default.
Program must be restarted in order to pick up changes in config file.

Can anyone test if this really works? I can't test it right now.

Thanks! It works very nicely with FBReader. My keymap.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<keymap>
	<binding key="92" action="nextPage"/>
	<binding key="93" action="previousPage"/>
	<binding key="94" action="nextPage"/>
	<binding key="95" action="previousPage"/>
</keymap>

Does anyone know the key number of the Nook button? It's quite useless for FBReader and it would be nice to remap it to some other function. Thanks!
 

GabrialDestruir

Senior Member
Nov 12, 2009
650
514
California
Anyone thought of trying to create a service that'd catch the button presses outside of the stock apps that'd then send the right command for whatever. For example if you press the page forward button or page backward button in stock apps it'd function as designed. If you push it somewhere else like within your custom launcher or another app it'd perform as menu/home/back whatever
 

nooktouch

Member
Jun 22, 2011
16
5
Anyone thought of trying to create a service that'd catch the button presses outside of the stock apps that'd then send the right command for whatever. For example if you press the page forward button or page backward button in stock apps it'd function as designed. If you push it somewhere else like within your custom launcher or another app it'd perform as menu/home/back whatever

Yes for remapping the n-button. See this post. But still haven't had the time to do it. Too busy with work.
 

mycr0ft

New member
Aug 1, 2011
4
4
Edmond, OK
Anyone thought of trying to create a service that'd catch the button presses outside of the stock apps that'd then send the right command for whatever. For example if you press the page forward button or page backward button in stock apps it'd function as designed. If you push it somewhere else like within your custom launcher or another app it'd perform as menu/home/back whatever
I've started working on exactly this during this weekend. I have so far succeeded in creating service that runs in the background and makes the upper left button a "HOME" button - meaning it shows the home activity of your choice rather than the built in menu like the n button. I'll be glad to give more technical details on what I have learned so far (when I have time, probably next weekend).

In the mean time, I would like input from other users as to some specifics on how it should work.

Here is my current vision:
- Have option to start the service manually or automatically start at boot (currently hard coded to start a boot)
- The keylayout files can remain untouched so that they still work properly for the stock applications
- the service will be aware of what Activity is in the foreground and remap purpose the buttons accordingly.
- there will be a settings Activity that lets you choose the functionality of each button on a per application basis
- the choices will to be to broadcast an Intent or to create a virtual key press (for example, my "HOME" button does not actually cause a HOME key press, but broadcasts a act...MAIN cat...HOME intent, my next experiment will be to send Vol Up/Down keys when Kindle app is running)

And this is slightly off topic, but I would like put this on sourceforge or google so that others can contribute and have easy access to it. I've never done that before, so advice on this would be appreciated.
 
Jan 19, 2011
9
5
but I would like put this on sourceforge or google so that others can contribute and have easy access to it. I've never done that before, so advice on this would be appreciated.

May I suggest github? git is much more sophisticated than CVS/SVN and their clones.

I basically agree with the app functionality. May be I will take part in implementation (I wish there will be ~36-48 hours in a day :) )
 
  • Like
Reactions: mycr0ft

mycr0ft

New member
Aug 1, 2011
4
4
Edmond, OK
Thanks for the advice. github looks promising.

Anyone interested can have a look:
Code:
https://github.com/mycr0ft/nook-touch-button-service

I've run into a bit of a problem with simulating a key press. The android developers have not made it easy (which is good for device security).
- I have tried Instrumentation.sendKey..., but that only works withing the same application. Even with the INJECT_EVENT permission, you cannot inject events into other applications (unless they are signed by the same packager). Repackaging every single app that you load does not sound like a good option.
- I have tried using the 'sendevent' shell command. This appears to be limited to only duplicating scan codes keys that actually exist.
- I am currently trying to compile uinput driver (available in the source code download from bn) and load it using insmod. I am stuck here for the time being because I can't figure out how to get it to compile to the right kernel version (version magic mismatch in dmesg)
 

giando78

Member
Dec 19, 2010
19
0
Latina
Droid Comic Viewer

I think also Droid Comic Viewer would benefit from hardware buttons support.

It's a nice little comic reader app supporting all relevant formats (CBR, CBZ, ACV & image formats). Animations can be disabled and there's no dependency with touchscreen interface (it can be entirely operated with button actions). This would make it perfect for an e-ink screen.

I sent an email to the devs today, let's hope they get back to us!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    I don't know about everyone else but I would love to see apps that support our Nook's hardware buttons for scrolling and turning pages. I created an small app just to find out exactly what these buttons were. I have attached the test apk and the source for it.

    The buttons generate a KeyEvent that can be captured in the normal manner for handling key presses.
    Left top button - 92
    Left bottom button - 93
    Right top button - 94
    Right bottom button - 95

    All the developer has to do is test for those in addition to whatever they are already monitoring for. I am going to begin emailing developers with this information and see if I get any "takers". I have emailed the following and will post a status here if I hear back:

    Kindle - 5/16: Received an email saying the suggestion would be forwarded on to the appropriate development group
    NewsRob (via google group) - 5/16: The developer is going to add page up/down and article up/down support!
    FeedR - 5/16: Email sent
    Aldiko - 5/16: Email sent
    FBReader - 5/16: Email sent

    In addition I am going to add hardware button support to some open source apps. I have located a number of open source RSS apps:
    http://code.google.com/p/feedgoal/
    http://code.google.com/p/feeddroid/
    http://code.google.com/p/reader/

    As an example of what we can do I have attached an updated FeedGoal where I have added support for the hardware buttons to scroll up and down on a feed article.

    Update 5/17/2011:
    I have modified the Browser from the stock Eclair to support page buttons and compiled it. When I try to start it on the Nook it comes up and then shuts down. One of the times I saw a "signing in" box. My thoughts is that it is trying to do something that requires gapps on the phone? If anyone has any ideas I'd be glad to try them.
    3
    Anyone thought of trying to create a service that'd catch the button presses outside of the stock apps that'd then send the right command for whatever. For example if you press the page forward button or page backward button in stock apps it'd function as designed. If you push it somewhere else like within your custom launcher or another app it'd perform as menu/home/back whatever
    I've started working on exactly this during this weekend. I have so far succeeded in creating service that runs in the background and makes the upper left button a "HOME" button - meaning it shows the home activity of your choice rather than the built in menu like the n button. I'll be glad to give more technical details on what I have learned so far (when I have time, probably next weekend).

    In the mean time, I would like input from other users as to some specifics on how it should work.

    Here is my current vision:
    - Have option to start the service manually or automatically start at boot (currently hard coded to start a boot)
    - The keylayout files can remain untouched so that they still work properly for the stock applications
    - the service will be aware of what Activity is in the foreground and remap purpose the buttons accordingly.
    - there will be a settings Activity that lets you choose the functionality of each button on a per application basis
    - the choices will to be to broadcast an Intent or to create a virtual key press (for example, my "HOME" button does not actually cause a HOME key press, but broadcasts a act...MAIN cat...HOME intent, my next experiment will be to send Vol Up/Down keys when Kindle app is running)

    And this is slightly off topic, but I would like put this on sourceforge or google so that others can contribute and have easy access to it. I've never done that before, so advice on this would be appreciated.
    2
    If you remaps two keys to VOLUME_UP and VOLUME_DOWN, almost all reading-centric programs work will hardware buttons. I have tested:

    Read It Later
    Kindle
    Aldiko
    FBreader
    CoolReader
    Moon+Reader
    RSSdaemon
    NewsRob
    BuzzBox RSS reader


    They all works with remapped buttons.
    1
    Keys are actually

    key 407 RIGHT_NEXTPAGE
    key 412 LEFT_NEXTPAGE
    key 139 LEFT_PREVPAGE
    key 158 RIGHT_PREVPAGE
    1
    Good news, everyone!

    This weekend I received reply from FBReader authors. Here is the translation:

    Since version 1.1.3 FBReader is able to read external file with actions mapped to keys. One can put keymap.xml file into main directory, which is /sdcard/Books by default.
    File format can be seen in example:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <keymap>
    	<binding key="4" action="cancelMenu"/>
    	<binding key="23" action="processHyperlink"/>
    	<binding key="24" action="volumeKeyScrollBackward"/>
    	<binding key="25" action="volumeKeyScrollForward"/>
    	<binding key="66" action="processHyperlink"/>
    </keymap>

    All possible actions are here:
    Code:
    	String SHOW_LIBRARY = "library";
    	String SHOW_PREFERENCES = "preferences";
    	String SHOW_BOOK_INFO = "bookInfo";
    	String SHOW_TOC = "toc";
    	String SHOW_BOOKMARKS = "bookmarks";
    	String SHOW_NETWORK_LIBRARY = "networkLibrary";
    
    	String SWITCH_TO_NIGHT_PROFILE = "night";
    	String SWITCH_TO_DAY_PROFILE = "day";
    
    	String SEARCH = "search";
    	String FIND_PREVIOUS = "findPrevious";
    	String FIND_NEXT = "findNext";
    	String CLEAR_FIND_RESULTS = "clearFindResults";
    
    	String SET_TEXT_VIEW_MODE_VISIT_HYPERLINKS = "hyperlinksOnlyMode";
    	String SET_TEXT_VIEW_MODE_VISIT_ALL_WORDS = "dictionaryMode";
    
    	String TURN_PAGE_BACK = "previousPage";
    	String TURN_PAGE_FORWARD = "nextPage";
    
    	String VOLUME_KEY_SCROLL_FORWARD = "volumeKeyScrollForward";
    	String VOLUME_KEY_SCROLL_BACK = "volumeKeyScrollBackward";
    	String SHOW_MENU = "menu";
    	String SHOW_NAVIGATION = "navigate";
    
    	String GO_BACK = "goBack";
    	String EXIT = "exit";
    	String SHOW_CANCEL_MENU = "cancelMenu";
    
    	String ROTATE = "rotate";
    	String INCREASE_FONT = "increaseFont";
    	String DECREASE_FONT = "decreaseFont";
    
    	String PROCESS_HYPERLINK = "processHyperlink";
    
    	String SELECTION_SHOW_PANEL = "selectionShowPanel";
    	String SELECTION_HIDE_PANEL = "selectionHidePanel";
    	String SELECTION_CLEAR = "selectionClear";
    	String SELECTION_COPY_TO_CLIPBOARD = "selectionCopyToClipboard";
    	String SELECTION_SHARE = "selectionShare";
    	String SELECTION_TRANSLATE = "selectionTranslate";
    	String SELECTION_BOOKMARK = "selectionBookmark";
    Program must be restarted in order to pick up changes in config file.

    Can anyone test if this really works? I can't test it right now.

    And, I suggest to make a donation to this wonderful program authors.

    Cheers.