Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 04-15-2013, 10:58 AM   #1
PaulFreund
*
PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.
 
PaulFreund's Avatar
 
Posts: 35
Karma: 145852
Join Date: Apr 2013
Device: Kindle Touch
Notification about power button presses for the K5 and hopefully for the KPW

This requires a little bit of help from outside and I figured udev would be a good way to catch the event in the first place.
The following shell code from the WebLaunch start.sh script creates a udev rule that listens to 'yoshibutton' and executes a shell script.

Code:
###############################################################################
## Register powerbutton handler

FILE_RULES="/etc/udev/rules.d/98-yoshibutton.rules"
FILE_NOTIFY="/lib/udev/bin/notifyyoshibutton"

#------------------------------------------------------------------------------
# Rules
if [ ! -f $FILE_RULES ]
then
	mntroot rw
	echo "KERNEL==\"yoshibutton\",  RUN+=\"$FILE_NOTIFY\"" > $FILE_RULES
	udevadm control --reload-rules
	mntroot ro
fi

#------------------------------------------------------------------------------
# Notifier
if [ ! -f $FILE_NOTIFY ]
then
	mntroot rw
	echo '#!/bin/sh' > $FILE_NOTIFY
	echo '/usr/bin/lipc-send-event com.lab126.system.event yoshibutton' >> $FILE_NOTIFY
	chmod +x $FILE_NOTIFY
	mntroot ro
fi
The executed script will send an event through lipc with the command "lipc-send-event com.lab126.system.event yoshibutton"(thanks eureka) which can later be catched in a mesquite app (I use pillowHelper.js for this).

So when the app gets started ( 'go' event in a Kindle template ):

PHP Code:
//-------------------------------------------------------------
// Register power button callback
function registerPowerButtonCallback()
{            
    
// Register Callback and watch for power button
    
pillowHelper.RegisterStatusBarEventCallback(appName
        function(
value
        {
            if( 
value.eventName && value.eventName === 'yoshibutton')
                
closeApplication();
        }
    );

    
// Request powerbutton event
    
pillowHelper.RequestStatusBarEvent(
        
appName
        
'com.lab126.system.event'
        
'yoshibutton'
    
);

And when the app gets closed to clean up ('unload' or 'pause' in a Kindle template):

PHP Code:
pillowHelper.UnRegisterStatusBarEventCallback(appName); 
Now when the power button is pressed, the function closeApplication() is called in this example and that regardless of whether preventScreenSaver is set or not.

This method is implemented in WebLaunch and works for me on the K5. As I developed this for the PaperWhite where there is no home button it would be nice if somebody with a PW could test it ( for example by testing the implementation in the WebLaunch application ).

EDIT: It is now tested and works on the K5 and the KPW Thanks for testing twobob!

Last edited by PaulFreund; 04-15-2013 at 02:00 PM. Reason: Now known to work with KPW
PaulFreund is offline   Reply With Quote
Old 04-15-2013, 11:27 AM   #2
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
Quote:
Originally Posted by PaulFreund View Post
send an event through lipc with the command "lipc-set-prop com.lab126.system sendEvent yoshibutton"
Just use lipc-send-event. Look into /etc/lipc-daemon-props.conf and you'll see the same lipc-send-event usage.
eureka is offline   Reply With Quote
Old 04-15-2013, 11:55 AM   #3
PaulFreund
*
PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.PaulFreund understands the importance of being earnest.
 
PaulFreund's Avatar
 
Posts: 35
Karma: 145852
Join Date: Apr 2013
Device: Kindle Touch
Quote:
Originally Posted by eureka View Post
Just use lipc-send-event. Look into /etc/lipc-daemon-props.conf and you'll see the same lipc-send-event usage.
Thanks, changed it.
PaulFreund is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simulating Button Presses Externally inuxy Kindle Developer's Corner 58 08-28-2012 01:55 PM
PRS-T1 How can I use back button as power button? younghere Sony Reader 1 03-12-2012 06:37 PM
Trouble With K4 Power Button? lindnet Amazon Kindle 5 01-03-2012 06:45 AM
Trouble with the Power Button Davimee Astak EZReader 16 05-04-2010 07:29 PM
power button stuck Utahcowboy Bookeen 10 03-13-2008 01:42 PM


All times are GMT -4. The time now is 03:54 AM.


MobileRead.com is a privately owned, operated and funded community.