summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2024-11-27 17:11:03 -0500
committerWilliam Wilgus <wilgus.william@gmail.com>2024-11-27 20:16:53 -0500
commitda9d67a0fe7a4ee6858d58e21614ba605188b4d9 (patch)
treeb4bb6220d69ded1e81c77004efc4cfc6252093ea
parent5954a2fd4854522364893480c98a5ae25e2fb7eb (diff)
downloadrockbox-da9d67a0fe.tar.gz
rockbox-da9d67a0fe.zip
Button queue handling is split from main button driver
First half of https://gerrit.rockbox.org/r/c/rockbox/+/570 Change-Id: Icc64dfd8194c18f69564ed5f8bf7dd70a4330eb9
-rw-r--r--apps/gui/bitmap/list.c2
-rw-r--r--apps/gui/statusbar-skinned.c2
-rw-r--r--apps/gui/wps.c2
-rw-r--r--apps/plugin.c5
-rw-r--r--apps/plugin.h7
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c2
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c2
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/drivers/button.c167
-rw-r--r--firmware/drivers/button_queue.c185
-rw-r--r--firmware/export/button.h22
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c4
-rw-r--r--firmware/target/arm/as3525/scrollwheel-as3525.c4
-rw-r--r--firmware/target/arm/ipod/button-1g-3g.c4
-rw-r--r--firmware/target/arm/ipod/button-clickwheel.c6
-rw-r--r--firmware/target/arm/ipod/button-mini1g.c4
-rw-r--r--firmware/target/arm/pbell/vibe500/button-vibe500.c2
-rw-r--r--firmware/target/arm/philips/hdd6330/button-hdd6330.c2
-rw-r--r--firmware/target/arm/samsung/button-yh82x_yh92x.c8
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/button-e200.c4
-rw-r--r--firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c4
-rw-r--r--firmware/target/coldfire/mpio/hd300/button-hd300.c12
-rw-r--r--firmware/target/hosted/android/button-android.c2
-rw-r--r--firmware/target/hosted/android/lcd-android.c2
-rw-r--r--firmware/target/hosted/button-devinput.c4
-rw-r--r--firmware/target/hosted/maemo/maemo-thread.c12
-rw-r--r--firmware/target/hosted/sdl/button-sdl.c4
-rw-r--r--firmware/target/mips/ingenic_x1000/erosqnative/button-erosqnative.c4
-rw-r--r--firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c4
-rw-r--r--firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c4
30 files changed, 266 insertions, 221 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 6fdac16ad6..740d78719a 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -694,7 +694,7 @@ static int kinetic_callback(struct timeout *tmo)
/* let get_action() timeout, which loads to a
* gui_synclist_draw() call from the main thread */
- queue_post(&button_queue, BUTTON_REDRAW, 0);
+ button_queue_post(BUTTON_REDRAW, 0);
/* stop if the velocity hit or crossed zero */
if (!data->velocity)
{
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c
index 8dd66641dd..e0b49efdae 100644
--- a/apps/gui/statusbar-skinned.c
+++ b/apps/gui/statusbar-skinned.c
@@ -198,7 +198,7 @@ void do_sbs_update_callback(unsigned short id, void *param)
skin_request_full_update(CUSTOM_STATUSBAR);
force_waiting = true;
/* force timeout in wps main loop, so that the update is instantly */
- queue_post(&button_queue, BUTTON_NONE, 0);
+ button_queue_post(BUTTON_NONE, 0);
}
void sb_skin_set_update_delay(int delay)
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 82b0394a53..9531e9a0e5 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -514,7 +514,7 @@ static void wps_lcd_activation_hook(unsigned short id, void *param)
(void)param;
skin_request_full_update(WPS);
/* force timeout in wps main loop, so that the update is instantly */
- queue_post(&button_queue, BUTTON_NONE, 0);
+ button_queue_post(BUTTON_NONE, 0);
}
#endif
diff --git a/apps/plugin.c b/apps/plugin.c
index a2bfc2f3fc..5a9cd0b6c7 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -249,7 +249,7 @@ static const struct plugin_api rockbox_api = {
lcd_set_mode,
#endif
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
- &button_queue,
+ button_queue_post,
#endif
bidi_l2v,
is_diacritic,
@@ -448,6 +448,7 @@ static const struct plugin_api rockbox_api = {
talk_idarray,
talk_file,
talk_file_or_spell,
+ talk_fullpath,
talk_dir_or_spell,
talk_number,
talk_value_decimal,
@@ -840,8 +841,6 @@ static const struct plugin_api rockbox_api = {
/* new stuff at the end, sort into place next time
the API gets incompatible */
-
- talk_fullpath,
};
static int plugin_buffer_handle;
diff --git a/apps/plugin.h b/apps/plugin.h
index d6635d04fa..d54f1ae951 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -163,7 +163,7 @@ int plugin_open(const char *plugin, const char *parameter);
* when this happens please take the opportunity to sort in
* any new functions "waiting" at the end of the list.
*/
-#define PLUGIN_API_VERSION 271
+#define PLUGIN_API_VERSION 272
/* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */
@@ -282,7 +282,7 @@ struct plugin_api {
#endif
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
- struct event_queue *button_queue;
+ void (*button_queue_post)(long id, intptr_t data);
#endif
unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
bool (*is_diacritic)(const unsigned short char_code, bool *is_rtl);
@@ -511,6 +511,7 @@ struct plugin_api {
const char *ext, const long *prefix_ids, bool enqueue);
int (*talk_file_or_spell)(const char *dirname, const char* filename,
const long *prefix_ids, bool enqueue);
+ int (*talk_fullpath)(const char* path, bool enqueue);
int (*talk_dir_or_spell)(const char* filename,
const long *prefix_ids, bool enqueue);
int (*talk_number)(long n, bool enqueue);
@@ -977,8 +978,6 @@ struct plugin_api {
#endif
/* new stuff at the end, sort into place next time
the API gets incompatible */
-
- int (*talk_fullpath)(const char* path, bool enqueue);
};
/* plugin header */
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index 6464f37217..f9686ad689 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -772,7 +772,7 @@ static void get_start_time_lcd_enable_hook(unsigned short id, void *param)
{
(void)id;
(void)param;
- rb->queue_post(rb->button_queue, LCD_ENABLE_EVENT_0, 0);
+ rb->button_queue_post(LCD_ENABLE_EVENT_0, 0);
}
#endif /* HAVE_LCD_ENABLE */
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index 654a348959..dadb8f6b8a 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -1208,7 +1208,7 @@ static void osd_lcd_enable_hook(unsigned short id, void* param)
{
(void)id;
(void)param;
- rb->queue_post(rb->button_queue, LCD_ENABLE_EVENT_1, 0);
+ rb->button_queue_post(LCD_ENABLE_EVENT_1, 0);
}
#endif
diff --git a/firmware/SOURCES b/firmware/SOURCES
index ae0fed0efe..8ad9093e20 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -338,6 +338,7 @@ backlight-sw-fading.c
/* Misc. */
drivers/led.c
drivers/button.c
+drivers/button_queue.c
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
#ifdef HAVE_DAC3550A
drivers/audio/dac3550a.c
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 3220f18ed7..8f34b31809 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -45,11 +45,8 @@
#include "lcd.h" /* lcd_active() prototype */
#endif
-struct event_queue button_queue SHAREDBSS_ATTR;
-
static long lastbtn; /* Last valid button status */
static long last_read; /* Last button status, for debouncing/filtering */
-static intptr_t button_data; /* data value from last message dequeued */
static bool flipped; /* buttons can be flipped to match the LCD flip */
#ifdef HAVE_BACKLIGHT /* Filter first keypress function pointer */
@@ -95,7 +92,7 @@ static void button_remote_post(void)
/* Post events for the remote control */
int btn = remote_control_rx();
if(btn)
- button_try_post(btn, 0);
+ button_queue_try_post(btn, 0);
#endif
}
@@ -104,8 +101,7 @@ static int hp_detect_callback(struct timeout *tmo)
{
/* Try to post only transistions */
const long id = tmo->data ? SYS_PHONE_PLUGGED : SYS_PHONE_UNPLUGGED;
- queue_remove_from_head(&button_queue, id);
- queue_post(&button_queue, id, 0);
+ button_queue_post_remove_head(id, 0);
return 0;
/*misc.c:hp_unplug_change*/
}
@@ -116,8 +112,7 @@ static int lo_detect_callback(struct timeout *tmo)
{
/* Try to post only transistions */
const long id = tmo->data ? SYS_LINEOUT_PLUGGED : SYS_LINEOUT_UNPLUGGED;
- queue_remove_from_head(&button_queue, id);
- queue_post(&button_queue, id, 0);
+ button_queue_post_remove_head(id, 0);
return 0;
/*misc.c:lo_unplug_change*/
}
@@ -151,40 +146,11 @@ static void check_audio_peripheral_state(void)
#endif
}
-static bool button_try_post(int button, int data)
-{
-#ifdef HAVE_TOUCHSCREEN
- /* one can swipe over the scren very quickly,
- * for this to work we want to forget about old presses and
- * only respect the very latest ones */
- const bool force_post = true;
-#else
- /* Only post events if the queue is empty,
- * to avoid afterscroll effects.
- * i.e. don't post new buttons if previous ones haven't been
- * processed yet - but always post releases */
- const bool force_post = button & BUTTON_REL;
-#endif
-
- bool ret = queue_empty(&button_queue);
- if (!ret && force_post)
- {
- queue_remove_from_head(&button_queue, button);
- ret = true;
- }
-
- if (ret)
- queue_post(&button_queue, button, data);
-
- /* on touchscreen we posted unconditionally */
- return ret;
-}
-
#ifdef HAVE_BACKLIGHT
/* disabled function is shared between Main & Remote LCDs */
static bool filter_first_keypress_disabled(int button, int data)
{
- button_try_post(button, data);
+ button_queue_try_post(button, data);
return false;
}
@@ -248,17 +214,17 @@ static void button_tick(void)
#ifdef HAVE_REMOTE_LCD
if(diff & BUTTON_REMOTE)
if(!skip_remote_release)
- button_try_post(BUTTON_REL | diff, data);
+ button_queue_try_post(BUTTON_REL | diff, data);
else
skip_remote_release = false;
else
#endif
if(!skip_release)
- button_try_post(BUTTON_REL | diff, data);
+ button_queue_try_post(BUTTON_REL | diff, data);
else
skip_release = false;
#else
- button_try_post(BUTTON_REL | diff, data);
+ button_queue_try_post(BUTTON_REL | diff, data);
#endif
}
else
@@ -367,7 +333,7 @@ static void button_tick(void)
{
/* Only post repeat events if the queue is empty,
* to avoid afterscroll effects. */
- if (button_try_post(BUTTON_REPEAT | btn, data))
+ if (button_queue_try_post(BUTTON_REPEAT | btn, data))
{
#ifdef HAVE_BACKLIGHT
#ifdef HAVE_REMOTE_LCD
@@ -394,7 +360,7 @@ static void button_tick(void)
buttonlight_on();
}
#else /* no backlight, nothing to skip */
- button_try_post(btn, data);
+ button_queue_try_post(btn, data);
#endif
post = false;
}
@@ -412,119 +378,11 @@ static void button_tick(void)
lastdata = data;
}
-#ifdef HAVE_ADJUSTABLE_CPU_FREQ
-static bool button_boosted = false;
-static long button_unboost_tick;
-#define BUTTON_UNBOOST_TMO HZ
-
-static void button_boost(bool state)
-{
- if (state)
- {
- button_unboost_tick = current_tick + BUTTON_UNBOOST_TMO;
-
- if (!button_boosted)
- {
- button_boosted = true;
- cpu_boost(true);
- }
- }
- else if (!state && button_boosted)
- {
- button_boosted = false;
- cpu_boost(false);
- }
-}
-
-static void button_queue_wait(struct queue_event *evp, int timeout)
-{
- /* Loop once after wait time if boosted in order to unboost and wait the
- full remaining time */
- do
- {
- int ticks = timeout;
-
- if (ticks == 0) /* TIMEOUT_NOBLOCK */
- ;
- else if (ticks > 0)
- {
- if (button_boosted && ticks > BUTTON_UNBOOST_TMO)
- ticks = BUTTON_UNBOOST_TMO;
-
- timeout -= ticks;
- }
- else /* TIMEOUT_BLOCK (ticks < 0) */
- {
- if (button_boosted)
- ticks = BUTTON_UNBOOST_TMO;
- }
-
- queue_wait_w_tmo(&button_queue, evp, ticks);
- if (evp->id != SYS_TIMEOUT)
- {
- /* GUI boost build gets immediate kick, otherwise at least 3
- messages had to be there */
- #ifndef HAVE_GUI_BOOST
- if (queue_count(&button_queue) >= 2)
- #endif
- button_boost(true);
-
- break;
- }
-
- if (button_boosted && TIME_AFTER(current_tick, button_unboost_tick))
- button_boost(false);
- }
- while (timeout);
-}
-#else /* ndef HAVE_ADJUSTABLE_CPU_FREQ */
-static inline void button_queue_wait(struct queue_event *evp, int timeout)
-{
- queue_wait_w_tmo(&button_queue, evp, timeout);
-}
-#endif /* HAVE_ADJUSTABLE_CPU_FREQ */
-
-int button_queue_count( void )
-{
- return queue_count(&button_queue);
-}
-
-long button_get(bool block)
-{
- struct queue_event ev;
- button_queue_wait(&ev, block ? TIMEOUT_BLOCK : TIMEOUT_NOBLOCK);
-
- if (ev.id == SYS_TIMEOUT)
- ev.id = BUTTON_NONE;
- else
- button_data = ev.data;
-
- return ev.id;
-}
-
-long button_get_w_tmo(int ticks)
-{
- struct queue_event ev;
- button_queue_wait(&ev, ticks);
-
- if (ev.id == SYS_TIMEOUT)
- ev.id = BUTTON_NONE;
- else
- button_data = ev.data;
-
- return ev.id;
-}
-
-intptr_t button_get_data(void)
-{
- return button_data;
-}
-
void button_init(void)
{
int temp;
/* Init used objects first */
- queue_init(&button_queue, true);
+ button_queue_init();
/* hardware inits */
button_init_device();
@@ -714,11 +572,6 @@ int button_status_wdata(int *pdata)
}
#endif
-void button_clear_queue(void)
-{
- queue_clear(&button_queue);
-}
-
#ifdef HAVE_TOUCHSCREEN
long touchscreen_last_touch(void)
{
diff --git a/firmware/drivers/button_queue.c b/firmware/drivers/button_queue.c
new file mode 100644
index 0000000000..6b4d0509d1
--- /dev/null
+++ b/firmware/drivers/button_queue.c
@@ -0,0 +1,185 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Daniel Stenberg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "config.h"
+#include "system.h"
+#include "kernel.h"
+#include "button.h"
+
+static struct event_queue button_queue SHAREDBSS_ATTR;
+static intptr_t button_data; /* data value from last message dequeued */
+
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+static bool button_boosted = false;
+static long button_unboost_tick;
+#define BUTTON_UNBOOST_TMO HZ
+
+static void button_boost(bool state)
+{
+ if (state)
+ {
+ /* update the unboost time each button_boost(true) call */
+ button_unboost_tick = current_tick + BUTTON_UNBOOST_TMO;
+
+ if (!button_boosted)
+ {
+ button_boosted = true;
+ cpu_boost(true);
+ }
+ }
+ else if (!button_boosted && TIME_AFTER(current_tick, button_unboost_tick))
+ {
+ button_boosted = false;
+ cpu_boost(false);
+ }
+}
+
+static void button_queue_wait(struct queue_event *evp, int timeout)
+{
+ /* Loop once after wait time if boosted in order to unboost and wait the
+ full remaining time */
+ do
+ {
+ int ticks = timeout;
+
+ if (ticks == TIMEOUT_NOBLOCK)
+ ;
+ else if (ticks > 0)
+ {
+ if (button_boosted && ticks > BUTTON_UNBOOST_TMO)
+ ticks = BUTTON_UNBOOST_TMO;
+
+ timeout -= ticks;
+ }
+ else if (button_boosted) /* TIMEOUT_BLOCK (ticks < 0) */
+ {
+ ticks = BUTTON_UNBOOST_TMO;
+ }
+
+ queue_wait_w_tmo(&button_queue, evp, ticks);
+ if (evp->id != SYS_TIMEOUT)
+ {
+ /* GUI boost build gets immediate kick, otherwise at least 3
+ messages had to be there */
+ #ifndef HAVE_GUI_BOOST
+ if (queue_count(&button_queue) >= 2)
+ #endif
+ button_boost(true);
+
+ break;
+ }
+ button_boost(false);
+ }
+ while (timeout);
+}
+#else /* ndef HAVE_ADJUSTABLE_CPU_FREQ */
+static inline void button_queue_wait(struct queue_event *evp, int timeout)
+{
+ queue_wait_w_tmo(&button_queue, evp, timeout);
+}
+#endif /* HAVE_ADJUSTABLE_CPU_FREQ */
+
+void button_queue_post(long id, intptr_t data)
+{
+ queue_post(&button_queue, id, data);
+}
+
+void button_queue_post_remove_head(long id, intptr_t data)
+{
+ queue_remove_from_head(&button_queue, id);
+ queue_post(&button_queue, id, data);
+}
+
+bool button_queue_try_post(long button, int data)
+{
+#ifdef HAVE_TOUCHSCREEN
+ /* one can swipe over the scren very quickly,
+ * for this to work we want to forget about old presses and
+ * only respect the very latest ones */
+ const bool force_post = true;
+#else
+ /* Only post events if the queue is empty,
+ * to avoid afterscroll effects.
+ * i.e. don't post new buttons if previous ones haven't been
+ * processed yet - but always post releases */
+ const bool force_post = button & BUTTON_REL;
+#endif
+
+ if (!queue_empty(&button_queue))
+ {
+ if (force_post)
+ queue_remove_from_head(&button_queue, button);
+ else
+ return false;
+ }
+
+ queue_post(&button_queue, button, data);
+
+ /* on touchscreen we posted unconditionally */
+ return true;
+}
+
+int button_queue_count(void)
+{
+ return queue_count(&button_queue);
+}
+
+bool button_queue_empty(void)
+{
+ return queue_empty(&button_queue);
+}
+
+bool button_queue_full(void)
+{
+ return queue_full(&button_queue);
+}
+
+void button_clear_queue(void)
+{
+ queue_clear(&button_queue);
+}
+
+long button_get_w_tmo(int ticks)
+{
+ struct queue_event ev;
+ button_queue_wait(&ev, ticks);
+
+ if (ev.id == SYS_TIMEOUT)
+ ev.id = BUTTON_NONE;
+ else
+ button_data = ev.data;
+
+ return ev.id;
+}
+
+long button_get(bool block)
+{
+ return button_get_w_tmo(block ? TIMEOUT_BLOCK : TIMEOUT_NOBLOCK);
+}
+
+intptr_t button_get_data(void)
+{
+ return button_data;
+}
+
+void INIT_ATTR button_queue_init(void)
+{
+ queue_init(&button_queue, true);
+}
diff --git a/firmware/export/button.h b/firmware/export/button.h
index 75a72ab66e..d45b9844bc 100644
--- a/firmware/export/button.h
+++ b/firmware/export/button.h
@@ -32,8 +32,6 @@
# define BUTTON_REMOTE 0
#endif
-extern struct event_queue button_queue;
-
void button_init_device(void);
#ifdef HAVE_BUTTON_DATA
int button_read_device(int *);
@@ -50,15 +48,12 @@ bool remote_button_hold(void);
void button_init (void) INIT_ATTR;
void button_close(void);
-int button_queue_count(void);
-long button_get (bool block);
-long button_get_w_tmo(int ticks);
-intptr_t button_get_data(void);
+
int button_status(void);
#ifdef HAVE_BUTTON_DATA
int button_status_wdata(int *pdata);
#endif
-void button_clear_queue(void);
+
void button_set_flip(bool flip); /* turn 180 degrees */
#ifdef HAVE_BACKLIGHT
void set_backlight_filter_keypress(bool value);
@@ -67,6 +62,19 @@ void set_remote_backlight_filter_keypress(bool value);
#endif
#endif
+/* button queue functions (in button_queue.c) */
+void button_queue_init(void);
+void button_queue_post(long id, intptr_t data);
+void button_queue_post_remove_head(long id, intptr_t data);
+bool button_queue_try_post(long button, int data);
+int button_queue_count(void);
+bool button_queue_empty(void);
+bool button_queue_full(void);
+void button_clear_queue(void);
+long button_get(bool block);
+long button_get_w_tmo(int ticks);
+intptr_t button_get_data(void);
+
#ifdef HAVE_HEADPHONE_DETECTION
bool headphones_inserted(void);
#endif
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
index 319b3e33d4..5023e72cc3 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
@@ -163,9 +163,9 @@ static void scrollwheel(unsigned int wheel_value)
last_wheel_post = time;
- if (queue_empty(&button_queue))
+ if (button_queue_empty())
{
- queue_post(&button_queue, btn, wheel_fast_mode |
+ button_queue_post(btn, wheel_fast_mode |
(wheel_delta << 24) | wheel_velocity*360/WHEELCLICKS_PER_ROTATION);
/* message posted - reset delta and poke backlight on*/
wheel_delta = 1;
diff --git a/firmware/target/arm/as3525/scrollwheel-as3525.c b/firmware/target/arm/as3525/scrollwheel-as3525.c
index c66f8e091a..357e7c55bf 100644
--- a/firmware/target/arm/as3525/scrollwheel-as3525.c
+++ b/firmware/target/arm/as3525/scrollwheel-as3525.c
@@ -105,12 +105,12 @@ void scrollwheel(unsigned int wheel_value)
/* the wheel is more reliable if we don't send every change,
* every WHEEL_COUNTER_DIVth is basically one "physical click"
* which should make up 1 item in lists */
- if (++counter >= WHEEL_COUNTER_DIV && queue_empty(&button_queue))
+ if (++counter >= WHEEL_COUNTER_DIV && button_queue_empty())
{
buttonlight_on();
backlight_on();
reset_poweroff_timer();
- queue_post(&button_queue, btn, ((wheel_delta+1)<<24));
+ button_queue_post(btn, ((wheel_delta+1)<<24));
/* message posted - reset count and remember post */
counter = 0;
last_wheel_post = current_tick;
diff --git a/firmware/target/arm/ipod/button-1g-3g.c b/firmware/target/arm/ipod/button-1g-3g.c
index 2710723866..34d63ec495 100644
--- a/firmware/target/arm/ipod/button-1g-3g.c
+++ b/firmware/target/arm/ipod/button-1g-3g.c
@@ -159,7 +159,7 @@ static void handle_scroll_wheel(int new_scroll)
wheel_velocity = (7*wheel_velocity + v) / 8;
}
- if (queue_empty(&button_queue)) {
+ if (button_queue_empty()) {
int key = wheel_keycode;
if (v >= WHEEL_REPEAT_VELOCITY && prev_keypost == key) {
@@ -171,7 +171,7 @@ static void handle_scroll_wheel(int new_scroll)
prev_keypost = wheel_keycode;
/* post wheel keycode with wheel data */
- queue_post(&button_queue, key,
+ button_queue_post(key,
(wheel_velocity >= WHEEL_ACCEL_START ? (1ul << 31) : 0)
| wheel_delta | wheel_velocity);
/* message posted - reset delta */
diff --git a/firmware/target/arm/ipod/button-clickwheel.c b/firmware/target/arm/ipod/button-clickwheel.c
index 90c08532b7..3014405bbd 100644
--- a/firmware/target/arm/ipod/button-clickwheel.c
+++ b/firmware/target/arm/ipod/button-clickwheel.c
@@ -223,7 +223,7 @@ static inline int ipod_4g_button_read(void)
if (send_events)
#endif
/* The queue should have no other events when scrolling */
- if (queue_empty(&button_queue))
+ if (button_queue_empty())
{
/* each WHEEL_SENSITIVITY clicks = scrolling 1 item */
accumulated_wheel_delta /= WHEEL_SENSITIVITY;
@@ -232,11 +232,11 @@ static inline int ipod_4g_button_read(void)
/* always use acceleration mode (1<<31) */
/* always set message post count to (1<<24) for iPod */
/* this way the scrolling is always calculated from wheel_velocity */
- queue_post(&button_queue, wheel_keycode | repeat,
+ button_queue_post(wheel_keycode | repeat,
(1<<31) | (1 << 24) | wheel_velocity);
#else
- queue_post(&button_queue, wheel_keycode | repeat,
+ button_queue_post(wheel_keycode | repeat,
(accumulated_wheel_delta << 16) | new_wheel_value);
#endif
accumulated_wheel_delta = 0;
diff --git a/firmware/target/arm/ipod/button-mini1g.c b/firmware/target/arm/ipod/button-mini1g.c
index a508958de1..d4fc1327a9 100644
--- a/firmware/target/arm/ipod/button-mini1g.c
+++ b/firmware/target/arm/ipod/button-mini1g.c
@@ -151,7 +151,7 @@ static void handle_scroll_wheel(int new_scroll)
wheel_velocity = (7*wheel_velocity + v) / 8;
}
- if (queue_empty(&button_queue)) {
+ if (button_queue_empty()) {
int key = wheel_keycode;
if (v >= WHEEL_REPEAT_VELOCITY && prev_keypost == key) {
@@ -163,7 +163,7 @@ static void handle_scroll_wheel(int new_scroll)
prev_keypost = wheel_keycode;
/* post wheel keycode with wheel data */
- queue_post(&button_queue, key,
+ button_queue_post(key,
(wheel_velocity >= WHEEL_ACCEL_START ? (1ul << 31) : 0)
| wheel_delta | wheel_velocity);
/* message posted - reset delta */
diff --git a/firmware/target/arm/pbell/vibe500/button-vibe500.c b/firmware/target/arm/pbell/vibe500/button-vibe500.c
index 1279e86725..71c3558403 100644
--- a/firmware/target/arm/pbell/vibe500/button-vibe500.c
+++ b/firmware/target/arm/pbell/vibe500/button-vibe500.c
@@ -126,7 +126,7 @@ int button_read_device(void)
/* Scrollstrip direct button post - much better response */
if ((buttons==BUTTON_UP) || (buttons==BUTTON_DOWN))
{
- queue_post(&button_queue,buttons|repeat,0);
+ button_queue_post(buttons|repeat,0);
backlight_on();
buttonlight_on();
reset_poweroff_timer();
diff --git a/firmware/target/arm/philips/hdd6330/button-hdd6330.c b/firmware/target/arm/philips/hdd6330/button-hdd6330.c
index 9e9bfd941a..8466c56625 100644
--- a/firmware/target/arm/philips/hdd6330/button-hdd6330.c
+++ b/firmware/target/arm/philips/hdd6330/button-hdd6330.c
@@ -144,7 +144,7 @@ int button_read_device(void)
/* Scrollstrip direct button post - much better response */
if ((btn == BUTTON_UP) || (btn == BUTTON_DOWN))
{
- queue_post(&button_queue,btn|repeat,0);
+ button_queue_post(btn|repeat,0);
backlight_on();
buttonlight_on();
reset_poweroff_timer();
diff --git a/firmware/target/arm/samsung/button-yh82x_yh92x.c b/firmware/target/arm/samsung/button-yh82x_yh92x.c
index 7d0f390644..ed3c3abf81 100644
--- a/firmware/target/arm/samsung/button-yh82x_yh92x.c
+++ b/firmware/target/arm/samsung/button-yh82x_yh92x.c
@@ -133,12 +133,12 @@ int button_read_device(void)
if ((~GPIOA_INPUT_VAL & 0x40) != rec_switch)
{
if (rec_switch) {
- queue_post(&button_queue,BUTTON_REC_SW_OFF,0);
- queue_post(&button_queue,BUTTON_REC_SW_OFF|BUTTON_REL,0);
+ button_queue_post(BUTTON_REC_SW_OFF,0);
+ button_queue_post(BUTTON_REC_SW_OFF|BUTTON_REL,0);
}
else {
- queue_post(&button_queue,BUTTON_REC_SW_ON,0);
- queue_post(&button_queue,BUTTON_REC_SW_ON|BUTTON_REL,0);
+ button_queue_post(BUTTON_REC_SW_ON,0);
+ button_queue_post(BUTTON_REC_SW_ON|BUTTON_REL,0);
}
rec_switch = ~GPIOA_INPUT_VAL & 0x40;
backlight_on();
diff --git a/firmware/target/arm/sandisk/sansa-e200/button-e200.c b/firmware/target/arm/sandisk/sansa-e200/button-e200.c
index 0df71f4815..1f108b9b90 100644
--- a/firmware/target/arm/sandisk/sansa-e200/button-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/button-e200.c
@@ -246,7 +246,7 @@ void clickwheel_int(void)
count = 0;
- if (queue_empty(&button_queue))
+ if (button_queue_empty())
{
/* Post wheel keycode with wheel data */
int key = keycode;
@@ -260,7 +260,7 @@ void clickwheel_int(void)
prev_keypost = keycode;
- queue_post(&button_queue, key, (fast_mode << 31) | delta | velocity);
+ button_queue_post(key, (fast_mode << 31) | delta | velocity);
/* Message posted - reset delta */
delta = 1ul << 24;
}
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c
index 6fd504a0f8..0d9e9722c8 100644
--- a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c
+++ b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c
@@ -195,7 +195,7 @@ static void handle_wheel(uint8_t wheel)
}
/* TODO: take velocity into account */
- if (queue_empty(&button_queue))
+ if (button_queue_empty())
{
if (prev_key_post == key)
{
@@ -204,7 +204,7 @@ static void handle_wheel(uint8_t wheel)
/* Post directly, don't update btn as avr doesn't give
interrupt on scroll stop */
- queue_post(&button_queue, key, wheel_delta);
+ button_queue_post(key, wheel_delta);
wheel_delta = 1ul << 24;
diff --git a/firmware/target/coldfire/mpio/hd300/button-hd300.c b/firmware/target/coldfire/mpio/hd300/button-hd300.c
index 2fdde6f641..b78276f351 100644
--- a/firmware/target/coldfire/mpio/hd300/button-hd300.c
+++ b/firmware/target/coldfire/mpio/hd300/button-hd300.c
@@ -109,8 +109,8 @@ void scrollstrip_isr(void)
if (direction != scroll_dir)
{
/* post release event to the button queue */
- if (queue_empty(&button_queue))
- queue_post(&button_queue, direction|BUTTON_REL, 0);
+ if (button_queue_empty())
+ button_queue_post(direction|BUTTON_REL, 0);
scroll.rel = true;
@@ -134,8 +134,8 @@ void scrollstrip_isr(void)
count = 0;
/* post scrollstrip event to the button queue */
- if (queue_empty(&button_queue))
- queue_post(&button_queue, scroll_dir, 0);
+ if (button_queue_empty())
+ button_queue_post(scroll_dir, 0);
scroll.dir = scroll_dir;
scroll.timeout = current_tick + SLIDER_REL_TIMEOUT;
@@ -264,9 +264,9 @@ int button_read_device(void)
if (!scroll.rel)
if (TIME_AFTER(current_tick, scroll.timeout))
{
- if (queue_empty(&button_queue))
+ if (button_queue_empty())
{
- queue_post(&button_queue, scroll.dir|BUTTON_REL, 0);
+ button_queue_post(scroll.dir|BUTTON_REL, 0);
scroll.rel = true;
}
}
diff --git a/firmware/target/hosted/android/button-android.c b/firmware/target/hosted/android/button-android.c
index b4f3d1bd90..8dad5961c4 100644
--- a/firmware/target/hosted/android/button-android.c
+++ b/firmware/target/hosted/android/button-android.c
@@ -84,7 +84,7 @@ Java_org_rockbox_RockboxFramebuffer_buttonHandler(JNIEnv*env, jclass class,
/* ensure button_queue can be safely posted to */
wait_rockbox_ready();
reset_poweroff_timer();
- queue_post(&button_queue, button, 0);
+ button_queue_post(button, 0);
return true;
}
}
diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c
index 12df52c95e..0b308eeced 100644
--- a/firmware/target/hosted/android/lcd-android.c
+++ b/firmware/target/hosted/android/lcd-android.c
@@ -140,7 +140,7 @@ Java_org_rockbox_RockboxFramebuffer_surfaceCreated(JNIEnv *env, jobject this,
send_event(LCD_EVENT_ACTIVATION, NULL);
/* Force an update, since the newly created surface is initially black
* waiting for the next normal update results in a longish black screen */
- queue_post(&button_queue, BUTTON_REDRAW, 0);
+ button_queue_post(BUTTON_REDRAW, 0);
}
/*
diff --git a/firmware/target/hosted/button-devinput.c b/firmware/target/hosted/button-devinput.c
index df2358579b..1fe998fa90 100644
--- a/firmware/target/hosted/button-devinput.c
+++ b/firmware/target/hosted/button-devinput.c
@@ -181,14 +181,14 @@ int button_read_device(void)
{
while (wheel_ticks-- > 0)
{
- queue_post(&button_queue, BUTTON_SCROLL_FWD, 0);
+ button_queue_post(BUTTON_SCROLL_FWD, 0);
}
}
else if (wheel_ticks < 0)
{
while (wheel_ticks++ < 0)
{
- queue_post(&button_queue, BUTTON_SCROLL_BACK, 0);
+ button_queue_post(BUTTON_SCROLL_BACK, 0);
}
}
#endif /* HAVE_SCROLLWHEEL */
diff --git a/firmware/target/hosted/maemo/maemo-thread.c b/firmware/target/hosted/maemo/maemo-thread.c
index c9ac073ed3..43d21c9ad4 100644
--- a/firmware/target/hosted/maemo/maemo-thread.c
+++ b/firmware/target/hosted/maemo/maemo-thread.c
@@ -103,17 +103,17 @@ static void on_bt_button_pressed(LibHalContext *ctx,
sim_enter_irq_handler();
if (g_str_equal(condition_detail, "play-cd") || g_str_equal(condition_detail, "pause-cd"))
- queue_post(&button_queue, BUTTON_MULTIMEDIA_PLAYPAUSE, 0);
+ button_queue_post(BUTTON_MULTIMEDIA_PLAYPAUSE, 0);
else if (g_str_equal(condition_detail, "stop-cd"))
- queue_post(&button_queue, BUTTON_MULTIMEDIA_STOP, 0);
+ button_queue_post(BUTTON_MULTIMEDIA_STOP, 0);
else if (g_str_equal(condition_detail, "next-song"))
- queue_post(&button_queue, BUTTON_MULTIMEDIA_NEXT, 0);
+ button_queue_post(BUTTON_MULTIMEDIA_NEXT, 0);
else if (g_str_equal(condition_detail, "previous-song"))
- queue_post(&button_queue, BUTTON_MULTIMEDIA_PREV, 0);
+ button_queue_post(BUTTON_MULTIMEDIA_PREV, 0);
else if (g_str_equal(condition_detail, "fast-forward"))
- queue_post(&button_queue, BUTTON_MULTIMEDIA_FFWD, 0);
+ button_queue_post(BUTTON_MULTIMEDIA_FFWD, 0);
else if (g_str_equal(condition_detail, "rewind"))
- queue_post(&button_queue, BUTTON_MULTIMEDIA_REW, 0);
+ button_queue_post(BUTTON_MULTIMEDIA_REW, 0);
sim_exit_irq_handler();
}
diff --git a/firmware/target/hosted/sdl/button-sdl.c b/firmware/target/hosted/sdl/button-sdl.c
index 8af6f3ffaf..49e4b15df4 100644
--- a/firmware/target/hosted/sdl/button-sdl.c
+++ b/firmware/target/hosted/sdl/button-sdl.c
@@ -125,8 +125,8 @@ static void scrollwheel_event(int x, int y)
buttonlight_on();
#endif
reset_poweroff_timer();
- if (new_btn && !queue_full(&button_queue))
- queue_post(&button_queue, new_btn, 1<<24);
+ if (new_btn && !button_queue_full())
+ button_queue_post(new_btn, 1<<24);
(void)x;
}
diff --git a/firmware/target/mips/ingenic_x1000/erosqnative/button-erosqnative.c b/firmware/target/mips/ingenic_x1000/erosqnative/button-erosqnative.c
index c5abd7c93f..67da3ce645 100644
--- a/firmware/target/mips/ingenic_x1000/erosqnative/button-erosqnative.c
+++ b/firmware/target/mips/ingenic_x1000/erosqnative/button-erosqnative.c
@@ -305,7 +305,7 @@ int button_read_device(void)
{
/* need to use queue_post() in order to do BUTTON_SCROLL_*,
* Rockbox treats these buttons differently. */
- queue_post(&button_queue, BUTTON_SCROLL_FWD, 0);
+ button_queue_post(BUTTON_SCROLL_FWD, 0);
enc_position = 0;
reset_poweroff_timer();
backlight_on();
@@ -314,7 +314,7 @@ int button_read_device(void)
{
/* need to use queue_post() in order to do BUTTON_SCROLL_*,
* Rockbox treats these buttons differently. */
- queue_post(&button_queue, BUTTON_SCROLL_BACK, 0);
+ button_queue_post(BUTTON_SCROLL_BACK, 0);
enc_position = 0;
reset_poweroff_timer();
backlight_on();
diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c
index 24daf2ef69..9a1cecd873 100644
--- a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c
+++ b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c
@@ -296,9 +296,9 @@ static void ft_step_state(uint32_t t, int evt, int tx, int ty)
* should not be necessary but better to be safe. */
if(fsm.active) {
if(dy < 0) {
- queue_post(&button_queue, BUTTON_SCROLL_BACK, 0);
+ button_queue_post(BUTTON_SCROLL_BACK, 0);
} else {
- queue_post(&button_queue, BUTTON_SCROLL_FWD, 0);
+ button_queue_post(BUTTON_SCROLL_FWD, 0);
}
/* Poke the backlight */
diff --git a/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c b/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c
index 13b0cdd078..5dbfb6b7d5 100644
--- a/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c
+++ b/firmware/target/mips/ingenic_x1000/shanlingq1/button-shanlingq1.c
@@ -136,8 +136,8 @@ int button_read_device(int* data)
wheel_pos = 0;
/* Post the event (rapid motion is more reliable this way) */
- queue_post(&button_queue, wheel_btn, 0);
- queue_post(&button_queue, wheel_btn|BUTTON_REL, 0);
+ button_queue_post(wheel_btn, 0);
+ button_queue_post(wheel_btn|BUTTON_REL, 0);
/* Poke the backlight */
backlight_on();