static void double_click_flow_control (void) { is_testing_double_click = 0; roadmap_main_remove_periodic(double_click_flow_control); exec_callbacks (SHORT_CLICK, &last_pointer_point); exec_callbacks (RELEASED, &last_pointer_point); }
void BUTTON_Handler() { static u32 last_buttons = 0; static u32 last_buttons_pressed = 0; static u32 long_press_at = 0; static u8 longpress_release = 0; static u32 last_button_time = 0; u32 ms = CLOCK_getms(); //debounce if (ms < last_button_time) return; u32 buttons = ScanButtons(); u32 buttons_pressed= buttons & (~last_buttons); u32 buttons_released=(~buttons) & last_buttons; if (buttons != last_buttons) last_button_time = ms; if(buttons_pressed && !longpress_release) { //printf("pressed: %08d\n", buttons_pressed); AUTODIMMER_Check(); exec_callbacks(buttons_pressed, BUTTON_PRESS); last_buttons_pressed = buttons_pressed; long_press_at = ms+500; longpress_release = 0; interrupt_longpress = 0; } if(buttons_released) { //printf("release: %08d\n", buttons_released); interrupt_longpress = 0; longpress_release = 0; if(!longpress_release) { exec_callbacks(buttons_released, BUTTON_RELEASE); } else { exec_callbacks(buttons_released, BUTTON_RELEASE | BUTTON_HAD_LONGPRESS); } } if(buttons && (buttons == last_buttons) && !interrupt_longpress) { if(ms > long_press_at) { //printf("long_press: %08d\n", buttons_released); exec_callbacks(last_buttons_pressed, BUTTON_LONGPRESS); longpress_release=1; long_press_at += 100; } } last_buttons=buttons; }
void SerialRendererController::on_rendering_abort() { // Execute any pending callback since the last time on_progress() was called. exec_callbacks(); m_controller->on_rendering_abort(); }
static void roadmap_pointer_moved (RoadMapGuiPoint *point) { if (cancel_dragging || is_testing_double_click || (!is_button_down && !is_dragging)) return; if (!is_dragging) { /* Less sensitive, since a car is not a quiet environment... */ if ((abs(point->x - last_pointer_point.x) <= get_drag_movement_thr()) && (abs(point->y - last_pointer_point.y) <= get_drag_movement_thr())) return; // roadmap_main_remove_periodic(roadmap_pointer_button_timeout); exec_callbacks (DRAG_START, &last_pointer_point); last_pointer_point = *point; is_drag_flow_control_on = 1; roadmap_main_set_periodic (DRAG_FLOW_CONTROL_TIMEOUT, drag_flow_control); is_dragging = 1; } else { /* the flow control timer will execute the handler */ last_pointer_point = *point; if (!is_drag_flow_control_on) { is_drag_flow_control_on = 1; roadmap_main_set_periodic (DRAG_FLOW_CONTROL_TIMEOUT, drag_flow_control); } } }
/* Instead of calling the drag motion event with every mouse move, * we use this timer as a flow control. It may take time for the * application to finish the task of drawing the screen and we don't * want to lag. */ static void drag_flow_control(void) { roadmap_main_remove_periodic(drag_flow_control); exec_callbacks (DRAG_MOTION, &last_pointer_point); is_drag_flow_control_on = 0; }
static void roadmap_pointer_button_released (RoadMapGuiPoint *point) { if (is_drag_flow_control_on) { roadmap_main_remove_periodic(drag_flow_control); is_drag_flow_control_on = 0; } if ( !is_button_down ) return; roadmap_main_remove_periodic( long_click_flow_control ); is_button_down = 0; cancel_dragging = 0; /* * Clicks are at higher priority */ if ( is_short_click( point ) ) { if ( is_testing_double_click ) { roadmap_main_remove_periodic(double_click_flow_control); is_testing_double_click = 0; exec_callbacks ( DOUBLE_CLICK, &last_pointer_point ); } else if ( is_double_click_enabled ) { is_dragging = 0; is_double_click_enabled = 0; is_testing_double_click = 1; roadmap_main_set_periodic(DOUBLE_CLICK_TIMEOUT, double_click_flow_control); /* * Don't call events' handlers at this stage */ return; } else { exec_callbacks (SHORT_CLICK, point); } } else if ( is_dragging ) { exec_callbacks (DRAG_END, point); } is_dragging = 0; exec_callbacks (RELEASED, point); }
static void long_click_flow_control(void) { roadmap_main_remove_periodic(long_click_flow_control); is_long_click_expired = 1; /* * If it was drag and stopped after that or drag was in radius */ if ( is_click( &last_pointer_point ) || !is_dragging ) { exec_callbacks (LONG_CLICK, &last_pointer_point); } }
static void roadmap_pointer_button_pressed (RoadMapGuiPoint *point) { first_pointer_point = *point; last_pointer_point = *point; /* The dragging can be cancelled from the callback, using the roadmap_pointer_cancel_dragging() */ cancel_dragging = 0; is_button_down = 1; exec_callbacks (PRESSED, point); is_long_click_expired = 0; roadmap_main_set_periodic (LONG_CLICK_TIMEOUT, long_click_flow_control); }
void SerialRendererController::on_progress() { exec_callbacks(); m_controller->on_progress(); }
int roadmap_pointer_force_click(int event,RoadMapGuiPoint *point){ return(exec_callbacks(event,point)); // delegate to the registered callbacks }