aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am3
-rw-r--r--src/Makefile.in410
-rw-r--r--src/getopt.c76
-rw-r--r--src/getopt.h16
-rw-r--r--src/ivypointer.c242
5 files changed, 747 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..4af348e
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,3 @@
+bin_PROGRAMS = ivypointer
+ivypointer_SOURCES = ivypointer.c getopt.c
+ivypointer_LDADD = -livy -lX11 -lXtst
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..1247e33
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,410 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006 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 = :
+bin_PROGRAMS = ivypointer$(EXEEXT)
+subdir = src
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(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 =
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_ivypointer_OBJECTS = ivypointer.$(OBJEXT) getopt.$(OBJEXT)
+ivypointer_OBJECTS = $(am_ivypointer_OBJECTS)
+ivypointer_DEPENDENCIES =
+DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(ivypointer_SOURCES)
+DIST_SOURCES = $(ivypointer_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+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@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XMKMF = @XMKMF@
+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@
+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_alias = @build_alias@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+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_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+ivypointer_SOURCES = ivypointer.c getopt.c
+ivypointer_LDADD = -livy -lX11 -lXtst
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in: $(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/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/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: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+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 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(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:
+ -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+ivypointer$(EXEEXT): $(ivypointer_OBJECTS) $(ivypointer_DEPENDENCIES)
+ @rm -f ivypointer$(EXEEXT)
+ $(LINK) $(ivypointer_OBJECTS) $(ivypointer_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ivypointer.Po@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) '$<'`
+
+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; } \
+ END { 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; } \
+ END { 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=; \
+ 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; } \
+ END { 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 $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; 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 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-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+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
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic ctags distclean distclean-compile \
+ distclean-generic 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-html install-html-am \
+ install-info install-info-am 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 pdf pdf-am ps ps-am tags uninstall \
+ uninstall-am uninstall-binPROGRAMS
+
+# 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/src/getopt.c b/src/getopt.c
new file mode 100644
index 0000000..36a9bc1
--- /dev/null
+++ b/src/getopt.c
@@ -0,0 +1,76 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+int optind = 1;
+char *optarg = (char *)NULL;
+
+int getopt (int argc, char **argv, char *optstring)
+{
+ int cur_option; /* Current option */
+ char *cp; /* Character pointer */
+ static int GetOptionPosition = 1;
+
+ if (GetOptionPosition == 1)
+ {
+
+/* Check for out of range, correct start character and not single */
+
+ if ((optind >= argc) || (*argv[optind] != '-') || !argv[optind][1])
+ return EOF;
+
+ if (!strcmp (argv[optind], "--"))
+ return EOF;
+ }
+
+/* Get the current character from the current argument vector */
+
+ cur_option = argv[optind][GetOptionPosition];
+
+/* Validate it */
+
+ if ((cur_option == ':') ||
+ ((cp = strchr (optstring, cur_option)) == (char *)NULL))
+ {
+
+/* Move to the next offset */
+
+ if (!argv[optind][++GetOptionPosition])
+ {
+ optind++;
+ GetOptionPosition = 1;
+ }
+
+ return '?';
+ }
+
+/* Parameters following ? */
+
+ optarg = (char *)NULL;
+
+ if (*(++cp) == ':')
+ {
+ if (argv[optind][GetOptionPosition + 1])
+ optarg = &argv[optind++][GetOptionPosition + 1];
+
+ else if (++optind >= argc)
+ {
+ optarg = (char *)NULL;
+ GetOptionPosition = 1;
+ return '?';
+ }
+
+ else
+ optarg = argv[optind++];
+
+ GetOptionPosition = 1;
+ }
+
+ else if (!argv[optind][++GetOptionPosition])
+ {
+ GetOptionPosition = 1;
+ optind++;
+ }
+
+ return cur_option;
+}
diff --git a/src/getopt.h b/src/getopt.h
new file mode 100644
index 0000000..d52543f
--- /dev/null
+++ b/src/getopt.h
@@ -0,0 +1,16 @@
+#ifndef __GETOPT_H_
+#define __GETOPT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int optind ;
+extern char *optarg ;
+extern int getopt (int argc, char **argv, char *optstring) ;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/ivypointer.c b/src/ivypointer.c
new file mode 100644
index 0000000..fe6e5a8
--- /dev/null
+++ b/src/ivypointer.c
@@ -0,0 +1,242 @@
+/*
+ * Ivy probe
+ *
+ * Copyright (C) 2007
+ * DGAC / DSNA / DTI / R&D
+ *
+ * Main and only file
+ *
+ * Authors: Benjamin Tissoires <tissoire@cena.fr>
+ *
+ * Please refer to file version.h for the
+ * copyright notice regarding this software
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if X_DISPLAY_MISSING
+# error X11 is required to build xtest
+#else
+# include <X11/Xlib.h>
+# include <X11/X.h>
+# include <X11/Xutil.h>
+# define XK_MISCELLANY
+# define XK_XKB_KEYS
+# include <X11/keysymdef.h>
+# if HAVE_X11_EXTENSIONS_XTEST_H
+# include <X11/extensions/XTest.h>
+//# else
+//# error The XTest extension is required to build xtest
+# endif
+# if HAVE_X11_EXTENSIONS_XINERAMA_H
+ // Xinerama.h may lack extern "C" for inclusion by C++
+ extern "C" {
+# include <X11/extensions/Xinerama.h>
+ }
+# endif
+# if HAVE_XKB_EXTENSION
+# include <X11/XKBlib.h>
+# endif
+#endif
+
+#include <Ivy/ivyloop.h>
+#include <Ivy/ivy.h>
+#include <Ivy/version.h>
+
+
+#include "getopt.h"
+
+#define REGEXP_MOVE "^TelepointerMotion Id=(.*) X=(.*) Y=(.*)"
+#define REGEXP_DRAG "^TelepointerDrag Id=(.*) X=(.*) Y=(.*)"
+//#define REGEXP_MOVE "^IvyPointer Move=(.*),(.*)"
+#define REGEXP_REL_MOVE "^TelepointerRelativeMotion Id=(.*) X=(.*) Y=(.*)"
+#define REGEXP_BUTTON "^TelepointerButton Id=(.*) Button=(.*) status=(.*)"
+
+
+Display* display = NULL;
+int width,height;
+
+int dragged = 0;
+
+Display*
+openDisplay(const char* displayName)
+{
+ // get the DISPLAY
+ if (displayName == NULL) {
+ displayName = getenv("DISPLAY");
+ if (displayName == NULL) {
+ displayName = ":0.0";
+ }
+ }
+
+ // open the display
+ printf("XOpenDisplay(\"%s\")\n", displayName);
+ display = XOpenDisplay(displayName);
+ if (display == NULL) {
+ printf("EE : can't open display \"%s\"\n", displayName);
+ return NULL;
+// throw XScreenUnavailable(60.0);
+ }
+
+ // verify the availability of the XTest extension
+ int majorOpcode, firstEvent, firstError;
+#if HAVE_X11_EXTENSIONS_XTEST_H
+ if (!XQueryExtension(display, XTestExtensionName,
+ &majorOpcode, &firstEvent, &firstError)) {
+ printf("XTEST extension not available");
+ XCloseDisplay(display);
+ return NULL;
+ }
+#endif
+#if HAVE_XKB_EXTENSION
+ {
+ m_xkb = false;
+ int major = XkbMajorVersion, minor = XkbMinorVersion;
+ if (XkbLibraryVersion(&major, &minor)) {
+ int opcode, firstError;
+ if (XkbQueryExtension(display, &opcode, &m_xkbEventBase,
+ &firstError, &major, &minor)) {
+ m_xkb = true;
+ XkbSelectEvents(display, XkbUseCoreKbd,
+ XkbMapNotifyMask, XkbMapNotifyMask);
+ XkbSelectEventDetails(display, XkbUseCoreKbd,
+ XkbStateNotifyMask,
+ XkbGroupStateMask, XkbGroupStateMask);
+ }
+ }
+ }
+#endif
+
+ return display;
+}
+
+void
+fakeMouseButton(const unsigned int xButton, Bool press)
+{
+#if HAVE_X11_EXTENSIONS_XTEST_H
+ if (xButton != 0) {
+ XTestFakeButtonEvent(display, xButton, press ? True : False, 0);
+ XFlush(display);
+ }
+#endif
+}
+
+void
+fakeMouseMove(int x, int y)
+{
+ XWarpPointer(display, None, RootWindow(display, 0), 0, 0, 0, 0, x, y);
+ XFlush(display);
+}
+
+void
+fakeMouseRelativeMove(int dx, int dy)
+{
+ XWarpPointer(display, None, None, 0, 0, 0, 0, dx, dy);
+ XFlush(display);
+}
+
+
+void CallbackMove (IvyClientPtr app, void *user_data, int argc, char *argv[]) {
+// printf ("%s sent (size : %d)",IvyGetApplicationName(app),argc);
+// for (i = 0; i < argc; i++)
+// printf(" '%s'",argv[i]);
+ if (dragged){
+ fakeMouseButton(1,0);
+ dragged = 0;
+ }
+ char *id = argv[0];
+ float x = atof(argv[1]);
+ float y = atof(argv[2]);
+// printf("x = %f,y = %f; ",x,y);
+ x = x*width/100.0;
+ y = y*height/100.0;
+// printf("x = %f,y = %f\n",x,y);
+ fakeMouseMove((int)x,(int)y);
+// IvyUnbindMsg(*ptr);
+}
+
+void CallbackDrag (IvyClientPtr app, void *user_data, int argc, char *argv[]) {
+ if (!dragged){
+ fakeMouseButton(1,1);
+ dragged = 1;
+ }
+ char *id = argv[0];
+ float x = atof(argv[1]);
+ float y = atof(argv[2]);
+ x *= width/100.0;
+ y *= height/100.0;
+// printf("x = %f,y = %f\n",x,y);
+ fakeMouseMove((int)x,(int)y);
+}
+
+void CallbackRelMove (IvyClientPtr app, void *user_data, int argc, char *argv[]) {
+ char *id = argv[0];
+ float x = atof(argv[1]);
+ float y = atof(argv[2]);
+ x *= width/100.0;
+ y *= height/100.0;
+ fakeMouseRelativeMove((int)x,(int)y);
+}
+
+void CallbackButton (IvyClientPtr app, void *user_data, int argc, char *argv[]) {
+ char *id = argv[0];
+ int b = atoi(argv[1]);
+ int press = atoi(argv[2]);
+// if (!b)
+// return
+ fakeMouseButton(b,press);
+}
+
+int main(int argc, char *argv[]) {
+ const char* bus = 0;
+ char busbuf [1024] = "";
+ const char* helpmsg =
+ "[options] [regexps]\n\t-b bus\tdefines the Ivy bus to which to connect to, defaults to 127:2010\n"
+ "\t-v\tprints the ivy relase number\n\n"
+ ;
+ int c;
+ while ((c = getopt(argc, argv, "vb:")) != EOF)
+ switch (c) {
+ case 'b':
+ strcpy (busbuf, optarg);
+ bus = busbuf;
+ break;
+ case 'v':
+ printf("ivy c library version %d.%d\n",IVYMAJOR_VERSION,IVYMINOR_VERSION);
+ break;
+ default:
+ printf("usage: %s %s",argv[0],helpmsg);
+ exit(1);
+ }
+ Display* d = openDisplay(NULL);
+ if (!d){
+ return 1;
+ }
+
+ width = DisplayWidth(d, DefaultScreen(d));
+ height = DisplayHeight(d, DefaultScreen(d));
+ printf("screen : %dx%d\n",width,height);
+ MsgRcvPtr ptrMove,ptrRelMove,ptrButton;
+ IvyInit("IvyPointer","IvyPointer Ready",NULL,NULL,NULL,NULL);
+ ptrMove=IvyBindMsg(CallbackMove,&ptrMove,REGEXP_MOVE);
+ printf("bound to %s\n",REGEXP_MOVE);
+ ptrMove=IvyBindMsg(CallbackDrag,&ptrMove,REGEXP_DRAG);
+ printf("bound to %s\n",REGEXP_DRAG);
+ ptrMove=IvyBindMsg(CallbackRelMove,&ptrRelMove,REGEXP_REL_MOVE);
+ printf("bound to %s\n",REGEXP_REL_MOVE);
+ ptrMove=IvyBindMsg(CallbackButton,&ptrButton,REGEXP_BUTTON);
+ printf("bound to %s\n",REGEXP_BUTTON);
+ IvyStart(bus);
+#if (IVYMAJOR_VERSION == 3) && (IVYMINOR_VERSION < 9)
+ IvyMainLoop(NULL, NULL);
+#else
+ IvyMainLoop();
+#endif
+ return 0;
+}