[Sugar-devel] Hacking onto the "appearing" and "hiding" of OSK

Paul Fox pgf at laptop.org
Mon Jan 28 12:31:40 EST 2013


ajay wrote:
 > Hi all.
 > 
 > A simple solution was found :)
 > 
 > I hacked the "KP_Prior" and "KP_Next" keys, and now they are used for
 > making-window-smaller and restoring-original-window-size respectively :)

so sugar takes over those keys?  aren't those keys used by activities? 
they're certainly useful in a terminal -- page up and page down.

paul

 > 
 > All thanks to
 >        * /usr/share/X11/xkb/keycodes/evdev
 >        * sugar/src/jarabe/view/keyhandler.py
 > 
 > 
 > 
 > Just one thing I noticed when  I tried to have the above keys take effect
 > ONLY in ebook-mode (via the "evtest --query" test), that when I ran this
 > again and again via the "suprocess" module, the XO-4 behaved very
 > erratically. However, when I made the keys take effect irrespective of the
 > test of ebook-mode, things worked cool. However, I will keep on looking
 > into the reason.
 > 
 > 
 > Thanks a ton to all :)
 > 
 > 
 > On Thu, Jan 24, 2013 at 10:45 PM, Paul Fox <pgf at laptop.org> wrote:
 > 
 > > gonzalo wrote:
 > >  > Write does not know what is the ebook switch state, that logic is in the
 > >  > osk.
 > >  >
 > >  > Looking in the wiki and sugar code, I could not find information about
 > > how
 > >  > read the switch,
 > >  > but in ticket http://dev.laptop.org/ticket/12326 found this:
 > >  >
 > >  > If you do:
 > >  >
 > >  > evtest --query /dev/input/event4 EV_SW SW_TABLET_MODE; echo $?
 > >  >
 > >  >
 > >  > If the xo is in ebook mode returns 10, if not, returns 0.
 > >  >
 > >  > There are any official doc about the switches I am missing? There are a
 > > way
 > >  > to catch a event when the switch is activated, using dbus or something
 > >  > similar?
 > >
 > > if you open the device and read it, you'll get a stream of "struct
 > > input_event" structures (/usr/include/linux/input.h) representing
 > > opening and closing of the SW_TABLET_MODE switch.  here's a C code
 > > snippet from olpc-switchd (part of powerd):
 > >
 > >     void ebook_event()
 > >     {
 > >         struct input_event ev[1];
 > >
 > >         if (read(ebk_fd, ev, sizeof(ev)) != sizeof(ev))
 > >             die("bad read from ebook switch");
 > >
 > >         dbg(3, "ebk: ev sec %d usec %d type %d code %d value %d",
 > >             ev->time.tv_sec, ev->time.tv_usec,
 > >             ev->type, ev->code, ev->value);
 > >
 > >         if (ev->type == EV_SW && ev->code == SW_TABLET_MODE) {
 > >             if (ev->value)
 > >                 send_event("ebookclose", round_secs(ev), ebk_device);
 > >             else
 > >                 send_event("ebookopen", round_secs(ev), ebk_device);
 > >         }
 > >     }
 > >
 > >
 > > perhaps there's an evdev to dbus gateway of some sort, but i don't know
 > > about it, if so.
 > >
 > > the "evtest" commandline example, above, uses an ioctl on the input
 > > device to determine current state.  here's snippet from the evtest source:
 > > (full source:  git://anongit.freedesktop.org/evtest)
 > >
 > >     static int query_device(const char *device, const struct query_mode
 > > *query_mode>
 > >     {
 > >             int fd;
 > >             int r;
 > >             unsigned long state[NBITS(query_mode->max)];
 > >
 > >             fd = open(device, O_RDONLY);
 > >             if (fd < 0) {
 > >                     perror("open");
 > >                     return EXIT_FAILURE;
 > >             }
 > >             memset(state, 0, sizeof(state));
 > >             r = ioctl(fd, query_mode->rq, state);
 > >             close(fd);
 > >
 > >             if (r == -1) {
 > >                     perror("ioctl");
 > >                     return EXIT_FAILURE;
 > >             }
 > >
 > >             if (test_bit(keycode, state))
 > >                     return 10; /* different from EXIT_FAILURE */
 > >             else
 > >                     return 0;
 > >     }
 > >
 > >
 > >
 > > paul
 > >
 > >
 > >  >
 > >  > Gonzalo
 > >  >
 > >  >
 > >  > On Thu, Jan 24, 2013 at 12:16 PM, Martin Langhoff <
 > > martin.langhoff at gmail.com
 > >  > > wrote:
 > >  >
 > >  > > On Thu, Jan 24, 2013 at 10:13 AM, Paul Fox <pgf at laptop.org> wrote:
 > >  > > > i believe sugar already has code to detect the two modes, since
 > >  > > > that's how it knows whether to present the OSK or not.
 > >  > >
 > >  > > Yep. Ajay, I think Write shows you the way :-)
 > >  > >
 > >  > >
 > >  > >
 > >  > >
 > >  > > m
 > >  > > --
 > >  > >  martin.langhoff at gmail.com
 > >  > >  martin at laptop.org -- Software Architect - OLPC
 > >  > >  - ask interesting questions
 > >  > >  - don't get distracted with shiny stuff  - working code first
 > >  > >  - http://wiki.laptop.org/go/User:Martinlanghoff
 > >  > >
 > >
 > > =---------------------
 > >  paul fox, pgf at laptop.org
 > > _______________________________________________
 > > Devel mailing list
 > > Devel at lists.laptop.org
 > > http://lists.laptop.org/listinfo/devel
 > >
 > 
 > 
 > 
 > -- 
 > Regards,
 > 
 > Ajay Garg
 > Dextrose Developer
 > Activity Central: http://activitycentral.com

=---------------------
 paul fox, pgf at laptop.org



More information about the Devel mailing list