Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
d83927d4
Commit
d83927d4
authored
Jan 31, 2013
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hotkeys: map mouse wheel actions in core
parent
a0cb1c29
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
47 deletions
+48
-47
modules/control/hotkeys.c
modules/control/hotkeys.c
+1
-28
src/config/keys.c
src/config/keys.c
+47
-19
No files found.
modules/control/hotkeys.c
View file @
d83927d4
...
...
@@ -55,7 +55,6 @@ struct intf_sys_t
vout_thread_t
*
p_last_vout
;
int
p_channels
[
CHANNELS_NUMBER
];
/* contains registered
* channel IDs */
int
i_mousewheel_mode
;
};
/*****************************************************************************
...
...
@@ -108,8 +107,6 @@ static int Open( vlc_object_t *p_this )
p_intf
->
p_sys
=
p_sys
;
p_sys
->
p_last_vout
=
NULL
;
p_intf
->
p_sys
->
i_mousewheel_mode
=
var_InheritInteger
(
p_intf
,
"hotkeys-mousewheel-mode"
);
var_AddCallback
(
p_intf
->
p_libvlc
,
"key-pressed"
,
SpecialKeyEvent
,
p_intf
);
var_AddCallback
(
p_intf
->
p_libvlc
,
"key-action"
,
ActionEvent
,
p_intf
);
...
...
@@ -924,44 +921,20 @@ static int SpecialKeyEvent( vlc_object_t *libvlc, char const *psz_var,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
{
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_data
;
int
i_action
=
0
;
(
void
)
p_data
;
(
void
)
psz_var
;
(
void
)
oldval
;
int
i_mode
=
p_intf
->
p_sys
->
i_mousewheel_mode
;
/* Special action for mouse event */
/* FIXME: rework hotkeys handling to allow more than 1 event
* to trigger one same action */
switch
(
newval
.
i_int
&
~
KEY_MODIFIER
)
{
case
KEY_MOUSEWHEELUP
:
i_action
=
(
i_mode
==
MOUSEWHEEL_VOLUME
)
?
ACTIONID_VOL_UP
:
ACTIONID_JUMP_FORWARD_EXTRASHORT
;
break
;
case
KEY_MOUSEWHEELDOWN
:
i_action
=
(
i_mode
==
MOUSEWHEEL_VOLUME
)
?
ACTIONID_VOL_DOWN
:
ACTIONID_JUMP_BACKWARD_EXTRASHORT
;
break
;
case
KEY_MOUSEWHEELLEFT
:
i_action
=
(
i_mode
==
MOUSEWHEEL_VOLUME
)
?
ACTIONID_JUMP_BACKWARD_EXTRASHORT
:
ACTIONID_VOL_DOWN
;
break
;
case
KEY_MOUSEWHEELRIGHT
:
i_action
=
(
i_mode
==
MOUSEWHEEL_VOLUME
)
?
ACTIONID_JUMP_FORWARD_EXTRASHORT
:
ACTIONID_VOL_UP
;
break
;
case
KEY_MENU
:
var_SetBool
(
libvlc
,
"intf-popupmenu"
,
true
);
break
;
}
if
(
i_mode
==
NO_MOUSEWHEEL
)
return
VLC_SUCCESS
;
if
(
i_action
)
return
PutAction
(
p_intf
,
i_action
);
return
VLC_SUCCESS
;
}
...
...
src/config/keys.c
View file @
d83927d4
...
...
@@ -38,6 +38,7 @@
#ifdef HAVE_SEARCH_H
# include <search.h>
#endif
#include <errno.h>
#include <vlc_common.h>
#include <vlc_keys.h>
...
...
@@ -405,13 +406,35 @@ static int vlc_key_to_action (vlc_object_t *obj, const char *varname,
return
var_SetInteger
(
obj
,
"key-action"
,
(
*
pent
)
->
action
);
}
/**
* Adds a mapping from a certain key code to a certain action.
*/
static
int
vlc_AddMapping
(
void
**
map
,
uint32_t
keycode
,
vlc_action_t
action
)
{
struct
mapping
*
entry
=
malloc
(
sizeof
(
*
entry
));
if
(
entry
==
NULL
)
return
ENOMEM
;
entry
->
key
=
keycode
;
entry
->
action
=
action
;
struct
mapping
**
pent
=
tsearch
(
entry
,
map
,
keycmp
);
if
(
unlikely
(
pent
==
NULL
))
return
ENOMEM
;
if
(
*
pent
!=
entry
)
{
free
(
entry
);
return
EEXIST
;
}
return
0
;
}
/**
* Sets up all key mappings for a given action.
* \param map tree (of struct mapping entries) to write mappings to
* \param confname VLC configuration item to read mappings from
* \param action action ID
*/
static
void
vlc_
Map
Action
(
vlc_object_t
*
obj
,
void
**
map
,
static
void
vlc_
Init
Action
(
vlc_object_t
*
obj
,
void
**
map
,
const
char
*
confname
,
vlc_action_t
action
)
{
char
*
keys
=
var_InheritString
(
obj
,
confname
);
...
...
@@ -429,25 +452,12 @@ static void vlc_MapAction (vlc_object_t *obj, void **map,
continue
;
}
struct
mapping
*
entry
=
malloc
(
sizeof
(
*
entry
));
if
(
entry
==
NULL
)
continue
;
entry
->
key
=
code
;
entry
->
action
=
action
;
struct
mapping
**
pent
=
tsearch
(
entry
,
map
,
keycmp
);
if
(
unlikely
(
pent
==
NULL
))
continue
;
if
(
*
pent
!=
entry
)
{
free
(
entry
);
if
(
vlc_AddMapping
(
map
,
code
,
action
)
==
EEXIST
)
msg_Warn
(
obj
,
"Key
\"
%s
\"
bound to multiple actions"
,
key
);
}
}
free
(
keys
);
}
/**
* Initializes the key map from configuration.
*/
...
...
@@ -485,12 +495,30 @@ struct vlc_actions *vlc_InitActions (libvlc_int_t *libvlc)
char
name
[
12
+
MAXACTION
];
snprintf
(
name
,
sizeof
(
name
),
"global-key-%s"
,
actions
[
i
].
name
);
vlc_
Map
Action
(
obj
,
&
as
->
map
,
name
+
7
,
actions
[
i
].
value
);
vlc_
Map
Action
(
obj
,
&
as
->
global_map
,
name
,
actions
[
i
].
value
);
vlc_
Init
Action
(
obj
,
&
as
->
map
,
name
+
7
,
actions
[
i
].
value
);
vlc_
Init
Action
(
obj
,
&
as
->
global_map
,
name
,
actions
[
i
].
value
);
}
keys
->
psz_action
=
NULL
;
/* Initialize mouse wheel events */
int
mousemode
=
var_InheritInteger
(
obj
,
"hotkeys-mousewheel-mode"
);
if
(
mousemode
<
2
)
{
vlc_AddMapping
(
&
as
->
map
,
mousemode
?
KEY_MOUSEWHEELLEFT
:
KEY_MOUSEWHEELUP
,
ACTIONID_VOL_UP
);
vlc_AddMapping
(
&
as
->
map
,
mousemode
?
KEY_MOUSEWHEELRIGHT
:
KEY_MOUSEWHEELDOWN
,
ACTIONID_VOL_DOWN
);
vlc_AddMapping
(
&
as
->
map
,
mousemode
?
KEY_MOUSEWHEELUP
:
KEY_MOUSEWHEELLEFT
,
ACTIONID_JUMP_FORWARD_EXTRASHORT
);
vlc_AddMapping
(
&
as
->
map
,
mousemode
?
KEY_MOUSEWHEELDOWN
:
KEY_MOUSEWHEELRIGHT
,
ACTIONID_JUMP_BACKWARD_EXTRASHORT
);
}
libvlc
->
p_hotkeys
=
as
->
keys
;
var_AddCallback
(
obj
,
"key-pressed"
,
vlc_key_to_action
,
&
as
->
map
);
var_AddCallback
(
obj
,
"global-key-pressed"
,
vlc_key_to_action
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment