revision 614:a2d239d4438a
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 614:a2d239d4438a |
parent | 613:c2dd87f947b2 |
child | 615:38b69ec2f4c8 |
author | nkeynes |
date | Mon Jan 28 02:38:09 2008 +0000 (15 years ago) |
Bug #49: Joystick support work in progress
![]() | Makefile.in | view | annotate | diff | log | |
![]() | config.h.in | view | annotate | diff | log | |
![]() | configure | view | annotate | diff | log | |
![]() | configure.in | view | annotate | diff | log | |
![]() | src/Makefile.am | view | annotate | diff | log | |
![]() | src/Makefile.in | view | annotate | diff | log | |
![]() | src/display.c | view | annotate | diff | log | |
![]() | src/display.h | view | annotate | diff | log | |
![]() | src/drivers/joy_linux.c | view | annotate | diff | log | |
![]() | src/drivers/joy_linux.h | view | annotate | diff | log | |
![]() | src/drivers/video_gtk.c | view | annotate | diff | log | |
![]() | src/drivers/video_null.c | view | annotate | diff | log | |
![]() | src/gtkui/ctrl_dlg.c | view | annotate | diff | log | |
![]() | src/gtkui/main_win.c | view | annotate | diff | log | |
![]() | src/maple/controller.c | view | annotate | diff | log | |
![]() | src/maple/kbd.c | view | annotate | diff | log |
1.1 --- a/Makefile.in Mon Jan 28 02:37:09 2008 +00001.2 +++ b/Makefile.in Mon Jan 28 02:38:09 2008 +00001.3 @@ -95,6 +95,8 @@1.4 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@1.5 INSTOBJEXT = @INSTOBJEXT@1.6 INTLLIBS = @INTLLIBS@1.7 +JOY_LINUX_FALSE = @JOY_LINUX_FALSE@1.8 +JOY_LINUX_TRUE = @JOY_LINUX_TRUE@1.9 LDFLAGS = @LDFLAGS@1.10 LIBOBJS = @LIBOBJS@1.11 LIBPNG_CFLAGS = @LIBPNG_CFLAGS@1.12 @@ -188,7 +190,7 @@1.13 installdirs-recursive install-recursive uninstall-recursive \1.14 check-recursive installcheck-recursive1.15 DIST_COMMON = README $(srcdir)/Makefile.in $(srcdir)/configure AUTHORS \1.16 - COPYING ChangeLog INSTALL Makefile.am NEWS TODO acconfig.h \1.17 + COPYING ChangeLog INSTALL Makefile.am NEWS acconfig.h \1.18 aclocal.m4 config.guess config.h.in config.sub configure \1.19 configure.in depcomp install-sh missing mkinstalldirs1.20 DIST_SUBDIRS = src po test
2.1 --- a/config.h.in Mon Jan 28 02:37:09 2008 +00002.2 +++ b/config.h.in Mon Jan 28 02:38:09 2008 +00002.3 @@ -52,6 +52,9 @@2.4 /* Define to 1 if you have the `z' library (-lz). */2.5 #undef HAVE_LIBZ2.7 +/* Have linux joystick support */2.8 +#undef HAVE_LINUX_JOYSTICK2.9 +2.10 /* Define to 1 if you have the <locale.h> header file. */2.11 #undef HAVE_LOCALE_H
3.1 --- a/configure Mon Jan 28 02:37:09 2008 +00003.2 +++ b/configure Mon Jan 28 02:38:09 2008 +00003.3 @@ -719,6 +719,8 @@3.4 AUDIO_ESOUND_FALSE3.5 CDROM_LINUX_TRUE3.6 CDROM_LINUX_FALSE3.7 +JOY_LINUX_TRUE3.8 +JOY_LINUX_FALSE3.9 SHCC3.10 SHLD3.11 SHOBJCOPY3.12 @@ -6126,6 +6128,155 @@3.13 fi3.16 +if test "${ac_cv_header_linux_joystick_h+set}" = set; then3.17 + { echo "$as_me:$LINENO: checking for linux/joystick.h" >&53.18 +echo $ECHO_N "checking for linux/joystick.h... $ECHO_C" >&6; }3.19 +if test "${ac_cv_header_linux_joystick_h+set}" = set; then3.20 + echo $ECHO_N "(cached) $ECHO_C" >&63.21 +fi3.22 +{ echo "$as_me:$LINENO: result: $ac_cv_header_linux_joystick_h" >&53.23 +echo "${ECHO_T}$ac_cv_header_linux_joystick_h" >&6; }3.24 +else3.25 + # Is the header compilable?3.26 +{ echo "$as_me:$LINENO: checking linux/joystick.h usability" >&53.27 +echo $ECHO_N "checking linux/joystick.h usability... $ECHO_C" >&6; }3.28 +cat >conftest.$ac_ext <<_ACEOF3.29 +/* confdefs.h. */3.30 +_ACEOF3.31 +cat confdefs.h >>conftest.$ac_ext3.32 +cat >>conftest.$ac_ext <<_ACEOF3.33 +/* end confdefs.h. */3.34 +$ac_includes_default3.35 +#include <linux/joystick.h>3.36 +_ACEOF3.37 +rm -f conftest.$ac_objext3.38 +if { (ac_try="$ac_compile"3.39 +case "(($ac_try" in3.40 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;3.41 + *) ac_try_echo=$ac_try;;3.42 +esac3.43 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&53.44 + (eval "$ac_compile") 2>conftest.er13.45 + ac_status=$?3.46 + grep -v '^ *+' conftest.er1 >conftest.err3.47 + rm -f conftest.er13.48 + cat conftest.err >&53.49 + echo "$as_me:$LINENO: \$? = $ac_status" >&53.50 + (exit $ac_status); } && {3.51 + test -z "$ac_c_werror_flag" ||3.52 + test ! -s conftest.err3.53 + } && test -s conftest.$ac_objext; then3.54 + ac_header_compiler=yes3.55 +else3.56 + echo "$as_me: failed program was:" >&53.57 +sed 's/^/| /' conftest.$ac_ext >&53.58 +3.59 + ac_header_compiler=no3.60 +fi3.61 +3.62 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext3.63 +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&53.64 +echo "${ECHO_T}$ac_header_compiler" >&6; }3.65 +3.66 +# Is the header present?3.67 +{ echo "$as_me:$LINENO: checking linux/joystick.h presence" >&53.68 +echo $ECHO_N "checking linux/joystick.h presence... $ECHO_C" >&6; }3.69 +cat >conftest.$ac_ext <<_ACEOF3.70 +/* confdefs.h. */3.71 +_ACEOF3.72 +cat confdefs.h >>conftest.$ac_ext3.73 +cat >>conftest.$ac_ext <<_ACEOF3.74 +/* end confdefs.h. */3.75 +#include <linux/joystick.h>3.76 +_ACEOF3.77 +if { (ac_try="$ac_cpp conftest.$ac_ext"3.78 +case "(($ac_try" in3.79 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;3.80 + *) ac_try_echo=$ac_try;;3.81 +esac3.82 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&53.83 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er13.84 + ac_status=$?3.85 + grep -v '^ *+' conftest.er1 >conftest.err3.86 + rm -f conftest.er13.87 + cat conftest.err >&53.88 + echo "$as_me:$LINENO: \$? = $ac_status" >&53.89 + (exit $ac_status); } >/dev/null && {3.90 + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||3.91 + test ! -s conftest.err3.92 + }; then3.93 + ac_header_preproc=yes3.94 +else3.95 + echo "$as_me: failed program was:" >&53.96 +sed 's/^/| /' conftest.$ac_ext >&53.97 +3.98 + ac_header_preproc=no3.99 +fi3.100 +3.101 +rm -f conftest.err conftest.$ac_ext3.102 +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&53.103 +echo "${ECHO_T}$ac_header_preproc" >&6; }3.104 +3.105 +# So? What about this header?3.106 +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in3.107 + yes:no: )3.108 + { echo "$as_me:$LINENO: WARNING: linux/joystick.h: accepted by the compiler, rejected by the preprocessor!" >&53.109 +echo "$as_me: WARNING: linux/joystick.h: accepted by the compiler, rejected by the preprocessor!" >&2;}3.110 + { echo "$as_me:$LINENO: WARNING: linux/joystick.h: proceeding with the compiler's result" >&53.111 +echo "$as_me: WARNING: linux/joystick.h: proceeding with the compiler's result" >&2;}3.112 + ac_header_preproc=yes3.113 + ;;3.114 + no:yes:* )3.115 + { echo "$as_me:$LINENO: WARNING: linux/joystick.h: present but cannot be compiled" >&53.116 +echo "$as_me: WARNING: linux/joystick.h: present but cannot be compiled" >&2;}3.117 + { echo "$as_me:$LINENO: WARNING: linux/joystick.h: check for missing prerequisite headers?" >&53.118 +echo "$as_me: WARNING: linux/joystick.h: check for missing prerequisite headers?" >&2;}3.119 + { echo "$as_me:$LINENO: WARNING: linux/joystick.h: see the Autoconf documentation" >&53.120 +echo "$as_me: WARNING: linux/joystick.h: see the Autoconf documentation" >&2;}3.121 + { echo "$as_me:$LINENO: WARNING: linux/joystick.h: section \"Present But Cannot Be Compiled\"" >&53.122 +echo "$as_me: WARNING: linux/joystick.h: section \"Present But Cannot Be Compiled\"" >&2;}3.123 + { echo "$as_me:$LINENO: WARNING: linux/joystick.h: proceeding with the preprocessor's result" >&53.124 +echo "$as_me: WARNING: linux/joystick.h: proceeding with the preprocessor's result" >&2;}3.125 + { echo "$as_me:$LINENO: WARNING: linux/joystick.h: in the future, the compiler will take precedence" >&53.126 +echo "$as_me: WARNING: linux/joystick.h: in the future, the compiler will take precedence" >&2;}3.127 +3.128 + ;;3.129 +esac3.130 +{ echo "$as_me:$LINENO: checking for linux/joystick.h" >&53.131 +echo $ECHO_N "checking for linux/joystick.h... $ECHO_C" >&6; }3.132 +if test "${ac_cv_header_linux_joystick_h+set}" = set; then3.133 + echo $ECHO_N "(cached) $ECHO_C" >&63.134 +else3.135 + ac_cv_header_linux_joystick_h=$ac_header_preproc3.136 +fi3.137 +{ echo "$as_me:$LINENO: result: $ac_cv_header_linux_joystick_h" >&53.138 +echo "${ECHO_T}$ac_cv_header_linux_joystick_h" >&6; }3.139 +3.140 +fi3.141 +if test $ac_cv_header_linux_joystick_h = yes; then3.142 +3.143 + HAVE_LINUX_JOYSTICK_H=yes3.144 +3.145 +cat >>confdefs.h <<\_ACEOF3.146 +#define HAVE_LINUX_JOYSTICK 13.147 +_ACEOF3.148 +3.149 +else3.150 + echo "Linux Joystick support not found, building without it."3.151 +fi3.152 +3.153 +3.154 +3.155 +3.156 +if test "$HAVE_LINUX_JOYSTICK_H" = "yes"; then3.157 + JOY_LINUX_TRUE=3.158 + JOY_LINUX_FALSE='#'3.159 +else3.160 + JOY_LINUX_TRUE='#'3.161 + JOY_LINUX_FALSE=3.162 +fi3.163 +3.164 +3.165 # Extract the first word of "sh-elf-gcc", so it can be a program name with args.3.166 set dummy sh-elf-gcc; ac_word=$23.167 { echo "$as_me:$LINENO: checking for $ac_word" >&53.168 @@ -8095,6 +8246,13 @@3.169 Usually this means the macro was only invoked conditionally." >&2;}3.170 { (exit 1); exit 1; }; }3.171 fi3.172 +if test -z "${JOY_LINUX_TRUE}" && test -z "${JOY_LINUX_FALSE}"; then3.173 + { { echo "$as_me:$LINENO: error: conditional \"JOY_LINUX\" was never defined.3.174 +Usually this means the macro was only invoked conditionally." >&53.175 +echo "$as_me: error: conditional \"JOY_LINUX\" was never defined.3.176 +Usually this means the macro was only invoked conditionally." >&2;}3.177 + { (exit 1); exit 1; }; }3.178 +fi3.179 if test -z "${BUILD_SYSTEST_TRUE}" && test -z "${BUILD_SYSTEST_FALSE}"; then3.180 { { echo "$as_me:$LINENO: error: conditional \"BUILD_SYSTEST\" was never defined.3.181 Usually this means the macro was only invoked conditionally." >&53.182 @@ -8792,6 +8950,8 @@3.183 AUDIO_ESOUND_FALSE!$AUDIO_ESOUND_FALSE$ac_delim3.184 CDROM_LINUX_TRUE!$CDROM_LINUX_TRUE$ac_delim3.185 CDROM_LINUX_FALSE!$CDROM_LINUX_FALSE$ac_delim3.186 +JOY_LINUX_TRUE!$JOY_LINUX_TRUE$ac_delim3.187 +JOY_LINUX_FALSE!$JOY_LINUX_FALSE$ac_delim3.188 SHCC!$SHCC$ac_delim3.189 SHLD!$SHLD$ac_delim3.190 SHOBJCOPY!$SHOBJCOPY$ac_delim3.191 @@ -8823,7 +8983,7 @@3.192 LTLIBOBJS!$LTLIBOBJS$ac_delim3.193 _ACEOF3.195 - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 38; then3.196 + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 40; then3.197 break3.198 elif $ac_last_try; then3.199 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
4.1 --- a/configure.in Mon Jan 28 02:37:09 2008 +00004.2 +++ b/configure.in Mon Jan 28 02:38:09 2008 +00004.3 @@ -85,6 +85,12 @@4.4 echo "Linux CDROM support not found, building without it."] )4.5 AM_CONDITIONAL(CDROM_LINUX, [test "$HAVE_LINUX_CDROM_H" = "yes"])4.7 +AC_CHECK_HEADER([linux/joystick.h], [4.8 + HAVE_LINUX_JOYSTICK_H=yes4.9 + AC_DEFINE([HAVE_LINUX_JOYSTICK], 1, [Have linux joystick support]) ],4.10 + [ echo "Linux Joystick support not found, building without it."] )4.11 +AM_CONDITIONAL(JOY_LINUX, [test "$HAVE_LINUX_JOYSTICK_H" = "yes"])4.12 +4.13 dnl Check for cross-compiler availability - needed for system tests4.14 AC_PATH_PROG(SHCC, [sh-elf-gcc])4.15 AC_PATH_PROG(SHLD, [sh-elf-ld])
5.1 --- a/src/Makefile.am Mon Jan 28 02:37:09 2008 +00005.2 +++ b/src/Makefile.am Mon Jan 28 02:38:09 2008 +00005.3 @@ -75,6 +75,10 @@5.4 lxdream_SOURCES += drivers/cd_none.c5.5 endif5.7 +if JOY_LINUX5.8 +lxdream_SOURCES += drivers/joy_linux.c5.9 +endif5.10 +5.11 if AUDIO_ESOUND5.12 lxdream_SOURCES += drivers/audio_esd.c5.13 endif
6.1 --- a/src/Makefile.in Mon Jan 28 02:37:09 2008 +00006.2 +++ b/src/Makefile.in Mon Jan 28 02:38:09 2008 +00006.3 @@ -52,7 +52,8 @@6.5 @CDROM_LINUX_TRUE@am__append_4 = drivers/cd_linux.c6.6 @CDROM_LINUX_FALSE@am__append_5 = drivers/cd_none.c6.7 -@AUDIO_ESOUND_TRUE@am__append_6 = drivers/audio_esd.c6.8 +@JOY_LINUX_TRUE@am__append_6 = drivers/joy_linux.c6.9 +@AUDIO_ESOUND_TRUE@am__append_7 = drivers/audio_esd.c6.10 ACLOCAL = @ACLOCAL@6.11 AMDEP_FALSE = @AMDEP_FALSE@6.12 AMDEP_TRUE = @AMDEP_TRUE@6.13 @@ -112,6 +113,8 @@6.14 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@6.15 INSTOBJEXT = @INSTOBJEXT@6.16 INTLLIBS = @INTLLIBS@6.17 +JOY_LINUX_FALSE = @JOY_LINUX_FALSE@6.18 +JOY_LINUX_TRUE = @JOY_LINUX_TRUE@6.19 LDFLAGS = @LDFLAGS@6.20 LIBOBJS = @LIBOBJS@6.21 LIBPNG_CFLAGS = @LIBPNG_CFLAGS@6.22 @@ -231,7 +234,7 @@6.23 drivers/audio_null.c drivers/video_null.c \6.24 drivers/gl_common.c drivers/gl_common.h drivers/gl_fbo.c \6.25 drivers/gl_sl.c drivers/gl_slsrc.c\6.26 -$(am__append_1) $(am__append_3) $(am__append_4) $(am__append_5) $(am__append_6)6.27 +$(am__append_1) $(am__append_3) $(am__append_4) $(am__append_5) $(am__append_6) $(am__append_7)6.29 @BUILD_SH4X86_TRUE@test_testsh4x86_LDADD = @GTK_LIBS@6.30 @BUILD_SH4X86_TRUE@test_testsh4x86_SOURCES = test/testsh4x86.c x86dasm/x86dasm.c \6.31 @@ -294,7 +297,8 @@6.32 gtkui/debug_win.c gtkui/dump_win.c gtkui/ctrl_dlg.c \6.33 gtkui/path_dlg.c gtkui/gdrom_menu.c drivers/video_gtk.c \6.34 drivers/video_gtk.h drivers/video_glx.c drivers/video_glx.h \6.35 - drivers/cd_linux.c drivers/cd_none.c drivers/audio_esd.c6.36 + drivers/cd_linux.c drivers/cd_none.c drivers/joy_linux.c \6.37 + drivers/audio_esd.c6.38 @BUILD_SH4X86_TRUE@am__objects_1 = sh4x86.$(OBJEXT) sh4trans.$(OBJEXT) \6.39 @BUILD_SH4X86_TRUE@ x86dasm.$(OBJEXT) i386-dis.$(OBJEXT) \6.40 @BUILD_SH4X86_TRUE@ dis-init.$(OBJEXT) dis-buf.$(OBJEXT)6.41 @@ -306,7 +310,8 @@6.42 @GUI_GTK_TRUE@ video_glx.$(OBJEXT)6.43 @CDROM_LINUX_TRUE@am__objects_3 = cd_linux.$(OBJEXT)6.44 @CDROM_LINUX_FALSE@am__objects_4 = cd_none.$(OBJEXT)6.45 -@AUDIO_ESOUND_TRUE@am__objects_5 = audio_esd.$(OBJEXT)6.46 +@JOY_LINUX_TRUE@am__objects_5 = joy_linux.$(OBJEXT)6.47 +@AUDIO_ESOUND_TRUE@am__objects_6 = audio_esd.$(OBJEXT)6.48 am_lxdream_OBJECTS = main.$(OBJEXT) config.$(OBJEXT) mem.$(OBJEXT) \6.49 watch.$(OBJEXT) asic.$(OBJEXT) syscall.$(OBJEXT) bios.$(OBJEXT) \6.50 dcload.$(OBJEXT) ide.$(OBJEXT) gdimage.$(OBJEXT) \6.51 @@ -326,7 +331,7 @@6.52 video_null.$(OBJEXT) gl_common.$(OBJEXT) gl_fbo.$(OBJEXT) \6.53 gl_sl.$(OBJEXT) gl_slsrc.$(OBJEXT) $(am__objects_1) \6.54 $(am__objects_2) $(am__objects_3) $(am__objects_4) \6.55 - $(am__objects_5)6.56 + $(am__objects_5) $(am__objects_6)6.57 lxdream_OBJECTS = $(am_lxdream_OBJECTS)6.58 lxdream_DEPENDENCIES =6.59 lxdream_LDFLAGS =6.60 @@ -375,27 +380,27 @@6.61 @AMDEP_TRUE@ ./$(DEPDIR)/gtkcb.Po ./$(DEPDIR)/gtkui.Po \6.62 @AMDEP_TRUE@ ./$(DEPDIR)/i386-dis.Po ./$(DEPDIR)/ide.Po \6.63 @AMDEP_TRUE@ ./$(DEPDIR)/insparse.Po ./$(DEPDIR)/intc.Po \6.64 -@AMDEP_TRUE@ ./$(DEPDIR)/kbd.Po ./$(DEPDIR)/loader.Po \6.65 -@AMDEP_TRUE@ ./$(DEPDIR)/main.Po ./$(DEPDIR)/main_win.Po \6.66 -@AMDEP_TRUE@ ./$(DEPDIR)/maple.Po ./$(DEPDIR)/mem.Po \6.67 -@AMDEP_TRUE@ ./$(DEPDIR)/mmio_win.Po ./$(DEPDIR)/mmu.Po \6.68 -@AMDEP_TRUE@ ./$(DEPDIR)/mouse.Po ./$(DEPDIR)/nrg.Po \6.69 -@AMDEP_TRUE@ ./$(DEPDIR)/path_dlg.Po ./$(DEPDIR)/pvr2.Po \6.70 -@AMDEP_TRUE@ ./$(DEPDIR)/pvr2mem.Po ./$(DEPDIR)/rendbkg.Po \6.71 -@AMDEP_TRUE@ ./$(DEPDIR)/rendcore.Po ./$(DEPDIR)/render.Po \6.72 -@AMDEP_TRUE@ ./$(DEPDIR)/rendsave.Po ./$(DEPDIR)/rendsort.Po \6.73 -@AMDEP_TRUE@ ./$(DEPDIR)/scif.Po ./$(DEPDIR)/sh4.Po \6.74 -@AMDEP_TRUE@ ./$(DEPDIR)/sh4core.Po ./$(DEPDIR)/sh4dasm.Po \6.75 -@AMDEP_TRUE@ ./$(DEPDIR)/sh4mem.Po ./$(DEPDIR)/sh4mmio.Po \6.76 -@AMDEP_TRUE@ ./$(DEPDIR)/sh4stat.Po ./$(DEPDIR)/sh4trans.Po \6.77 -@AMDEP_TRUE@ ./$(DEPDIR)/sh4x86.Po ./$(DEPDIR)/syscall.Po \6.78 -@AMDEP_TRUE@ ./$(DEPDIR)/tacore.Po ./$(DEPDIR)/testsh4x86.Po \6.79 -@AMDEP_TRUE@ ./$(DEPDIR)/testxlt.Po ./$(DEPDIR)/texcache.Po \6.80 -@AMDEP_TRUE@ ./$(DEPDIR)/timer.Po ./$(DEPDIR)/util.Po \6.81 -@AMDEP_TRUE@ ./$(DEPDIR)/video_glx.Po ./$(DEPDIR)/video_gtk.Po \6.82 -@AMDEP_TRUE@ ./$(DEPDIR)/video_null.Po ./$(DEPDIR)/watch.Po \6.83 -@AMDEP_TRUE@ ./$(DEPDIR)/x86dasm.Po ./$(DEPDIR)/xltcache.Po \6.84 -@AMDEP_TRUE@ ./$(DEPDIR)/yuv.Po6.85 +@AMDEP_TRUE@ ./$(DEPDIR)/joy_linux.Po ./$(DEPDIR)/kbd.Po \6.86 +@AMDEP_TRUE@ ./$(DEPDIR)/loader.Po ./$(DEPDIR)/main.Po \6.87 +@AMDEP_TRUE@ ./$(DEPDIR)/main_win.Po ./$(DEPDIR)/maple.Po \6.88 +@AMDEP_TRUE@ ./$(DEPDIR)/mem.Po ./$(DEPDIR)/mmio_win.Po \6.89 +@AMDEP_TRUE@ ./$(DEPDIR)/mmu.Po ./$(DEPDIR)/mouse.Po \6.90 +@AMDEP_TRUE@ ./$(DEPDIR)/nrg.Po ./$(DEPDIR)/path_dlg.Po \6.91 +@AMDEP_TRUE@ ./$(DEPDIR)/pvr2.Po ./$(DEPDIR)/pvr2mem.Po \6.92 +@AMDEP_TRUE@ ./$(DEPDIR)/rendbkg.Po ./$(DEPDIR)/rendcore.Po \6.93 +@AMDEP_TRUE@ ./$(DEPDIR)/render.Po ./$(DEPDIR)/rendsave.Po \6.94 +@AMDEP_TRUE@ ./$(DEPDIR)/rendsort.Po ./$(DEPDIR)/scif.Po \6.95 +@AMDEP_TRUE@ ./$(DEPDIR)/sh4.Po ./$(DEPDIR)/sh4core.Po \6.96 +@AMDEP_TRUE@ ./$(DEPDIR)/sh4dasm.Po ./$(DEPDIR)/sh4mem.Po \6.97 +@AMDEP_TRUE@ ./$(DEPDIR)/sh4mmio.Po ./$(DEPDIR)/sh4stat.Po \6.98 +@AMDEP_TRUE@ ./$(DEPDIR)/sh4trans.Po ./$(DEPDIR)/sh4x86.Po \6.99 +@AMDEP_TRUE@ ./$(DEPDIR)/syscall.Po ./$(DEPDIR)/tacore.Po \6.100 +@AMDEP_TRUE@ ./$(DEPDIR)/testsh4x86.Po ./$(DEPDIR)/testxlt.Po \6.101 +@AMDEP_TRUE@ ./$(DEPDIR)/texcache.Po ./$(DEPDIR)/timer.Po \6.102 +@AMDEP_TRUE@ ./$(DEPDIR)/util.Po ./$(DEPDIR)/video_glx.Po \6.103 +@AMDEP_TRUE@ ./$(DEPDIR)/video_gtk.Po ./$(DEPDIR)/video_null.Po \6.104 +@AMDEP_TRUE@ ./$(DEPDIR)/watch.Po ./$(DEPDIR)/x86dasm.Po \6.105 +@AMDEP_TRUE@ ./$(DEPDIR)/xltcache.Po ./$(DEPDIR)/yuv.Po6.106 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \6.107 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)6.108 CCLD = $(CC)6.109 @@ -513,6 +518,7 @@6.110 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ide.Po@am__quote@6.111 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insparse.Po@am__quote@6.112 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/intc.Po@am__quote@6.113 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/joy_linux.Po@am__quote@6.114 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kbd.Po@am__quote@6.115 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loader.Po@am__quote@6.116 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@6.117 @@ -2029,6 +2035,28 @@6.118 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@6.119 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cd_none.obj `if test -f 'drivers/cd_none.c'; then $(CYGPATH_W) 'drivers/cd_none.c'; else $(CYGPATH_W) '$(srcdir)/drivers/cd_none.c'; fi`6.121 +joy_linux.o: drivers/joy_linux.c6.122 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT joy_linux.o -MD -MP -MF "$(DEPDIR)/joy_linux.Tpo" \6.123 +@am__fastdepCC_TRUE@ -c -o joy_linux.o `test -f 'drivers/joy_linux.c' || echo '$(srcdir)/'`drivers/joy_linux.c; \6.124 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/joy_linux.Tpo" "$(DEPDIR)/joy_linux.Po"; \6.125 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/joy_linux.Tpo"; exit 1; \6.126 +@am__fastdepCC_TRUE@ fi6.127 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/joy_linux.c' object='joy_linux.o' libtool=no @AMDEPBACKSLASH@6.128 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/joy_linux.Po' tmpdepfile='$(DEPDIR)/joy_linux.TPo' @AMDEPBACKSLASH@6.129 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@6.130 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o joy_linux.o `test -f 'drivers/joy_linux.c' || echo '$(srcdir)/'`drivers/joy_linux.c6.131 +6.132 +joy_linux.obj: drivers/joy_linux.c6.133 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT joy_linux.obj -MD -MP -MF "$(DEPDIR)/joy_linux.Tpo" \6.134 +@am__fastdepCC_TRUE@ -c -o joy_linux.obj `if test -f 'drivers/joy_linux.c'; then $(CYGPATH_W) 'drivers/joy_linux.c'; else $(CYGPATH_W) '$(srcdir)/drivers/joy_linux.c'; fi`; \6.135 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/joy_linux.Tpo" "$(DEPDIR)/joy_linux.Po"; \6.136 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/joy_linux.Tpo"; exit 1; \6.137 +@am__fastdepCC_TRUE@ fi6.138 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/joy_linux.c' object='joy_linux.obj' libtool=no @AMDEPBACKSLASH@6.139 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/joy_linux.Po' tmpdepfile='$(DEPDIR)/joy_linux.TPo' @AMDEPBACKSLASH@6.140 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@6.141 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o joy_linux.obj `if test -f 'drivers/joy_linux.c'; then $(CYGPATH_W) 'drivers/joy_linux.c'; else $(CYGPATH_W) '$(srcdir)/drivers/joy_linux.c'; fi`6.142 +6.143 audio_esd.o: drivers/audio_esd.c6.144 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT audio_esd.o -MD -MP -MF "$(DEPDIR)/audio_esd.Tpo" \6.145 @am__fastdepCC_TRUE@ -c -o audio_esd.o `test -f 'drivers/audio_esd.c' || echo '$(srcdir)/'`drivers/audio_esd.c; \
7.1 --- a/src/display.c Mon Jan 28 02:37:09 2008 +00007.2 +++ b/src/display.c Mon Jan 28 02:38:09 2008 +00007.3 @@ -31,8 +31,24 @@7.4 &display_null_driver,7.5 NULL };7.7 +/* Some explanation:7.8 + * The system has at least one "root" device representing the main display7.9 + * (which may be the null display). This device is part of the display_driver7.10 + * and generates events with no input_driver. The root device has no id7.11 + * as such (for the purposes of event names)7.12 + *7.13 + * The system may also have one or more auxilliary devices which each have7.14 + * an input_driver and an id (eg "JS0"). So the keysym "Return" is (de)coded by7.15 + * the root device, and the keysym "JS0: Button0" is (de)coded by the JS0 input7.16 + * device as "Button0".7.17 + *7.18 + * For the moment, mice are handled specially, as they behave a little7.19 + * differently from other devices (although this will probably change in the7.20 + * future.7.21 + */7.22 +7.23 +7.24 typedef struct keymap_entry {7.25 - uint16_t keycode;7.26 input_key_callback_t callback;7.27 void *data;7.28 uint32_t value;7.29 @@ -46,6 +62,12 @@7.30 struct mouse_entry *next;7.31 } *mouse_entry_t;7.33 +typedef struct input_driver_entry {7.34 + input_driver_t driver;7.35 + uint16_t entry_count;7.36 + struct keymap_entry *keymap[0];7.37 +} *input_driver_entry_t;7.38 +7.39 /**7.40 * Colour format information7.41 */7.42 @@ -66,68 +88,183 @@7.43 /**7.44 * FIXME: make this more memory efficient7.45 */7.46 -struct keymap_entry *keymap[65536];7.47 -struct keymap_entry *keyhooks = NULL;7.48 -struct mouse_entry *mousehooks = NULL;7.49 +static struct keymap_entry *root_keymap[65535];7.50 +static struct keymap_entry *keyhooks = NULL;7.51 +static struct mouse_entry *mousehooks = NULL;7.52 +static gboolean display_focused = TRUE;7.53 +static GList *input_drivers= NULL;7.54 +static display_keysym_callback_t display_keysym_hook = NULL;7.55 +void *display_keysym_hook_data;7.57 -static struct keymap_entry *input_create_key( uint16_t keycode )7.58 +gboolean input_register_device( input_driver_t driver, uint16_t max_keycode )7.59 {7.60 - struct keymap_entry *key = keymap[ keycode ];7.61 - if( key == NULL ) {7.62 - key = malloc( sizeof( struct keymap_entry ) );7.63 - assert( key != NULL );7.64 - keymap[ keycode ] = key;7.65 - key->keycode = keycode;7.66 + GList *ptr;7.67 + for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {7.68 + input_driver_entry_t entry = (input_driver_entry_t)ptr->data;7.69 + if( strcasecmp( entry->driver->id, driver->id ) == 0 ) {7.70 + return FALSE;7.71 + }7.72 }7.73 - return key;7.74 +7.75 + input_driver_entry_t entry = g_malloc0( sizeof(struct input_driver_entry) + (sizeof(keymap_entry_t) * max_keycode) );7.76 + entry->driver = driver;7.77 + entry->entry_count = max_keycode;7.78 + input_drivers = g_list_append( input_drivers, entry );7.79 + return TRUE;7.80 }7.82 -static void input_delete_key( uint16_t keycode, input_key_callback_t callback, void *data,7.83 - uint32_t value )7.84 +void input_unregister_device( input_driver_t driver )7.85 {7.86 - struct keymap_entry *key = keymap[keycode];7.87 - if( key != NULL && key->callback == callback && key->data == data && key->value == value ) {7.88 - free( key );7.89 - keymap[keycode] = NULL;7.90 + GList *ptr;7.91 + for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {7.92 + input_driver_entry_t entry = (input_driver_entry_t)ptr->data;7.93 + if( entry->driver == driver ) {7.94 + if( driver->destroy != NULL ) {7.95 + driver->destroy(driver);7.96 + }7.97 + input_drivers = g_list_remove(input_drivers, (gpointer)entry);7.98 + g_free( entry );7.99 + return;7.100 + }7.101 }7.102 }7.104 -static struct keymap_entry *input_get_key( uint16_t keycode )7.105 +/**7.106 + * Resolve the keysym and return a pointer to the keymap entry pointer7.107 + * @return keymap pointer or NULL if the key was unresolved7.108 + */7.109 +static struct keymap_entry **input_entry_from_keysym( const gchar *keysym )7.110 {7.111 - return keymap[ keycode ];7.112 + if( keysym == NULL || keysym[0] == 0 ) {7.113 + return NULL;7.114 + }7.115 + char **strv = g_strsplit(keysym,":",2);7.116 + if( strv[1] == NULL ) {7.117 + /* root device */7.118 + if( display_driver == NULL || display_driver->resolve_keysym == NULL) {7.119 + // Root device has no input handling7.120 + g_strfreev(strv);7.121 + return NULL;7.122 + }7.123 + uint16_t keycode = display_driver->resolve_keysym(g_strstrip(strv[0]));7.124 + g_strfreev(strv);7.125 + if( keycode == 0 ) {7.126 + return NULL;7.127 + }7.128 + return &root_keymap[keycode-1];7.129 + } else {7.130 + char *id = g_strstrip(strv[0]);7.131 + GList *ptr;7.132 + for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {7.133 + input_driver_entry_t entry = (input_driver_entry_t)ptr->data;7.134 + if( strcasecmp( entry->driver->id, id ) == 0 ) {7.135 + /* we have ze device */7.136 + if( entry->driver->resolve_keysym == NULL ) {7.137 + g_strfreev(strv);7.138 + return NULL;7.139 + }7.140 + uint16_t keycode = entry->driver->resolve_keysym(entry->driver, g_strstrip(strv[1]));7.141 + g_strfreev(strv);7.142 + if( keycode == 0 || keycode > entry->entry_count ) {7.143 + return NULL;7.144 + }7.145 + return &entry->keymap[keycode-1];7.146 + }7.147 + }7.148 + g_strfreev(strv);7.149 + return NULL; // device not found7.150 + }7.151 }7.153 +static struct keymap_entry **input_entry_from_keycode( input_driver_t driver, uint16_t keycode )7.154 +{7.155 + GList *ptr;7.156 +7.157 + if( keycode == 0 ) {7.158 + return NULL;7.159 + }7.160 +7.161 + if( driver == NULL ) {7.162 + return &root_keymap[keycode-1];7.163 + }7.164 +7.165 + for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {7.166 + input_driver_entry_t entry = (input_driver_entry_t)ptr->data;7.167 + if( entry->driver == driver ) {7.168 + if( keycode > entry->entry_count ) {7.169 + return NULL;7.170 + } else {7.171 + return &entry->keymap[keycode-1];7.172 + }7.173 + }7.174 + }7.175 + return NULL;7.176 +}7.177 +7.178 +static gchar *input_keysym_for_keycode( input_driver_t driver, uint16_t keycode )7.179 +{7.180 + if( keycode == 0 ) {7.181 + return NULL;7.182 + }7.183 + if( driver == NULL ) {7.184 + if( display_driver != NULL && display_driver->get_keysym_for_keycode != NULL ) {7.185 + return display_driver->get_keysym_for_keycode(keycode);7.186 + }7.187 + } else if( driver->get_keysym_for_keycode ) {7.188 + gchar *sym = driver->get_keysym_for_keycode(driver,keycode);7.189 + if( sym != NULL ) {7.190 + gchar *result = g_strdup_printf( "%s: %s", driver->id, sym );7.191 + g_free(sym);7.192 + return result;7.193 + }7.194 + }7.195 + return NULL;7.196 +}7.197 +7.198 +7.199 gboolean input_register_key( const gchar *keysym, input_key_callback_t callback,7.200 void *data, uint32_t value )7.201 {7.202 - if( display_driver == NULL || keysym == NULL || display_driver->resolve_keysym == NULL )7.203 - return FALSE; /* No display driver */7.204 + if( keysym == NULL ) {7.205 + return FALSE;7.206 + }7.207 + int keys = 0;7.208 gchar **strv = g_strsplit(keysym, ",", 16);7.209 gchar **s = strv;7.210 while( *s != NULL ) {7.211 - uint16_t keycode = display_driver->resolve_keysym(g_strstrip(*s));7.212 - if( keycode == 0 )7.213 - return FALSE; /* Invalid keysym */7.214 -7.215 - struct keymap_entry *key = input_create_key( keycode );7.216 - key->callback = callback;7.217 - key->data = data;7.218 - key->value = value;7.219 + keymap_entry_t *entryp = input_entry_from_keysym(*s);7.220 + if( entryp != NULL ) {7.221 + *entryp = g_malloc0(sizeof(struct keymap_entry));7.222 + (*entryp)->callback = callback;7.223 + (*entryp)->data = data;7.224 + (*entryp)->value = value;7.225 + keys++;7.226 + }7.227 s++;7.228 }7.229 g_strfreev(strv);7.230 - return TRUE;7.231 + return keys != 0;7.232 }7.234 void input_unregister_key( const gchar *keysym, input_key_callback_t callback,7.235 void *data, uint32_t value )7.236 {7.237 - if( display_driver == NULL || keysym == NULL || display_driver->resolve_keysym == NULL )7.238 + if( keysym == NULL ) {7.239 return;7.240 - uint16_t keycode = display_driver->resolve_keysym(keysym);7.241 - if( keycode == 0 )7.242 - return;7.243 - input_delete_key( keycode, callback, data, value );7.244 + }7.245 +7.246 + gchar **strv = g_strsplit(keysym, ",", 16);7.247 + gchar **s = strv;7.248 + while( *s != NULL ) {7.249 + keymap_entry_t *entryp = input_entry_from_keysym(*s);7.250 + if( entryp != NULL && *entryp != NULL && (*entryp)->callback == callback &&7.251 + (*entryp)->data == data && (*entryp)->value == value ) {7.252 + g_free( *entryp );7.253 + *entryp = NULL;7.254 + }7.255 + s++;7.256 + }7.257 + g_strfreev(strv);7.258 }7.260 gboolean input_register_hook( input_key_callback_t callback,7.261 @@ -204,44 +341,51 @@7.263 gboolean input_is_key_valid( const gchar *keysym )7.264 {7.265 - if( display_driver == NULL )7.266 - return FALSE; /* No display driver */7.267 - return display_driver->resolve_keysym(keysym) != 0;7.268 + keymap_entry_t *ptr = input_entry_from_keysym(keysym);7.269 + return ptr != NULL;7.270 }7.272 gboolean input_is_key_registered( const gchar *keysym )7.273 {7.274 - if( display_driver == NULL )7.275 - return FALSE;7.276 - uint16_t keycode = display_driver->resolve_keysym(keysym);7.277 - if( keycode == 0 )7.278 - return FALSE;7.279 - return input_get_key( keycode ) != NULL;7.280 + keymap_entry_t *ptr = input_entry_from_keysym(keysym);7.281 + return ptr != NULL && *ptr != NULL;7.282 }7.284 -void input_event_keydown( uint16_t keycode )7.285 +void input_event_keydown( input_driver_t driver, uint16_t keycode, uint32_t pressure )7.286 {7.287 - struct keymap_entry *key = input_get_key(keycode);7.288 - if( key != NULL ) {7.289 - key->callback( key->data, key->value, TRUE );7.290 + if( display_focused ) {7.291 + keymap_entry_t *entryp = input_entry_from_keycode(driver,keycode);7.292 + if( entryp != NULL && *entryp != NULL ) {7.293 + (*entryp)->callback( (*entryp)->data, (*entryp)->value, pressure, TRUE );7.294 + }7.295 + keymap_entry_t key = keyhooks;7.296 + while( key != NULL ) {7.297 + key->callback( key->data, keycode, pressure, TRUE );7.298 + key = key->next;7.299 + }7.300 }7.301 - key = keyhooks;7.302 - while( key != NULL ) {7.303 - key->callback( key->data, keycode, TRUE );7.304 - key = key->next;7.305 + if( display_keysym_hook != NULL ) {7.306 + gchar *sym = input_keysym_for_keycode( driver, keycode );7.307 + if( sym != NULL ) {7.308 + display_keysym_hook(display_keysym_hook_data, sym);7.309 + g_free(sym);7.310 + }7.311 }7.312 }7.314 -void input_event_keyup( uint16_t keycode )7.315 +void input_event_keyup( input_driver_t driver, uint16_t keycode, uint32_t pressure )7.316 {7.317 - struct keymap_entry *key = input_get_key(keycode);7.318 - if( key != NULL ) {7.319 - key->callback( key->data, key->value, FALSE );7.320 - }7.321 - key = keyhooks;7.322 - while( key != NULL ) {7.323 - key->callback( key->data, keycode, FALSE );7.324 - key = key->next;7.325 + if( display_focused ) {7.326 + keymap_entry_t *entryp = input_entry_from_keycode(driver,keycode);7.327 + if( entryp != NULL && *entryp != NULL ) {7.328 + (*entryp)->callback( (*entryp)->data, (*entryp)->value, pressure, FALSE );7.329 + }7.330 +7.331 + keymap_entry_t key = keyhooks;7.332 + while( key != NULL ) {7.333 + key->callback( key->data, keycode, pressure, FALSE );7.334 + key = key->next;7.335 + }7.336 }7.337 }7.339 @@ -280,3 +424,14 @@7.340 }7.341 return rv;7.342 }7.343 +7.344 +void display_set_focused( gboolean has_focus )7.345 +{7.346 + display_focused = has_focus;7.347 +}7.348 +7.349 +void input_set_keysym_hook( display_keysym_callback_t hook, void *data )7.350 +{7.351 + display_keysym_hook = hook;7.352 + display_keysym_hook_data = data;7.353 +}
8.1 --- a/src/display.h Mon Jan 28 02:37:09 2008 +00008.2 +++ b/src/display.h Mon Jan 28 02:38:09 2008 +00008.3 @@ -123,6 +123,12 @@8.4 uint16_t (*convert_to_dckeysym)( uint16_t keycode );8.6 /**8.7 + * Given a device-specific event code, return the corresponding keysym.8.8 + * The string should be newly allocated (caller will free)8.9 + */8.10 + gchar *(*get_keysym_for_keycode)( uint16_t keycode );8.11 +8.12 + /**8.13 * Create a render target with the given width and height.8.14 */8.15 render_buffer_t (*create_render_buffer)( uint32_t width, uint32_t height );8.16 @@ -183,7 +189,7 @@8.18 /****************** Input methods **********************/8.20 -typedef void (*input_key_callback_t)( void *data, uint32_t value, gboolean isKeyDown );8.21 +typedef void (*input_key_callback_t)( void *data, uint32_t value, uint32_t pressure, gboolean isKeyDown );8.23 /**8.24 * Callback to receive mouse input events8.25 @@ -221,13 +227,83 @@8.27 gboolean input_is_key_registered( const gchar *keysym );8.29 -void input_event_keydown( uint16_t keycode );8.30 +uint16_t input_keycode_to_dckeysym( uint16_t keycode );8.32 -void input_event_keyup( uint16_t keycode );8.33 +/********************** Display/Input methods ***********************/8.34 +8.35 +/**8.36 + * Auxilliary input driver - provides input separate to and in addition to the8.37 + * core UI/display. (primarily used for joystick devices)8.38 + */8.39 +typedef struct input_driver {8.40 + const char *id; /* Short identifier to display in the UI for the device (eg "JS0" ) */8.41 +8.42 + /**8.43 + * Given a particular keysym, return the keycode associated with it.8.44 + * @param keysym The keysym to be resolved, ie "Tab"8.45 + * @return the display-specific keycode, or 0 if the keysym cannot8.46 + * be resolved.8.47 + */8.48 + uint16_t (*resolve_keysym)( struct input_driver *driver, const gchar *keysym );8.49 +8.50 + /**8.51 + * Given a device-specific event code, convert it to a dreamcast keyboard code.8.52 + * This is only required for actual keyboard devices, other devices should just8.53 + * leave this method NULL.8.54 + */8.55 + uint16_t (*convert_to_dckeysym)( struct input_driver *driver, uint16_t keycode );8.56 +8.57 + /**8.58 + * Given a device-specific event code, return the corresponding keysym.8.59 + * The string should be newly allocated (caller will free)8.60 + */8.61 + gchar *(*get_keysym_for_keycode)( struct input_driver *driver, uint16_t keycode );8.62 +8.63 + /**8.64 + * Destroy the input driver.8.65 + */8.66 + void (*destroy)( struct input_driver *driver );8.67 +8.68 +} *input_driver_t;8.69 +8.70 +/**8.71 + * Register a new input driver (which must have a unique name)8.72 + * @param driver the driver to register8.73 + * @param max_keycode the highest possible keycode reported by the device8.74 + * @return TRUE on success, FALSE on failure (eg driver already registed).8.75 + */8.76 +gboolean input_register_device( input_driver_t driver, uint16_t max_keycode );8.77 +8.78 +/**8.79 + * Unregister an input driver.8.80 + * @param driver the driver to unregister8.81 + * If the driver is not in fact registered, this function has no effect.8.82 + */8.83 +void input_unregister_device( input_driver_t driver );8.84 +8.85 +/**8.86 + * Called from the UI to indicate that the emulation window is focused (ie8.87 + * able to receive input). This method is used to gate non-UI input devices -8.88 + * when the display is not focused, all input events will be silently ignored.8.89 + */8.90 +void display_set_focused( gboolean has_focus );8.91 +8.92 +void input_event_keydown( input_driver_t input, uint16_t keycode, uint32_t pressure );8.93 +8.94 +void input_event_keyup( input_driver_t input, uint16_t keycode, uint32_t pressure );8.96 void input_event_mouse( uint32_t buttons, int32_t x_axis, int32_t y_axis );8.98 -uint16_t input_keycode_to_dckeysym( uint16_t keycode );8.99 +8.100 +typedef void (*display_keysym_callback_t)( void *data, const gchar *keysym );8.101 +8.102 +/**8.103 + * Set the keysym hook function (normally used by the UI to receive non-UI8.104 + * input events during configuration.8.105 + */8.106 +void input_set_keysym_hook( display_keysym_callback_t hook, void *data );8.107 +8.108 +8.110 #ifdef __cplusplus8.111 }
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00009.2 +++ b/src/drivers/joy_linux.c Mon Jan 28 02:38:09 2008 +00009.3 @@ -0,0 +1,206 @@9.4 +/**9.5 + * $Id: joy_linux.c,v 1.12 2007-11-08 11:54:16 nkeynes Exp $9.6 + *9.7 + * Linux joystick input device support9.8 + *9.9 + * Copyright (c) 2008 Nathan Keynes.9.10 + *9.11 + * This program is free software; you can redistribute it and/or modify9.12 + * it under the terms of the GNU General Public License as published by9.13 + * the Free Software Foundation; either version 2 of the License, or9.14 + * (at your option) any later version.9.15 + *9.16 + * This program is distributed in the hope that it will be useful,9.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of9.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9.19 + * GNU General Public License for more details.9.20 + */9.21 +9.22 +#include <sys/types.h>9.23 +#include <sys/ioctl.h>9.24 +#include <errno.h>9.25 +#include <stdio.h>9.26 +#include <string.h>9.27 +#include <fcntl.h>9.28 +#include <dirent.h>9.29 +#include <ctype.h>9.30 +9.31 +#include <linux/joystick.h>9.32 +#include <glib/giochannel.h>9.33 +#include <glib.h>9.34 +9.35 +#include "lxdream.h"9.36 +#include "display.h"9.37 +9.38 +#define INPUT_PATH "/dev/input"9.39 +9.40 +typedef struct linux_joystick {9.41 + struct input_driver driver;9.42 + const gchar *filename;9.43 + char name[128];9.44 + int fd;9.45 + int button_count, axis_count;9.46 + GIOChannel *channel;9.47 +9.48 +} *linux_joystick_t;9.49 +9.50 +static GList *linux_joysticks = NULL;9.51 +9.52 +9.53 +static gboolean linux_joystick_callback( GIOChannel *source, GIOCondition condition,9.54 + gpointer data );9.55 +static linux_joystick_t linux_joystick_add( const gchar *filename, int fd );9.56 +static uint16_t linux_joystick_resolve_keysym( input_driver_t dev, const gchar *str );9.57 +static gchar *linux_joystick_keysym_for_keycode( input_driver_t dev, uint16_t keycode );9.58 +static void linux_joystick_destroy( input_driver_t joy );9.59 +9.60 +/**9.61 + * Convert keysym to keycode. Keysyms are either Button%d or Axis%d, with buttons9.62 + * numbered 1 .. button_count, then axes from button_count+1 .. button_count + axis_count.9.63 + * The first button is Button1. (no Button0)9.64 + */9.65 +static uint16_t linux_joystick_resolve_keysym( input_driver_t dev, const gchar *str )9.66 +{9.67 + linux_joystick_t joy = (linux_joystick_t)dev;9.68 + if( strncasecmp( str, "Button", 6 ) == 0 ){9.69 + unsigned long button = strtoul( str+6, NULL, 10 );9.70 + if( button > joy->button_count ) {9.71 + return 0;9.72 + }9.73 + return (uint16_t)button;9.74 + } else if( strncasecmp( str, "Axis", 4 ) == 0 ) {9.75 + unsigned long axis = strtoul( str+4, NULL, 10 );9.76 + if( axis > joy->axis_count || axis == 0 ) {9.77 + return 0;9.78 + }9.79 + return (uint16_t)(axis+joy->button_count);9.80 + } else {9.81 + return 0;9.82 + }9.83 +}9.84 +9.85 +static gchar *linux_joystick_keysym_for_keycode( input_driver_t dev, uint16_t keycode )9.86 +{9.87 + linux_joystick_t joy = (linux_joystick_t)dev;9.88 + if( keycode == 0 ) {9.89 + return NULL;9.90 + }9.91 + if( keycode <= joy->button_count ) {9.92 + return g_strdup_printf( "Button%d", keycode );9.93 + }9.94 + if( keycode <= joy->button_count + joy->axis_count ) {9.95 + return g_strdup_printf( "Axis%d", keycode - joy->button_count );9.96 + }9.97 + return NULL;9.98 +}9.99 +9.100 +static void linux_joystick_destroy( input_driver_t dev )9.101 +{9.102 + linux_joystick_t joy = (linux_joystick_t)dev;9.103 + g_free( (gchar *)joy->filename );9.104 + g_io_channel_shutdown(joy->channel, FALSE, NULL );9.105 + g_io_channel_unref(joy->channel);9.106 + g_free( joy );9.107 +}9.108 +9.109 +/**9.110 + * Callback from the GIOChannel whenever data is available, or an error/disconnect9.111 + * occurs.9.112 + *9.113 + * On data, process all pending events and direct them to the input system.9.114 + * On error, close the channel and delete the device.9.115 + */9.116 +static gboolean linux_joystick_callback( GIOChannel *source, GIOCondition condition,9.117 + gpointer data )9.118 +{9.119 + linux_joystick_t joy = (linux_joystick_t)data;9.120 +9.121 + if( condition & G_IO_HUP ) {9.122 + close(joy->fd);9.123 + INFO( "Joystick '%s' disconnected\n", joy->name );9.124 + input_unregister_device((input_driver_t)joy);9.125 + return FALSE;9.126 + }9.127 + if( condition & G_IO_IN ) {9.128 + struct js_event event;9.129 + while( read( joy->fd, &event, sizeof(event) ) == sizeof(event) ) {9.130 + int keycode = 0;9.131 + if( event.type == JS_EVENT_BUTTON ) {9.132 + keycode = event.number+1;9.133 + } else if( event.type == JS_EVENT_AXIS ) {9.134 + keycode = event.number+1 + joy->button_count;9.135 + }9.136 + if( keycode != 0 ) {9.137 + if( event.value == 0 ) {9.138 + input_event_keyup( (input_driver_t)joy, keycode, event.value );9.139 + } else {9.140 + input_event_keydown( (input_driver_t)joy, keycode, event.value );9.141 + }9.142 + }9.143 + }9.144 + return TRUE;9.145 + }9.146 +}9.147 +9.148 +/**9.149 + * Create a new joystick device structure given filename and (open) file9.150 + * descriptor. The joystick is automatically added to the watch list.9.151 + * @return The new joystick, or NULL if an error occurred.9.152 + */9.153 +linux_joystick_t linux_joystick_add( const gchar *filename, int fd )9.154 +{9.155 + linux_joystick_t joy = g_malloc0(sizeof(struct linux_joystick));9.156 + joy->filename = filename;9.157 + joy->fd = fd;9.158 + joy->name[0] = '\0';9.159 + joy->driver.resolve_keysym = linux_joystick_resolve_keysym;9.160 + joy->driver.get_keysym_for_keycode = linux_joystick_keysym_for_keycode;9.161 + joy->driver.destroy = linux_joystick_destroy;9.162 +9.163 + char *p = strrchr(filename, '/');9.164 + if( p == NULL ) {9.165 + joy->driver.id = filename;9.166 + } else {9.167 + joy->driver.id = p+1;9.168 + }9.169 +9.170 + if( ioctl( fd, JSIOCGNAME(128), joy->name ) == -1 ||9.171 + ioctl( fd, JSIOCGAXES, &joy->axis_count ) == -1 ||9.172 + ioctl( fd, JSIOCGBUTTONS, &joy->button_count ) == -1 ) {9.173 + ERROR( "Error reading joystick data from %s (%s)\n", filename, strerror(errno) );9.174 + g_free(joy);9.175 + return NULL;9.176 + }9.177 +9.178 + joy->channel = g_io_channel_unix_new(fd);9.179 + g_io_add_watch( joy->channel, G_IO_IN|G_IO_ERR|G_IO_HUP, linux_joystick_callback, joy );9.180 + input_register_device( (input_driver_t)joy, joy->axis_count + joy->button_count );9.181 + INFO( "Attached joystick '%s' at %s (%d buttons, %d axes)", joy->name, joy->filename,9.182 + joy->button_count, joy->axis_count );9.183 + return joy;9.184 +}9.185 +9.186 +int linux_joystick_init()9.187 +{9.188 + struct dirent *ent;9.189 + DIR *dir = opendir(INPUT_PATH);9.190 +9.191 + if( dir == NULL ) {9.192 + return 0;9.193 + }9.194 +9.195 + while( (ent = readdir(dir)) != NULL ) {9.196 + if( ent->d_name[0] == 'j' && ent->d_name[1] == 's' &&9.197 + isdigit(ent->d_name[2]) ) {9.198 + gchar *name = g_strdup_printf( "%s/%s", INPUT_PATH, ent->d_name );9.199 + int fd = open(name, O_RDONLY|O_NONBLOCK);9.200 + if( fd == -1 ) {9.201 + g_free( name );9.202 + } else {9.203 + linux_joystick_t js = linux_joystick_add( name, fd );9.204 + }9.205 + }9.206 + }9.207 +9.208 + closedir(dir);9.209 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +000010.2 +++ b/src/drivers/joy_linux.h Mon Jan 28 02:38:09 2008 +000010.3 @@ -0,0 +1,39 @@10.4 +/**10.5 + * $Id: joy_linux.c,v 1.12 2007-11-08 11:54:16 nkeynes Exp $10.6 + *10.7 + * Linux joystick input device support10.8 + *10.9 + * Copyright (c) 2008 Nathan Keynes.10.10 + *10.11 + * This program is free software; you can redistribute it and/or modify10.12 + * it under the terms of the GNU General Public License as published by10.13 + * the Free Software Foundation; either version 2 of the License, or10.14 + * (at your option) any later version.10.15 + *10.16 + * This program is distributed in the hope that it will be useful,10.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of10.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the10.19 + * GNU General Public License for more details.10.20 + */10.21 +10.22 +#ifndef lxdream_joy_linux_H10.23 +#define lxdream_joy_linux_H10.24 +10.25 +/**10.26 + * Initialize the linux joystick code, and scan for devices10.27 + */10.28 +gboolean linux_joystick_init();10.29 +10.30 +/**10.31 + * Re-scan the available joystick devices, adding any new ones.10.32 + */10.33 +gboolean linux_joystick_rescan();10.34 +10.35 +/**10.36 + * Shutdown the linux joystick system10.37 + */10.38 +void linux_joystick_shutdown();10.39 +10.40 +10.41 +10.42 +#endif /* !lxdream_joy_linux_H */
11.1 --- a/src/drivers/video_gtk.c Mon Jan 28 02:37:09 2008 +000011.2 +++ b/src/drivers/video_gtk.c Mon Jan 28 02:38:09 2008 +000011.3 @@ -36,11 +36,12 @@11.4 void video_gtk_shutdown();11.5 gboolean video_gtk_display_blank( uint32_t colour );11.6 uint16_t video_gtk_resolve_keysym( const gchar *keysym );11.7 -uint16_t video_gtk_keycode_to_dckeysym(uint32_t keycode);11.8 +uint16_t video_gtk_keycode_to_dckeysym(uint16_t keycode);11.10 struct display_driver display_gtk_driver = { "gtk", video_gtk_init, video_gtk_shutdown,11.11 video_gtk_resolve_keysym,11.12 video_gtk_keycode_to_dckeysym,11.13 + NULL,11.14 NULL, NULL, NULL, NULL, NULL,11.15 video_gtk_display_blank, NULL };11.17 @@ -71,7 +72,7 @@11.18 return TRUE;11.19 }11.21 -uint16_t video_gtk_keycode_to_dckeysym(uint32_t keycode)11.22 +uint16_t video_gtk_keycode_to_dckeysym(uint16_t keycode)11.23 {11.24 if( keycode >= 'a' && keycode <= 'z' ) {11.25 return (keycode - 'a') + DCKB_A;11.26 @@ -170,6 +171,9 @@11.27 ! video_glx_init_driver( &display_gtk_driver ) ) {11.28 return FALSE;11.29 }11.30 +#ifdef HAVE_LINUX_JOYSTICK11.31 + linux_joystick_init();11.32 +#endif11.33 return TRUE;11.34 }
12.1 --- a/src/drivers/video_null.c Mon Jan 28 02:37:09 2008 +000012.2 +++ b/src/drivers/video_null.c Mon Jan 28 02:38:09 2008 +000012.3 @@ -1,3 +1,6 @@12.4 +12.5 +12.6 +12.7 /**12.8 * $Id$12.9 *12.10 @@ -61,6 +64,7 @@12.11 NULL,12.12 NULL,12.13 NULL,12.14 + NULL,12.15 video_null_create_render_buffer,12.16 video_null_destroy_render_buffer,12.17 video_null_set_render_target,
13.1 --- a/src/gtkui/ctrl_dlg.c Mon Jan 28 02:37:09 2008 +000013.2 +++ b/src/gtkui/ctrl_dlg.c Mon Jan 28 02:38:09 2008 +000013.3 @@ -21,7 +21,8 @@13.4 #include <gtk/gtk.h>13.5 #include <gdk/gdkkeysyms.h>13.7 -#include "dream.h"13.8 +#include "lxdream.h"13.9 +#include "display.h"13.10 #include "gtkui/gtkui.h"13.11 #include "maple/maple.h"13.13 @@ -47,12 +48,21 @@13.15 static struct maple_slot_data maple_data[MAX_DEVICES];13.17 +static void config_keysym_hook( void *data, const gchar *keysym )13.18 +{13.19 + GtkWidget *widget = (GtkWidget *)data;13.20 + gtk_entry_set_text( GTK_ENTRY(widget), keysym );13.21 + g_object_set_data( G_OBJECT(widget), "keypress_mode", GINT_TO_POINTER(FALSE) );13.22 + input_set_keysym_hook(NULL, NULL);13.23 +}13.24 +13.25 static gboolean config_key_buttonpress( GtkWidget *widget, GdkEventButton *event, gpointer user_data )13.26 {13.27 gboolean keypress_mode = GPOINTER_TO_INT(g_object_get_data( G_OBJECT(widget), "keypress_mode"));13.28 if( !keypress_mode ) {13.29 gtk_entry_set_text( GTK_ENTRY(widget), _("<press key>") );13.30 g_object_set_data( G_OBJECT(widget), "keypress_mode", GINT_TO_POINTER(TRUE) );13.31 + input_set_keysym_hook(config_keysym_hook, widget);13.32 }13.33 return FALSE;13.34 }13.35 @@ -73,6 +83,7 @@13.36 NULL, NULL, NULL );13.37 gtk_entry_set_text( GTK_ENTRY(widget), gdk_keyval_name(keyval) );13.38 g_object_set_data( G_OBJECT(widget), "keypress_mode", GINT_TO_POINTER(FALSE) );13.39 + input_set_keysym_hook(NULL, NULL);13.40 return TRUE;13.41 } else {13.42 switch( event->keyval ) {13.43 @@ -80,6 +91,7 @@13.44 case GDK_KP_Enter:13.45 gtk_entry_set_text( GTK_ENTRY(widget), _("<press key>") );13.46 g_object_set_data( G_OBJECT(widget), "keypress_mode", GINT_TO_POINTER(TRUE) );13.47 + input_set_keysym_hook(config_keysym_hook, widget);13.48 return TRUE;13.49 case GDK_BackSpace:13.50 case GDK_Delete:13.51 @@ -118,7 +130,7 @@13.52 }13.53 }13.54 }13.55 -13.56 + input_set_keysym_hook(NULL, NULL);13.57 }13.59 static void controller_device_configure( maple_device_t device )
14.1 --- a/src/gtkui/main_win.c Mon Jan 28 02:37:09 2008 +000014.2 +++ b/src/gtkui/main_win.c Mon Jan 28 02:38:09 2008 +000014.3 @@ -178,7 +178,7 @@14.4 return TRUE;14.5 }14.6 }14.7 - input_event_keydown( gtk_get_unmodified_keyval(event) );14.8 + input_event_keydown( NULL, gtk_get_unmodified_keyval(event), 1 );14.9 return TRUE;14.10 }14.12 @@ -186,7 +186,7 @@14.13 gpointer user_data )14.14 {14.15 main_window_t win = (main_window_t)user_data;14.16 - input_event_keyup( gtk_get_unmodified_keyval(event) );14.17 + input_event_keyup( NULL, gtk_get_unmodified_keyval(event), 0 );14.18 return TRUE;14.19 }14.21 @@ -197,6 +197,12 @@14.22 fprintf( stderr, "Grab broken\n" );14.23 }14.25 +static gboolean on_video_window_focus_changed( GtkWidget *widget, GdkEventFocus *event,14.26 + gpointer user_data )14.27 +{14.28 + display_set_focused(event->in);14.29 +}14.30 +14.31 /*************************** Main window (frame) ******************************/14.33 static gboolean on_main_window_deleted( GtkWidget *widget, GdkEvent event, gpointer user_data )14.34 @@ -299,11 +305,15 @@14.35 G_CALLBACK(on_video_window_mouse_pressed), win );14.36 g_signal_connect( win->video, "button-release-event",14.37 G_CALLBACK(on_video_window_mouse_released), win );14.38 + g_signal_connect( win->video, "focus-in-event",14.39 + G_CALLBACK(on_video_window_focus_changed), win);14.40 + g_signal_connect( win->video, "focus-out-event",14.41 + G_CALLBACK(on_video_window_focus_changed), win);14.43 gtk_widget_add_events( win->video,14.44 GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |14.45 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |14.46 - GDK_POINTER_MOTION_MASK );14.47 + GDK_POINTER_MOTION_MASK | GDK_FOCUS_CHANGE_MASK );14.49 return win;14.50 }
15.1 --- a/src/maple/controller.c Mon Jan 28 02:37:09 2008 +000015.2 +++ b/src/maple/controller.c Mon Jan 28 02:38:09 2008 +000015.3 @@ -85,7 +85,7 @@15.4 /**15.5 * Input callback15.6 */15.7 -void controller_key_callback( void *mdev, uint32_t value, gboolean isKeyDown )15.8 +void controller_key_callback( void *mdev, uint32_t value, uint32_t pressure, gboolean isKeyDown )15.9 {15.10 controller_device_t dev = (controller_device_t)mdev;15.11 if( isKeyDown ) {
16.1 --- a/src/maple/kbd.c Mon Jan 28 02:37:09 2008 +000016.2 +++ b/src/maple/kbd.c Mon Jan 28 02:38:09 2008 +000016.3 @@ -105,7 +105,7 @@16.4 }16.5 }16.7 -void keyboard_input_hook( void *mdev, uint32_t keycode, gboolean isKeyDown )16.8 +void keyboard_input_hook( void *mdev, uint32_t keycode, uint32_t pressure, gboolean isKeyDown )16.9 {16.10 keyboard_device_t dev = (keyboard_device_t)mdev;16.11 uint16_t key = input_keycode_to_dckeysym( keycode );
.