Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
54335f5e
Commit
54335f5e
authored
Jan 03, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sort hotkeys per key code and use binary search
parent
64651009
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
+19
-9
src/misc/action.c
src/misc/action.c
+19
-9
No files found.
src/misc/action.c
View file @
54335f5e
...
...
@@ -27,6 +27,17 @@
#include "../libvlc.h"
#include <vlc_keys.h>
#include <stdlib.h>
#include <limits.h>
static
int
keycmp
(
const
void
*
a
,
const
void
*
b
)
{
const
struct
hotkey
*
ka
=
a
,
*
kb
=
b
;
#if (INT_MAX >= 0x7fffffff)
return
ka
->
i_key
-
kb
->
i_key
;
#else
return
(
ka
->
i_key
<
kb
->
i_key
)
?
-
1
:
(
ka
->
i_key
>
kb
->
i_key
)
?
+
1
:
0
;
#endif
}
/**
* Get the action associated with a VLC key code, if any.
...
...
@@ -34,15 +45,12 @@
static
vlc_key_t
vlc_TranslateKey
(
const
vlc_object_t
*
obj
,
uint_fast32_t
keycode
)
{
/* TODO: search should be O(log n), not O(n) */
for
(
const
struct
hotkey
*
key
=
obj
->
p_libvlc
->
p_hotkeys
;
key
->
psz_action
!=
NULL
;
key
++
)
{
if
(
key
->
i_key
==
keycode
)
return
key
->
i_action
;
}
return
ACTIONID_NONE
;
struct
hotkey
k
=
{
.
psz_action
=
NULL
,
.
i_key
=
keycode
,
.
i_action
=
0
};
const
struct
hotkey
*
key
;
key
=
bsearch
(
&
k
,
obj
->
p_libvlc
->
p_hotkeys
,
libvlc_actions_count
,
sizeof
(
*
key
),
keycmp
);
return
(
key
!=
NULL
)
?
key
->
i_action
:
ACTIONID_NONE
;
}
static
int
vlc_key_to_action
(
vlc_object_t
*
libvlc
,
const
char
*
varname
,
...
...
@@ -89,6 +97,8 @@ int vlc_InitActions (libvlc_int_t *libvlc)
}
#endif
}
qsort
(
keys
,
libvlc_actions_count
,
sizeof
(
*
keys
),
keycmp
);
keys
[
libvlc_actions_count
].
psz_action
=
NULL
;
keys
[
libvlc_actions_count
].
i_key
=
0
;
keys
[
libvlc_actions_count
].
i_action
=
0
;
...
...
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