<br><br><div class="gmail_quote">On Mon, Jan 28, 2013 at 11:01 PM, Paul Fox <span dir="ltr"><<a href="mailto:pgf@laptop.org" target="_blank">pgf@laptop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">ajay wrote:<br>
 > Hi all.<br>
 ><br>
 > A simple solution was found :)<br>
 ><br>
 > I hacked the "KP_Prior" and "KP_Next" keys, and now they are used for<br>
 > making-window-smaller and restoring-original-window-size respectively :)<br>
<br>
</div>so sugar takes over those keys?  aren't those keys used by activities?<br>
they're certainly useful in a terminal -- page up and page down.<br></blockquote><div><br>Hmm.. Well a simple "grepping" showed that the "Read" activity is the only activity that explicitly makes use of the "KP_Home" and "KP_End" keys; but none seemed to make use of "KP_Prior" and "KP_Next".<br>
<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
paul<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
 ><br>
 > All thanks to<br>
 >        * /usr/share/X11/xkb/keycodes/evdev<br>
 >        * sugar/src/jarabe/view/keyhandler.py<br>
 ><br>
 ><br>
 ><br>
 > Just one thing I noticed when  I tried to have the above keys take effect<br>
 > ONLY in ebook-mode (via the "evtest --query" test), that when I ran this<br>
 > again and again via the "suprocess" module, the XO-4 behaved very<br>
 > erratically. However, when I made the keys take effect irrespective of the<br>
 > test of ebook-mode, things worked cool. However, I will keep on looking<br>
 > into the reason.<br>
 ><br>
 ><br>
 > Thanks a ton to all :)<br>
 ><br>
 ><br>
 > On Thu, Jan 24, 2013 at 10:45 PM, Paul Fox <<a href="mailto:pgf@laptop.org">pgf@laptop.org</a>> wrote:<br>
 ><br>
 > > gonzalo wrote:<br>
 > >  > Write does not know what is the ebook switch state, that logic is in the<br>
 > >  > osk.<br>
 > >  ><br>
 > >  > Looking in the wiki and sugar code, I could not find information about<br>
 > > how<br>
 > >  > read the switch,<br>
 > >  > but in ticket <a href="http://dev.laptop.org/ticket/12326" target="_blank">http://dev.laptop.org/ticket/12326</a> found this:<br>
 > >  ><br>
 > >  > If you do:<br>
 > >  ><br>
 > >  > evtest --query /dev/input/event4 EV_SW SW_TABLET_MODE; echo $?<br>
 > >  ><br>
 > >  ><br>
 > >  > If the xo is in ebook mode returns 10, if not, returns 0.<br>
 > >  ><br>
 > >  > There are any official doc about the switches I am missing? There are a<br>
 > > way<br>
 > >  > to catch a event when the switch is activated, using dbus or something<br>
 > >  > similar?<br>
 > ><br>
 > > if you open the device and read it, you'll get a stream of "struct<br>
 > > input_event" structures (/usr/include/linux/input.h) representing<br>
 > > opening and closing of the SW_TABLET_MODE switch.  here's a C code<br>
 > > snippet from olpc-switchd (part of powerd):<br>
 > ><br>
 > >     void ebook_event()<br>
 > >     {<br>
 > >         struct input_event ev[1];<br>
 > ><br>
 > >         if (read(ebk_fd, ev, sizeof(ev)) != sizeof(ev))<br>
 > >             die("bad read from ebook switch");<br>
 > ><br>
 > >         dbg(3, "ebk: ev sec %d usec %d type %d code %d value %d",<br>
 > >             ev->time.tv_sec, ev->time.tv_usec,<br>
 > >             ev->type, ev->code, ev->value);<br>
 > ><br>
 > >         if (ev->type == EV_SW && ev->code == SW_TABLET_MODE) {<br>
 > >             if (ev->value)<br>
 > >                 send_event("ebookclose", round_secs(ev), ebk_device);<br>
 > >             else<br>
 > >                 send_event("ebookopen", round_secs(ev), ebk_device);<br>
 > >         }<br>
 > >     }<br>
 > ><br>
 > ><br>
 > > perhaps there's an evdev to dbus gateway of some sort, but i don't know<br>
 > > about it, if so.<br>
 > ><br>
 > > the "evtest" commandline example, above, uses an ioctl on the input<br>
 > > device to determine current state.  here's snippet from the evtest source:<br>
 > > (full source:  git://<a href="http://anongit.freedesktop.org/evtest" target="_blank">anongit.freedesktop.org/evtest</a>)<br>
 > ><br>
 > >     static int query_device(const char *device, const struct query_mode<br>
 > > *query_mode><br>
 > >     {<br>
 > >             int fd;<br>
 > >             int r;<br>
 > >             unsigned long state[NBITS(query_mode->max)];<br>
 > ><br>
 > >             fd = open(device, O_RDONLY);<br>
 > >             if (fd < 0) {<br>
 > >                     perror("open");<br>
 > >                     return EXIT_FAILURE;<br>
 > >             }<br>
 > >             memset(state, 0, sizeof(state));<br>
 > >             r = ioctl(fd, query_mode->rq, state);<br>
 > >             close(fd);<br>
 > ><br>
 > >             if (r == -1) {<br>
 > >                     perror("ioctl");<br>
 > >                     return EXIT_FAILURE;<br>
 > >             }<br>
 > ><br>
 > >             if (test_bit(keycode, state))<br>
 > >                     return 10; /* different from EXIT_FAILURE */<br>
 > >             else<br>
 > >                     return 0;<br>
 > >     }<br>
 > ><br>
 > ><br>
 > ><br>
 > > paul<br>
 > ><br>
 > ><br>
 > >  ><br>
 > >  > Gonzalo<br>
 > >  ><br>
 > >  ><br>
 > >  > On Thu, Jan 24, 2013 at 12:16 PM, Martin Langhoff <<br>
 > > <a href="mailto:martin.langhoff@gmail.com">martin.langhoff@gmail.com</a><br>
 > >  > > wrote:<br>
 > >  ><br>
 > >  > > On Thu, Jan 24, 2013 at 10:13 AM, Paul Fox <<a href="mailto:pgf@laptop.org">pgf@laptop.org</a>> wrote:<br>
 > >  > > > i believe sugar already has code to detect the two modes, since<br>
 > >  > > > that's how it knows whether to present the OSK or not.<br>
 > >  > ><br>
 > >  > > Yep. Ajay, I think Write shows you the way :-)<br>
 > >  > ><br>
 > >  > ><br>
 > >  > ><br>
 > >  > ><br>
 > >  > > m<br>
 > >  > > --<br>
 > >  > >  <a href="mailto:martin.langhoff@gmail.com">martin.langhoff@gmail.com</a><br>
 > >  > >  <a href="mailto:martin@laptop.org">martin@laptop.org</a> -- Software Architect - OLPC<br>
 > >  > >  - ask interesting questions<br>
 > >  > >  - don't get distracted with shiny stuff  - working code first<br>
 > >  > >  - <a href="http://wiki.laptop.org/go/User:Martinlanghoff" target="_blank">http://wiki.laptop.org/go/User:Martinlanghoff</a><br>
 > >  > ><br>
 > ><br>
 > > =---------------------<br>
 > >  paul fox, <a href="mailto:pgf@laptop.org">pgf@laptop.org</a><br>
 > > _______________________________________________<br>
 > > Devel mailing list<br>
 > > <a href="mailto:Devel@lists.laptop.org">Devel@lists.laptop.org</a><br>
 > > <a href="http://lists.laptop.org/listinfo/devel" target="_blank">http://lists.laptop.org/listinfo/devel</a><br>
 > ><br>
 ><br>
 ><br>
 ><br>
 > --<br>
 > Regards,<br>
 ><br>
 > Ajay Garg<br>
 > Dextrose Developer<br>
 > Activity Central: <a href="http://activitycentral.com" target="_blank">http://activitycentral.com</a><br>
<br>
=---------------------<br>
 paul fox, <a href="mailto:pgf@laptop.org">pgf@laptop.org</a><br>
_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@lists.laptop.org">Devel@lists.laptop.org</a><br>
<a href="http://lists.laptop.org/listinfo/devel" target="_blank">http://lists.laptop.org/listinfo/devel</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><font face="arial, sans-serif">Regards,<br><br>Ajay Garg</font><br style="font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><font face="arial, sans-serif">Dextrose Developer</font><br style="font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Activity Central: </span><a href="http://activitycentral.com/" style="font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)" target="_blank">http://activitycentral.com</a>