/[soft]/drakx-kbd-mouse-x11/trunk/lib/xf86misc/main.xs
ViewVC logotype

Contents of /drakx-kbd-mouse-x11/trunk/lib/xf86misc/main.xs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 391 - (show annotations) (download)
Thu Feb 3 13:54:58 2011 UTC (13 years, 2 months ago) by dmorgan
File size: 1705 byte(s)
Import cleaned drakx-kbd-mouse-x11
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4
5 #include <X11/Xlib.h>
6 #include <X11/extensions/xf86misc.h>
7
8 #include <term.h>
9 #undef max_colors
10
11 void initIMPS2() {
12 unsigned char imps2_s1[] = { 243, 200, 243, 100, 243, 80, };
13 unsigned char imps2_s2[] = { 246, 230, 244, 243, 100, 232, 3, };
14
15 int fd = open("/dev/mouse", O_WRONLY);
16 if (fd < 0) return;
17
18 write (fd, imps2_s1, sizeof (imps2_s1));
19 usleep (30000);
20 write (fd, imps2_s2, sizeof (imps2_s2));
21 usleep (30000);
22 tcflush (fd, TCIFLUSH);
23 tcdrain(fd);
24 }
25
26 MODULE = xf86misc::main PACKAGE = xf86misc::main
27
28 PROTOTYPES: DISABLE
29
30
31 int
32 Xtest(display)
33 char *display
34 CODE:
35 int pid;
36 if ((pid = fork()) == 0) {
37 Display *d = XOpenDisplay(display);
38 if (d) {
39 int child;
40 /* keep a client until some window is created, otherwise X server blinks to hell */
41 if ((child = fork()) == 0) {
42 XEvent event;
43 XSelectInput(d, DefaultRootWindow(d), SubstructureNotifyMask);
44 do {
45 XNextEvent(d, &event);
46 } while (event.type != CreateNotify);
47 XCloseDisplay(d);
48 exit(0);
49 }
50 }
51 _exit(d != NULL);
52 }
53 waitpid(pid, &RETVAL, 0);
54 OUTPUT:
55 RETVAL
56
57 void
58 setMouseLive(display, type, emulate3buttons)
59 char *display
60 int type
61 int emulate3buttons
62 CODE:
63 {
64 XF86MiscMouseSettings mseinfo;
65 Display *d = XOpenDisplay(display);
66 if (d) {
67 if (XF86MiscGetMouseSettings(d, &mseinfo) == True) {
68 mseinfo.type = type;
69 mseinfo.flags |= MF_REOPEN;
70 mseinfo.emulate3buttons = emulate3buttons;
71 XF86MiscSetMouseSettings(d, &mseinfo);
72 XFlush(d);
73 if (type == MTYPE_IMPS2) initIMPS2();
74 }
75 }
76 }

  ViewVC Help
Powered by ViewVC 1.1.30