Skip to content

Commit fe01b98

Browse files
committed
Joystick mapping support for MacOS using SDL2
1 parent 590f0ab commit fe01b98

File tree

8 files changed

+685
-87
lines changed

8 files changed

+685
-87
lines changed

Makefile.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
278278
PKG_CONFIG = @PKG_CONFIG@
279279
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
280280
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
281+
SDL2_CFLAGS = @SDL2_CFLAGS@
282+
SDL2_LIBS = @SDL2_LIBS@
281283
SET_MAKE = @SET_MAKE@
282284
SHELL = @SHELL@
283285
STRIP = @STRIP@

aclocal.m4

Lines changed: 6 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ If you have problems, you may need to regenerate the build system entirely.
2121
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
2222

2323
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
24-
# serial 11 (pkg-config-0.29.1)
24+
# serial 12 (pkg-config-0.29.2)
2525

2626
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
2727
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
@@ -63,7 +63,7 @@ dnl
6363
dnl See the "Since" comment for each macro you use to see what version
6464
dnl of the macros you require.
6565
m4_defun([PKG_PREREQ],
66-
[m4_define([PKG_MACROS_VERSION], [0.29.1])
66+
[m4_define([PKG_MACROS_VERSION], [0.29.2])
6767
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
6868
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
6969
])dnl PKG_PREREQ
@@ -164,7 +164,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
164164
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
165165
166166
pkg_failed=no
167-
AC_MSG_CHECKING([for $1])
167+
AC_MSG_CHECKING([for $2])
168168
169169
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
170170
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
@@ -174,11 +174,11 @@ and $1[]_LIBS to avoid the need to call pkg-config.
174174
See the pkg-config man page for more details.])
175175
176176
if test $pkg_failed = yes; then
177-
AC_MSG_RESULT([no])
177+
AC_MSG_RESULT([no])
178178
_PKG_SHORT_ERRORS_SUPPORTED
179179
if test $_pkg_short_errors_supported = yes; then
180180
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
181-
else
181+
else
182182
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
183183
fi
184184
# Put the nasty error message in config.log where it belongs
@@ -195,7 +195,7 @@ installed software in a non-standard prefix.
195195
_PKG_TEXT])[]dnl
196196
])
197197
elif test $pkg_failed = untried; then
198-
AC_MSG_RESULT([no])
198+
AC_MSG_RESULT([no])
199199
m4_default([$4], [AC_MSG_FAILURE(
200200
[The pkg-config script could not be found or is too old. Make sure it
201201
is in your PATH or set the PKG_CONFIG environment variable to the full
@@ -296,74 +296,6 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
296296
AS_VAR_IF([$1], [""], [$5], [$4])dnl
297297
])dnl PKG_CHECK_VAR
298298

299-
dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
300-
dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
301-
dnl [DESCRIPTION], [DEFAULT])
302-
dnl ------------------------------------------
303-
dnl
304-
dnl Prepare a "--with-" configure option using the lowercase
305-
dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
306-
dnl PKG_CHECK_MODULES in a single macro.
307-
AC_DEFUN([PKG_WITH_MODULES],
308-
[
309-
m4_pushdef([with_arg], m4_tolower([$1]))
310-
311-
m4_pushdef([description],
312-
[m4_default([$5], [build with ]with_arg[ support])])
313-
314-
m4_pushdef([def_arg], [m4_default([$6], [auto])])
315-
m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
316-
m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
317-
318-
m4_case(def_arg,
319-
[yes],[m4_pushdef([with_without], [--without-]with_arg)],
320-
[m4_pushdef([with_without],[--with-]with_arg)])
321-
322-
AC_ARG_WITH(with_arg,
323-
AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
324-
[AS_TR_SH([with_]with_arg)=def_arg])
325-
326-
AS_CASE([$AS_TR_SH([with_]with_arg)],
327-
[yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
328-
[auto],[PKG_CHECK_MODULES([$1],[$2],
329-
[m4_n([def_action_if_found]) $3],
330-
[m4_n([def_action_if_not_found]) $4])])
331-
332-
m4_popdef([with_arg])
333-
m4_popdef([description])
334-
m4_popdef([def_arg])
335-
336-
])dnl PKG_WITH_MODULES
337-
338-
dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
339-
dnl [DESCRIPTION], [DEFAULT])
340-
dnl -----------------------------------------------
341-
dnl
342-
dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
343-
dnl check._[VARIABLE-PREFIX] is exported as make variable.
344-
AC_DEFUN([PKG_HAVE_WITH_MODULES],
345-
[
346-
PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
347-
348-
AM_CONDITIONAL([HAVE_][$1],
349-
[test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
350-
])dnl PKG_HAVE_WITH_MODULES
351-
352-
dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
353-
dnl [DESCRIPTION], [DEFAULT])
354-
dnl ------------------------------------------------------
355-
dnl
356-
dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
357-
dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
358-
dnl and preprocessor variable.
359-
AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
360-
[
361-
PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
362-
363-
AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
364-
[AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
365-
])dnl PKG_HAVE_DEFINE_WITH_MODULES
366-
367299
# Copyright (C) 2002-2021 Free Software Foundation, Inc.
368300
#
369301
# This file is free software; the Free Software Foundation

configure

Lines changed: 87 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,8 @@ am__EXEEXT_TRUE
650650
LTLIBOBJS
651651
LIBOBJS
652652
DEFINES
653+
SDL2_LIBS
654+
SDL2_CFLAGS
653655
GTK_LIBS
654656
GTK_CFLAGS
655657
PKG_CONFIG_LIBDIR
@@ -774,7 +776,9 @@ PKG_CONFIG
774776
PKG_CONFIG_PATH
775777
PKG_CONFIG_LIBDIR
776778
GTK_CFLAGS
777-
GTK_LIBS'
779+
GTK_LIBS
780+
SDL2_CFLAGS
781+
SDL2_LIBS'
778782

779783

780784
# Initialize some variables set by options.
@@ -1424,6 +1428,8 @@ Some influential environment variables:
14241428
path overriding pkg-config's built-in search path
14251429
GTK_CFLAGS C compiler flags for GTK, overriding pkg-config
14261430
GTK_LIBS linker flags for GTK, overriding pkg-config
1431+
SDL2_CFLAGS C compiler flags for SDL2, overriding pkg-config
1432+
SDL2_LIBS linker flags for SDL2, overriding pkg-config
14271433
14281434
Use these variables to override the choices made by `configure' or to help
14291435
it to find libraries and programs with nonstandard names/locations.
@@ -4886,8 +4892,8 @@ fi
48864892

48874893

48884894
pkg_failed=no
4889-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GTK" >&5
4890-
printf %s "checking for GTK... " >&6; }
4895+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gtk+-3.0 >= 3.16 glib-2.0 >= 2.42" >&5
4896+
printf %s "checking for gtk+-3.0 >= 3.16 glib-2.0 >= 2.42... " >&6; }
48914897

48924898
if test -n "$GTK_CFLAGS"; then
48934899
pkg_cv_GTK_CFLAGS="$GTK_CFLAGS"
@@ -4927,7 +4933,7 @@ fi
49274933

49284934

49294935
if test $pkg_failed = yes; then
4930-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
4936+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
49314937
printf "%s\n" "no" >&6; }
49324938

49334939
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -4945,7 +4951,7 @@ fi
49454951

49464952
as_fn_error $? "Mednaffe needs GTK+ >= 3.16 development libraries" "$LINENO" 5
49474953
elif test $pkg_failed = untried; then
4948-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
4954+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
49494955
printf "%s\n" "no" >&6; }
49504956
as_fn_error $? "Mednaffe needs GTK+ >= 3.16 development libraries" "$LINENO" 5
49514957
else
@@ -4956,6 +4962,82 @@ printf "%s\n" "yes" >&6; }
49564962
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checking for GTK+ 3 development libraries" >&5
49574963
printf "%s\n" "$as_me: Checking for GTK+ 3 development libraries" >&6;}
49584964
fi
4965+
case $host_os in
4966+
darwin*)
4967+
4968+
pkg_failed=no
4969+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SDL2 >= 2.0.6" >&5
4970+
printf %s "checking for SDL2 >= 2.0.6... " >&6; }
4971+
4972+
if test -n "$SDL2_CFLAGS"; then
4973+
pkg_cv_SDL2_CFLAGS="$SDL2_CFLAGS"
4974+
elif test -n "$PKG_CONFIG"; then
4975+
if test -n "$PKG_CONFIG" && \
4976+
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"SDL2 >= 2.0.6\""; } >&5
4977+
($PKG_CONFIG --exists --print-errors "SDL2 >= 2.0.6") 2>&5
4978+
ac_status=$?
4979+
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
4980+
test $ac_status = 0; }; then
4981+
pkg_cv_SDL2_CFLAGS=`$PKG_CONFIG --cflags "SDL2 >= 2.0.6" 2>/dev/null`
4982+
test "x$?" != "x0" && pkg_failed=yes
4983+
else
4984+
pkg_failed=yes
4985+
fi
4986+
else
4987+
pkg_failed=untried
4988+
fi
4989+
if test -n "$SDL2_LIBS"; then
4990+
pkg_cv_SDL2_LIBS="$SDL2_LIBS"
4991+
elif test -n "$PKG_CONFIG"; then
4992+
if test -n "$PKG_CONFIG" && \
4993+
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"SDL2 >= 2.0.6\""; } >&5
4994+
($PKG_CONFIG --exists --print-errors "SDL2 >= 2.0.6") 2>&5
4995+
ac_status=$?
4996+
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
4997+
test $ac_status = 0; }; then
4998+
pkg_cv_SDL2_LIBS=`$PKG_CONFIG --libs "SDL2 >= 2.0.6" 2>/dev/null`
4999+
test "x$?" != "x0" && pkg_failed=yes
5000+
else
5001+
pkg_failed=yes
5002+
fi
5003+
else
5004+
pkg_failed=untried
5005+
fi
5006+
5007+
5008+
5009+
if test $pkg_failed = yes; then
5010+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
5011+
printf "%s\n" "no" >&6; }
5012+
5013+
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
5014+
_pkg_short_errors_supported=yes
5015+
else
5016+
_pkg_short_errors_supported=no
5017+
fi
5018+
if test $_pkg_short_errors_supported = yes; then
5019+
SDL2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "SDL2 >= 2.0.6" 2>&1`
5020+
else
5021+
SDL2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "SDL2 >= 2.0.6" 2>&1`
5022+
fi
5023+
# Put the nasty error message in config.log where it belongs
5024+
echo "$SDL2_PKG_ERRORS" >&5
5025+
5026+
as_fn_error $? "Mednaffe darwin needs SDL2 >= 2.0.6 development libraries" "$LINENO" 5
5027+
elif test $pkg_failed = untried; then
5028+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
5029+
printf "%s\n" "no" >&6; }
5030+
as_fn_error $? "Mednaffe darwin needs SDL2 >= 2.0.6 development libraries" "$LINENO" 5
5031+
else
5032+
SDL2_CFLAGS=$pkg_cv_SDL2_CFLAGS
5033+
SDL2_LIBS=$pkg_cv_SDL2_LIBS
5034+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
5035+
printf "%s\n" "yes" >&6; }
5036+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Checking for SDL2 development libraries" >&5
5037+
printf "%s\n" "$as_me: Checking for SDL2 development libraries" >&6;}
5038+
fi
5039+
;;
5040+
esac
49595041

49605042

49615043

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ else
6565
fi
6666

6767
PKG_CHECK_MODULES([GTK],[gtk+-3.0 >= 3.16 glib-2.0 >= 2.42], AC_MSG_NOTICE([Checking for GTK+ 3 development libraries]), AC_MSG_ERROR(Mednaffe needs GTK+ >= 3.16 development libraries))
68+
case $host_os in
69+
darwin*)
70+
PKG_CHECK_MODULES([SDL2],[SDL2 >= 2.0.6], AC_MSG_NOTICE([Checking for SDL2 development libraries]), AC_MSG_ERROR(Mednaffe darwin needs SDL2 >= 2.0.6 development libraries))
71+
;;
72+
esac
6873

6974
AC_SUBST(DEFINES)
7075

share/Makefile.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
200200
PKG_CONFIG = @PKG_CONFIG@
201201
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
202202
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
203+
SDL2_CFLAGS = @SDL2_CFLAGS@
204+
SDL2_LIBS = @SDL2_LIBS@
203205
SET_MAKE = @SET_MAKE@
204206
SHELL = @SHELL@
205207
STRIP = @STRIP@

src/Makefile.am

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if WINDOWS
4545
LIBS +=../share/win/mednaffe.res -ldxguid -ldinput
4646
else
4747
if MAC
48-
mednaffe_SOURCES+= widgets/joystick_dummy.c
48+
mednaffe_SOURCES+= widgets/joystick_sdl.c
4949
else
5050
mednaffe_SOURCES+= widgets/joystick_dummy.c
5151
override CFLAGS +=-Wl,-export-dynamic
@@ -54,7 +54,12 @@ endif
5454
endif
5555

5656

57-
AM_CPPFLAGS = @GTK_CFLAGS@
58-
LDADD = @GTK_LIBS@
57+
if MAC
58+
AM_CPPFLAGS = @GTK_CFLAGS@ @SDL2_CFLAGS@
59+
LDADD = @GTK_LIBS@ @SDL2_LIBS@
60+
else
61+
AM_CPPFLAGS = @GTK_CFLAGS@
62+
LDADD = @GTK_LIBS@
63+
endif
5964
CLEANFILES = *~
6065
DISTCLEANFILES = .deps/*.P

0 commit comments

Comments
 (0)