⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hotkeys.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************** * hotkeys.c: Hotkey handling for vlc ***************************************************************************** * Copyright (C) 2005 the VideoLAN team * $Id: 22a08870ffbcce9cf7f5897645180cf7ef7b1b87 $ * * Authors: Sigmund Augdal Helberg <dnumgis@videolan.org> *          Jean-Paul Saman <jpsaman #_at_# m2x.nl> * * 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 program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#ifdef HAVE_CONFIG_H# include "config.h"#endif#include <vlc_common.h>#include <vlc_plugin.h>#include <vlc_interface.h>#include <vlc_input.h>#include <vlc_vout.h>#include <vlc_aout.h>#include <vlc_osd.h>#include <vlc_playlist.h>#include "vlc_keys.h"#define BUFFER_SIZE 10#define CHANNELS_NUMBER 4#define VOLUME_TEXT_CHAN     p_intf->p_sys->p_channels[ 0 ]#define VOLUME_WIDGET_CHAN   p_intf->p_sys->p_channels[ 1 ]#define POSITION_TEXT_CHAN   p_intf->p_sys->p_channels[ 2 ]#define POSITION_WIDGET_CHAN p_intf->p_sys->p_channels[ 3 ]/***************************************************************************** * intf_sys_t: description and status of FB interface *****************************************************************************/struct intf_sys_t{    int                 p_actions[ BUFFER_SIZE ]; /* buffer that contains                                                   * action events */    int                 i_size;        /* number of events in buffer */    int                 p_channels[ CHANNELS_NUMBER ]; /* contains registered                                                        * channel IDs */    input_thread_t *    p_input;       /* pointer to input */    vout_thread_t *     p_vout;        /* pointer to vout object */};/***************************************************************************** * Local prototypes *****************************************************************************/static int  Open    ( vlc_object_t * );static void Close   ( vlc_object_t * );static void Run     ( intf_thread_t * );static int  GetAction( intf_thread_t *);static int  ActionEvent( vlc_object_t *, char const *,                         vlc_value_t, vlc_value_t, void * );static int  SpecialKeyEvent( vlc_object_t *, char const *,                             vlc_value_t, vlc_value_t, void * );static void PlayBookmark( intf_thread_t *, int );static void SetBookmark ( intf_thread_t *, int );static void DisplayPosition( intf_thread_t *, vout_thread_t *, input_thread_t * );static void DisplayVolume  ( intf_thread_t *, vout_thread_t *, audio_volume_t );static void ClearChannels  ( intf_thread_t *, vout_thread_t * );/***************************************************************************** * Module descriptor *****************************************************************************/#define BOOKMARK1_TEXT    N_("Playlist bookmark 1")#define BOOKMARK2_TEXT    N_("Playlist bookmark 2")#define BOOKMARK3_TEXT    N_("Playlist bookmark 3")#define BOOKMARK4_TEXT    N_("Playlist bookmark 4")#define BOOKMARK5_TEXT    N_("Playlist bookmark 5")#define BOOKMARK6_TEXT    N_("Playlist bookmark 6")#define BOOKMARK7_TEXT    N_("Playlist bookmark 7")#define BOOKMARK8_TEXT    N_("Playlist bookmark 8")#define BOOKMARK9_TEXT    N_("Playlist bookmark 9")#define BOOKMARK10_TEXT   N_("Playlist bookmark 10")#define BOOKMARK_LONGTEXT N_("Define playlist bookmarks.")vlc_module_begin();    set_shortname( N_("Hotkeys") );    set_description( N_("Hotkeys management interface") );    set_capability( "interface", 0 );    set_callbacks( Open, Close );vlc_module_end();/***************************************************************************** * Open: initialize interface *****************************************************************************/static int Open( vlc_object_t *p_this ){    intf_thread_t *p_intf = (intf_thread_t *)p_this;    MALLOC_ERR( p_intf->p_sys, intf_sys_t );    p_intf->p_sys->i_size = 0;    p_intf->pf_run = Run;    var_AddCallback( p_intf->p_libvlc, "key-pressed", SpecialKeyEvent, p_intf );    var_AddCallback( p_intf->p_libvlc, "key-action", ActionEvent, p_intf );    return VLC_SUCCESS;}/***************************************************************************** * Close: destroy interface *****************************************************************************/static void Close( vlc_object_t *p_this ){    intf_thread_t *p_intf = (intf_thread_t *)p_this;    var_DelCallback( p_intf->p_libvlc, "key-action", ActionEvent, p_intf );    var_DelCallback( p_intf->p_libvlc, "key-pressed", SpecialKeyEvent, p_intf );    /* Destroy structure */    free( p_intf->p_sys );}/***************************************************************************** * Run: main loop *****************************************************************************/static void Run( intf_thread_t *p_intf ){    vout_thread_t *p_vout = NULL;    vlc_value_t val;    int i;    playlist_t *p_playlist = pl_Yield( p_intf );    /* Initialize hotkey structure */    for( struct hotkey *p_hotkey = p_intf->p_libvlc->p_hotkeys;         p_hotkey->psz_action != NULL;         p_hotkey++ )    {        p_hotkey->i_key = config_GetInt( p_intf, p_hotkey->psz_action );    }    for( ;; )    {        input_thread_t *p_input;        vout_thread_t *p_last_vout;        int i_action = GetAction( p_intf );        if( i_action == -1 )            break; /* die */        /* Update the input */        PL_LOCK;        p_input = p_playlist->p_input;        if( p_input )            vlc_object_yield( p_input );        PL_UNLOCK;        /* Update the vout */        p_last_vout = p_vout;        p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );        /* Register OSD channels */        if( p_vout && p_vout != p_last_vout )        {            for( i = 0; i < CHANNELS_NUMBER; i++ )            {                spu_Control( p_vout->p_spu, SPU_CHANNEL_REGISTER,                             &p_intf->p_sys->p_channels[ i ] );            }        }        /* Quit */        if( i_action == ACTIONID_QUIT )        {            if( p_playlist )                playlist_Stop( p_playlist );            vlc_object_kill( p_intf->p_libvlc );            vlc_object_kill( p_intf );            ClearChannels( p_intf, p_vout );            vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Quit" ) );            if( p_vout )                vlc_object_release( p_vout );            if( p_input )                vlc_object_release( p_input );            continue;        }        /* Volume and audio actions */        else if( i_action == ACTIONID_VOL_UP )        {            audio_volume_t i_newvol;            aout_VolumeUp( p_intf, 1, &i_newvol );            DisplayVolume( p_intf, p_vout, i_newvol );        }        else if( i_action == ACTIONID_VOL_DOWN )        {            audio_volume_t i_newvol;            aout_VolumeDown( p_intf, 1, &i_newvol );            DisplayVolume( p_intf, p_vout, i_newvol );        }        else if( i_action == ACTIONID_VOL_MUTE )        {            audio_volume_t i_newvol = -1;            aout_VolumeMute( p_intf, &i_newvol );            if( p_vout )            {                if( i_newvol == 0 )                {                    ClearChannels( p_intf, p_vout );                    vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,                                  OSD_MUTE_ICON );                }                else                {                    DisplayVolume( p_intf, p_vout, i_newvol );                }            }        }        /* Interface showing */        else if( i_action == ACTIONID_INTF_SHOW )            var_SetBool( p_intf->p_libvlc, "intf-show", true );        else if( i_action == ACTIONID_INTF_HIDE )            var_SetBool( p_intf->p_libvlc, "intf-show", false );        /* Video Output actions */        else if( i_action == ACTIONID_SNAPSHOT )        {            if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );        }        else if( i_action == ACTIONID_TOGGLE_FULLSCREEN )        {            if( p_vout )            {                var_Get( p_vout, "fullscreen", &val );                val.b_bool = !val.b_bool;                var_Set( p_vout, "fullscreen", val );            }            else            {                var_Get( p_playlist, "fullscreen", &val );                val.b_bool = !val.b_bool;                var_Set( p_playlist, "fullscreen", val );            }        }        else if( i_action == ACTIONID_LEAVE_FULLSCREEN )        {            if( p_vout && var_GetBool( p_vout, "fullscreen" ) )            {                var_SetBool( p_vout, "fullscreen", false );            }        }        else if( i_action == ACTIONID_ZOOM_QUARTER ||                 i_action == ACTIONID_ZOOM_HALF ||                 i_action == ACTIONID_ZOOM_ORIGINAL ||                 i_action == ACTIONID_ZOOM_DOUBLE )        {            if( p_vout )            {                if( i_action == ACTIONID_ZOOM_QUARTER )                    val.f_float = 0.25;                if( i_action == ACTIONID_ZOOM_HALF )                    val.f_float = 0.5;                if( i_action == ACTIONID_ZOOM_ORIGINAL )                    val.f_float = 1;                if( i_action == ACTIONID_ZOOM_DOUBLE )                    val.f_float = 2;                var_Set( p_vout, "zoom", val );            }        }        else if( i_action == ACTIONID_WALLPAPER )        {            if( p_vout )            {                var_Get( p_vout, "directx-wallpaper", &val );                val.b_bool = !val.b_bool;                var_Set( p_vout, "directx-wallpaper", val );            }            else            {                var_Get( p_playlist, "directx-wallpaper", &val );                val.b_bool = !val.b_bool;                var_Set( p_playlist, "directx-wallpaper", val );            }        }        /* Playlist actions */        else if( i_action == ACTIONID_LOOP )        {            /* Toggle Normal -> Loop -> Repeat -> Normal ... */            vlc_value_t val2;            var_Get( p_playlist, "loop", &val );            var_Get( p_playlist, "repeat", &val2 );            if( val2.b_bool == true )            {                val.b_bool = false;                val2.b_bool = false;            }            else if( val.b_bool == true )            {                val.b_bool = false;                val2.b_bool = true;            }            else            {                val.b_bool = true;            }            var_Set( p_playlist, "loop", val );            var_Set( p_playlist, "repeat", val2 );        }        else if( i_action == ACTIONID_RANDOM )        {            var_Get( p_playlist, "random", &val );            val.b_bool = !val.b_bool;            var_Set( p_playlist, "random", val );        }        else if( i_action == ACTIONID_PLAY_PAUSE )        {            val.i_int = PLAYING_S;            if( p_input )            {                ClearChannels( p_intf, p_vout );                var_Get( p_input, "state", &val );                if( val.i_int != PAUSE_S )                {                    vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,                                  OSD_PAUSE_ICON );                    val.i_int = PAUSE_S;                }                else                {                    vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,                                  OSD_PLAY_ICON );                    val.i_int = PLAYING_S;                }                var_Set( p_input, "state", val );            }            else            {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -