From 7fe60435bce6595a9c58a9bfd8244d74b5320e96 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 15 Jan 2013 08:46:13 +0100 Subject: Import DirectFB141_2k11R3_beta5 --- Source/DirectFB/src/input/Makefile.am | 22 + Source/DirectFB/src/input/Makefile.in | 556 +++++++++++ Source/DirectFB/src/input/idirectfbinputbuffer.c | 1121 ++++++++++++++++++++++ Source/DirectFB/src/input/idirectfbinputbuffer.h | 56 ++ Source/DirectFB/src/input/idirectfbinputdevice.c | 446 +++++++++ Source/DirectFB/src/input/idirectfbinputdevice.h | 40 + 6 files changed, 2241 insertions(+) create mode 100755 Source/DirectFB/src/input/Makefile.am create mode 100755 Source/DirectFB/src/input/Makefile.in create mode 100755 Source/DirectFB/src/input/idirectfbinputbuffer.c create mode 100755 Source/DirectFB/src/input/idirectfbinputbuffer.h create mode 100755 Source/DirectFB/src/input/idirectfbinputdevice.c create mode 100755 Source/DirectFB/src/input/idirectfbinputdevice.h (limited to 'Source/DirectFB/src/input') diff --git a/Source/DirectFB/src/input/Makefile.am b/Source/DirectFB/src/input/Makefile.am new file mode 100755 index 0000000..b80f078 --- /dev/null +++ b/Source/DirectFB/src/input/Makefile.am @@ -0,0 +1,22 @@ +## Makefile.am for DirectFB/src/input + +INCLUDES = \ + -I$(top_builddir)/lib \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src + + +internalincludedir = $(INTERNALINCLUDEDIR)/input + +internalinclude_HEADERS = \ + idirectfbinputdevice.h \ + idirectfbinputbuffer.h + + +noinst_LTLIBRARIES = libdirectfb_input.la + +libdirectfb_input_la_SOURCES = \ + idirectfbinputdevice.c \ + idirectfbinputbuffer.c diff --git a/Source/DirectFB/src/input/Makefile.in b/Source/DirectFB/src/input/Makefile.in new file mode 100755 index 0000000..2873417 --- /dev/null +++ b/Source/DirectFB/src/input/Makefile.in @@ -0,0 +1,556 @@ +# Makefile.in generated by automake 1.10.1 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@ +subdir = src/input +DIST_COMMON = $(internalinclude_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libdirectfb_input_la_LIBADD = +am_libdirectfb_input_la_OBJECTS = idirectfbinputdevice.lo \ + idirectfbinputbuffer.lo +libdirectfb_input_la_OBJECTS = $(am_libdirectfb_input_la_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +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 = $(libdirectfb_input_la_SOURCES) +DIST_SOURCES = $(libdirectfb_input_la_SOURCES) +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)$(internalincludedir)" +internalincludeHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(internalinclude_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +ASFLAGS = @ASFLAGS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DFB_CFLAGS_OMIT_FRAME_POINTER = @DFB_CFLAGS_OMIT_FRAME_POINTER@ +DFB_INTERNAL_CFLAGS = @DFB_INTERNAL_CFLAGS@ +DFB_LDFLAGS = @DFB_LDFLAGS@ +DFB_SMOOTH_SCALING = @DFB_SMOOTH_SCALING@ +DIRECTFB_BINARY_AGE = @DIRECTFB_BINARY_AGE@ +DIRECTFB_CSOURCE = @DIRECTFB_CSOURCE@ +DIRECTFB_INTERFACE_AGE = @DIRECTFB_INTERFACE_AGE@ +DIRECTFB_MAJOR_VERSION = @DIRECTFB_MAJOR_VERSION@ +DIRECTFB_MICRO_VERSION = @DIRECTFB_MICRO_VERSION@ +DIRECTFB_MINOR_VERSION = @DIRECTFB_MINOR_VERSION@ +DIRECTFB_VERSION = @DIRECTFB_VERSION@ +DIRECT_BUILD_DEBUG = @DIRECT_BUILD_DEBUG@ +DIRECT_BUILD_DEBUGS = @DIRECT_BUILD_DEBUGS@ +DIRECT_BUILD_GETTID = @DIRECT_BUILD_GETTID@ +DIRECT_BUILD_NETWORK = @DIRECT_BUILD_NETWORK@ +DIRECT_BUILD_STDBOOL = @DIRECT_BUILD_STDBOOL@ +DIRECT_BUILD_TEXT = @DIRECT_BUILD_TEXT@ +DIRECT_BUILD_TRACE = @DIRECT_BUILD_TRACE@ +DSYMUTIL = @DSYMUTIL@ +DYNLIB = @DYNLIB@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +FREETYPE_PROVIDER = @FREETYPE_PROVIDER@ +FUSION_BUILD_KERNEL = @FUSION_BUILD_KERNEL@ +FUSION_BUILD_MULTI = @FUSION_BUILD_MULTI@ +FUSION_MESSAGE_SIZE = @FUSION_MESSAGE_SIZE@ +GIF_PROVIDER = @GIF_PROVIDER@ +GREP = @GREP@ +HAVE_LINUX = @HAVE_LINUX@ +INCLUDEDIR = @INCLUDEDIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTERNALINCLUDEDIR = @INTERNALINCLUDEDIR@ +JPEG_PROVIDER = @JPEG_PROVIDER@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBJPEG = @LIBJPEG@ +LIBOBJS = @LIBOBJS@ +LIBPNG = @LIBPNG@ +LIBPNG_CONFIG = @LIBPNG_CONFIG@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_BINARY = @LT_BINARY@ +LT_CURRENT = @LT_CURRENT@ +LT_RELEASE = @LT_RELEASE@ +LT_REVISION = @LT_REVISION@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAN2HTML = @MAN2HTML@ +MKDIR_P = @MKDIR_P@ +MODULEDIR = @MODULEDIR@ +MODULEDIRNAME = @MODULEDIRNAME@ +NMEDIT = @NMEDIT@ +OBJEXT = @OBJEXT@ +OSX_LIBS = @OSX_LIBS@ +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@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PNG_PROVIDER = @PNG_PROVIDER@ +RANLIB = @RANLIB@ +RUNTIME_SYSROOT = @RUNTIME_SYSROOT@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_LIBS = @SDL_LIBS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOPATH = @SOPATH@ +STRIP = @STRIP@ +SYSCONFDIR = @SYSCONFDIR@ +SYSFS_LIBS = @SYSFS_LIBS@ +THREADFLAGS = @THREADFLAGS@ +THREADLIB = @THREADLIB@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +VERSION = @VERSION@ +VNC_CFLAGS = @VNC_CFLAGS@ +VNC_CONFIG = @VNC_CONFIG@ +VNC_LIBS = @VNC_LIBS@ +X11_CFLAGS = @X11_CFLAGS@ +X11_LIBS = @X11_LIBS@ +ZLIB_LIBS = @ZLIB_LIBS@ +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_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +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@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +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_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +INCLUDES = \ + -I$(top_builddir)/lib \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src + +internalincludedir = $(INTERNALINCLUDEDIR)/input +internalinclude_HEADERS = \ + idirectfbinputdevice.h \ + idirectfbinputbuffer.h + +noinst_LTLIBRARIES = libdirectfb_input.la +libdirectfb_input_la_SOURCES = \ + idirectfbinputdevice.c \ + idirectfbinputbuffer.c + +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 \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/input/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/input/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 + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_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 +libdirectfb_input.la: $(libdirectfb_input_la_OBJECTS) $(libdirectfb_input_la_DEPENDENCIES) + $(LINK) $(libdirectfb_input_la_OBJECTS) $(libdirectfb_input_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idirectfbinputbuffer.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idirectfbinputdevice.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-internalincludeHEADERS: $(internalinclude_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(internalincludedir)" || $(MKDIR_P) "$(DESTDIR)$(internalincludedir)" + @list='$(internalinclude_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(internalincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(internalincludedir)/$$f'"; \ + $(internalincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(internalincludedir)/$$f"; \ + done + +uninstall-internalincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(internalinclude_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(internalincludedir)/$$f'"; \ + rm -f "$(DESTDIR)$(internalincludedir)/$$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; nonemtpy = 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) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(internalincludedir)"; 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-generic clean-libtool clean-noinstLTLIBRARIES \ + 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-internalincludeHEADERS + +install-dvi: install-dvi-am + +install-exec-am: + +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-internalincludeHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am \ + install-internalincludeHEADERS 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-internalincludeHEADERS + +# 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/Source/DirectFB/src/input/idirectfbinputbuffer.c b/Source/DirectFB/src/input/idirectfbinputbuffer.c new file mode 100755 index 0000000..6a4cf08 --- /dev/null +++ b/Source/DirectFB/src/input/idirectfbinputbuffer.c @@ -0,0 +1,1121 @@ +/* + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + Written by Denis Oliver Kropp , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include "idirectfbinputbuffer.h" + + +D_DEBUG_DOMAIN( IDFBEvBuf, "IDFBEventBuffer", "IDirectFBEventBuffer Interface" ); + + +typedef struct { + DirectLink link; + DFBEvent evt; +} EventBufferItem; + +typedef struct { + DirectLink link; + + CoreInputDevice *device; /* pointer to input core device struct */ + Reaction reaction; + + DFBInputDeviceDescription desc; +} AttachedDevice; + +typedef struct { + DirectLink link; + + CoreWindow *window; /* pointer to core window struct */ + Reaction reaction; +} AttachedWindow; + +/* + * private data struct of IDirectFBInputDevice + */ +typedef struct { + int ref; /* reference counter */ + + EventBufferFilterCallback filter; + void *filter_ctx; + + DirectLink *devices; /* attached devices */ + + DirectLink *windows; /* attached windows */ + + DirectLink *events; /* linked list containing events */ + + pthread_mutex_t events_mutex; /* mutex lock for accessing the event queue */ + + pthread_cond_t wait_condition; /* condition for idle wait in WaitForEvent() */ + + bool pipe; /* file descriptor mode? */ + int pipe_fds[2]; /* read & write file descriptor */ + + DirectThread *pipe_thread; /* thread feeding the pipe */ + + DFBEventBufferStats stats; + bool stats_enabled; +} IDirectFBEventBuffer_data; + +/* + * adds an event to the event queue + */ +static void IDirectFBEventBuffer_AddItem( IDirectFBEventBuffer_data *data, + EventBufferItem *item ); + +#ifndef DIRECTFB_PURE_VOODOO +static ReactionResult IDirectFBEventBuffer_InputReact( const void *msg_data, + void *ctx ); + +static ReactionResult IDirectFBEventBuffer_WindowReact( const void *msg_data, + void *ctx ); +#endif + +static void *IDirectFBEventBuffer_Feed( DirectThread *thread, void *arg ); + +static void CollectEventStatistics( DFBEventBufferStats *stats, + const DFBEvent *event, + int incdec ); + + +static void +IDirectFBEventBuffer_Destruct( IDirectFBEventBuffer *thiz ) +{ + IDirectFBEventBuffer_data *data = thiz->priv; + AttachedDevice *device; + AttachedWindow *window; + EventBufferItem *item; + DirectLink *n; + + D_DEBUG_AT( IDFBEvBuf, "%s( %p )\n", __FUNCTION__, thiz ); + + pthread_mutex_lock( &data->events_mutex ); + + if (data->pipe) { + data->pipe = false; + + pthread_cond_broadcast( &data->wait_condition ); + + pthread_mutex_unlock( &data->events_mutex ); + + direct_thread_join( data->pipe_thread ); + direct_thread_destroy( data->pipe_thread ); + + pthread_mutex_lock( &data->events_mutex ); + + close( data->pipe_fds[0] ); + close( data->pipe_fds[1] ); + } + +#ifndef DIRECTFB_PURE_VOODOO + direct_list_foreach_safe (device, n, data->devices) { + dfb_input_detach( device->device, &device->reaction ); + + D_FREE( device ); + } + + direct_list_foreach_safe (window, n, data->windows) { + if (window->window) { + dfb_window_detach( window->window, &window->reaction ); + dfb_window_unref( window->window ); + } + + D_FREE( window ); + } +#endif + + direct_list_foreach_safe (item, n, data->events) + D_FREE( item ); + + pthread_cond_destroy( &data->wait_condition ); + pthread_mutex_destroy( &data->events_mutex ); + + DIRECT_DEALLOCATE_INTERFACE( thiz ); +} + +static DirectResult +IDirectFBEventBuffer_AddRef( IDirectFBEventBuffer *thiz ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p )\n", __FUNCTION__, thiz ); + + data->ref++; + + return DFB_OK; +} + +static DirectResult +IDirectFBEventBuffer_Release( IDirectFBEventBuffer *thiz ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p )\n", __FUNCTION__, thiz ); + + if (--data->ref == 0) + IDirectFBEventBuffer_Destruct( thiz ); + + return DFB_OK; +} + +static DFBResult +IDirectFBEventBuffer_Reset( IDirectFBEventBuffer *thiz ) +{ + EventBufferItem *item; + DirectLink *n; + + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p )\n", __FUNCTION__, thiz ); + + if (data->pipe) + return DFB_UNSUPPORTED; + + pthread_mutex_lock( &data->events_mutex ); + + direct_list_foreach_safe (item, n, data->events) + D_FREE( item ); + + data->events = NULL; + + pthread_mutex_unlock( &data->events_mutex ); + + return DFB_OK; +} + +static DFBResult +IDirectFBEventBuffer_WaitForEvent( IDirectFBEventBuffer *thiz ) +{ + DFBResult ret = DFB_OK; + + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p )\n", __FUNCTION__, thiz ); + + if (data->pipe) + return DFB_UNSUPPORTED; + + pthread_mutex_lock( &data->events_mutex ); + + if (!data->events) + pthread_cond_wait( &data->wait_condition, &data->events_mutex ); + if (!data->events) + ret = DFB_INTERRUPTED; + + pthread_mutex_unlock( &data->events_mutex ); + + return ret; +} + +static DFBResult +IDirectFBEventBuffer_WaitForEventWithTimeout( IDirectFBEventBuffer *thiz, + unsigned int seconds, + unsigned int milli_seconds ) +{ + struct timespec timeout; + DFBResult ret = DFB_OK; + int locked = 0; + long int nano_seconds = milli_seconds * 1000000; + + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, %u, %u )\n", __FUNCTION__, thiz, seconds, milli_seconds ); + + if (data->pipe) + return DFB_UNSUPPORTED; + + if (pthread_mutex_trylock( &data->events_mutex ) == 0) { + if (data->events) { + pthread_mutex_unlock ( &data->events_mutex ); + return ret; + } + locked = 1; + } + + direct_util_get_monotonic_pthread_timeout(&timeout, seconds, nano_seconds); + + if (!locked) + pthread_mutex_lock( &data->events_mutex ); + + if (!data->events) { + if (pthread_cond_timedwait( &data->wait_condition, + &data->events_mutex, + &timeout ) == ETIMEDOUT) + ret = DFB_TIMEOUT; + else if (!data->events) + ret = DFB_INTERRUPTED; + } + + pthread_mutex_unlock( &data->events_mutex ); + + return ret; +} + +static DFBResult +IDirectFBEventBuffer_WakeUp( IDirectFBEventBuffer *thiz ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p )\n", __FUNCTION__, thiz ); + + if (data->pipe) + return DFB_UNSUPPORTED; + + pthread_cond_broadcast( &data->wait_condition ); + + return DFB_OK; +} + +static DFBResult +IDirectFBEventBuffer_GetEvent( IDirectFBEventBuffer *thiz, + DFBEvent *event ) +{ + EventBufferItem *item; + + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, %p )\n", __FUNCTION__, thiz, event ); + + if (data->pipe) + return DFB_UNSUPPORTED; + + pthread_mutex_lock( &data->events_mutex ); + + if (!data->events) { + pthread_mutex_unlock( &data->events_mutex ); + return DFB_BUFFEREMPTY; + } + + item = (EventBufferItem*) data->events; + + switch (item->evt.clazz) { + case DFEC_INPUT: + event->input = item->evt.input; + break; + + case DFEC_WINDOW: + event->window = item->evt.window; + break; + + case DFEC_USER: + event->user = item->evt.user; + break; + + case DFEC_VIDEOPROVIDER: + event->videoprovider = item->evt.videoprovider; + break; + + case DFEC_UNIVERSAL: + direct_memcpy( event, &item->evt, item->evt.universal.size ); + break; + + default: + D_BUG("unknown event class"); + } + + if (data->stats_enabled) + CollectEventStatistics( &data->stats, &item->evt, -1 ); + + direct_list_remove( &data->events, &item->link ); + + D_FREE( item ); + + pthread_mutex_unlock( &data->events_mutex ); + + D_DEBUG_AT( IDFBEvBuf, " -> class %d, type/size %d, data/id %p\n", event->clazz, event->user.type, event->user.data ); + + return DFB_OK; +} + +static DFBResult +IDirectFBEventBuffer_PeekEvent( IDirectFBEventBuffer *thiz, + DFBEvent *event ) +{ + EventBufferItem *item; + + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, %p )\n", __FUNCTION__, thiz, event ); + + if (data->pipe) + return DFB_UNSUPPORTED; + + pthread_mutex_lock( &data->events_mutex ); + + if (!data->events) { + pthread_mutex_unlock( &data->events_mutex ); + return DFB_BUFFEREMPTY; + } + + item = (EventBufferItem*) data->events; + + switch (item->evt.clazz) { + case DFEC_INPUT: + event->input = item->evt.input; + break; + + case DFEC_WINDOW: + event->window = item->evt.window; + break; + + case DFEC_USER: + event->user = item->evt.user; + break; + + case DFEC_VIDEOPROVIDER: + event->videoprovider = item->evt.videoprovider; + break; + + case DFEC_UNIVERSAL: + direct_memcpy( event, &item->evt, item->evt.universal.size ); + break; + + default: + D_BUG("unknown event class"); + } + + pthread_mutex_unlock( &data->events_mutex ); + + D_DEBUG_AT( IDFBEvBuf, " -> class %d, type/size %d, data/id %p\n", event->clazz, event->user.type, event->user.data ); + + return DFB_OK; +} + +static DFBResult +IDirectFBEventBuffer_HasEvent( IDirectFBEventBuffer *thiz ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p ) <- events: %p, pipe: %d\n", __FUNCTION__, thiz, data->events, data->pipe ); + + if (data->pipe) + return DFB_UNSUPPORTED; + + return (data->events ? DFB_OK : DFB_BUFFEREMPTY); +} + +static DFBResult +IDirectFBEventBuffer_PostEvent( IDirectFBEventBuffer *thiz, + const DFBEvent *event ) +{ + EventBufferItem *item; + int size; + + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, %p [class %d, type/size %d, data/id %p] )\n", __FUNCTION__, + thiz, event, event->clazz, event->user.type, event->user.data ); + + switch (event->clazz) { + case DFEC_INPUT: + case DFEC_WINDOW: + case DFEC_USER: + case DFEC_VIDEOPROVIDER: + size = sizeof(EventBufferItem); + break; + + case DFEC_UNIVERSAL: + size = event->universal.size; + if (size < sizeof(DFBUniversalEvent)) + return DFB_INVARG; + /* We must not exceed the union to avoid crashes in generic code (reading DFBEvents) + * and to support pipe mode where each written block has to have a fixed size. */ + if (size > sizeof(DFBEvent)) + return DFB_INVARG; + size += sizeof(DirectLink); + break; + + default: + return DFB_INVARG; + } + + item = D_CALLOC( 1, size ); + if (!item) + return D_OOM(); + + switch (event->clazz) { + case DFEC_INPUT: + item->evt.input = event->input; + break; + + case DFEC_WINDOW: + item->evt.window = event->window; + break; + + case DFEC_USER: + item->evt.user = event->user; + break; + + case DFEC_VIDEOPROVIDER: + item->evt.videoprovider = event->videoprovider; + break; + + case DFEC_UNIVERSAL: + direct_memcpy( &item->evt, event, event->universal.size ); + break; + + default: + D_BUG("unexpected event class"); + } + + IDirectFBEventBuffer_AddItem( data, item ); + + return DFB_OK; +} + +static DFBResult +IDirectFBEventBuffer_CreateFileDescriptor( IDirectFBEventBuffer *thiz, + int *ret_fd ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p )\n", __FUNCTION__, thiz ); + + /* Check arguments. */ + if (!ret_fd) + return DFB_INVARG; + + /* Lock the event queue. */ + pthread_mutex_lock( &data->events_mutex ); + + /* Already in pipe mode? */ + if (data->pipe) { + pthread_mutex_unlock( &data->events_mutex ); + return DFB_BUSY; + } + + /* Create the file descriptor(s). */ + if (socketpair( PF_LOCAL, SOCK_STREAM, 0, data->pipe_fds )) { + D_PERROR( "%s(): socketpair( PF_LOCAL, SOCK_STREAM, 0, fds ) failed!\n", __FUNCTION__ ); + pthread_mutex_unlock( &data->events_mutex ); + return errno2result( errno ); + } + + D_DEBUG_AT( IDFBEvBuf, " -> entering pipe mode\n" ); + + /* Enter pipe mode. */ + data->pipe = true; + + /* Signal any waiting processes. */ + pthread_cond_broadcast( &data->wait_condition ); + + /* Create the feeding thread. */ + data->pipe_thread = direct_thread_create( DTT_MESSAGING, + IDirectFBEventBuffer_Feed, data, + "EventBufferFeed" ); + + /* Unlock the event queue. */ + pthread_mutex_unlock( &data->events_mutex ); + + /* Return the file descriptor for reading. */ + *ret_fd = data->pipe_fds[0]; + + D_DEBUG_AT( IDFBEvBuf, " -> fd %d/%d\n", data->pipe_fds[0], data->pipe_fds[1] ); + + return DFB_OK; +} + +static DFBResult +IDirectFBEventBuffer_EnableStatistics( IDirectFBEventBuffer *thiz, + DFBBoolean enable ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, %sable )\n", __FUNCTION__, thiz, enable ? "en" : "dis" ); + + /* Lock the event queue. */ + pthread_mutex_lock( &data->events_mutex ); + + /* Already enabled/disabled? */ + if (data->stats_enabled == !!enable) { + pthread_mutex_unlock( &data->events_mutex ); + return DFB_OK; + } + + if (enable) { + EventBufferItem *item; + + /* Collect statistics for events already in the queue. */ + direct_list_foreach (item, data->events) + CollectEventStatistics( &data->stats, &item->evt, 1 ); + } + else { + /* Clear statistics. */ + memset( &data->stats, 0, sizeof(DFBEventBufferStats) ); + } + + /* Remember state. */ + data->stats_enabled = !!enable; + + /* Unlock the event queue. */ + pthread_mutex_unlock( &data->events_mutex ); + + return DFB_OK; +} + +static DFBResult +IDirectFBEventBuffer_GetStatistics( IDirectFBEventBuffer *thiz, + DFBEventBufferStats *ret_stats ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, %p )\n", __FUNCTION__, thiz, ret_stats ); + + if (!ret_stats) + return DFB_INVARG; + + /* Lock the event queue. */ + pthread_mutex_lock( &data->events_mutex ); + + /* Not enabled? */ + if (!data->stats_enabled) { + pthread_mutex_unlock( &data->events_mutex ); + return DFB_UNSUPPORTED; + } + + /* Return current stats. */ + *ret_stats = data->stats; + + /* Unlock the event queue. */ + pthread_mutex_unlock( &data->events_mutex ); + + return DFB_OK; +} + +DFBResult +IDirectFBEventBuffer_Construct( IDirectFBEventBuffer *thiz, + EventBufferFilterCallback filter, + void *filter_ctx ) +{ + DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IDirectFBEventBuffer) + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, filter %p, ctx %p )\n", __FUNCTION__, thiz, filter, filter_ctx ); + + data->ref = 1; + data->filter = filter; + data->filter_ctx = filter_ctx; + + direct_util_recursive_pthread_mutex_init( &data->events_mutex ); + direct_util_monotonic_pthread_cond_init( &data->wait_condition ); + + thiz->AddRef = IDirectFBEventBuffer_AddRef; + thiz->Release = IDirectFBEventBuffer_Release; + thiz->Reset = IDirectFBEventBuffer_Reset; + thiz->WaitForEvent = IDirectFBEventBuffer_WaitForEvent; + thiz->WaitForEventWithTimeout = IDirectFBEventBuffer_WaitForEventWithTimeout; + thiz->GetEvent = IDirectFBEventBuffer_GetEvent; + thiz->PeekEvent = IDirectFBEventBuffer_PeekEvent; + thiz->HasEvent = IDirectFBEventBuffer_HasEvent; + thiz->PostEvent = IDirectFBEventBuffer_PostEvent; + thiz->WakeUp = IDirectFBEventBuffer_WakeUp; + thiz->CreateFileDescriptor = IDirectFBEventBuffer_CreateFileDescriptor; + thiz->EnableStatistics = IDirectFBEventBuffer_EnableStatistics; + thiz->GetStatistics = IDirectFBEventBuffer_GetStatistics; + + D_DEBUG_AT( IDFBEvBuf, " -> %p [%p]\n", thiz, thiz->priv ); + + return DFB_OK; +} + +/* directfb internals */ + +#ifndef DIRECTFB_PURE_VOODOO +DFBResult IDirectFBEventBuffer_AttachInputDevice( IDirectFBEventBuffer *thiz, + CoreInputDevice *device ) +{ + AttachedDevice *attached; + DFBInputDeviceDescription desc; + + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_ASSERT( device != NULL ); + + dfb_input_device_description( device, &desc ); + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, %p [%02u - %s] )\n", __FUNCTION__, thiz, device, + dfb_input_device_id(device), desc.name ); + + attached = D_CALLOC( 1, sizeof(AttachedDevice) ); + attached->device = device; + attached->desc = desc; + + direct_list_prepend( &data->devices, &attached->link ); + + dfb_input_attach( device, IDirectFBEventBuffer_InputReact, + data, &attached->reaction ); + + return DFB_OK; +} + +DFBResult IDirectFBEventBuffer_DetachInputDevice( IDirectFBEventBuffer *thiz, + CoreInputDevice *device ) +{ + AttachedDevice *attached; + DirectLink *link; + + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_ASSERT( device != NULL ); + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, %p [%02u] )\n", __FUNCTION__, thiz, device, + dfb_input_device_id(device) ); + + direct_list_foreach_safe (attached, link, data->devices) { + if (attached->device == device) { + direct_list_remove( &data->devices, &attached->link ); + + dfb_input_detach( attached->device, &attached->reaction ); + + D_FREE( attached ); + + return DFB_OK; + } + } + + return DFB_ITEMNOTFOUND; +} + +DFBResult IDirectFBEventBuffer_AttachWindow( IDirectFBEventBuffer *thiz, + CoreWindow *window ) +{ + AttachedWindow *attached; + + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_ASSERT( window != NULL ); + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, %p [%02u - %d,%d-%dx%d] )\n", __FUNCTION__, thiz, + window, window->id, window->config.bounds.x, window->config.bounds.y, + window->config.bounds.w, window->config.bounds.h ); + + attached = D_CALLOC( 1, sizeof(AttachedWindow) ); + attached->window = window; + + window->caps &= ~DWCAPS_NOFOCUS; //no focus patch PR brg36mgr#118432 + + dfb_window_ref( window ); + + direct_list_prepend( &data->windows, &attached->link ); + + dfb_window_attach( window, IDirectFBEventBuffer_WindowReact, + data, &attached->reaction ); + + return DFB_OK; +} + +DFBResult IDirectFBEventBuffer_DetachWindow( IDirectFBEventBuffer *thiz, + CoreWindow *window ) +{ + AttachedWindow *attached; + DirectLink *link; + + DIRECT_INTERFACE_GET_DATA(IDirectFBEventBuffer) + + D_ASSERT( window != NULL ); + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, %p [%02u - %d,%d-%dx%d] )\n", __FUNCTION__, thiz, + window, window->id, window->config.bounds.x, window->config.bounds.y, + window->config.bounds.w, window->config.bounds.h ); + + direct_list_foreach_safe (attached, link, data->windows) { + if (!attached->window || attached->window == window) { + direct_list_remove( &data->windows, &attached->link ); + + if (attached->window) { + dfb_window_detach( attached->window, &attached->reaction ); + dfb_window_unref( attached->window ); + } + + D_FREE( attached ); + } + } + + return DFB_OK; +} +#endif + +/* file internals */ + +static void IDirectFBEventBuffer_AddItem( IDirectFBEventBuffer_data *data, + EventBufferItem *item ) +{ + if (data->filter && data->filter( &item->evt, data->filter_ctx )) { + D_FREE( item ); + return; + } + + pthread_mutex_lock( &data->events_mutex ); + + if (data->stats_enabled) + CollectEventStatistics( &data->stats, &item->evt, 1 ); + + direct_list_append( &data->events, &item->link ); + + pthread_cond_broadcast( &data->wait_condition ); + + pthread_mutex_unlock( &data->events_mutex ); +} + +#ifndef DIRECTFB_PURE_VOODOO +static ReactionResult IDirectFBEventBuffer_InputReact( const void *msg_data, + void *ctx ) +{ + const DFBInputEvent *evt = msg_data; + IDirectFBEventBuffer_data *data = ctx; + EventBufferItem *item; + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, %p ) <- type %06x\n", __FUNCTION__, evt, data, evt->type ); + + if (dfb_config->discard_repeat_events && (evt->flags & DIEF_REPEAT)) { + D_DEBUG_AT( IDFBEvBuf, " -> discarding repeat event!\n" ); + return DFB_OK; + } + + item = D_CALLOC( 1, sizeof(EventBufferItem) ); + + item->evt.input = *evt; + item->evt.clazz = DFEC_INPUT; + + IDirectFBEventBuffer_AddItem( data, item ); + + return RS_OK; +} + +static ReactionResult IDirectFBEventBuffer_WindowReact( const void *msg_data, + void *ctx ) +{ + const DFBWindowEvent *evt = msg_data; + IDirectFBEventBuffer_data *data = ctx; + EventBufferItem *item; + + D_DEBUG_AT( IDFBEvBuf, "%s( %p, %p ) <- type %06x\n", __FUNCTION__, evt, data, evt->type ); + + if (dfb_config->discard_repeat_events && (evt->flags & DWEF_REPEAT)) { + D_DEBUG_AT( IDFBEvBuf, " -> discarding repeat event!\n" ); + return DFB_OK; + } + + item = D_CALLOC( 1, sizeof(EventBufferItem) ); + + item->evt.window = *evt; + item->evt.clazz = DFEC_WINDOW; + + IDirectFBEventBuffer_AddItem( data, item ); + + if (evt->type == DWET_DESTROYED) { + AttachedWindow *window; + + direct_list_foreach (window, data->windows) { + if (!window->window) + continue; + + if (dfb_window_id( window->window ) == evt->window_id) { + /* FIXME: free memory later, because reactor writes to it + after we return RS_REMOVE */ + dfb_window_unref( window->window ); + window->window = NULL; + } + } + + return RS_REMOVE; + } + + return RS_OK; +} +#endif + +static void * +IDirectFBEventBuffer_Feed( DirectThread *thread, void *arg ) +{ + IDirectFBEventBuffer_data *data = arg; + + pthread_mutex_lock( &data->events_mutex ); + + while (data->pipe) { + while (data->events && data->pipe) { + int ret; + EventBufferItem *item = (EventBufferItem*) data->events; + + if (data->stats_enabled) + CollectEventStatistics( &data->stats, &item->evt, -1 ); + + direct_list_remove( &data->events, &item->link ); + + if (item->evt.clazz == DFEC_UNIVERSAL) { + D_WARN( "universal events not supported in pipe mode" ); + continue; + } + + pthread_mutex_unlock( &data->events_mutex ); + + D_DEBUG_AT( IDFBEvBuf, "Going to write %zu bytes to file descriptor %d...\n", + sizeof(DFBEvent), data->pipe_fds[1] ); + + ret = write( data->pipe_fds[1], &item->evt, sizeof(DFBEvent) ); + + D_DEBUG_AT( IDFBEvBuf, "...wrote %d bytes to file descriptor %d.\n", + ret, data->pipe_fds[1] ); + + D_FREE( item ); + + pthread_mutex_lock( &data->events_mutex ); + } + + if (data->pipe) + pthread_cond_wait( &data->wait_condition, &data->events_mutex ); + } + + pthread_mutex_unlock( &data->events_mutex ); + + return NULL; +} + +static void +CollectEventStatistics( DFBEventBufferStats *stats, + const DFBEvent *event, + int incdec ) +{ + stats->num_events += incdec; + + switch (event->clazz) { + case DFEC_INPUT: + stats->DFEC_INPUT += incdec; + + switch (event->input.type) { + case DIET_KEYPRESS: + stats->DIET_KEYPRESS += incdec; + break; + + case DIET_KEYRELEASE: + stats->DIET_KEYRELEASE += incdec; + break; + + case DIET_BUTTONPRESS: + stats->DIET_BUTTONPRESS += incdec; + break; + + case DIET_BUTTONRELEASE: + stats->DIET_BUTTONRELEASE += incdec; + break; + + case DIET_AXISMOTION: + stats->DIET_AXISMOTION += incdec; + break; + + default: + D_BUG( "unknown input event type 0x%08x\n", event->input.type ); + } + break; + + case DFEC_WINDOW: + stats->DFEC_WINDOW += incdec; + + switch (event->window.type) { + case DWET_POSITION: + stats->DWET_POSITION += incdec; + break; + + case DWET_SIZE: + stats->DWET_SIZE += incdec; + break; + + case DWET_CLOSE: + stats->DWET_CLOSE += incdec; + break; + + case DWET_DESTROYED: + stats->DWET_DESTROYED += incdec; + break; + + case DWET_GOTFOCUS: + stats->DWET_GOTFOCUS += incdec; + break; + + case DWET_LOSTFOCUS: + stats->DWET_LOSTFOCUS += incdec; + break; + + case DWET_KEYDOWN: + stats->DWET_KEYDOWN += incdec; + break; + + case DWET_KEYUP: + stats->DWET_KEYUP += incdec; + break; + + case DWET_BUTTONDOWN: + stats->DWET_BUTTONDOWN += incdec; + break; + + case DWET_BUTTONUP: + stats->DWET_BUTTONUP += incdec; + break; + + case DWET_MOTION: + stats->DWET_MOTION += incdec; + break; + + case DWET_ENTER: + stats->DWET_ENTER += incdec; + break; + + case DWET_LEAVE: + stats->DWET_LEAVE += incdec; + break; + + case DWET_WHEEL: + stats->DWET_WHEEL += incdec; + break; + + case DWET_POSITION_SIZE: + stats->DWET_POSITION_SIZE += incdec; + break; + + default: + D_BUG( "unknown window event type 0x%08x\n", event->window.type ); + } + break; + + case DFEC_USER: + stats->DFEC_USER += incdec; + break; + + case DFEC_VIDEOPROVIDER: + stats->DFEC_VIDEOPROVIDER +=incdec; + + switch (event->videoprovider.type) { + case DVPET_STARTED: + stats->DVPET_STARTED += incdec; + break; + + case DVPET_STOPPED: + stats->DVPET_STOPPED += incdec; + break; + + case DVPET_SPEEDCHANGE: + stats->DVPET_SPEEDCHANGE += incdec; + break; + + case DVPET_STREAMCHANGE: + stats->DVPET_STREAMCHANGE += incdec; + break; + + case DVPET_FATALERROR: + stats->DVPET_FATALERROR += incdec; + break; + + case DVPET_FINISHED: + stats->DVPET_FINISHED += incdec; + break; + + case DVPET_SURFACECHANGE: + stats->DVPET_SURFACECHANGE += incdec; + break; + + case DVPET_FRAMEDECODED: + stats->DVPET_FRAMEDECODED += incdec; + break; + + case DVPET_FRAMEDISPLAYED: + stats->DVPET_FRAMEDISPLAYED += incdec; + break; + + case DVPET_DATAEXHAUSTED: + stats->DVPET_DATAEXHAUSTED += incdec; + break; + + case DVPET_VIDEOACTION: + stats->DVPET_VIDEOACTION += incdec; + break; + + case DVPET_DATALOW: + stats->DVPET_DATALOW += incdec; + break; + + case DVPET_DATAHIGH: + stats->DVPET_DATAHIGH += incdec; + break; + + case DVPET_BUFFERTIMELOW: + stats->DVPET_BUFFERTIMELOW += incdec; + break; + + case DVPET_BUFFERTIMEHIGH: + stats->DVPET_BUFFERTIMEHIGH += incdec; + break; + + default: + D_BUG( "unknown video provider event type 0x%08x\n", event->videoprovider.type ); + } + break; + + case DFEC_UNIVERSAL: + stats->DFEC_UNIVERSAL += incdec; + break; + + default: + D_BUG( "unknown event class 0x%08x\n", event->clazz ); + } +} + diff --git a/Source/DirectFB/src/input/idirectfbinputbuffer.h b/Source/DirectFB/src/input/idirectfbinputbuffer.h new file mode 100755 index 0000000..53b263b --- /dev/null +++ b/Source/DirectFB/src/input/idirectfbinputbuffer.h @@ -0,0 +1,56 @@ +/* + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + Written by Denis Oliver Kropp , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef __IDIRECTFBEVENTBUFFER_H__ +#define __IDIRECTFBEVENTBUFFER_H__ + +#include +#include + +typedef bool (*EventBufferFilterCallback)( DFBEvent *evt, + void *ctx ); + +/* + * initializes event buffer, adds it to input listeners and initializes mutexes + */ +DFBResult IDirectFBEventBuffer_Construct( IDirectFBEventBuffer *thiz, + EventBufferFilterCallback filter, + void *filter_ctx ); + +DFBResult IDirectFBEventBuffer_AttachInputDevice( IDirectFBEventBuffer *thiz, + CoreInputDevice *device ); +DFBResult IDirectFBEventBuffer_DetachInputDevice( IDirectFBEventBuffer *thiz, + CoreInputDevice *device ); + +DFBResult IDirectFBEventBuffer_AttachWindow( IDirectFBEventBuffer *thiz, + CoreWindow *window ); +DFBResult IDirectFBEventBuffer_DetachWindow( IDirectFBEventBuffer *thiz, + CoreWindow *window ); + + +#endif diff --git a/Source/DirectFB/src/input/idirectfbinputdevice.c b/Source/DirectFB/src/input/idirectfbinputdevice.c new file mode 100755 index 0000000..f00af8e --- /dev/null +++ b/Source/DirectFB/src/input/idirectfbinputdevice.c @@ -0,0 +1,446 @@ +/* + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + Written by Denis Oliver Kropp , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include + +#include +#include +#include + +#include + +#include + +#include + +#include +#include + +#include + +#include +#include +#include + +#include "idirectfbinputdevice.h" +#include "idirectfbinputbuffer.h" + + +/* + * processes an event, updates device state + * (funcion is added to the event listeners) + */ +static ReactionResult +IDirectFBInputDevice_React( const void *msg_data, + void *ctx ); + +/* + * private data struct of IDirectFBInputDevice + */ +typedef struct { + int ref; /* reference counter */ + CoreInputDevice *device; /* pointer to input core + device struct*/ + + int axis[DIAI_LAST+1]; /* position of all axes */ + DFBInputDeviceKeyState keystates[DIKI_NUMBER_OF_KEYS]; + /* state of all keys */ + DFBInputDeviceModifierMask modifiers; /* bitmask reflecting the + state of the modifier + keys */ + DFBInputDeviceLockState locks; /* bitmask reflecting the + state of the key locks */ + DFBInputDeviceButtonMask buttonmask; /* bitmask reflecting the + state of the buttons */ + + DFBInputDeviceDescription desc; /* device description */ + + Reaction reaction; +} IDirectFBInputDevice_data; + + + +static void +IDirectFBInputDevice_Destruct( IDirectFBInputDevice *thiz ) +{ + IDirectFBInputDevice_data *data = (IDirectFBInputDevice_data*)thiz->priv; + + dfb_input_detach( data->device, &data->reaction ); + + DIRECT_DEALLOCATE_INTERFACE( thiz ); +} + +static DirectResult +IDirectFBInputDevice_AddRef( IDirectFBInputDevice *thiz ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + data->ref++; + + return DFB_OK; +} + +static DirectResult +IDirectFBInputDevice_Release( IDirectFBInputDevice *thiz ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (--data->ref == 0) + IDirectFBInputDevice_Destruct( thiz ); + + return DFB_OK; +} + +static DFBResult +IDirectFBInputDevice_GetID( IDirectFBInputDevice *thiz, + DFBInputDeviceID *id ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!id) + return DFB_INVARG; + + *id = dfb_input_device_id( data->device ); + + return DFB_OK; +} + +static DFBResult +IDirectFBInputDevice_CreateEventBuffer( IDirectFBInputDevice *thiz, + IDirectFBEventBuffer **buffer ) +{ + IDirectFBEventBuffer *b; + + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + DIRECT_ALLOCATE_INTERFACE( b, IDirectFBEventBuffer ); + + IDirectFBEventBuffer_Construct( b, NULL, NULL ); + + IDirectFBEventBuffer_AttachInputDevice( b, data->device ); + + *buffer = b; + + return DFB_OK; +} + +static DFBResult +IDirectFBInputDevice_AttachEventBuffer( IDirectFBInputDevice *thiz, + IDirectFBEventBuffer *buffer ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + return IDirectFBEventBuffer_AttachInputDevice( buffer, data->device ); +} + +static DFBResult +IDirectFBInputDevice_DetachEventBuffer( IDirectFBInputDevice *thiz, + IDirectFBEventBuffer *buffer ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + return IDirectFBEventBuffer_DetachInputDevice( buffer, data->device ); +} + +static DFBResult +IDirectFBInputDevice_GetDescription( IDirectFBInputDevice *thiz, + DFBInputDeviceDescription *desc ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!desc) + return DFB_INVARG; + + *desc = data->desc; + + return DFB_OK; +} + +static DFBResult +IDirectFBInputDevice_GetKeymapEntry( IDirectFBInputDevice *thiz, + int keycode, + DFBInputDeviceKeymapEntry *entry ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!entry) + return DFB_INVARG; + + if (data->desc.min_keycode < 0 || data->desc.max_keycode < 0) + return DFB_UNSUPPORTED; + + if (keycode < data->desc.min_keycode || + keycode > data->desc.max_keycode) + return DFB_INVARG; + + return dfb_input_device_get_keymap_entry( data->device, keycode, entry ); +} + +static DFBResult +IDirectFBInputDevice_SetKeymapEntry( IDirectFBInputDevice *thiz, + int keycode, + DFBInputDeviceKeymapEntry *entry ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!entry) + return DFB_INVARG; + + if (data->desc.min_keycode < 0 || data->desc.max_keycode < 0) + return DFB_UNSUPPORTED; + + if (keycode < data->desc.min_keycode || + keycode > data->desc.max_keycode) + return DFB_INVARG; + + return dfb_input_device_set_keymap_entry( data->device, keycode, entry ); +} + +static DFBResult +IDirectFBInputDevice_LoadKeymap ( IDirectFBInputDevice *thiz, + char *filename ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!filename) + return DFB_INVARG; + + return dfb_input_device_load_keymap( data->device, filename ); +} + +static DFBResult +IDirectFBInputDevice_GetKeyState( IDirectFBInputDevice *thiz, + DFBInputDeviceKeyIdentifier key_id, + DFBInputDeviceKeyState *state ) +{ + unsigned int index = key_id - DFB_KEY(IDENTIFIER, 0); + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!state || index >= DIKI_NUMBER_OF_KEYS) + return DFB_INVARG; + + *state = data->keystates[index]; + + return DFB_OK; +} + +static DFBResult +IDirectFBInputDevice_GetModifiers( IDirectFBInputDevice *thiz, + DFBInputDeviceModifierMask *modifiers ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!modifiers) + return DFB_INVARG; + + *modifiers = data->modifiers; + + return DFB_OK; +} + +static DFBResult +IDirectFBInputDevice_GetLockState( IDirectFBInputDevice *thiz, + DFBInputDeviceLockState *locks ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!locks) + return DFB_INVARG; + + *locks = data->locks; + + return DFB_OK; +} + +static DFBResult +IDirectFBInputDevice_GetButtons( IDirectFBInputDevice *thiz, + DFBInputDeviceButtonMask *buttons ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!buttons) + return DFB_INVARG; + + *buttons = data->buttonmask; + + return DFB_OK; +} + +static DFBResult +IDirectFBInputDevice_GetButtonState( IDirectFBInputDevice *thiz, + DFBInputDeviceButtonIdentifier button, + DFBInputDeviceButtonState *state) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!state || (int)button < DIBI_FIRST || button > DIBI_LAST) + return DFB_INVARG; + + *state = (data->buttonmask & (1 << button)) ? DIBS_DOWN : DIBS_UP; + + return DFB_OK; +} + +static DFBResult +IDirectFBInputDevice_GetAxis( IDirectFBInputDevice *thiz, + DFBInputDeviceAxisIdentifier axis, + int *pos ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!pos || (int)axis < DIAI_FIRST || axis > DIAI_LAST) + return DFB_INVARG; + + *pos = data->axis[axis]; + + return DFB_OK; +} + +static DFBResult +IDirectFBInputDevice_GetXY( IDirectFBInputDevice *thiz, + int *x, + int *y ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!x && !y) + return DFB_INVARG; + + if (x) + *x = data->axis[DIAI_X]; + + if (y) + *y = data->axis[DIAI_Y]; + + return DFB_OK; +} + +static DFBResult +IDirectFBInputDevice_SetSensitivity( IDirectFBInputDevice *thiz, + int sensitivity ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + return dfb_input_device_set_sensitivity( data->device, sensitivity ); +} + +static DFBResult +IDirectFBInputDevice_GetState( IDirectFBInputDevice *thiz, + DFBInputDeviceState *state ) +{ + DIRECT_INTERFACE_GET_DATA(IDirectFBInputDevice) + + if (!state) + return DFB_INVARG; + + return dfb_input_device_get_state( data->device, state ); +} + + +DFBResult +IDirectFBInputDevice_Construct( IDirectFBInputDevice *thiz, + CoreInputDevice *device ) +{ + DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IDirectFBInputDevice) + + data->ref = 1; + data->device = device; + + dfb_input_device_description( device, &data->desc ); + + dfb_input_attach( data->device, IDirectFBInputDevice_React, + data, &data->reaction ); + + thiz->AddRef = IDirectFBInputDevice_AddRef; + thiz->Release = IDirectFBInputDevice_Release; + thiz->GetID = IDirectFBInputDevice_GetID; + thiz->GetDescription = IDirectFBInputDevice_GetDescription; + thiz->GetKeymapEntry = IDirectFBInputDevice_GetKeymapEntry; + thiz->SetKeymapEntry = IDirectFBInputDevice_SetKeymapEntry; + thiz->LoadKeymap = IDirectFBInputDevice_LoadKeymap; + thiz->CreateEventBuffer = IDirectFBInputDevice_CreateEventBuffer; + thiz->AttachEventBuffer = IDirectFBInputDevice_AttachEventBuffer; + thiz->DetachEventBuffer = IDirectFBInputDevice_DetachEventBuffer; + thiz->GetKeyState = IDirectFBInputDevice_GetKeyState; + thiz->GetModifiers = IDirectFBInputDevice_GetModifiers; + thiz->GetLockState = IDirectFBInputDevice_GetLockState; + thiz->GetButtons = IDirectFBInputDevice_GetButtons; + thiz->GetButtonState = IDirectFBInputDevice_GetButtonState; + thiz->GetAxis = IDirectFBInputDevice_GetAxis; + thiz->GetXY = IDirectFBInputDevice_GetXY; + thiz->SetSensitivity = IDirectFBInputDevice_SetSensitivity; + thiz->GetState = IDirectFBInputDevice_GetState; + + return DFB_OK; +} + + +/* internals */ + +static ReactionResult +IDirectFBInputDevice_React( const void *msg_data, + void *ctx ) +{ + const DFBInputEvent *evt = msg_data; + IDirectFBInputDevice_data *data = ctx; + unsigned int index; + + if (evt->flags & DIEF_MODIFIERS) + data->modifiers = evt->modifiers; + if (evt->flags & DIEF_LOCKS) + data->locks = evt->locks; + if (evt->flags & DIEF_BUTTONS) + data->buttonmask = evt->buttons; + + switch (evt->type) { + case DIET_KEYPRESS: + index = evt->key_id - DFB_KEY(IDENTIFIER, 0); + if (index < DIKI_NUMBER_OF_KEYS) + data->keystates[index] = DIKS_DOWN; + break; + + case DIET_KEYRELEASE: + index = evt->key_id - DFB_KEY(IDENTIFIER, 0); + if (index < DIKI_NUMBER_OF_KEYS) + data->keystates[index] = DIKS_UP; + break; + + case DIET_AXISMOTION: + if (evt->flags & DIEF_AXISREL) + data->axis[evt->axis] += evt->axisrel; + if (evt->flags & DIEF_AXISABS) + data->axis[evt->axis] = evt->axisabs; + break; + + default: + D_DEBUG( "DirectFB/IDirectFBInputDevice: Unknown event type detected (0x%x), skipping!\n", evt->type ); + } + + return RS_OK; +} + diff --git a/Source/DirectFB/src/input/idirectfbinputdevice.h b/Source/DirectFB/src/input/idirectfbinputdevice.h new file mode 100755 index 0000000..65bdc23 --- /dev/null +++ b/Source/DirectFB/src/input/idirectfbinputdevice.h @@ -0,0 +1,40 @@ +/* + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + Written by Denis Oliver Kropp , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef __IDIRECTFBINPUTDEVICE_H__ +#define __IDIRECTFBINPUTDEVICE_H__ + +#include + +/* + * initializes input device, adds it to input listeners and initializes mutexes + */ +DFBResult IDirectFBInputDevice_Construct( IDirectFBInputDevice *thiz, + CoreInputDevice *device ); + +#endif -- cgit