void osd_MenuActivate( vlc_object_t *p_this ) { osd_menu_t *p_osd; osd_button_t *p_button = NULL; vlc_mutex_t *p_lock = osd_GetMutex( p_this ); vlc_mutex_lock( p_lock ); p_osd = osd_Find( p_this ); if( p_osd == NULL || !osd_isVisible( p_osd ) ) { vlc_mutex_unlock( p_lock ); msg_Err( p_this, "osd_MenuActivate failed" ); return; } #if defined(OSD_MENU_DEBUG) msg_Dbg( p_osd, "select" ); #endif p_button = p_osd->p_state->p_visible; /* * Is there a menu item above or below? If so, then select it. */ if( p_button && p_button->p_up ) { vlc_mutex_unlock( p_lock ); osd_MenuUp( p_this ); /* "menu select" means go to menu item above. */ return; } if( p_button && p_button->p_down ) { vlc_mutex_unlock( p_lock ); osd_MenuDown( p_this ); /* "menu select" means go to menu item below. */ return; } if( p_button && !p_button->b_range ) { p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_PRESSED ); osd_UpdateState( p_osd->p_state, p_button->i_x, p_button->i_y, p_osd->p_state->p_visible->p_current_state->i_width, p_osd->p_state->p_visible->p_current_state->i_height, p_button->p_current_state->p_pic ); osd_SetMenuUpdate( p_osd, true ); osd_SetMenuVisible( p_osd, true ); osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), var_InheritInteger( p_osd, p_button->psz_action ) ); #if defined(OSD_MENU_DEBUG) msg_Dbg( p_osd, "select (%d, %s)", var_InheritInteger( p_osd, p_button->psz_action ), p_button->psz_action ); #endif } vlc_mutex_unlock( p_lock ); }
static int vlclua_menu_down( lua_State *L ) { vlc_object_t *p_this = vlclua_get_this( L ); osd_MenuDown( p_this ); return 0; }
/***************************************************************************** * Run: main loop *****************************************************************************/ static void Run( intf_thread_t *p_intf ) { intf_sys_t *p_sys = p_intf->p_sys; for( ;; ) { /* Wait for data */ struct pollfd ufd = { .fd = p_sys->i_fd, .events = POLLIN, .revents = 0 }; if( poll( &ufd, 1, -1 ) == -1 ) { if( errno == EINTR ) continue; else break; } /* Process */ int canc = vlc_savecancel(); Process( p_intf ); vlc_restorecancel(canc); } } static void Process( intf_thread_t *p_intf ) { for( ;; ) { char *code, *c; if( lirc_nextcode( &code ) ) return; if( code == NULL ) return; while( vlc_object_alive( p_intf ) && (lirc_code2char( p_intf->p_sys->config, code, &c ) == 0) && (c != NULL) ) { if( !strncmp( "key-", c, 4 ) ) { vlc_action_t i_key = vlc_GetActionId( c ); if( i_key ) var_SetInteger( p_intf->p_libvlc, "key-action", i_key ); else msg_Err( p_intf, "Unknown hotkey '%s'", c ); } else if( !strncmp( "menu ", c, 5) ) { if( !strncmp( c, "menu on", 7 ) || !strncmp( c, "menu show", 9 )) osd_MenuShow( VLC_OBJECT(p_intf) ); else if( !strncmp( c, "menu off", 8 ) || !strncmp( c, "menu hide", 9 ) ) osd_MenuHide( VLC_OBJECT(p_intf) ); else if( !strncmp( c, "menu up", 7 ) ) osd_MenuUp( VLC_OBJECT(p_intf) ); else if( !strncmp( c, "menu down", 9 ) ) osd_MenuDown( VLC_OBJECT(p_intf) ); else if( !strncmp( c, "menu left", 9 ) ) osd_MenuPrev( VLC_OBJECT(p_intf) ); else if( !strncmp( c, "menu right", 10 ) ) osd_MenuNext( VLC_OBJECT(p_intf) ); else if( !strncmp( c, "menu select", 11 ) ) osd_MenuActivate( VLC_OBJECT(p_intf) ); else { msg_Err( p_intf, "Please provide one of the following parameters:" ); msg_Err( p_intf, "[on|off|up|down|left|right|select]" ); break; } } else { msg_Err( p_intf, "this doesn't appear to be a valid keycombo " "lirc sent us. Please look at the " "doc/lirc/example.lirc file in VLC" ); break; } } free( code ); } }