summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/options.rst3
-rw-r--r--audio/out/ao.c2
-rw-r--r--etc/builtin.conf1
-rw-r--r--input/input.c13
-rw-r--r--input/input.h2
-rw-r--r--input/keycodes.c26
-rw-r--r--input/keycodes.h28
-rw-r--r--input/sdl_gamepad.c277
-rw-r--r--test/input-gamepad.conf4
-rw-r--r--video/out/vo.c2
-rw-r--r--wscript23
-rw-r--r--wscript_build.py5
12 files changed, 378 insertions, 8 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index f9516d1787..e147883f29 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -3407,6 +3407,9 @@ Input
(OS X only)
Enable/disable Apple Remote support. Enabled by default (except for libmpv).
+``--input-gamepad=<yes|no>``
+ Enable/disable SDL2 Gamepad support. Enabled by default (except for libmpv).
+
``--input-cursor``, ``--no-input-cursor``
Permit mpv to receive pointer events reported by the video output
driver. Necessary to use the OSC, or to select the buttons in DVD menus.
diff --git a/audio/out/ao.c b/audio/out/ao.c
index 817aa29399..1b89e3c591 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -82,7 +82,7 @@ static const struct ao_driver * const audio_out_drivers[] = {
#if HAVE_OPENSLES
&audio_out_opensles,
#endif
-#if HAVE_SDL2
+#if HAVE_SDL2_AUDIO
&audio_out_sdl,
#endif
#if HAVE_SNDIO
diff --git a/etc/builtin.conf b/etc/builtin.conf
index 28788c9598..1e3702c68e 100644
--- a/etc/builtin.conf
+++ b/etc/builtin.conf
@@ -26,6 +26,7 @@ input-terminal=no
osc=no
input-default-bindings=no
input-vo-keyboard=no
+input-gamepad=no
# OSX/Cocoa global input hooks
input-appleremote=no
input-media-keys=no
diff --git a/input/input.c b/input/input.c
index 8a14d862b3..32ee75b4cf 100644
--- a/input/input.c
+++ b/input/input.c
@@ -173,6 +173,7 @@ struct input_opts {
int ar_rate;
int use_alt_gr;
int use_appleremote;
+ int use_gamepad;
int use_media_keys;
int default_bindings;
int enable_mouse_movements;
@@ -199,6 +200,9 @@ const struct m_sub_options input_config = {
#if HAVE_COCOA
OPT_FLAG("input-appleremote", use_appleremote, 0),
#endif
+#if HAVE_SDL2_GAMEPAD
+ OPT_FLAG("input-gamepad", use_gamepad, 0),
+#endif
OPT_FLAG("window-dragging", allow_win_drag, 0),
OPT_REPLACED("input-x11-keyboard", "input-vo-keyboard"),
{0}
@@ -215,6 +219,9 @@ const struct m_sub_options input_config = {
#if HAVE_COCOA
.use_appleremote = 1,
#endif
+#if HAVE_SDL2_GAMEPAD
+ .use_gamepad = 1,
+#endif
.default_bindings = 1,
.vo_key_input = 1,
.allow_win_drag = 1,
@@ -1377,6 +1384,12 @@ void mp_input_load_config(struct input_ctx *ictx)
talloc_free(ifile);
#endif
+#if HAVE_SDL2_GAMEPAD
+ if (ictx->opts->use_gamepad) {
+ mp_input_sdl_gamepad_add(ictx);
+ }
+#endif
+
input_unlock(ictx);
}
diff --git a/input/input.h b/input/input.h
index 3dfc053bd0..f62a50bdca 100644
--- a/input/input.h
+++ b/input/input.h
@@ -210,6 +210,8 @@ void mp_input_set_repeat_info(struct input_ctx *ictx, int rate, int delay);
void mp_input_pipe_add(struct input_ctx *ictx, const char *filename);
+void mp_input_sdl_gamepad_add(struct input_ctx *ictx);
+
struct mp_ipc_ctx;
struct mp_client_api;
diff --git a/input/keycodes.c b/input/keycodes.c
index 81371e20bf..a03f07e59a 100644
--- a/input/keycodes.c
+++ b/input/keycodes.c
@@ -117,6 +117,32 @@ static const struct key_name key_names[] = {
{ MP_AR_VDOWN, "AR_VDOWN" },
{ MP_AR_VDOWN_HOLD, "AR_VDOWN_HOLD" },
+ { MP_KEY_GAMEPAD_ACTION_DOWN, "GAMEPAD_ACTION_DOWN" },
+ { MP_KEY_GAMEPAD_ACTION_RIGHT, "GAMEPAD_ACTION_RIGHT" },
+ { MP_KEY_GAMEPAD_ACTION_LEFT, "GAMEPAD_ACTION_LEFT" },
+ { MP_KEY_GAMEPAD_ACTION_UP, "GAMEPAD_ACTION_UP" },
+ { MP_KEY_GAMEPAD_BACK, "GAMEPAD_BACK" },
+ { MP_KEY_GAMEPAD_MENU, "GAMEPAD_MENU" },
+ { MP_KEY_GAMEPAD_START, "GAMEPAD_START" },
+ { MP_KEY_GAMEPAD_LEFT_SHOULDER, "GAMEPAD_LEFT_SHOULDER" },
+ { MP_KEY_GAMEPAD_RIGHT_SHOULDER, "GAMEPAD_RIGHT_SHOULDER" },
+ { MP_KEY_GAMEPAD_LEFT_TRIGGER, "GAMEPAD_LEFT_TRIGGER" },
+ { MP_KEY_GAMEPAD_RIGHT_TRIGGER, "GAMEPAD_RIGHT_TRIGGER" },
+ { MP_KEY_GAMEPAD_LEFT_STICK, "GAMEPAD_LEFT_STICK" },
+ { MP_KEY_GAMEPAD_RIGHT_STICK, "GAMEPAD_RIGHT_STICK" },
+ { MP_KEY_GAMEPAD_DPAD_UP, "GAMEPAD_DPAD_UP" },
+ { MP_KEY_GAMEPAD_DPAD_DOWN, "GAMEPAD_DPAD_DOWN" },
+ { MP_KEY_GAMEPAD_DPAD_LEFT, "GAMEPAD_DPAD_LEFT" },
+ { MP_KEY_GAMEPAD_DPAD_RIGHT, "GAMEPAD_DPAD_RIGHT" },
+ { MP_KEY_GAMEPAD_LEFT_STICK_UP, "GAMEPAD_LEFT_STICK_UP" },
+ { MP_KEY_GAMEPAD_LEFT_STICK_DOWN, "GAMEPAD_LEFT_STICK_DOWN" },
+ { MP_KEY_GAMEPAD_LEFT_STICK_LEFT, "GAMEPAD_LEFT_STICK_LEFT" },
+ { MP_KEY_GAMEPAD_LEFT_STICK_RIGHT, "GAMEPAD_LEFT_STICK_RIGHT" },
+ { MP_KEY_GAMEPAD_RIGHT_STICK_UP, "GAMEPAD_RIGHT_STICK_UP" },
+ { MP_KEY_GAMEPAD_RIGHT_STICK_DOWN, "GAMEPAD_RIGHT_STICK_DOWN" },
+ { MP_KEY_GAMEPAD_RIGHT_STICK_LEFT, "GAMEPAD_RIGHT_STICK_LEFT" },
+ { MP_KEY_GAMEPAD_RIGHT_STICK_RIGHT, "GAMEPAD_RIGHT_STICK_RIGHT" },
+
{ MP_KEY_POWER, "POWER" },
{ MP_KEY_MENU, "MENU" },
{ MP_KEY_PLAY, "PLAY" },
diff --git a/input/keycodes.h b/input/keycodes.h
index 604fee53dc..12b45e528a 100644
--- a/input/keycodes.h
+++ b/input/keycodes.h
@@ -154,6 +154,34 @@
#define MP_AR_VDOWN (MP_AR_BASE + 12)
#define MP_AR_VDOWN_HOLD (MP_AR_BASE + 13)
+/* game controller keys */
+#define MP_KEY_GAMEPAD (MP_KEY_BASE+0xF0)
+#define MP_KEY_GAMEPAD_ACTION_DOWN (MP_KEY_GAMEPAD+0)
+#define MP_KEY_GAMEPAD_ACTION_RIGHT (MP_KEY_GAMEPAD+1)
+#define MP_KEY_GAMEPAD_ACTION_LEFT (MP_KEY_GAMEPAD+2)
+#define MP_KEY_GAMEPAD_ACTION_UP (MP_KEY_GAMEPAD+3)
+#define MP_KEY_GAMEPAD_BACK (MP_KEY_GAMEPAD+4)
+#define MP_KEY_GAMEPAD_MENU (MP_KEY_GAMEPAD+5)
+#define MP_KEY_GAMEPAD_START (MP_KEY_GAMEPAD+6)
+#define MP_KEY_GAMEPAD_LEFT_SHOULDER (MP_KEY_GAMEPAD+7)
+#define MP_KEY_GAMEPAD_RIGHT_SHOULDER (MP_KEY_GAMEPAD+8)
+#define MP_KEY_GAMEPAD_LEFT_TRIGGER (MP_KEY_GAMEPAD+9)
+#define MP_KEY_GAMEPAD_RIGHT_TRIGGER (MP_KEY_GAMEPAD+10)
+#define MP_KEY_GAMEPAD_LEFT_STICK (MP_KEY_GAMEPAD+11)
+#define MP_KEY_GAMEPAD_RIGHT_STICK (MP_KEY_GAMEPAD+12)
+#define MP_KEY_GAMEPAD_DPAD_UP (MP_KEY_GAMEPAD+13)
+#define MP_KEY_GAMEPAD_DPAD_DOWN (MP_KEY_GAMEPAD+14)
+#define MP_KEY_GAMEPAD_DPAD_LEFT (MP_KEY_GAMEPAD+15)
+#define MP_KEY_GAMEPAD_DPAD_RIGHT (MP_KEY_GAMEPAD+16)
+#define MP_KEY_GAMEPAD_LEFT_STICK_UP (MP_KEY_GAMEPAD+17)
+#define MP_KEY_GAMEPAD_LEFT_STICK_DOWN (MP_KEY_GAMEPAD+18)
+#define MP_KEY_GAMEPAD_LEFT_STICK_LEFT (MP_KEY_GAMEPAD+19)
+#define MP_KEY_GAMEPAD_LEFT_STICK_RIGHT (MP_KEY_GAMEPAD+20)
+#define MP_KEY_GAMEPAD_RIGHT_STICK_UP (MP_KEY_GAMEPAD+21)
+#define MP_KEY_GAMEPAD_RIGHT_STICK_DOWN (MP_KEY_GAMEPAD+22)
+#define MP_KEY_GAMEPAD_RIGHT_STICK_LEFT (MP_KEY_GAMEPAD+23)
+#define MP_KEY_GAMEPAD_RIGHT_STICK_RIGHT (MP_KEY_GAMEPAD+24)
+
// Reserved area. Can be used for keys that have no explicit names assigned,
// but should be mappable by the user anyway.
#define MP_KEY_UNKNOWN_RESERVED_START (MP_KEY_BASE+0x10000)
diff --git a/input/sdl_gamepad.c b/input/sdl_gamepad.c
new file mode 100644
index 0000000000..23997bfa07
--- /dev/null
+++ b/input/sdl_gamepad.c
@@ -0,0 +1,277 @@
+/*
+ * This file is part of mpv.
+ *
+ * mpv is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * mpv 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with mpv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <SDL.h>
+#include <stdbool.h>
+#include <pthread.h>
+#include "common/common.h"
+#include "common/msg.h"
+#include "input.h"
+#include "input/keycodes.h"
+
+struct gamepad_priv {
+ SDL_GameController *controller;
+};
+
+static Uint32 gamepad_cancel_wakeup;
+
+static void initalize_events()
+{
+ gamepad_cancel_wakeup = SDL_RegisterEvents(1);
+}
+
+static pthread_once_t events_initialized = PTHREAD_ONCE_INIT;
+
+#define INVALID_KEY -1
+
+static const int button_map[][2] = {
+ { SDL_CONTROLLER_BUTTON_A, MP_KEY_GAMEPAD_ACTION_DOWN },
+ { SDL_CONTROLLER_BUTTON_B, MP_KEY_GAMEPAD_ACTION_RIGHT },
+ { SDL_CONTROLLER_BUTTON_X, MP_KEY_GAMEPAD_ACTION_LEFT },
+ { SDL_CONTROLLER_BUTTON_Y, MP_KEY_GAMEPAD_ACTION_UP },
+ { SDL_CONTROLLER_BUTTON_BACK, MP_KEY_GAMEPAD_BACK },
+ { SDL_CONTROLLER_BUTTON_GUIDE, MP_KEY_GAMEPAD_MENU },
+ { SDL_CONTROLLER_BUTTON_START, MP_KEY_GAMEPAD_START },
+ { SDL_CONTROLLER_BUTTON_LEFTSTICK, MP_KEY_GAMEPAD_LEFT_STICK },
+ { SDL_CONTROLLER_BUTTON_RIGHTSTICK, MP_KEY_GAMEPAD_RIGHT_STICK },
+ { SDL_CONTROLLER_BUTTON_LEFTSHOULDER, MP_KEY_GAMEPAD_LEFT_SHOULDER },
+ { SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, MP_KEY_GAMEPAD_RIGHT_SHOULDER },
+ { SDL_CONTROLLER_BUTTON_DPAD_UP, MP_KEY_GAMEPAD_DPAD_UP },
+ { SDL_CONTROLLER_BUTTON_DPAD_DOWN, MP_KEY_GAMEPAD_DPAD_DOWN },
+ { SDL_CONTROLLER_BUTTON_DPAD_LEFT, MP_KEY_GAMEPAD_DPAD_LEFT },
+ { SDL_CONTROLLER_BUTTON_DPAD_RIGHT, MP_KEY_GAMEPAD_DPAD_RIGHT },
+};
+
+static const int analog_map[][5] = {
+ // 0 -> sdl enum
+ // 1 -> negative state
+ // 2 -> neutral-negative state
+ // 3 -> neutral-positive state
+ // 4 -> positive state
+ { SDL_CONTROLLER_AXIS_LEFTX,
+ MP_KEY_GAMEPAD_LEFT_STICK_LEFT | MP_KEY_STATE_DOWN,
+ MP_KEY_GAMEPAD_LEFT_STICK_LEFT | MP_KEY_STATE_UP,
+ MP_KEY_GAMEPAD_LEFT_STICK_RIGHT | MP_KEY_STATE_UP,
+ MP_KEY_GAMEPAD_LEFT_STICK_RIGHT | MP_KEY_STATE_DOWN },
+
+ { SDL_CONTROLLER_AXIS_LEFTY,
+ MP_KEY_GAMEPAD_LEFT_STICK_UP | MP_KEY_STATE_DOWN,
+ MP_KEY_GAMEPAD_LEFT_STICK_UP | MP_KEY_STATE_UP,
+ MP_KEY_GAMEPAD_LEFT_STICK_DOWN | MP_KEY_STATE_UP,
+ MP_KEY_GAMEPAD_LEFT_STICK_DOWN | MP_KEY_STATE_DOWN },
+
+ { SDL_CONTROLLER_AXIS_RIGHTX,
+ MP_KEY_GAMEPAD_RIGHT_STICK_LEFT | MP_KEY_STATE_DOWN,
+ MP_KEY_GAMEPAD_RIGHT_STICK_LEFT | MP_KEY_STATE_UP,
+ MP_KEY_GAMEPAD_RIGHT_STICK_RIGHT | MP_KEY_STATE_UP,
+ MP_KEY_GAMEPAD_RIGHT_STICK_RIGHT | MP_KEY_STATE_DOWN },
+
+ { SDL_CONTROLLER_AXIS_RIGHTY,
+ MP_KEY_GAMEPAD_RIGHT_STICK_UP | MP_KEY_STATE_DOWN,
+ MP_KEY_GAMEPAD_RIGHT_STICK_UP | MP_KEY_STATE_UP,
+ MP_KEY_GAMEPAD_RIGHT_STICK_DOWN | MP_KEY_STATE_UP,
+ MP_KEY_GAMEPAD_RIGHT_STICK_DOWN | MP_KEY_STATE_DOWN },
+
+ { SDL_CONTROLLER_AXIS_TRIGGERLEFT,
+ INVALID_KEY,
+ INVALID_KEY,
+ MP_KEY_GAMEPAD_LEFT_TRIGGER | MP_KEY_STATE_UP,
+ MP_KEY_GAMEPAD_LEFT_TRIGGER | MP_KEY_STATE_DOWN },
+
+ { SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
+ INVALID_KEY,
+ INVALID_KEY,
+ MP_KEY_GAMEPAD_RIGHT_TRIGGER | MP_KEY_STATE_UP,
+ MP_KEY_GAMEPAD_RIGHT_TRIGGER | MP_KEY_STATE_DOWN },
+};
+
+static int lookup_button_mp_key(int sdl_key)
+{
+ for (int i = 0; i < MP_ARRAY_SIZE(button_map); i++) {
+ if (button_map[i][0] == sdl_key) {
+ return button_map[i][1];
+ }
+ }
+ return INVALID_KEY;
+}
+
+static int lookup_analog_mp_key(int sdl_key, int16_t value)
+{
+ const int sdl_axis_max = 32767;
+ const int negative = 1;
+ const int negative_neutral = 2;
+ const int positive_neutral = 3;
+ const int positive = 4;
+
+ const float activation_threshold = sdl_axis_max * 0.33;
+ const float noise_threshold = sdl_axis_max * 0.06;
+
+ // sometimes SDL just keeps shitting out low values around 0 that mess
+ // with key repeating code
+ if (value < noise_threshold && value > -noise_threshold) {
+ return INVALID_KEY;
+ }
+
+ int state = value > 0 ? positive_neutral : negative_neutral;
+
+ if (value >= sdl_axis_max - activation_threshold) {
+ state = positive;
+ }
+
+ if (value <= activation_threshold - sdl_axis_max) {
+ state = negative;
+ }
+
+ for (int i = 0; i < MP_ARRAY_SIZE(analog_map); i++) {
+ if (analog_map[i][0] == sdl_key) {
+ return analog_map[i][state];
+ }
+ }
+
+ return INVALID_KEY;
+}
+
+
+static void request_cancel(struct mp_input_src *src)
+{
+ MP_VERBOSE(src, "exiting...\n");
+ SDL_Event event = { .type = gamepad_cancel_wakeup };
+ SDL_PushEvent(&event);
+}
+
+static void uninit(struct mp_input_src *src)
+{
+ MP_VERBOSE(src, "exited.\n");
+}
+
+#define GUID_LEN 33
+
+static void add_gamepad(struct mp_input_src *src, int id)
+{
+ struct gamepad_priv *p = src->priv;
+
+ if (p->controller) {
+ MP_WARN(src, "can't add more than one controller\n");
+ return;
+ }
+
+ if (SDL_IsGameController(id)) {
+ SDL_GameController *controller = SDL_GameControllerOpen(id);
+
+ if (controller) {
+ const char *name = SDL_GameControllerName(controller);
+ MP_INFO(src, "added controller: %s\n", name);
+ p->controller = controller;
+ return;
+ }
+ }
+}
+
+static void remove_gamepad(struct mp_input_src *src, int id)
+{
+ struct gamepad_priv *p = src->priv;
+ SDL_GameController *controller = p->controller;
+ SDL_Joystick* j = SDL_GameControllerGetJoystick(controller);
+ SDL_JoystickID jid = SDL_JoystickInstanceID(j);
+
+ if (controller && jid == id) {
+ const char *name = SDL_GameControllerName(controller);
+ MP_INFO(src, "removed controller: %s\n", name);
+ SDL_GameControllerClose(controller);
+ p->controller = NULL;
+ }
+}
+
+static void read_gamepad_thread(struct mp_input_src *src, void *param)
+{
+ if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)) {
+ MP_ERR(src, "SDL_Init failed\n");
+ mp_input_src_init_done(src);
+ return;
+ };
+
+ pthread_once(&events_initialized, initalize_events);
+
+ if (gamepad_cancel_wakeup == (Uint32)-1) {
+ MP_ERR(src, "Can't register SDL custom events\n");
+ mp_input_src_init_done(src);
+ return;
+ }
+
+ struct gamepad_priv *p =src->priv = talloc_zero(src, struct gamepad_priv);
+ src->cancel = request_cancel;
+ src->uninit = uninit;
+
+ mp_input_src_init_done(src);
+
+ SDL_Event ev;
+
+ while (SDL_WaitEvent(&ev) != 0) {
+ if (ev.type == gamepad_cancel_wakeup) {
+ break;
+ }
+
+ switch (ev.type) {
+ case SDL_CONTROLLERDEVICEADDED: {
+ add_gamepad(src, ev.cdevice.which);
+ continue;
+ }
+ case SDL_CONTROLLERDEVICEREMOVED: {
+ remove_gamepad(src, ev.cdevice.which);
+ continue;
+ }
+ case SDL_CONTROLLERBUTTONDOWN: {
+ const int key = lookup_button_mp_key(ev.cbutton.button);
+ if (key != INVALID_KEY) {
+ mp_input_put_key(src->input_ctx, key | MP_KEY_STATE_DOWN);
+ }
+ continue;
+ }
+ case SDL_CONTROLLERBUTTONUP: {
+ const int key = lookup_button_mp_key(ev.cbutton.button);
+ if (key != INVALID_KEY) {
+ mp_input_put_key(src->input_ctx, key | MP_KEY_STATE_UP);
+ }
+ continue;
+ }
+ case SDL_CONTROLLERAXISMOTION: {
+ const int key =
+ lookup_analog_mp_key(ev.caxis.axis, ev.caxis.value);
+ if (key != INVALID_KEY) {
+ mp_input_put_key(src->input_ctx, key);
+ }
+ continue;
+ }
+
+ }
+ }
+
+ if (p->controller) {
+ SDL_Joystick* j = SDL_GameControllerGetJoystick(p->controller);
+ SDL_JoystickID jid = SDL_JoystickInstanceID(j);
+ remove_gamepad(src, jid);
+ }
+
+ // must be called on the same thread of SDL_InitSubSystem, so uninit
+ // callback can't be used for this
+ SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
+}
+
+void mp_input_sdl_gamepad_add(struct input_ctx *ictx)
+{
+ mp_input_add_thread_src(ictx, NULL, read_gamepad_thread);
+}
diff --git a/test/input-gamepad.conf b/test/input-gamepad.conf
new file mode 100644
index 0000000000..ad79fb9973
--- /dev/null
+++ b/test/input-gamepad.conf
@@ -0,0 +1,4 @@
+GAMEPAD_RIGHT_STICK_LEFT seek -10
+GAMEPAD_RIGHT_STICK_RIGHT seek 10
+GAMEPAD_LEFT_TRIGGER seek -1
+GAMEPAD_RIGHT_TRIGGER seek 1
diff --git a/video/out/vo.c b/video/out/vo.c
index 64ac8aa3ed..e28026cab5 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -83,7 +83,7 @@ const struct vo_driver *const video_out_drivers[] =
#if HAVE_XV
&video_out_xv,
#endif
-#if HAVE_SDL2
+#if HAVE_SDL2_VIDEO
&video_out_sdl,
#endif
#if HAVE_VAAPI_X11 && HAVE_GPL
diff --git a/wscript b/wscript
index b1fc93a8e0..c2b84411a5 100644
--- a/wscript
+++ b/wscript
@@ -420,6 +420,16 @@ iconv support use --disable-iconv.",
'deps': 'gpl',
'func': check_true,
'default': 'disable',
+ }, {
+ 'name': '--sdl2',
+ 'desc': 'SDL2',
+ 'func': check_pkg_config('sdl2'),
+ 'default': 'disable',
+ }, {
+ 'name': '--sdl2-gamepad',
+ 'desc': 'SDL2 gamepad input',
+ 'deps': 'sdl2',
+ 'func': check_true,
}
]
@@ -499,10 +509,10 @@ FFmpeg/Libav libraries. Git master is recommended."
audio_output_features = [
{
- 'name': '--sdl2',
- 'desc': 'SDL2',
- 'func': check_pkg_config('sdl2'),
- 'default': 'disable'
+ 'name': '--sdl2-audio',
+ 'desc': 'SDL2 audio output',
+ 'deps': 'sdl2',
+ 'func': check_true,
}, {
'name': '--oss-audio',
'desc': 'OSS',
@@ -563,6 +573,11 @@ audio_output_features = [
video_output_features = [
{
+ 'name': '--sdl2-video',
+ 'desc': 'SDL2 video output',
+ 'deps': 'sdl2',
+ 'func': check_true,
+ }, {
'name': '--cocoa',
'desc': 'Cocoa',
'func': check_cocoa
diff --git a/wscript_build.py b/wscript_build.py
index 9f47153413..951584ec9d 100644
--- a/wscript_build.py
+++ b/wscript_build.py
@@ -257,7 +257,7 @@ def build(ctx):
( "audio/out/ao_pcm.c" ),
( "audio/out/ao_pulse.c", "pulse" ),
( "audio/out/ao_rsound.c", "rsound" ),
- ( "audio/out/ao_sdl.c", "sdl2" ),
+ ( "audio/out/ao_sdl.c", "sdl2-audio" ),
( "audio/out/ao_sndio.c", "sndio" ),
( "audio/out/ao_wasapi.c", "wasapi" ),
( "audio/out/ao_wasapi_changenotify.c", "wasapi" ),
@@ -320,6 +320,7 @@ def build(ctx):
( ipc_c ),
( "input/keycodes.c" ),
( "input/pipe-win32.c", "win32-pipes" ),
+ ( "input/sdl_gamepad.c", "sdl2-gamepad" ),
## Misc
( "misc/bstr.c" ),
@@ -490,7 +491,7 @@ def build(ctx):
( "video/out/vo_mediacodec_embed.c", "android" ),
( "video/out/vo_null.c" ),
( "video/out/vo_rpi.c", "rpi-mmal" ),
- ( "video/out/vo_sdl.c", "sdl2" ),
+ ( "video/out/vo_sdl.c", "sdl2-video" ),
( "video/out/vo_tct.c" ),
( "video/out/vo_vaapi.c", "vaapi-x11 && gpl" ),
( "video/out/vo_vdpau.c", "vdpau" ),