dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: peeking at the keys
From: TP Diffenbach (
Date: 2003-07-28

I want to peek at the keys, without actually using up a keypress. get_button is
written in terms of queue_wait, which advances the queue->read pointer:

button.c, line 168:
int button_get(bool block)
    struct event ev;

    if ( block || !queue_empty(&button_queue) ) {
        queue_wait(&button_queue, &ev);
    return BUTTON_NONE;

kernal.c, line 97:
void queue_wait(struct event_queue *q, struct event *ev)
    while(q->read == q->write)

    *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];

I've written a version of queue_wait that does everything queue_wait does EXCEPT
increment read, and that seems to work.

But if queue_wait can stand the time overhead of a function call, it might make
sense to implement queue_read in terms of queue_read_peek:

void queue_wait(struct event_queue *q, struct event *ev)
  queue_wait_peek( q, ve ) ;
  ++q->read ;

or (with the overhead of an extra operation) implement queue_wait_peek in terms of
void queue_wait_peek(struct event_queue *q, struct event *ev)
  queue_wait( q, ve ) ;
  --q->read ;

Since queue_wait is called more often, it seems better to implement _peek in terms
of queue_wait, but I await your advice.

Archos FM has a Rockbox!

Page was last modified "Jan 10 2012" The Rockbox Crew