static int script_key_dequeue() { if (!script_key_mq) return -1; int msg; int err = msg_queue_receive(script_key_mq, (struct event**)&msg, 10); if (err) return -1; return msg; }
static void gui_main_task_7d() { struct event * event = NULL; int index = 0; void* funcs[GMT_NFUNCS]; memcpy(funcs, (void*)GMT_FUNCTABLE, 4*GMT_NFUNCS); gui_init_end(); while(1) { msg_queue_receive(gui_main_struct.msg_queue, &event, 0); gui_main_struct.counter--; if (event == NULL) continue; index = event->type; if (!magic_is_off()) { if (event->type == 0) { if (handle_buttons(event) == 0) // ML button/event handler continue; } else { if (handle_other_events(event) == 0) continue; } } if (IS_FAKE(event)) event->arg = 0; if ((index >= GMT_NFUNCS) || (index < 0)) continue; void(*f)(struct event *) = funcs[index]; f(event); } }
// Replaces the gui_main_task static void my_gui_main_task( void ) { gui_init_end(); uint32_t * obj = 0; while(1) { struct event * event; msg_queue_receive( gui_main_struct.msg_queue, &event, 0 ); if( !event ) goto event_loop_bottom; if (!magic_is_off() && event->type == 0) { if (handle_buttons(event) == 0) // ML button/event handler goto event_loop_bottom; } if (IS_FAKE(event)) { event->arg = 0; /* do not pass the "fake" flag to Canon code */ } if (event->type == 0 && event->param < 0) { goto event_loop_bottom; /* do not pass internal ML events to Canon code */ } switch( event->type ) { case 0: if( gui_main_struct.obj != obj && event->param != 0x29 && event->param != 0x2A && event->param != 0x2B && event->param != 0x2C && event->param != 0x2D && event->param != 0x2E && event->param != 0x23 && event->param != 0x2F && event->param != 0x27 && event->param != 0x30 && event->param != 0x31 && event->param != 0x32 && event->param != 0x33 && event->param != 0x34 && event->param != 0x35 && event->param != 0x36 && event->param != 0x3F ) goto queue_clear; DebugMsg( DM_MAGIC, 2, "GUI_CONTROL:%d", event->param ); gui_massive_event_loop( event->param, event->obj, event->arg ); break; case 1: if( gui_main_struct.obj != obj && event->param != 0x00 && event->param != 0x07 && event->param != 0x05 ) goto queue_clear; DebugMsg( 0x84, 2, "GUI_CHANGE_MODE:%d", event->param ); if( event->param == 0 ) { gui_local_post( 0x12, 0, 0 ); if( gui_timer_struct.obj ) gui_timer_something( gui_timer_struct.obj, 4 ); } gui_change_mode( event->param ); break; case 2: if( gui_main_struct.obj != obj && event->param != 0x17 && event->param != 0x18 && event->param != 0x14 && event->param != 0x1B && event->param != 0x32 && event->param != 0x33 ) goto queue_clear; gui_local_post( event->param, event->obj, event->arg ); break; case 3: if( event->param == 0x11 ) { DebugMsg( 0x84, 2, "GUIOTHER_CANCEL_ALL_EVENT" ); obj = event->obj; break; } if( gui_main_struct.obj != obj && event->param != 0x00 && event->param != 0x03 && event->param != 0x01 && event->param != 0x12 && event->param != 0x13 && event->param != 0x14 && event->param != 0x15 ) goto queue_clear; DebugMsg( 0x84, 2, "GUI_OTHEREVENT:%d", event->param ); gui_other_post( event->param, event->obj, event->arg ); break; case 4: gui_post_10000085( event->param, event->obj, event->arg ); break; case 5: gui_init_event( event->obj ); break; case 6: DebugMsg( 0x84, 2, "GUI_CHANGE_SHOOT_TYPE:%d", event->param ); gui_change_shoot_type_post( event->param ); break; case 7: DebugMsg( 0x84, 2, "GUI_CHANGE_LCD_STATE:%d", event->param ); gui_change_lcd_state_post( event->param ); break; default: break; } event_loop_bottom: gui_main_struct.counter--; continue; queue_clear: DebugMsg( 0x84, 3, "**** Queue Clear **** event(%d) param(%d)", event->type, event->param ); goto event_loop_bottom; } }