summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/xf86misc/.cvsignore5
-rw-r--r--lib/xf86misc/Makefile10
-rw-r--r--lib/xf86misc/Makefile.PL15
-rw-r--r--lib/xf86misc/main.pm12
-rw-r--r--lib/xf86misc/main.xs76
5 files changed, 118 insertions, 0 deletions
diff --git a/lib/xf86misc/.cvsignore b/lib/xf86misc/.cvsignore
new file mode 100644
index 0000000..83a662f
--- /dev/null
+++ b/lib/xf86misc/.cvsignore
@@ -0,0 +1,5 @@
+main.bs
+main.c
+pm_to_blib
+blib
+Makefile_c
diff --git a/lib/xf86misc/Makefile b/lib/xf86misc/Makefile
new file mode 100644
index 0000000..2d874b9
--- /dev/null
+++ b/lib/xf86misc/Makefile
@@ -0,0 +1,10 @@
+.PHONY: clean
+
+main: %: %.xs
+ test -e Makefile_c || perl Makefile.PL
+ $(MAKE) -f Makefile_c LD_RUN_PATH= || $(MAKE) -f Makefile_c LD_RUN_PATH=
+ rm -f ../auto/xf86misc ; ln -s ../xf86misc/blib/arch/auto ../auto/xf86misc
+
+clean:
+ test ! -e Makefile_c || $(MAKE) -f Makefile_c clean
+ rm -f *~ *.o
diff --git a/lib/xf86misc/Makefile.PL b/lib/xf86misc/Makefile.PL
new file mode 100644
index 0000000..c0a1070
--- /dev/null
+++ b/lib/xf86misc/Makefile.PL
@@ -0,0 +1,15 @@
+use ExtUtils::MakeMaker;
+use MDK::Common;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+
+my $lib = arch() =~ /x86_64/ ? 'lib64' : 'lib';
+
+WriteMakefile(
+ 'NAME' => 'main',
+ 'MAKEFILE' => 'Makefile_c',
+ 'OPTIMIZE' => '-Os',
+ 'VERSION_FROM' => 'main.pm', # finds $VERSION
+ 'LIBS' => ["-L/usr/X11R6/$lib -lX11 -lXext -lXxf86misc"],
+ 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
+);
diff --git a/lib/xf86misc/main.pm b/lib/xf86misc/main.pm
new file mode 100644
index 0000000..300e1ab
--- /dev/null
+++ b/lib/xf86misc/main.pm
@@ -0,0 +1,12 @@
+package xf86misc::main; # $Id$
+
+use strict;
+use vars qw($VERSION @ISA);
+use DynaLoader;
+
+use vars qw($VERSION @ISA);
+@ISA = qw(DynaLoader);
+$VERSION = '0.01';
+xf86misc::main->bootstrap($VERSION);
+
+1;
diff --git a/lib/xf86misc/main.xs b/lib/xf86misc/main.xs
new file mode 100644
index 0000000..696f8dd
--- /dev/null
+++ b/lib/xf86misc/main.xs
@@ -0,0 +1,76 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#include <X11/Xlib.h>
+#include <X11/extensions/xf86misc.h>
+
+#include <term.h>
+#undef max_colors
+
+void initIMPS2() {
+ unsigned char imps2_s1[] = { 243, 200, 243, 100, 243, 80, };
+ unsigned char imps2_s2[] = { 246, 230, 244, 243, 100, 232, 3, };
+
+ int fd = open("/dev/mouse", O_WRONLY);
+ if (fd < 0) return;
+
+ write (fd, imps2_s1, sizeof (imps2_s1));
+ usleep (30000);
+ write (fd, imps2_s2, sizeof (imps2_s2));
+ usleep (30000);
+ tcflush (fd, TCIFLUSH);
+ tcdrain(fd);
+}
+
+MODULE = xf86misc::main PACKAGE = xf86misc::main
+
+PROTOTYPES: DISABLE
+
+
+int
+Xtest(display)
+ char *display
+ CODE:
+ int pid;
+ if ((pid = fork()) == 0) {
+ Display *d = XOpenDisplay(display);
+ if (d) {
+ int child;
+ /* keep a client until some window is created, otherwise X server blinks to hell */
+ if ((child = fork()) == 0) {
+ XEvent event;
+ XSelectInput(d, DefaultRootWindow(d), SubstructureNotifyMask);
+ do {
+ XNextEvent(d, &event);
+ } while (event.type != CreateNotify);
+ XCloseDisplay(d);
+ exit(0);
+ }
+ }
+ _exit(d != NULL);
+ }
+ waitpid(pid, &RETVAL, 0);
+ OUTPUT:
+ RETVAL
+
+void
+setMouseLive(display, type, emulate3buttons)
+ char *display
+ int type
+ int emulate3buttons
+ CODE:
+ {
+ XF86MiscMouseSettings mseinfo;
+ Display *d = XOpenDisplay(display);
+ if (d) {
+ if (XF86MiscGetMouseSettings(d, &mseinfo) == True) {
+ mseinfo.type = type;
+ mseinfo.flags |= MF_REOPEN;
+ mseinfo.emulate3buttons = emulate3buttons;
+ XF86MiscSetMouseSettings(d, &mseinfo);
+ XFlush(d);
+ if (type == MTYPE_IMPS2) initIMPS2();
+ }
+ }
+ }