Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 10-17-2013, 10:16 AM   #1
sergeyvl12
ebook fan
sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.
 
Posts: 735
Karma: 2528718
Join Date: Dec 2010
Device: PocketBook 301+, Kindle 3 Wi-Fi, Onyx Boox A62, Kindle Touch
Power button handling

Hi!

How to handle the "POWER" button on KT/KPW?

I tried /dev/input/eventN but no success.
sergeyvl12 is offline   Reply With Quote
Old 10-17-2013, 10:19 AM   #2
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by sergeyvl12 View Post
Hi!

How to handle the "POWER" button on KT/KPW?

I tried /dev/input/eventN but no success.
Press it gently.
knc1 is offline   Reply With Quote
Advert
Old 10-17-2013, 11:06 AM   #3
sergeyvl12
ebook fan
sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.
 
Posts: 735
Karma: 2528718
Join Date: Dec 2010
Device: PocketBook 301+, Kindle 3 Wi-Fi, Onyx Boox A62, Kindle Touch
Quote:
Originally Posted by knc1 View Post
Press it gently.
wittily
sergeyvl12 is offline   Reply With Quote
Old 10-17-2013, 11:31 AM   #4
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by sergeyvl12 View Post
wittily
OH,
Did you mean "how to handle power button EVENTS" ?

There are threads on that subject here.
And an event handler or two.

Any more of an answer would require some details on what you mean by "handle".

http://www.gerv.net/hacking/how-to-ask-good-questions/
knc1 is offline   Reply With Quote
Old 10-17-2013, 12:08 PM   #5
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
[!]131017:160326 KERNEL: I pmic: PWRON1 event: is what showlog chucks out.

I personally use the builtin /usr/bin/powerd_test

tried strings on it...

Quote:
...
Sending input event
lipc-send-event com.lab126.powerd.debug dbg_input_event
Failed to send event. shell returned 0x%x
Sending button pressed event
lipc-send-event com.lab126.powerd.debug dbg_power_button_pressed
Deferring suspend for %d seconds
lipc-set-prop com.lab126.powerd deferSuspend %d
Failed to defer suspend. Shell returned 0x%x
/tmp/fakebatt
Could not open fakebatt file
Invalid interval
hlsd:iprt:b::
Setting %d
/usr/bin/lipc-get-prop com.lab126.powerd status
Sending low batt event
lipc-send-event com.lab126.powerd.debug dbg_low_batt_low
Sending power button held
lipc-send-event com.lab126.powerd.debug dbg_power_button_held
...

that fell out.. (amongst other rubbish)
twobob is offline   Reply With Quote
Advert
Old 10-17-2013, 12:08 PM   #6
sergeyvl12
ebook fan
sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.
 
Posts: 735
Karma: 2528718
Join Date: Dec 2010
Device: PocketBook 301+, Kindle 3 Wi-Fi, Onyx Boox A62, Kindle Touch
Quote:
Originally Posted by knc1 View Post
OH,
Did you mean "how to handle power button EVENTS" ?

There are threads on that subject here.
And an event handler or two.

Any more of an answer would require some details on what you mean by "handle".

http://www.gerv.net/hacking/how-to-ask-good-questions/
Yes, I meant "get power button events: press and release".
sergeyvl12 is offline   Reply With Quote
Old 10-17-2013, 12:35 PM   #7
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by sergeyvl12 View Post
Yes, I meant "get power button events: press and release".
And what sort of "Handling" do you have in mind.

If you would just read and follow the directions in the link I gave you, this could go much faster.

And how do you plan to monitor for a 'power on' event when the cpu is halted?
knc1 is offline   Reply With Quote
Old 10-17-2013, 03:17 PM   #8
sergeyvl12
ebook fan
sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.
 
Posts: 735
Karma: 2528718
Join Date: Dec 2010
Device: PocketBook 301+, Kindle 3 Wi-Fi, Onyx Boox A62, Kindle Touch
Quote:
Originally Posted by knc1 View Post
And what sort of "Handling" do you have in mind.

If you would just read and follow the directions in the link I gave you, this could go much faster.

And how do you plan to monitor for a 'power on' event when the cpu is halted?
I need to put Kindle into suspend mode in my Qt programs. Kindle standard screensaver doesn't work because I completely freeze the kindle framework when starting it. I want to have my own suspend/resume + screensaver like it is already implemented for kobo in the KoboLauncher.

There is no need to monitor power event when cpu is halted because this event resumes cpu.

twobob, thanks. I think it's not a good idea to launch process every time I want to find out power status...

Do you know how to monitor the PWRON1 event?

Last edited by sergeyvl12; 10-17-2013 at 03:22 PM.
sergeyvl12 is offline   Reply With Quote
Old 10-17-2013, 03:24 PM   #9
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
ah right. it's available to look at in one of the err.. sys? proc? locations

knc1 has posted a thread about that before, would have to find it.

when I have fixed my mangled debian and eaten my dinner I'll have a look for it
twobob is offline   Reply With Quote
Old 10-17-2013, 03:55 PM   #10
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by sergeyvl12 View Post
I need to put Kindle into suspend mode in my Qt programs. Kindle standard screensaver doesn't work because I completely freeze the kindle framework when starting it. I want to have my own suspend/resume + screensaver like it is already implemented for kobo in the KoboLauncher.

There is no need to monitor power event when cpu is halted because this event resumes cpu.

twobob, thanks. I think it's not a good idea to launch process every time I want to find out power status...

Do you know how to monitor the PWRON1 event?
See the event handler thread posted by dos1

No need to monitor the power status -
if its off, there isn't anything user accessible still running.
Conversely, if any thing at all runs, then the power is on.

check the /sys sub-tree for what you can monitor and what you can change

Last edited by knc1; 10-17-2013 at 03:59 PM.
knc1 is offline   Reply With Quote
Old 10-17-2013, 04:13 PM   #11
sergeyvl12
ebook fan
sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.
 
Posts: 735
Karma: 2528718
Join Date: Dec 2010
Device: PocketBook 301+, Kindle 3 Wi-Fi, Onyx Boox A62, Kindle Touch
Quote:
Originally Posted by knc1 View Post
See the event handler thread posted by dos1

No need to monitor the power status -
if its off, there isn't anything user accessible still running.
Conversely, if any thing at all runs, then the power is on.

check the /sys sub-tree for what you can monitor and what you can change
I've switched off kindle screensaver and power button do nothing for now. Absolutely no reaction on power button when my program is not suspended. My program works and don't freezes when I press it one or multiple times. But I want to implement my own screensaver. I don't beleave that it is impossible in kindle. In kobo I just have to read /dev/input/event0 to receive power button and other buttons events.

Now I implemented sleep by timeout in kindle and it works well. Power button resumes device and I close the screen saver. I just want to make suspend by pressing the power button and by sleep cower.

Last edited by sergeyvl12; 10-17-2013 at 04:20 PM.
sergeyvl12 is offline   Reply With Quote
Old 10-17-2013, 07:04 PM   #12
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
https://www.mobileread.com/forums/sho...d.php?t=198484
twobob is offline   Reply With Quote
Old 10-18-2013, 11:55 AM   #13
sergeyvl12
ebook fan
sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.
 
Posts: 735
Karma: 2528718
Join Date: Dec 2010
Device: PocketBook 301+, Kindle 3 Wi-Fi, Onyx Boox A62, Kindle Touch
Thanks, twobob, knc1!
sergeyvl12 is offline   Reply With Quote
Old 11-13-2013, 09:41 AM   #14
sergeyvl12
ebook fan
sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.sergeyvl12 ought to be getting tired of karma fortunes by now.
 
Posts: 735
Karma: 2528718
Join Date: Dec 2010
Device: PocketBook 301+, Kindle 3 Wi-Fi, Onyx Boox A62, Kindle Touch
Code:
lipc-wait-event -m com.lab126.powerd goingToScreenSaver,outOfScreenSaver
doesn't work for me because I turn off the screen saver during my program execution:

Code:
# prevent screensaver activation
lipc-set-prop com.lab126.powerd preventScreenSaver 1
...
# restore screensaver
lipc-set-prop com.lab126.powerd preventScreenSaver 0
exploring kernel sources I've found yoshi_button.c.

So, I can get power button release event using netlink socket:

code sample
Spoiler:

Code:
#include <sys/socket.h>
#include <linux/netlink.h>

#define MAX_PAYLOAD 1024  /* maximum payload size*/

struct sockaddr_nl src_addr, dest_addr;
struct nlmsghdr *nlh = NULL;
struct msghdr msg;
struct iovec iov;
int sock_fd;

int main()
{
   /* Changed LJ article example to use NETLINK_KOBJECT_UEVENT */
   sock_fd=socket(PF_NETLINK, SOCK_RAW, NETLINK_KOBJECT_UEVENT);

   memset(&src_addr, 0, sizeof(src_addr));
   src_addr.nl_family = AF_NETLINK;
   src_addr.nl_pid = getpid(); // self pid
   src_addr.nl_groups = 1;     // interested in group 1<<0

   bind(sock_fd, (struct sockaddr*)&src_addr, sizeof(src_addr));

   memset(&dest_addr, 0, sizeof(dest_addr));

   nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_PAYLOAD));
   memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD));

   iov.iov_base = (void *)nlh;
   iov.iov_len = NLMSG_SPACE(MAX_PAYLOAD);
   msg.msg_name = (void *)&dest_addr;
   msg.msg_namelen = sizeof(dest_addr);
   msg.msg_iov = &iov;
   msg.msg_iovlen = 1;

   printf("Waiting for message from kernel\n");

   /* Read message from kernel */
   recvmsg(sock_fd, &msg, 0);

   printf("Received message payload: %s\n",  NLMSG_DATA(nlh));

   close(sock_fd);

   return 0;
}


Message for power button is: "virtual/misc/yoshibutton"

Probably it will be useful for sombody else. It works at least for KT and KPW-1. KPW-2 seems to use another approach (through event-N).

Now I need to get the sleepcover event also. But the main problem that I have no sleep cover on my KT.

Please, I need to know, does sleep cover use the same approach?

Last edited by sergeyvl12; 11-13-2013 at 09:43 AM.
sergeyvl12 is offline   Reply With Quote
Old 11-13-2013, 09:45 AM   #15
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Get a small "refrigerator" type magnet - place on lower right corner of benzel -
Pretend that is the cover magnet - "on" == closed, "off" == open
It is just a Hall Effect device on the underside of that corner.
knc1 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PRS-505 Power button not shutting off Atagahi Sony Reader 2 11-16-2012 05:48 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 04:21 AM.


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