Button queue handling is split from main button driver

First half of
https://gerrit.rockbox.org/r/c/rockbox/+/570

Change-Id: Icc64dfd8194c18f69564ed5f8bf7dd70a4330eb9
This commit is contained in:
William Wilgus 2024-11-27 17:11:03 -05:00
parent 5954a2fd48
commit da9d67a0fe
30 changed files with 266 additions and 221 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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 */

View file

@ -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;

View file

@ -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 */

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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);
}
/*

View file

@ -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 */

View file

@ -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();
}

View file

@ -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;
}

View file

@ -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();

View file

@ -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 */

View file

@ -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();