aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfinput
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dfinput')
-rw-r--r--plugins/dfinput/Makefile.am23
-rw-r--r--plugins/dfinput/Makefile.in600
-rw-r--r--plugins/dfinput/analog.c183
-rw-r--r--plugins/dfinput/cfg-gtk2.c738
-rw-r--r--plugins/dfinput/cfg.c346
-rw-r--r--plugins/dfinput/dfinput.glade2489
-rw-r--r--plugins/dfinput/pad.c392
-rw-r--r--plugins/dfinput/pad.h193
-rw-r--r--plugins/dfinput/sdljoy.c111
-rw-r--r--plugins/dfinput/xkb.c88
10 files changed, 3163 insertions, 0 deletions
diff --git a/plugins/dfinput/Makefile.am b/plugins/dfinput/Makefile.am
new file mode 100644
index 0000000..0f5138a
--- /dev/null
+++ b/plugins/dfinput/Makefile.am
@@ -0,0 +1,23 @@
+bindir = @libdir@/games/psemu/
+libdir = @libdir@/games/psemu/
+
+lib_LTLIBRARIES = libDFInput.la
+
+libDFInput_la_SOURCES = cfg.c pad.c pad.h sdljoy.c xkb.c analog.c
+libDFInput_la_LDFLAGS = -module -avoid-version -lpthread -lX11 \
+ `$(SDL_CONFIG) --libs` -L/usr/X11R6/lib64 -L/usr/X11R6/lib
+
+INCLUDES = -DPIXMAPDIR=\"${datadir}/pixmaps/\" \
+ -DLOCALE_DIR=\"${datadir}/locale/\" \
+ -DDATADIR=\"${datadir}/psemu/\" \
+ $(GTK2_CFLAGS) $(GLADE2_CFLAGS) -I/usr/X11R6/include \
+ -I../../include -I../../libpcsxcore $(SDL_CFLAGS)
+
+bin_PROGRAMS = cfgDFInput
+cfgDFInput_SOURCES = cfg-gtk2.c pad.h
+cfgDFInput_LDADD = $(GTK2_LIBS) $(GLADE2_LIBS)
+cfgDFInput_LDFLAGS = $(SDL_LIBS) -L/usr/X11R6/lib64 -L/usr/X11R6/lib -lX11
+
+glade_DATA = dfinput.glade2
+gladedir = $(datadir)/psemu/
+EXTRA_DIST = $(glade_DATA)
diff --git a/plugins/dfinput/Makefile.in b/plugins/dfinput/Makefile.in
new file mode 100644
index 0000000..854f5df
--- /dev/null
+++ b/plugins/dfinput/Makefile.in
@@ -0,0 +1,600 @@
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+bin_PROGRAMS = cfgDFInput$(EXEEXT)
+subdir = plugins/dfinput
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
+ "$(DESTDIR)$(gladedir)"
+libLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(lib_LTLIBRARIES)
+libDFInput_la_LIBADD =
+am_libDFInput_la_OBJECTS = cfg.lo pad.lo sdljoy.lo xkb.lo analog.lo
+libDFInput_la_OBJECTS = $(am_libDFInput_la_OBJECTS)
+libDFInput_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libDFInput_la_LDFLAGS) $(LDFLAGS) -o $@
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_cfgDFInput_OBJECTS = cfg-gtk2.$(OBJEXT)
+cfgDFInput_OBJECTS = $(am_cfgDFInput_OBJECTS)
+am__DEPENDENCIES_1 =
+cfgDFInput_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+cfgDFInput_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(cfgDFInput_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libDFInput_la_SOURCES) $(cfgDFInput_SOURCES)
+DIST_SOURCES = $(libDFInput_la_SOURCES) $(cfgDFInput_SOURCES)
+gladeDATA_INSTALL = $(INSTALL_DATA)
+DATA = $(glade_DATA)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALSA_CFLAGS = @ALSA_CFLAGS@
+ALSA_LIBS = @ALSA_LIBS@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GLADE2_CFLAGS = @GLADE2_CFLAGS@
+GLADE2_LIBS = @GLADE2_LIBS@
+GLIB2_CFLAGS = @GLIB2_CFLAGS@
+GLIB2_LIBS = @GLIB2_LIBS@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GTK2_CFLAGS = @GTK2_CFLAGS@
+GTK2_LIBS = @GTK2_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBCDIO_CFLAGS = @LIBCDIO_CFLAGS@
+LIBCDIO_LIBS = @LIBCDIO_LIBS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NASM = @NASM@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PEOPSXGL = @PEOPSXGL@
+PKG_CONFIG = @PKG_CONFIG@
+POSUB = @POSUB@
+PULSEAUDIO_CFLAGS = @PULSEAUDIO_CFLAGS@
+PULSEAUDIO_LIBS = @PULSEAUDIO_LIBS@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @libdir@/games/psemu/
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@/games/psemu/
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+lib_LTLIBRARIES = libDFInput.la
+libDFInput_la_SOURCES = cfg.c pad.c pad.h sdljoy.c xkb.c analog.c
+libDFInput_la_LDFLAGS = -module -avoid-version -lpthread -lX11 \
+ `$(SDL_CONFIG) --libs` -L/usr/X11R6/lib64 -L/usr/X11R6/lib
+
+INCLUDES = -DPIXMAPDIR=\"${datadir}/pixmaps/\" \
+ -DLOCALE_DIR=\"${datadir}/locale/\" \
+ -DDATADIR=\"${datadir}/psemu/\" \
+ $(GTK2_CFLAGS) $(GLADE2_CFLAGS) -I/usr/X11R6/include \
+ -I../../include -I../../libpcsxcore $(SDL_CFLAGS)
+
+cfgDFInput_SOURCES = cfg-gtk2.c pad.h
+cfgDFInput_LDADD = $(GTK2_LIBS) $(GLADE2_LIBS)
+cfgDFInput_LDFLAGS = $(SDL_LIBS) -L/usr/X11R6/lib64 -L/usr/X11R6/lib -lX11
+glade_DATA = dfinput.glade2
+gladedir = $(datadir)/psemu/
+EXTRA_DIST = $(glade_DATA)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plugins/dfinput/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu plugins/dfinput/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f=$(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ p=$(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libDFInput.la: $(libDFInput_la_OBJECTS) $(libDFInput_la_DEPENDENCIES)
+ $(libDFInput_la_LINK) -rpath $(libdir) $(libDFInput_la_OBJECTS) $(libDFInput_la_LIBADD) $(LIBS)
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+cfgDFInput$(EXEEXT): $(cfgDFInput_OBJECTS) $(cfgDFInput_DEPENDENCIES)
+ @rm -f cfgDFInput$(EXEEXT)
+ $(cfgDFInput_LINK) $(cfgDFInput_OBJECTS) $(cfgDFInput_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analog.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfg-gtk2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfg.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pad.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdljoy.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xkb.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-gladeDATA: $(glade_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(gladedir)" || $(MKDIR_P) "$(DESTDIR)$(gladedir)"
+ @list='$(glade_DATA)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(gladeDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(gladedir)/$$f'"; \
+ $(gladeDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(gladedir)/$$f"; \
+ done
+
+uninstall-gladeDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(glade_DATA)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(gladedir)/$$f'"; \
+ rm -f "$(DESTDIR)$(gladedir)/$$f"; \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA)
+install-binPROGRAMS: install-libLTLIBRARIES
+
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(gladedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
+ clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-gladeDATA
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-gladeDATA \
+ uninstall-libLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libLTLIBRARIES clean-libtool ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-gladeDATA install-html \
+ install-html-am install-info install-info-am \
+ install-libLTLIBRARIES install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS \
+ uninstall-gladeDATA uninstall-libLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/plugins/dfinput/analog.c b/plugins/dfinput/analog.c
new file mode 100644
index 0000000..8d14b00
--- /dev/null
+++ b/plugins/dfinput/analog.c
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#include "pad.h"
+
+void InitAnalog() {
+ g.PadState[0].AnalogStatus[ANALOG_LEFT][0] = 127;
+ g.PadState[0].AnalogStatus[ANALOG_LEFT][1] = 127;
+ g.PadState[0].AnalogStatus[ANALOG_RIGHT][0] = 127;
+ g.PadState[0].AnalogStatus[ANALOG_RIGHT][1] = 127;
+ g.PadState[1].AnalogStatus[ANALOG_LEFT][0] = 127;
+ g.PadState[1].AnalogStatus[ANALOG_LEFT][1] = 127;
+ g.PadState[1].AnalogStatus[ANALOG_RIGHT][0] = 127;
+ g.PadState[1].AnalogStatus[ANALOG_RIGHT][1] = 127;
+
+ memset(g.PadState[0].AnalogKeyStatus, 0, sizeof(g.PadState[0].AnalogKeyStatus));
+ memset(g.PadState[1].AnalogKeyStatus, 0, sizeof(g.PadState[1].AnalogKeyStatus));
+}
+
+void CheckAnalog() {
+ int i, j, k, val;
+ uint8_t n;
+
+ for (i = 0; i < 2; i++) {
+ if (g.cfg.PadDef[i].Type != PSE_PAD_TYPE_ANALOGPAD) {
+ continue;
+ }
+
+ for (j = 0; j < ANALOG_TOTAL; j++) {
+ for (k = 0; k < 4; k++) {
+ if (g.PadState[i].AnalogKeyStatus[j][k]) {
+ switch (k) {
+ case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 255; k++; break;
+ case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 0; break;
+ case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 255; k++; break;
+ case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 0; break;
+ }
+ continue;
+ }
+
+ switch (g.cfg.PadDef[i].AnalogDef[j][k].JoyEvType) {
+ case AXIS:
+ n = abs(g.cfg.PadDef[i].AnalogDef[j][k].J.Axis) - 1;
+
+ if (g.cfg.PadDef[i].AnalogDef[j][k].J.Axis > 0) {
+ val = SDL_JoystickGetAxis(g.PadState[i].JoyDev, n);
+ if (val >= 0) {
+ val += 32640;
+ val /= 256;
+
+ switch (k) {
+ case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = val; break;
+ case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 255 - val; break;
+ case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = val; break;
+ case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 255 - val; break;
+ }
+ }
+ } else if (g.cfg.PadDef[i].AnalogDef[j][k].J.Axis < 0) {
+ val = SDL_JoystickGetAxis(g.PadState[i].JoyDev, n);
+ if (val <= 0) {
+ val += 32640;
+ val /= 256;
+
+ switch (k) {
+ case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 255 - val; break;
+ case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = val; break;
+ case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 255 - val; break;
+ case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = val; break;
+ }
+ }
+ }
+ break;
+
+ case HAT:
+ n = (g.cfg.PadDef[i].AnalogDef[j][k].J.Hat >> 8);
+
+ g.PadState[i].AnalogStatus[j][0] = 0;
+
+ if (SDL_JoystickGetHat(g.PadState[i].JoyDev, n) & (g.cfg.PadDef[i].AnalogDef[j][k].J.Hat & 0xFF)) {
+ switch (k) {
+ case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 255; k++; break;
+ case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 0; break;
+ case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 255; k++; break;
+ case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 0; break;
+ }
+ } else {
+ switch (k) {
+ case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 127; break;
+ case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 127; break;
+ case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 127; break;
+ case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 127; break;
+ }
+ }
+ break;
+
+ case BUTTON:
+ if (SDL_JoystickGetButton(g.PadState[i].JoyDev, g.cfg.PadDef[i].AnalogDef[j][k].J.Button)) {
+ switch (k) {
+ case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 255; k++; break;
+ case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 0; break;
+ case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 255; k++; break;
+ case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 0; break;
+ }
+ } else {
+ switch (k) {
+ case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 127; break;
+ case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 127; break;
+ case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 127; break;
+ case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 127; break;
+ }
+ }
+ break;
+
+ default:
+ switch (k) {
+ case ANALOG_XP: g.PadState[i].AnalogStatus[j][0] = 127; break;
+ case ANALOG_XM: g.PadState[i].AnalogStatus[j][0] = 127; break;
+ case ANALOG_YP: g.PadState[i].AnalogStatus[j][1] = 127; break;
+ case ANALOG_YM: g.PadState[i].AnalogStatus[j][1] = 127; break;
+ }
+ break;
+ }
+ }
+ }
+ }
+}
+
+int AnalogKeyPressed(uint16_t Key) {
+ int i, j, k;
+
+ for (i = 0; i < 2; i++) {
+ if (g.cfg.PadDef[i].Type != PSE_PAD_TYPE_ANALOGPAD) {
+ continue;
+ }
+
+ for (j = 0; j < ANALOG_TOTAL; j++) {
+ for (k = 0; k < 4; k++) {
+ if (g.cfg.PadDef[i].AnalogDef[j][k].Key == Key) {
+ g.PadState[i].AnalogKeyStatus[j][k] = 1;
+ return 1;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+int AnalogKeyReleased(uint16_t Key) {
+ int i, j, k;
+
+ for (i = 0; i < 2; i++) {
+ if (g.cfg.PadDef[i].Type != PSE_PAD_TYPE_ANALOGPAD) {
+ continue;
+ }
+
+ for (j = 0; j < ANALOG_TOTAL; j++) {
+ for (k = 0; k < 4; k++) {
+ if (g.cfg.PadDef[i].AnalogDef[j][k].Key == Key) {
+ g.PadState[i].AnalogKeyStatus[j][k] = 0;
+ return 1;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
diff --git a/plugins/dfinput/cfg-gtk2.c b/plugins/dfinput/cfg-gtk2.c
new file mode 100644
index 0000000..cfbd8fa
--- /dev/null
+++ b/plugins/dfinput/cfg-gtk2.c
@@ -0,0 +1,738 @@
+/*
+ * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#include "cfg.c"
+
+#include <time.h>
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+
+GtkWidget *MainWindow;
+
+const int DPad[DKEY_TOTAL] = {
+ DKEY_UP,
+ DKEY_DOWN,
+ DKEY_LEFT,
+ DKEY_RIGHT,
+ DKEY_CROSS,
+ DKEY_CIRCLE,
+ DKEY_SQUARE,
+ DKEY_TRIANGLE,
+ DKEY_L1,
+ DKEY_R1,
+ DKEY_L2,
+ DKEY_R2,
+ DKEY_SELECT,
+ DKEY_START,
+ DKEY_L3,
+ DKEY_R3
+};
+
+const char *DPadText[DKEY_TOTAL] = {
+ N_("D-Pad Up"),
+ N_("D-Pad Down"),
+ N_("D-Pad Left"),
+ N_("D-Pad Right"),
+ N_("Cross"),
+ N_("Circle"),
+ N_("Square"),
+ N_("Triangle"),
+ N_("L1"),
+ N_("R1"),
+ N_("L2"),
+ N_("R2"),
+ N_("Select"),
+ N_("Start"),
+ N_("L3"),
+ N_("R3")
+};
+
+const char *AnalogText[] = {
+ N_("L-Stick Right"),
+ N_("L-Stick Left"),
+ N_("L-Stick Down"),
+ N_("L-Stick Up"),
+ N_("R-Stick Right"),
+ N_("R-Stick Left"),
+ N_("R-Stick Down"),
+ N_("R-Stick Up")
+};
+
+static int GetSelectedKeyIndex(int padnum) {
+ GladeXML *xml;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ gboolean selected;
+ int i;
+
+ xml = glade_get_widget_tree(MainWindow);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(xml, padnum == 0 ? "treeview1" : "treeview2")));
+ selected = gtk_tree_selection_get_selected(selection, &model, &iter);
+
+ if (!selected) {
+ return -1;
+ }
+
+ path = gtk_tree_model_get_path(model, &iter);
+ i = *gtk_tree_path_get_indices(path);
+ gtk_tree_path_free(path);
+
+ return i;
+}
+
+static void GetKeyDescription(char *buf, int joynum, int key) {
+ const char *hatname[16] = {_("Centered"), _("Up"), _("Right"), _("Rightup"),
+ _("Down"), "", _("Rightdown"), "", _("Left"), _("Leftup"), "", "",
+ _("Leftdown"), "", "", ""};
+
+ switch (g.cfg.PadDef[joynum].KeyDef[key].JoyEvType) {
+ case BUTTON:
+ sprintf(buf, _("Joystick: Button %d"), g.cfg.PadDef[joynum].KeyDef[key].J.Button);
+ break;
+
+ case AXIS:
+ sprintf(buf, _("Joystick: Axis %d%c"), abs(g.cfg.PadDef[joynum].KeyDef[key].J.Axis) - 1,
+ g.cfg.PadDef[joynum].KeyDef[key].J.Axis > 0 ? '+' : '-');
+ break;
+
+ case HAT:
+ sprintf(buf, _("Joystick: Hat %d %s"), (g.cfg.PadDef[joynum].KeyDef[key].J.Hat >> 8),
+ hatname[g.cfg.PadDef[joynum].KeyDef[key].J.Hat & 0x0F]);
+ break;
+
+ case NONE:
+ default:
+ buf[0] = '\0';
+ break;
+ }
+
+ if (g.cfg.PadDef[joynum].KeyDef[key].Key != 0) {
+ if (buf[0] != '\0') {
+ strcat(buf, " / ");
+ }
+
+ strcat(buf, _("Keyboard:"));
+ strcat(buf, " ");
+ strcat(buf, XKeysymToString(g.cfg.PadDef[joynum].KeyDef[key].Key));
+ } else if (buf[0] == '\0') {
+ strcpy(buf, _("(Not Set)"));
+ }
+}
+
+static void GetAnalogDescription(char *buf, int joynum, int analognum, int dir) {
+ const char *hatname[16] = {_("Centered"), _("Up"), _("Right"), _("Rightup"),
+ _("Down"), "", _("Rightdown"), "", _("Left"), _("Leftup"), "", "",
+ _("Leftdown"), "", "", ""};
+
+ switch (g.cfg.PadDef[joynum].AnalogDef[analognum][dir].JoyEvType) {
+ case BUTTON:
+ sprintf(buf, _("Joystick: Button %d"), g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Button);
+ break;
+
+ case AXIS:
+ sprintf(buf, _("Joystick: Axis %d%c"), abs(g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Axis) - 1,
+ g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Axis > 0 ? '+' : '-');
+ break;
+
+ case HAT:
+ sprintf(buf, _("Joystick: Hat %d %s"), (g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Hat >> 8),
+ hatname[g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Hat & 0x0F]);
+ break;
+
+ case NONE:
+ default:
+ buf[0] = '\0';
+ break;
+ }
+
+ if (g.cfg.PadDef[joynum].AnalogDef[analognum][dir].Key != 0) {
+ if (buf[0] != '\0') {
+ strcat(buf, " / ");
+ }
+
+ strcat(buf, _("Keyboard:"));
+ strcat(buf, " ");
+ strcat(buf, XKeysymToString(g.cfg.PadDef[joynum].AnalogDef[analognum][dir].Key));
+ } else if (buf[0] == '\0') {
+ strcpy(buf, _("(Not Set)"));
+ }
+}
+
+static void UpdateKeyList() {
+ const char *widgetname[2] = {"treeview1", "treeview2"};
+
+ GladeXML *xml;
+ GtkWidget *widget;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ int i, j;
+ char buf[256];
+
+ xml = glade_get_widget_tree(MainWindow);
+
+ for (i = 0; i < 2; i++) {
+ int total;
+
+ if (g.cfg.PadDef[i].Type == PSE_PAD_TYPE_ANALOGPAD) {
+ total = DKEY_TOTAL;
+ } else {
+ total = DKEY_TOTAL - 2;
+ }
+
+ widget = glade_xml_get_widget(xml, widgetname[i]);
+
+ store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
+
+ for (j = 0; j < total; j++) {
+ gtk_list_store_append(store, &iter);
+ GetKeyDescription(buf, i, DPad[j]);
+ gtk_list_store_set(store, &iter, 0, _(DPadText[j]), 1, buf, -1);
+ }
+
+ if (g.cfg.PadDef[i].Type == PSE_PAD_TYPE_ANALOGPAD) {
+ for (j = 0; j < 8; j++) {
+ gtk_list_store_append(store, &iter);
+ GetAnalogDescription(buf, i, j / 4, j % 4);
+ gtk_list_store_set(store, &iter, 0, _(AnalogText[j]), 1, buf, -1);
+ }
+ }
+
+ gtk_tree_view_set_model(GTK_TREE_VIEW(widget), GTK_TREE_MODEL(store));
+ g_object_unref(G_OBJECT(store));
+ gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(widget), TRUE);
+ gtk_widget_show(widget);
+ }
+}
+
+static void UpdateKey() {
+ const char *widgetname[2] = {"treeview1", "treeview2"};
+ int i, index;
+ GladeXML *xml;
+ GtkWidget *widget;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GValue value = {0, };
+ char buf[256];
+
+ xml = glade_get_widget_tree(MainWindow);
+
+ for (i = 0; i < 2; i++) {
+ index = GetSelectedKeyIndex(i);
+ if (index == -1) continue;
+
+ widget = glade_xml_get_widget(xml, widgetname[i]);
+ gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)), &model, &iter);
+
+ if (index < DKEY_TOTAL) {
+ GetKeyDescription(buf, i, DPad[index]);
+ } else {
+ GetAnalogDescription(buf, i, (index - DKEY_TOTAL) / 4, (index - DKEY_TOTAL) % 4);
+ }
+
+ g_value_init(&value, G_TYPE_STRING);
+ g_value_set_string(&value, buf);
+ gtk_list_store_set_value(GTK_LIST_STORE(model), &iter, 1, &value);
+ }
+}
+
+static void OnConfigExit(GtkWidget *widget, gpointer user_data) {
+ SavePADConfig();
+
+ gtk_widget_destroy(widget);
+ SDL_Quit();
+
+ gtk_exit(0);
+}
+
+static void TreeSelectionChanged(GtkTreeSelection *selection, gpointer user_data) {
+ GladeXML *xml;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+
+ gboolean selected;
+ int i;
+
+ selected = gtk_tree_selection_get_selected(selection, &model, &iter);
+
+ if (selected) {
+ path = gtk_tree_model_get_path(model, &iter);
+ i = *gtk_tree_path_get_indices(path);
+ gtk_tree_path_free(path);
+
+ // If a row was selected, and the row is not blank, we can now enable
+ // some of the disabled widgets
+ xml = glade_get_widget_tree(MainWindow);
+
+ if ((int)user_data == 0) {
+ gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnchange1")), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnreset1")), TRUE);
+ } else {
+ gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnchange2")), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnreset2")), TRUE);
+ }
+ } else {
+ xml = glade_get_widget_tree(MainWindow);
+
+ if ((int)user_data == 0) {
+ gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnchange1")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnreset1")), FALSE);
+ } else {
+ gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnchange2")), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(glade_xml_get_widget(xml, "btnreset2")), FALSE);
+ }
+ }
+}
+
+static void OnDeviceChanged(GtkWidget *widget, gpointer user_data) {
+ int n = (int)user_data, current = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ current--;
+ g.cfg.PadDef[n].DevNum = current;
+}
+
+static void OnTypeChanged(GtkWidget *widget, gpointer user_data) {
+ int n = (int)user_data, current = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ g.cfg.PadDef[n].Type = (current == 0 ? PSE_PAD_TYPE_STANDARD : PSE_PAD_TYPE_ANALOGPAD);
+
+ UpdateKeyList();
+}
+
+static void OnThreadedToggled(GtkWidget *widget, gpointer user_data) {
+ g.cfg.Threaded = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+}
+
+static void ReadDKeyEvent(int padnum, int key) {
+ SDL_Joystick *js;
+ time_t t;
+ GdkEvent *ge;
+ int i;
+ Sint16 axis, numAxes = 0, InitAxisPos[256], PrevAxisPos[256];
+
+ if (g.cfg.PadDef[padnum].DevNum >= 0) {
+ js = SDL_JoystickOpen(g.cfg.PadDef[padnum].DevNum);
+ SDL_JoystickEventState(SDL_IGNORE);
+
+ SDL_JoystickUpdate();
+
+ numAxes = SDL_JoystickNumAxes(js);
+ if (numAxes > 256) numAxes = 256;
+
+ for (i = 0; i < numAxes; i++) {
+ InitAxisPos[i] = PrevAxisPos[i] = SDL_JoystickGetAxis(js, i);
+ }
+ } else {
+ js = NULL;
+ }
+
+ t = time(NULL);
+
+ while (time(NULL) < t + 10) {
+ // check joystick events
+ if (js != NULL) {
+ SDL_JoystickUpdate();
+
+ for (i = 0; i < SDL_JoystickNumButtons(js); i++) {
+ if (SDL_JoystickGetButton(js, i)) {
+ g.cfg.PadDef[padnum].KeyDef[key].JoyEvType = BUTTON;
+ g.cfg.PadDef[padnum].KeyDef[key].J.Button = i;
+ goto end;
+ }
+ }
+
+ for (i = 0; i < numAxes; i++) {
+ axis = SDL_JoystickGetAxis(js, i);
+ if (abs(axis) > 16383 && (abs(axis - InitAxisPos[i]) > 4096 || abs(axis - PrevAxisPos[i]) > 4096)) {
+ g.cfg.PadDef[padnum].KeyDef[key].JoyEvType = AXIS;
+ g.cfg.PadDef[padnum].KeyDef[key].J.Axis = (i + 1) * (axis > 0 ? 1 : -1);
+ goto end;
+ }
+ PrevAxisPos[i] = axis;
+ }
+
+ for (i = 0; i < SDL_JoystickNumHats(js); i++) {
+ axis = SDL_JoystickGetHat(js, i);
+ if (axis != SDL_HAT_CENTERED) {
+ g.cfg.PadDef[padnum].KeyDef[key].JoyEvType = HAT;
+
+ if (axis & SDL_HAT_UP) {
+ g.cfg.PadDef[padnum].KeyDef[key].J.Hat = ((i << 8) | SDL_HAT_UP);
+ } else if (axis & SDL_HAT_DOWN) {
+ g.cfg.PadDef[padnum].KeyDef[key].J.Hat = ((i << 8) | SDL_HAT_DOWN);
+ } else if (axis & SDL_HAT_LEFT) {
+ g.cfg.PadDef[padnum].KeyDef[key].J.Hat = ((i << 8) | SDL_HAT_LEFT);
+ } else if (axis & SDL_HAT_RIGHT) {
+ g.cfg.PadDef[padnum].KeyDef[key].J.Hat = ((i << 8) | SDL_HAT_RIGHT);
+ }
+
+ goto end;
+ }
+ }
+ }
+
+ // check keyboard events
+ while ((ge = gdk_event_get()) != NULL) {
+ if (ge->type == GDK_KEY_PRESS) {
+ if (ge->key.keyval != XK_Escape) {
+ g.cfg.PadDef[padnum].KeyDef[key].Key = ge->key.keyval;
+ }
+ gdk_event_free(ge);
+ goto end;
+ }
+ gdk_event_free(ge);
+ }
+
+ usleep(5000);
+ }
+
+end:
+ if (js != NULL) {
+ SDL_JoystickClose(js);
+ }
+}
+
+static void ReadAnalogEvent(int padnum, int analognum, int analogdir) {
+ SDL_Joystick *js;
+ time_t t;
+ GdkEvent *ge;
+ int i;
+ Sint16 axis, numAxes = 0, InitAxisPos[256], PrevAxisPos[256];
+
+ if (g.cfg.PadDef[padnum].DevNum >= 0) {
+ js = SDL_JoystickOpen(g.cfg.PadDef[padnum].DevNum);
+ SDL_JoystickEventState(SDL_IGNORE);
+
+ SDL_JoystickUpdate();
+
+ numAxes = SDL_JoystickNumAxes(js);
+ if (numAxes > 256) numAxes = 256;
+
+ for (i = 0; i < SDL_JoystickNumAxes(js); i++) {
+ InitAxisPos[i] = PrevAxisPos[i] = SDL_JoystickGetAxis(js, i);
+ }
+ } else {
+ js = NULL;
+ }
+
+ t = time(NULL);
+
+ while (time(NULL) < t + 10) {
+ // check joystick events
+ if (js != NULL) {
+ SDL_JoystickUpdate();
+
+ for (i = 0; i < SDL_JoystickNumButtons(js); i++) {
+ if (SDL_JoystickGetButton(js, i)) {
+ g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].JoyEvType = BUTTON;
+ g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Button = i;
+ goto end;
+ }
+ }
+
+ for (i = 0; i < numAxes; i++) {
+ axis = SDL_JoystickGetAxis(js, i);
+ if (abs(axis) > 16383 && (abs(axis - InitAxisPos[i]) > 4096 || abs(axis - PrevAxisPos[i]) > 4096)) {
+ g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].JoyEvType = AXIS;
+ g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Axis = (i + 1) * (axis > 0 ? 1 : -1);
+ goto end;
+ }
+ PrevAxisPos[i] = axis;
+ }
+
+ for (i = 0; i < SDL_JoystickNumHats(js); i++) {
+ axis = SDL_JoystickGetHat(js, i);
+ if (axis != SDL_HAT_CENTERED) {
+ g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].JoyEvType = HAT;
+
+ if (axis & SDL_HAT_UP) {
+ g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Hat = ((i << 8) | SDL_HAT_UP);
+ } else if (axis & SDL_HAT_DOWN) {
+ g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Hat = ((i << 8) | SDL_HAT_DOWN);
+ } else if (axis & SDL_HAT_LEFT) {
+ g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Hat = ((i << 8) | SDL_HAT_LEFT);
+ } else if (axis & SDL_HAT_RIGHT) {
+ g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Hat = ((i << 8) | SDL_HAT_RIGHT);
+ }
+
+ goto end;
+ }
+ }
+ }
+
+ // check keyboard events
+ while ((ge = gdk_event_get()) != NULL) {
+ if (ge->type == GDK_KEY_PRESS) {
+ if (ge->key.keyval != XK_Escape) {
+ g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].Key = ge->key.keyval;
+ }
+ gdk_event_free(ge);
+ goto end;
+ }
+ gdk_event_free(ge);
+ }
+
+ usleep(5000);
+ }
+
+end:
+ if (js != NULL) {
+ SDL_JoystickClose(js);
+ }
+}
+
+static void OnChangeClicked(GtkWidget *widget, gpointer user_data) {
+ int pad = (int)user_data;
+ int index = GetSelectedKeyIndex(pad);
+
+ if (index == -1) return;
+
+ if (index < DKEY_TOTAL) {
+ ReadDKeyEvent(pad, DPad[index]);
+ } else {
+ index -= DKEY_TOTAL;
+ ReadAnalogEvent(pad, index / 4, index % 4);
+ }
+
+ UpdateKey();
+}
+
+static void OnResetClicked(GtkWidget *widget, gpointer user_data) {
+ int pad = (int)user_data;
+ int index = GetSelectedKeyIndex(pad);
+
+ if (index == -1) return;
+
+ if (index < DKEY_TOTAL) {
+ g.cfg.PadDef[pad].KeyDef[DPad[index]].Key = 0;
+ g.cfg.PadDef[pad].KeyDef[DPad[index]].JoyEvType = NONE;
+ g.cfg.PadDef[pad].KeyDef[DPad[index]].J.Button = 0;
+ } else {
+ index -= DKEY_TOTAL;
+ g.cfg.PadDef[pad].AnalogDef[index / 4][index % 4].Key = 0;
+ g.cfg.PadDef[pad].AnalogDef[index / 4][index % 4].JoyEvType = NONE;
+ g.cfg.PadDef[pad].AnalogDef[index / 4][index % 4].J.Button = 0;
+ }
+
+ UpdateKey();
+}
+
+static void PopulateDevList() {
+ const char *widgetname[2] = {"combodev1", "combodev2"};
+ int i, j, n;
+ GtkWidget *widget;
+ GladeXML *xml;
+ GtkTreeIter iter;
+ GtkListStore *store;
+ GtkCellRenderer *renderer;
+ char buf[256];
+
+ xml = glade_get_widget_tree(MainWindow);
+
+ for (i = 0; i < 2; i++) {
+ widget = glade_xml_get_widget(xml, widgetname[i]);
+
+ renderer = gtk_cell_renderer_text_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, FALSE);
+ gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(widget), renderer, "text", 0);
+
+ store = gtk_list_store_new(1, G_TYPE_STRING);
+
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, 0, _("None"), -1);
+
+ n = SDL_NumJoysticks();
+ for (j = 0; j < n; j++) {
+ sprintf(buf, "%d: %s", j + 1, SDL_JoystickName(j));
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, 0, buf, -1);
+ }
+
+ gtk_combo_box_set_model(GTK_COMBO_BOX(widget), GTK_TREE_MODEL(store));
+
+ n = g.cfg.PadDef[i].DevNum + 1;
+ if (n > SDL_NumJoysticks()) {
+ n = 0;
+ g.cfg.PadDef[i].DevNum = -1;
+ }
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), n);
+ }
+}
+
+long PADconfigure() {
+ GladeXML *xml;
+ GtkWidget *widget;
+ GtkTreeSelection *treesel;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+
+ if (SDL_Init(SDL_INIT_JOYSTICK) == -1) {
+ fprintf(stderr, "Failed to initialize SDL!\n");
+ return -1;
+ }
+
+ LoadPADConfig();
+
+ xml = glade_xml_new(DATADIR "dfinput.glade2", "CfgWnd", NULL);
+ if (xml == NULL) {
+ g_warning("We could not load the interface!");
+ return -1;
+ }
+
+ MainWindow = glade_xml_get_widget(xml, "CfgWnd");
+ gtk_window_set_title(GTK_WINDOW(MainWindow), _("Gamepad/Keyboard Input Configuration"));
+
+ widget = glade_xml_get_widget(xml, "treeview1");
+
+ // column for key
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Key"),
+ renderer, "text", 0, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column);
+
+ // column for button
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Button"),
+ renderer, "text", 1, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column);
+
+ treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
+ gtk_tree_selection_set_mode(treesel, GTK_SELECTION_SINGLE);
+
+ g_signal_connect_data(G_OBJECT(treesel), "changed",
+ G_CALLBACK(TreeSelectionChanged), (gpointer)0, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "treeview2");
+
+ // column for key
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Key"),
+ renderer, "text", 0, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column);
+
+ // column for button
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Button"),
+ renderer, "text", 1, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column);
+
+ treesel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
+ gtk_tree_selection_set_mode(treesel, GTK_SELECTION_SINGLE);
+
+ g_signal_connect_data(G_OBJECT(treesel), "changed",
+ G_CALLBACK(TreeSelectionChanged), (gpointer)1, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "CfgWnd");
+ g_signal_connect_data(GTK_OBJECT(widget), "delete_event",
+ GTK_SIGNAL_FUNC(OnConfigExit), NULL, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btnclose");
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnConfigExit), NULL, NULL, G_CONNECT_AFTER);
+
+ PopulateDevList();
+ UpdateKeyList();
+
+ widget = glade_xml_get_widget(xml, "checkmt");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), g.cfg.Threaded);
+ g_signal_connect_data(GTK_OBJECT(widget), "toggled",
+ GTK_SIGNAL_FUNC(OnThreadedToggled), NULL, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "combodev1");
+ g_signal_connect_data(GTK_OBJECT(widget), "changed",
+ GTK_SIGNAL_FUNC(OnDeviceChanged), (gpointer)0, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "combodev2");
+ g_signal_connect_data(GTK_OBJECT(widget), "changed",
+ GTK_SIGNAL_FUNC(OnDeviceChanged), (gpointer)1, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "combotype1");
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
+ g.cfg.PadDef[0].Type == PSE_PAD_TYPE_ANALOGPAD ? 1 : 0);
+ g_signal_connect_data(GTK_OBJECT(widget), "changed",
+ GTK_SIGNAL_FUNC(OnTypeChanged), (gpointer)0, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "combotype2");
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
+ g.cfg.PadDef[1].Type == PSE_PAD_TYPE_ANALOGPAD ? 1 : 0);
+ g_signal_connect_data(GTK_OBJECT(widget), "changed",
+ GTK_SIGNAL_FUNC(OnTypeChanged), (gpointer)1, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btnchange1");
+ gtk_widget_set_sensitive(widget, FALSE);
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnChangeClicked), (gpointer)0, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btnreset1");
+ gtk_widget_set_sensitive(widget, FALSE);
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnResetClicked), (gpointer)0, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btnchange2");
+ gtk_widget_set_sensitive(widget, FALSE);
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnChangeClicked), (gpointer)1, NULL, G_CONNECT_AFTER);
+
+ widget = glade_xml_get_widget(xml, "btnreset2");
+ gtk_widget_set_sensitive(widget, FALSE);
+ g_signal_connect_data(GTK_OBJECT(widget), "clicked",
+ GTK_SIGNAL_FUNC(OnResetClicked), (gpointer)1, NULL, G_CONNECT_AFTER);
+
+ gtk_widget_show(MainWindow);
+ gtk_main();
+
+ return 0;
+}
+
+void PADabout() {
+ const char *authors[]= {"Wei Mingzhi <weimingzhi@gmail.com>", NULL};
+ GtkWidget *widget;
+
+ widget = gtk_about_dialog_new();
+ gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(widget), "Gamepad/Keyboard Input");
+ gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(widget), "1.1");
+ gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(widget), authors);
+ gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(widget), "http://www.codeplex.com/pcsxr/");
+
+ gtk_dialog_run(GTK_DIALOG(widget));
+ gtk_widget_destroy(widget);
+}
+
+int main(int argc, char *argv[]) {
+#ifdef ENABLE_NLS
+ setlocale(LC_ALL, "");
+ bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ textdomain(GETTEXT_PACKAGE);
+#endif
+
+ gtk_set_locale();
+ gtk_init(&argc, &argv);
+
+ if (argc > 1 && !strcmp(argv[1], "-about")) {
+ PADabout();
+ } else {
+ PADconfigure();
+ }
+
+ gtk_exit(0);
+ return 0;
+}
diff --git a/plugins/dfinput/cfg.c b/plugins/dfinput/cfg.c
new file mode 100644
index 0000000..ce9a97f
--- /dev/null
+++ b/plugins/dfinput/cfg.c
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#include "pad.h"
+
+#define CONFIG_FILE "dfinput.cfg"
+
+GLOBALDATA g;
+
+static void SetDefaultConfig() {
+ memset(&g.cfg, 0, sizeof(g.cfg));
+
+ g.cfg.Threaded = 1;
+
+ g.cfg.PadDef[0].DevNum = 0;
+ g.cfg.PadDef[1].DevNum = 1;
+
+ g.cfg.PadDef[0].Type = PSE_PAD_TYPE_STANDARD;
+ g.cfg.PadDef[1].Type = PSE_PAD_TYPE_STANDARD;
+
+ // Pad1 keyboard
+ g.cfg.PadDef[0].KeyDef[DKEY_SELECT].Key = XK_c;
+ g.cfg.PadDef[0].KeyDef[DKEY_START].Key = XK_v;
+ g.cfg.PadDef[0].KeyDef[DKEY_UP].Key = XK_Up;
+ g.cfg.PadDef[0].KeyDef[DKEY_RIGHT].Key = XK_Right;
+ g.cfg.PadDef[0].KeyDef[DKEY_DOWN].Key = XK_Down;
+ g.cfg.PadDef[0].KeyDef[DKEY_LEFT].Key = XK_Left;
+ g.cfg.PadDef[0].KeyDef[DKEY_L2].Key = XK_e;
+ g.cfg.PadDef[0].KeyDef[DKEY_R2].Key = XK_t;
+ g.cfg.PadDef[0].KeyDef[DKEY_L1].Key = XK_w;
+ g.cfg.PadDef[0].KeyDef[DKEY_R1].Key = XK_r;
+ g.cfg.PadDef[0].KeyDef[DKEY_TRIANGLE].Key = XK_d;
+ g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].Key = XK_x;
+ g.cfg.PadDef[0].KeyDef[DKEY_CROSS].Key = XK_z;
+ g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].Key = XK_s;
+
+ // Pad1 joystick
+ g.cfg.PadDef[0].KeyDef[DKEY_SELECT].JoyEvType = BUTTON;
+ g.cfg.PadDef[0].KeyDef[DKEY_SELECT].J.Button = 8;
+ g.cfg.PadDef[0].KeyDef[DKEY_START].JoyEvType = BUTTON;
+ g.cfg.PadDef[0].KeyDef[DKEY_START].J.Button = 9;
+ g.cfg.PadDef[0].KeyDef[DKEY_UP].JoyEvType = AXIS;
+ g.cfg.PadDef[0].KeyDef[DKEY_UP].J.Axis = -2;
+ g.cfg.PadDef[0].KeyDef[DKEY_RIGHT].JoyEvType = AXIS;
+ g.cfg.PadDef[0].KeyDef[DKEY_RIGHT].J.Axis = 1;
+ g.cfg.PadDef[0].KeyDef[DKEY_DOWN].JoyEvType = AXIS;
+ g.cfg.PadDef[0].KeyDef[DKEY_DOWN].J.Axis = 2;
+ g.cfg.PadDef[0].KeyDef[DKEY_LEFT].JoyEvType = AXIS;
+ g.cfg.PadDef[0].KeyDef[DKEY_LEFT].J.Axis = -1;
+ g.cfg.PadDef[0].KeyDef[DKEY_L2].JoyEvType = BUTTON;
+ g.cfg.PadDef[0].KeyDef[DKEY_L2].J.Button = 4;
+ g.cfg.PadDef[0].KeyDef[DKEY_L1].JoyEvType = BUTTON;
+ g.cfg.PadDef[0].KeyDef[DKEY_L1].J.Button = 6;
+ g.cfg.PadDef[0].KeyDef[DKEY_R2].JoyEvType = BUTTON;
+ g.cfg.PadDef[0].KeyDef[DKEY_R2].J.Button = 5;
+ g.cfg.PadDef[0].KeyDef[DKEY_R1].JoyEvType = BUTTON;
+ g.cfg.PadDef[0].KeyDef[DKEY_R1].J.Button = 7;
+ g.cfg.PadDef[0].KeyDef[DKEY_TRIANGLE].JoyEvType = BUTTON;
+ g.cfg.PadDef[0].KeyDef[DKEY_TRIANGLE].J.Button = 0;
+ g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].JoyEvType = BUTTON;
+ g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].J.Button = 1;
+ g.cfg.PadDef[0].KeyDef[DKEY_CROSS].JoyEvType = BUTTON;
+ g.cfg.PadDef[0].KeyDef[DKEY_CROSS].J.Button = 2;
+ g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].JoyEvType = BUTTON;
+ g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].J.Button = 3;
+
+ // Pad2 joystick
+ g.cfg.PadDef[1].KeyDef[DKEY_SELECT].JoyEvType = BUTTON;
+ g.cfg.PadDef[1].KeyDef[DKEY_SELECT].J.Button = 8;
+ g.cfg.PadDef[1].KeyDef[DKEY_START].JoyEvType = BUTTON;
+ g.cfg.PadDef[1].KeyDef[DKEY_START].J.Button = 9;
+ g.cfg.PadDef[1].KeyDef[DKEY_UP].JoyEvType = AXIS;
+ g.cfg.PadDef[1].KeyDef[DKEY_UP].J.Axis = -2;
+ g.cfg.PadDef[1].KeyDef[DKEY_RIGHT].JoyEvType = AXIS;
+ g.cfg.PadDef[1].KeyDef[DKEY_RIGHT].J.Axis = 1;
+ g.cfg.PadDef[1].KeyDef[DKEY_DOWN].JoyEvType = AXIS;
+ g.cfg.PadDef[1].KeyDef[DKEY_DOWN].J.Axis = 2;
+ g.cfg.PadDef[1].KeyDef[DKEY_LEFT].JoyEvType = AXIS;
+ g.cfg.PadDef[1].KeyDef[DKEY_LEFT].J.Axis = -1;
+ g.cfg.PadDef[1].KeyDef[DKEY_L2].JoyEvType = BUTTON;
+ g.cfg.PadDef[1].KeyDef[DKEY_L2].J.Button = 4;
+ g.cfg.PadDef[1].KeyDef[DKEY_L1].JoyEvType = BUTTON;
+ g.cfg.PadDef[1].KeyDef[DKEY_L1].J.Button = 6;
+ g.cfg.PadDef[1].KeyDef[DKEY_R2].JoyEvType = BUTTON;
+ g.cfg.PadDef[1].KeyDef[DKEY_R2].J.Button = 5;
+ g.cfg.PadDef[1].KeyDef[DKEY_R1].JoyEvType = BUTTON;
+ g.cfg.PadDef[1].KeyDef[DKEY_R1].J.Button = 7;
+ g.cfg.PadDef[1].KeyDef[DKEY_TRIANGLE].JoyEvType = BUTTON;
+ g.cfg.PadDef[1].KeyDef[DKEY_TRIANGLE].J.Button = 0;
+ g.cfg.PadDef[1].KeyDef[DKEY_CIRCLE].JoyEvType = BUTTON;
+ g.cfg.PadDef[1].KeyDef[DKEY_CIRCLE].J.Button = 1;
+ g.cfg.PadDef[1].KeyDef[DKEY_CROSS].JoyEvType = BUTTON;
+ g.cfg.PadDef[1].KeyDef[DKEY_CROSS].J.Button = 2;
+ g.cfg.PadDef[1].KeyDef[DKEY_SQUARE].JoyEvType = BUTTON;
+ g.cfg.PadDef[1].KeyDef[DKEY_SQUARE].J.Button = 3;
+}
+
+void LoadPADConfig() {
+ FILE *fp;
+ char buf[256];
+ int current, a, b, c;
+
+ SetDefaultConfig();
+
+ fp = fopen(CONFIG_FILE, "r");
+ if (fp == NULL) {
+ return;
+ }
+
+ current = 0;
+
+ while (fgets(buf, 256, fp) != NULL) {
+ if (strncmp(buf, "Threaded=", 9) == 0) {
+ g.cfg.Threaded = atoi(&buf[9]);
+ } else if (strncmp(buf, "[PAD", 4) == 0) {
+ current = atoi(&buf[4]) - 1;
+ if (current < 0) {
+ current = 0;
+ } else if (current > 1) {
+ current = 1;
+ }
+ } else if (strncmp(buf, "DevNum=", 7) == 0) {
+ g.cfg.PadDef[current].DevNum = atoi(&buf[7]);
+ } else if (strncmp(buf, "Type=", 5) == 0) {
+ g.cfg.PadDef[current].Type = atoi(&buf[5]);
+ } else if (strncmp(buf, "Select=", 7) == 0) {
+ sscanf(buf, "Select=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_SELECT].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_SELECT].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_SELECT].J.d = c;
+ } else if (strncmp(buf, "L3=", 3) == 0) {
+ sscanf(buf, "L3=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_L3].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_L3].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_L3].J.d = c;
+ } else if (strncmp(buf, "R3=", 3) == 0) {
+ sscanf(buf, "R3=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_R3].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_R3].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_R3].J.d = c;
+ } else if (strncmp(buf, "Start=", 6) == 0) {
+ sscanf(buf, "Start=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_START].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_START].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_START].J.d = c;
+ } else if (strncmp(buf, "Up=", 3) == 0) {
+ sscanf(buf, "Up=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_UP].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_UP].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_UP].J.d = c;
+ } else if (strncmp(buf, "Right=", 6) == 0) {
+ sscanf(buf, "Right=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].J.d = c;
+ } else if (strncmp(buf, "Down=", 5) == 0) {
+ sscanf(buf, "Down=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_DOWN].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_DOWN].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_DOWN].J.d = c;
+ } else if (strncmp(buf, "Left=", 5) == 0) {
+ sscanf(buf, "Left=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_LEFT].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_LEFT].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_LEFT].J.d = c;
+ } else if (strncmp(buf, "L2=", 3) == 0) {
+ sscanf(buf, "L2=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_L2].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_L2].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_L2].J.d = c;
+ } else if (strncmp(buf, "R2=", 3) == 0) {
+ sscanf(buf, "R2=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_R2].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_R2].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_R2].J.d = c;
+ } else if (strncmp(buf, "L1=", 3) == 0) {
+ sscanf(buf, "L1=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_L1].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_L1].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_L1].J.d = c;
+ } else if (strncmp(buf, "R1=", 3) == 0) {
+ sscanf(buf, "R1=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_R1].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_R1].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_R1].J.d = c;
+ } else if (strncmp(buf, "Triangle=", 9) == 0) {
+ sscanf(buf, "Triangle=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].J.d = c;
+ } else if (strncmp(buf, "Circle=", 7) == 0) {
+ sscanf(buf, "Circle=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].J.d = c;
+ } else if (strncmp(buf, "Cross=", 6) == 0) {
+ sscanf(buf, "Cross=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_CROSS].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_CROSS].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_CROSS].J.d = c;
+ } else if (strncmp(buf, "Square=", 7) == 0) {
+ sscanf(buf, "Square=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].Key = a;
+ g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].JoyEvType = b;
+ g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].J.d = c;
+ } else if (strncmp(buf, "LeftAnalogXP=", 13) == 0) {
+ sscanf(buf, "LeftAnalogXP=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].Key = a;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].JoyEvType = b;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].J.d = c;
+ } else if (strncmp(buf, "LeftAnalogXM=", 13) == 0) {
+ sscanf(buf, "LeftAnalogXM=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].Key = a;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].JoyEvType = b;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].J.d = c;
+ } else if (strncmp(buf, "LeftAnalogYP=", 13) == 0) {
+ sscanf(buf, "LeftAnalogYP=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].Key = a;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].JoyEvType = b;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].J.d = c;
+ } else if (strncmp(buf, "LeftAnalogYM=", 13) == 0) {
+ sscanf(buf, "LeftAnalogYM=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].Key = a;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].JoyEvType = b;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].J.d = c;
+ } else if (strncmp(buf, "RightAnalogXP=", 14) == 0) {
+ sscanf(buf, "RightAnalogXP=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].Key = a;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].JoyEvType = b;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].J.d = c;
+ } else if (strncmp(buf, "RightAnalogXM=", 14) == 0) {
+ sscanf(buf, "RightAnalogXM=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].Key = a;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].JoyEvType = b;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].J.d = c;
+ } else if (strncmp(buf, "RightAnalogYP=", 14) == 0) {
+ sscanf(buf, "RightAnalogYP=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].Key = a;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].JoyEvType = b;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].J.d = c;
+ } else if (strncmp(buf, "RightAnalogYM=", 14) == 0) {
+ sscanf(buf, "RightAnalogYM=%d,%d,%d", &a, &b, &c);
+ g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].Key = a;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].JoyEvType = b;
+ g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].J.d = c;
+ }
+ }
+
+ fclose(fp);
+}
+
+void SavePADConfig() {
+ FILE *fp;
+ int i;
+
+ fp = fopen(CONFIG_FILE, "w");
+ if (fp == NULL) {
+ return;
+ }
+
+ fprintf(fp, "[CONFIG]\n");
+ fprintf(fp, "Threaded=%d\n", g.cfg.Threaded);
+ fprintf(fp, "\n");
+
+ for (i = 0; i < 2; i++) {
+ fprintf(fp, "[PAD%d]\n", i + 1);
+ fprintf(fp, "DevNum=%d\n", g.cfg.PadDef[i].DevNum);
+ fprintf(fp, "Type=%d\n", g.cfg.PadDef[i].Type);
+
+ fprintf(fp, "Select=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_SELECT].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_SELECT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_SELECT].J.d);
+ fprintf(fp, "L3=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_L3].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_L3].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L3].J.d);
+ fprintf(fp, "R3=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R3].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_R3].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R3].J.d);
+ fprintf(fp, "Start=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_START].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_START].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_START].J.d);
+ fprintf(fp, "Up=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_UP].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_UP].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_UP].J.d);
+ fprintf(fp, "Right=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_RIGHT].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_RIGHT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_RIGHT].J.d);
+ fprintf(fp, "Down=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_DOWN].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_DOWN].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_DOWN].J.d);
+ fprintf(fp, "Left=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_LEFT].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_LEFT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_LEFT].J.d);
+ fprintf(fp, "L2=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_L2].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_L2].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L2].J.d);
+ fprintf(fp, "R2=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R2].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_R2].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R2].J.d);
+ fprintf(fp, "L1=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_L1].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_L1].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L1].J.d);
+ fprintf(fp, "R1=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R1].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_R1].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R1].J.d);
+ fprintf(fp, "Triangle=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_TRIANGLE].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_TRIANGLE].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_TRIANGLE].J.d);
+ fprintf(fp, "Circle=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_CIRCLE].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_CIRCLE].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_CIRCLE].J.d);
+ fprintf(fp, "Cross=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_CROSS].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_CROSS].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_CROSS].J.d);
+ fprintf(fp, "Square=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_SQUARE].Key,
+ g.cfg.PadDef[i].KeyDef[DKEY_SQUARE].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_SQUARE].J.d);
+ fprintf(fp, "LeftAnalogXP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XP].Key,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XP].JoyEvType,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XP].J.d);
+ fprintf(fp, "LeftAnalogXM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XM].Key,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XM].JoyEvType,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XM].J.d);
+ fprintf(fp, "LeftAnalogYP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YP].Key,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YP].JoyEvType,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YP].J.d);
+ fprintf(fp, "LeftAnalogYM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YM].Key,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YM].JoyEvType,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YM].J.d);
+ fprintf(fp, "RightAnalogXP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XP].Key,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XP].JoyEvType,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XP].J.d);
+ fprintf(fp, "RightAnalogXM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XM].Key,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XM].JoyEvType,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XM].J.d);
+ fprintf(fp, "RightAnalogYP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YP].Key,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YP].JoyEvType,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YP].J.d);
+ fprintf(fp, "RightAnalogYM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YM].Key,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YM].JoyEvType,
+ g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YM].J.d);
+
+ fprintf(fp, "\n");
+ }
+
+ fclose(fp);
+}
diff --git a/plugins/dfinput/dfinput.glade2 b/plugins/dfinput/dfinput.glade2
new file mode 100644
index 0000000..c7bdd11
--- /dev/null
+++ b/plugins/dfinput/dfinput.glade2
@@ -0,0 +1,489 @@
+<?xml version="1.0"?>
+<glade-interface>
+ <!-- interface-requires gtk+ 2.12 -->
+ <!-- interface-naming-policy project-wide -->
+ <widget class="GtkDialog" id="CfgWnd">
+ <property name="border_width">5</property>
+ <property name="resizable">False</property>
+ <property name="window_position">center</property>
+ <property name="type_hint">normal</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkNotebook" id="notebook1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkHBox" id="hbox6">
+ <property name="visible">True</property>
+ <property name="spacing">10</property>
+ <child>
+ <widget class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Device:</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combodev1">
+ <property name="width_request">150</property>
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox5">
+ <property name="visible">True</property>
+ <property name="spacing">10</property>
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Type:</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combotype1">
+ <property name="width_request">200</property>
+ <property name="visible">True</property>
+ <property name="items" translatable="yes">Digital Pad
+Analog Pad</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="border_width">5</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="window_placement_set">True</property>
+ <property name="shadow_type">etched-in</property>
+ <child>
+ <widget class="GtkTreeView" id="treeview1">
+ <property name="width_request">500</property>
+ <property name="height_request">275</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHButtonBox" id="hbuttonbox2">
+ <property name="visible">True</property>
+ <property name="spacing">20</property>
+ <property name="layout_style">center</property>
+ <child>
+ <widget class="GtkButton" id="btnchange1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="stock">gtk-edit</property>
+ <property name="icon-size">1</property>
+ </widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Change</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="btnreset1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="stock">gtk-undo</property>
+ <property name="icon-size">1</property>
+ </widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Reset</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Controller 1</property>
+ </widget>
+ <packing>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkHButtonBox" id="hbuttonbox4">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkHBox" id="hbox8">
+ <property name="visible">True</property>
+ <property name="spacing">10</property>
+ <child>
+ <widget class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Device:</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combodev2">
+ <property name="width_request">150</property>
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox7">
+ <property name="visible">True</property>
+ <property name="spacing">10</property>
+ <child>
+ <widget class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Type:</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combotype2">
+ <property name="width_request">200</property>
+ <property name="visible">True</property>
+ <property name="items" translatable="yes">Digital Pad
+Analog Pad</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="border_width">5</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="window_placement_set">True</property>
+ <property name="shadow_type">etched-in</property>
+ <child>
+ <widget class="GtkTreeView" id="treeview2">
+ <property name="width_request">500</property>
+ <property name="height_request">275</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHButtonBox" id="hbuttonbox3">
+ <property name="visible">True</property>
+ <property name="spacing">20</property>
+ <property name="layout_style">center</property>
+ <child>
+ <widget class="GtkButton" id="btnchange2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <child>
+ <widget class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="stock">gtk-edit</property>
+ <property name="icon-size">1</property>
+ </widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Change</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="btnreset2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <child>
+ <widget class="GtkHBox" id="hbox4">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkImage" id="image4">
+ <property name="visible">True</property>
+ <property name="stock">gtk-undo</property>
+ <property name="icon-size">1</property>
+ </widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Reset</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Controller 2</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">20</property>
+ <child>
+ <widget class="GtkCheckButton" id="checkmt">
+ <property name="label" translatable="yes">Multi-Threaded (Recommended)</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">16</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Options</property>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <widget class="GtkButton" id="btnclose">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c
new file mode 100644
index 0000000..a0207aa
--- /dev/null
+++ b/plugins/dfinput/pad.c
@@ -0,0 +1,392 @@
+/*
+ * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#include "pad.h"
+
+char *PSEgetLibName(void) {
+ return _("Gamepad/Keyboard Input");
+}
+
+uint32_t PSEgetLibType(void) {
+ return PSE_LT_PAD;
+}
+
+uint32_t PSEgetLibVersion(void) {
+ return (1 << 16) | (1 << 8);
+}
+
+long PADinit(long flags) {
+ LoadPADConfig();
+
+ g.PadState[0].PadMode = 0;
+ g.PadState[0].PadID = 0x41;
+ g.PadState[1].PadMode = 0;
+ g.PadState[1].PadID = 0x41;
+
+ return PSE_PAD_ERR_SUCCESS;
+}
+
+long PADshutdown(void) {
+ PADclose();
+ return PSE_PAD_ERR_SUCCESS;
+}
+
+static pthread_t ThreadID;
+static volatile uint8_t TerminateThread = 0;
+
+static void *JoyThread(void *param) {
+ while (!TerminateThread) {
+ CheckJoy();
+ usleep(1000);
+ }
+ pthread_exit(0);
+ return NULL;
+}
+
+long PADopen(unsigned long *Disp) {
+ g.Disp = (Display *)*Disp;
+
+ if (!g.Opened) {
+ if (SDL_WasInit(SDL_INIT_EVERYTHING)) {
+ if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) {
+ return PSE_PAD_ERR_FAILURE;
+ }
+ } else if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) == -1) {
+ return PSE_PAD_ERR_FAILURE;
+ }
+
+ InitSDLJoy();
+ InitKeyboard();
+
+ g.KeyLeftOver = 0;
+
+ if (g.cfg.Threaded) {
+ TerminateThread = 0;
+
+ if (pthread_create(&ThreadID, NULL, JoyThread, NULL) != 0) {
+ // thread creation failed, fallback to polling
+ g.cfg.Threaded = 0;
+ }
+ }
+ }
+
+ g.Opened = 1;
+
+ return PSE_PAD_ERR_SUCCESS;
+}
+
+long PADclose(void) {
+ if (g.Opened) {
+ if (g.cfg.Threaded) {
+ TerminateThread = 1;
+ pthread_join(ThreadID, NULL);
+ }
+
+ DestroySDLJoy();
+ DestroyKeyboard();
+
+ if (SDL_WasInit(SDL_INIT_EVERYTHING & ~SDL_INIT_JOYSTICK)) {
+ SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
+ } else {
+ SDL_Quit();
+ }
+ }
+
+ g.Opened = 0;
+
+ return PSE_PAD_ERR_SUCCESS;
+}
+
+long PADquery(void) {
+ return PSE_PAD_USE_PORT1 | PSE_PAD_USE_PORT2;
+}
+
+static void UpdateInput(void) {
+ if (!g.cfg.Threaded) CheckJoy();
+ CheckKeyboard();
+}
+
+static uint8_t stdpar[2][8] = {
+ {0xFF, 0x5A, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x80},
+ {0xFF, 0x5A, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x80}
+};
+
+static uint8_t unk46[2][8] = {
+ {0xFF, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A},
+ {0xFF, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A}
+};
+
+static uint8_t unk47[2][8] = {
+ {0xFF, 0x5A, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00},
+ {0xFF, 0x5A, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00}
+};
+
+static uint8_t unk4c[2][8] = {
+ {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+};
+
+static uint8_t unk4d[2][8] = {
+ {0xFF, 0x5A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
+ {0xFF, 0x5A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
+};
+
+static uint8_t stdcfg[2][8] = {
+ {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+};
+
+static uint8_t stdmode[2][8] = {
+ {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+};
+
+static uint8_t stdmodel[2][8] = {
+ {0xFF,
+ 0x5A,
+ 0x01, // 03 - dualshock2, 01 - dualshock
+ 0x02, // number of modes
+ 0x01, // current mode: 01 - analog, 00 - digital
+ 0x02,
+ 0x01,
+ 0x00},
+ {0xFF,
+ 0x5A,
+ 0x01, // 03 - dualshock2, 01 - dualshock
+ 0x02, // number of modes
+ 0x01, // current mode: 01 - analog, 00 - digital
+ 0x02,
+ 0x01,
+ 0x00}
+};
+
+static uint8_t CurPad = 0, CurByte = 0, CurCmd = 0, CmdLen = 0;
+
+unsigned char PADstartPoll(int pad) {
+ CurPad = pad - 1;
+ CurByte = 0;
+
+ return 0xFF;
+}
+
+unsigned char PADpoll(unsigned char value) {
+ static uint8_t *buf = NULL;
+ uint16_t n;
+
+ if (CurByte == 0) {
+ CurByte++;
+
+ // Don't enable Analog/Vibration for a standard pad
+ if (g.cfg.PadDef[CurPad].Type != PSE_PAD_TYPE_ANALOGPAD) {
+ CurCmd = CMD_READ_DATA_AND_VIBRATE;
+ } else {
+ CurCmd = value;
+ }
+
+ switch (CurCmd) {
+ case CMD_CONFIG_MODE:
+ CmdLen = 8;
+ buf = stdcfg[CurPad];
+ if (stdcfg[CurPad][3] == 0xFF) return 0xF3;
+ else return g.PadState[CurPad].PadID;
+
+ case CMD_SET_MODE_AND_LOCK:
+ CmdLen = 8;
+ buf = stdmode[CurPad];
+ return 0xF3;
+
+ case CMD_QUERY_MODEL_AND_MODE:
+ CmdLen = 8;
+ buf = stdmodel[CurPad];
+ buf[4] = g.PadState[CurPad].PadMode;
+ return 0xF3;
+
+ case CMD_QUERY_ACT:
+ CmdLen = 8;
+ buf = unk46[CurPad];
+ return 0xF3;
+
+ case CMD_QUERY_COMB:
+ CmdLen = 8;
+ buf = unk47[CurPad];
+ return 0xF3;
+
+ case CMD_QUERY_MODE:
+ CmdLen = 8;
+ buf = unk4c[CurPad];
+ return 0xF3;
+
+ case CMD_VIBRATION_TOGGLE:
+ CmdLen = 8;
+ buf = unk4d[CurPad];
+ return 0xF3;
+
+ case CMD_READ_DATA_AND_VIBRATE:
+ default:
+ UpdateInput();
+
+ n = g.PadState[CurPad].KeyStatus;
+ n &= g.PadState[CurPad].JoyKeyStatus;
+
+ stdpar[CurPad][2] = n & 0xFF;
+ stdpar[CurPad][3] = n >> 8;
+
+ if (g.PadState[CurPad].PadMode == 1) {
+ CmdLen = 8;
+
+ stdpar[CurPad][4] = g.PadState[CurPad].AnalogStatus[ANALOG_RIGHT][0];
+ stdpar[CurPad][5] = g.PadState[CurPad].AnalogStatus[ANALOG_RIGHT][1];
+ stdpar[CurPad][6] = g.PadState[CurPad].AnalogStatus[ANALOG_LEFT][0];
+ stdpar[CurPad][7] = g.PadState[CurPad].AnalogStatus[ANALOG_LEFT][1];
+ } else {
+ CmdLen = 4;
+ }
+
+ buf = stdpar[CurPad];
+ return g.PadState[CurPad].PadID;
+ }
+ }
+
+ switch (CurCmd) {
+ case CMD_CONFIG_MODE:
+ if (CurByte == 2) {
+ switch (value) {
+ case 0:
+ buf[2] = 0;
+ buf[3] = 0;
+ break;
+
+ case 1:
+ buf[2] = 0xFF;
+ buf[3] = 0xFF;
+ break;
+ }
+ }
+ break;
+
+ case CMD_SET_MODE_AND_LOCK:
+ if (CurByte == 2) {
+ g.PadState[CurPad].PadMode = value;
+ g.PadState[CurPad].PadID = value ? 0x73 : 0x41;
+ }
+ break;
+
+ case CMD_QUERY_ACT:
+ if (CurByte == 2) {
+ switch (value) {
+ case 0: // default
+ buf[5] = 0x02;
+ buf[6] = 0x00;
+ buf[7] = 0x0A;
+ break;
+
+ case 1: // Param std conf change
+ buf[5] = 0x01;
+ buf[6] = 0x01;
+ buf[7] = 0x14;
+ break;
+ }
+ }
+ break;
+
+ case CMD_QUERY_MODE:
+ if (CurByte == 2) {
+ switch (value) {
+ case 0: // mode 0 - digital mode
+ buf[5] = PSE_PAD_TYPE_STANDARD;
+ break;
+
+ case 1: // mode 1 - analog mode
+ buf[5] = PSE_PAD_TYPE_ANALOGPAD;
+ break;
+ }
+ }
+ break;
+ }
+
+ if (CurByte >= CmdLen) return 0;
+ return buf[CurByte++];
+}
+
+static long PADreadPort(int num, PadDataS *pad) {
+ UpdateInput();
+
+ pad->buttonStatus = (g.PadState[num].KeyStatus & g.PadState[num].JoyKeyStatus);
+
+ // ePSXe different from pcsx, swap bytes
+ pad->buttonStatus = (pad->buttonStatus >> 8) | (pad->buttonStatus << 8);
+
+ switch (g.cfg.PadDef[num].Type) {
+ case PSE_PAD_TYPE_ANALOGPAD: // Analog Controller SCPH-1150
+ pad->controllerType = PSE_PAD_TYPE_ANALOGPAD;
+ pad->rightJoyX = g.PadState[num].AnalogStatus[ANALOG_RIGHT][0];
+ pad->rightJoyY = g.PadState[num].AnalogStatus[ANALOG_RIGHT][1];
+ pad->leftJoyX = g.PadState[num].AnalogStatus[ANALOG_LEFT][0];
+ pad->leftJoyY = g.PadState[num].AnalogStatus[ANALOG_LEFT][1];
+ break;
+
+ case PSE_PAD_TYPE_STANDARD: // Standard Pad SCPH-1080, SCPH-1150
+ default:
+ pad->controllerType = PSE_PAD_TYPE_STANDARD;
+ break;
+ }
+
+ return PSE_PAD_ERR_SUCCESS;
+}
+
+long PADreadPort1(PadDataS *pad) {
+ return PADreadPort(0, pad);
+}
+
+long PADreadPort2(PadDataS *pad) {
+ return PADreadPort(1, pad);
+}
+
+long PADkeypressed(void) {
+ long s;
+
+ CheckKeyboard();
+
+ s = g.KeyLeftOver;
+ g.KeyLeftOver = 0;
+
+ return s;
+}
+
+#ifndef _MACOSX
+
+long PADconfigure(void) {
+ if (fork() == 0) {
+ execl("cfg/cfgDFInput", "cfgDFInput", NULL);
+ exit(0);
+ }
+ return PSE_PAD_ERR_SUCCESS;
+}
+
+void PADabout(void) {
+ if (fork() == 0) {
+ execl("cfg/cfgDFInput", "cfgDFInput", "-about", NULL);
+ exit(0);
+ }
+}
+
+#endif
+
+long PADtest(void) {
+ return PSE_PAD_ERR_SUCCESS;
+}
diff --git a/plugins/dfinput/pad.h b/plugins/dfinput/pad.h
new file mode 100644
index 0000000..8347caf
--- /dev/null
+++ b/plugins/dfinput/pad.h
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#ifndef PAD_H_
+#define PAD_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _MACOSX
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <pthread.h>
+
+#include <SDL.h>
+#include <SDL_joystick.h>
+
+#ifdef _MACOSX
+#include <Carbon/Carbon.h>
+typedef void *Display;
+#define ThreadID ThreadID_MACOSX
+#else
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/keysym.h>
+#include <X11/XKBlib.h>
+#endif
+
+#include "psemu_plugin_defs.h"
+
+#ifdef ENABLE_NLS
+#include <libintl.h>
+#include <locale.h>
+#define _(x) gettext(x)
+#define N_(x) (x)
+#else
+#define _(x) (x)
+#define N_(x) (x)
+#endif
+
+enum {
+ DKEY_SELECT = 0,
+ DKEY_L3,
+ DKEY_R3,
+ DKEY_START,
+ DKEY_UP,
+ DKEY_RIGHT,
+ DKEY_DOWN,
+ DKEY_LEFT,
+ DKEY_L2,
+ DKEY_R2,
+ DKEY_L1,
+ DKEY_R1,
+ DKEY_TRIANGLE,
+ DKEY_CIRCLE,
+ DKEY_CROSS,
+ DKEY_SQUARE,
+
+ DKEY_TOTAL
+};
+
+enum {
+ ANALOG_LEFT = 0,
+ ANALOG_RIGHT,
+
+ ANALOG_TOTAL
+};
+
+enum { NONE = 0, AXIS, HAT, BUTTON };
+
+typedef struct tagKeyDef {
+ uint8_t JoyEvType;
+ union {
+ int16_t d;
+ int16_t Axis; // positive=axis+, negative=axis-, abs(Axis)-1=axis index
+ uint16_t Hat; // 8-bit for hat number, 8-bit for direction
+ uint16_t Button; // button number
+ } J;
+ uint16_t Key;
+} KEYDEF;
+
+enum { ANALOG_XP = 0, ANALOG_XM, ANALOG_YP, ANALOG_YM };
+
+typedef struct tagPadDef {
+ int8_t DevNum;
+ uint16_t Type;
+ KEYDEF KeyDef[DKEY_TOTAL];
+ KEYDEF AnalogDef[ANALOG_TOTAL][4];
+} PADDEF;
+
+typedef struct tagConfig {
+ uint8_t Threaded;
+ PADDEF PadDef[2];
+} CONFIG;
+
+typedef struct tagPadState {
+ SDL_Joystick *JoyDev;
+ uint8_t PadMode;
+ uint8_t PadID;
+ volatile uint16_t KeyStatus;
+ volatile uint16_t JoyKeyStatus;
+ volatile uint8_t AnalogStatus[ANALOG_TOTAL][2]; // 0-255 where 127 is center position
+ volatile uint8_t AnalogKeyStatus[ANALOG_TOTAL][4];
+} PADSTATE;
+
+typedef struct tagGlobalData {
+ CONFIG cfg;
+
+ uint8_t Opened;
+ Display *Disp;
+
+ PADSTATE PadState[2];
+ volatile long KeyLeftOver;
+} GLOBALDATA;
+
+extern GLOBALDATA g;
+
+enum {
+ CMD_READ_DATA_AND_VIBRATE = 0x42,
+ CMD_CONFIG_MODE = 0x43,
+ CMD_SET_MODE_AND_LOCK = 0x44,
+ CMD_QUERY_MODEL_AND_MODE = 0x45,
+ CMD_QUERY_ACT = 0x46, // ??
+ CMD_QUERY_COMB = 0x47, // ??
+ CMD_QUERY_MODE = 0x4C, // QUERY_MODE ??
+ CMD_VIBRATION_TOGGLE = 0x4D,
+};
+
+// cfg.c functions...
+void LoadPADConfig();
+void SavePADConfig();
+
+// sdljoy.c functions...
+void InitSDLJoy();
+void DestroySDLJoy();
+void CheckJoy();
+
+// xkb.c functions...
+void InitKeyboard();
+void DestroyKeyboard();
+void CheckKeyboard();
+
+// analog.c functions...
+void InitAnalog();
+void CheckAnalog();
+int AnalogKeyPressed(uint16_t Key);
+int AnalogKeyReleased(uint16_t Key);
+
+// pad.c functions...
+char *PSEgetLibName(void);
+uint32_t PSEgetLibType(void);
+uint32_t PSEgetLibVersion(void);
+long PADinit(long flags);
+long PADshutdown(void);
+long PADopen(unsigned long *Disp);
+long PADclose(void);
+long PADquery(void);
+unsigned char PADstartPoll(int pad);
+unsigned char PADpoll(unsigned char value);
+long PADreadPort1(PadDataS *pad);
+long PADreadPort2(PadDataS *pad);
+long PADkeypressed(void);
+long PADconfigure(void);
+void PADabout(void);
+long PADtest(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/plugins/dfinput/sdljoy.c b/plugins/dfinput/sdljoy.c
new file mode 100644
index 0000000..ff4ed46
--- /dev/null
+++ b/plugins/dfinput/sdljoy.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#include "pad.h"
+
+void InitSDLJoy() {
+ uint8_t i;
+
+ g.PadState[0].JoyKeyStatus = 0xFFFF;
+ g.PadState[1].JoyKeyStatus = 0xFFFF;
+
+ for (i = 0; i < 2; i++) {
+ if (g.cfg.PadDef[i].DevNum >= 0) {
+ g.PadState[i].JoyDev = SDL_JoystickOpen(g.cfg.PadDef[i].DevNum);
+ } else {
+ g.PadState[i].JoyDev = NULL;
+ }
+ }
+
+ SDL_JoystickEventState(SDL_IGNORE);
+
+ InitAnalog();
+}
+
+void DestroySDLJoy() {
+ uint8_t i;
+
+ if (SDL_WasInit(SDL_INIT_JOYSTICK)) {
+ for (i = 0; i < 2; i++) {
+ if (g.PadState[i].JoyDev != NULL) {
+ SDL_JoystickClose(g.PadState[i].JoyDev);
+ }
+ }
+ }
+
+ for (i = 0; i < 2; i++) {
+ g.PadState[i].JoyDev = NULL;
+ }
+}
+
+void CheckJoy() {
+ uint8_t i, j, n;
+
+ SDL_JoystickUpdate();
+
+ for (i = 0; i < 2; i++) {
+ if (g.PadState[i].JoyDev == NULL) {
+ continue;
+ }
+
+ for (j = 0; j < DKEY_TOTAL; j++) {
+ switch (g.cfg.PadDef[i].KeyDef[j].JoyEvType) {
+ case AXIS:
+ n = abs(g.cfg.PadDef[i].KeyDef[j].J.Axis) - 1;
+
+ if (g.cfg.PadDef[i].KeyDef[j].J.Axis > 0) {
+ if (SDL_JoystickGetAxis(g.PadState[i].JoyDev, n) > 16383) {
+ g.PadState[i].JoyKeyStatus &= ~(1 << j);
+ } else {
+ g.PadState[i].JoyKeyStatus |= (1 << j);
+ }
+ } else if (g.cfg.PadDef[i].KeyDef[j].J.Axis < 0) {
+ if (SDL_JoystickGetAxis(g.PadState[i].JoyDev, n) < -16383) {
+ g.PadState[i].JoyKeyStatus &= ~(1 << j);
+ } else {
+ g.PadState[i].JoyKeyStatus |= (1 << j);
+ }
+ }
+ break;
+
+ case HAT:
+ n = (g.cfg.PadDef[i].KeyDef[j].J.Hat >> 8);
+
+ if (SDL_JoystickGetHat(g.PadState[i].JoyDev, n) & (g.cfg.PadDef[i].KeyDef[j].J.Hat & 0xFF)) {
+ g.PadState[i].JoyKeyStatus &= ~(1 << j);
+ } else {
+ g.PadState[i].JoyKeyStatus |= (1 << j);
+ }
+ break;
+
+ case BUTTON:
+ if (SDL_JoystickGetButton(g.PadState[i].JoyDev, g.cfg.PadDef[i].KeyDef[j].J.Button)) {
+ g.PadState[i].JoyKeyStatus &= ~(1 << j);
+ } else {
+ g.PadState[i].JoyKeyStatus |= (1 << j);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ CheckAnalog();
+}
diff --git a/plugins/dfinput/xkb.c b/plugins/dfinput/xkb.c
new file mode 100644
index 0000000..bfadef1
--- /dev/null
+++ b/plugins/dfinput/xkb.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#include "pad.h"
+
+static Atom wmprotocols, wmdelwindow;
+
+void InitKeyboard() {
+ wmprotocols = XInternAtom(g.Disp, "WM_PROTOCOLS", 0);
+ wmdelwindow = XInternAtom(g.Disp, "WM_DELETE_WINDOW", 0);
+
+ XkbSetDetectableAutoRepeat(g.Disp, 1, NULL);
+
+ g.PadState[0].KeyStatus = 0xFFFF;
+ g.PadState[1].KeyStatus = 0xFFFF;
+}
+
+void DestroyKeyboard() {
+ XkbSetDetectableAutoRepeat(g.Disp, 0, NULL);
+}
+
+void CheckKeyboard() {
+ uint8_t i, j, found;
+ XEvent evt;
+ XClientMessageEvent *xce;
+ uint16_t Key;
+
+ while (XPending(g.Disp)) {
+ XNextEvent(g.Disp, &evt);
+ switch (evt.type) {
+ case KeyPress:
+ Key = XLookupKeysym((XKeyEvent *)&evt, 0);
+ found = 0;
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < DKEY_TOTAL; j++) {
+ if (g.cfg.PadDef[i].KeyDef[j].Key == Key) {
+ found = 1;
+ g.PadState[i].KeyStatus &= ~(1 << j);
+ }
+ }
+ }
+ if (!found && !AnalogKeyPressed(Key)) {
+ g.KeyLeftOver = Key;
+ }
+ return;
+
+ case KeyRelease:
+ Key = XLookupKeysym((XKeyEvent *)&evt, 0);
+ found = 0;
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < DKEY_TOTAL; j++) {
+ if (g.cfg.PadDef[i].KeyDef[j].Key == Key) {
+ found = 1;
+ g.PadState[i].KeyStatus |= (1 << j);
+ }
+ }
+ }
+ if (!found && !AnalogKeyReleased(Key)) {
+ g.KeyLeftOver = ((long)Key | 0x40000000);
+ }
+ break;
+
+ case ClientMessage:
+ xce = (XClientMessageEvent *)&evt;
+ if (xce->message_type == wmprotocols && (Atom)xce->data.l[0] == wmdelwindow) {
+ // Fake an ESC key if user clicked the close button on window
+ g.KeyLeftOver = XK_Escape;
+ return;
+ }
+ break;
+ }
+ }
+}