x-input-evdev: 3 commits - .gitignore src/evdev.c src/evdev_funcs.c src/.gitignore src/Makefile.am src/Xevdev.h
Tiago Vignatti
vignatti at kemper.freedesktop.org
Wed Aug 23 16:34:05 PDT 2006
.gitignore | 19 ++++++++
src/.gitignore | 5 ++
src/Makefile.am | 2
src/Xevdev.h | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/evdev.c | 35 ++++++++--------
src/evdev_funcs.c | 57 ++++++++++++++++++++++++++
6 files changed, 217 insertions(+), 17 deletions(-)
New commits:
diff-tree 9bd0b0d0b624a193eb7ef545f17b029a4619eb94 (from 0e75da26c80051a50401028e417aa965304b207b)
Author: root <root at mt4.c3sl.ufpr.br>
Date: Wed Aug 23 20:09:26 2006 -0300
Fix typo.
diff --git a/src/.gitignore b/src/.gitignore
index a5425d8..36f1a75 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,5 +1,5 @@
.deps
.libs
-evdev.lo
+*.lo
libXevdev.la
-
+*c.swp
diff --git a/src/Makefile.am b/src/Makefile.am
index 11b7457..eaec850 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,5 +3,5 @@ lib_LTLIBRARIES = libXevdev.la
libXevdevincludedir = $(includedir)/X11
libXevdevinclude_HEADERS = Xevdev.h
-libXevdev_la_SOURCES = evdev.c
+libXevdev_la_SOURCES = evdev.c evdev_funcs.c
libXevdev_la_LDFLAGS = -version-info @VERSION_INFO@
diff --git a/src/Xevdev.h b/src/Xevdev.h
index 2103e9f..dc07458 100644
--- a/src/Xevdev.h
+++ b/src/Xevdev.h
@@ -2,7 +2,123 @@
#define XEVDEV_H
#include <linux/input.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <X11/Xdefs.h>
+//#include <X11/extensions/XKBstr.h>
+
+#ifndef BITS_PER_LONG
+#define BITS_PER_LONG (sizeof(unsigned long) * 8)
+#endif
+
+#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
+
+#ifndef SYSCALL
+#define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
+#endif
+
+#define EVDEV_MAXBUTTONS 96
+
+typedef struct {
+ unsigned long ev[NBITS(EV_MAX)];
+ unsigned long key[NBITS(KEY_MAX)];
+ unsigned long rel[NBITS(REL_MAX)];
+ unsigned long abs[NBITS(ABS_MAX)];
+ unsigned long msc[NBITS(MSC_MAX)];
+ unsigned long led[NBITS(LED_MAX)];
+ unsigned long snd[NBITS(SND_MAX)];
+ unsigned long ff[NBITS(FF_MAX)];
+} evdevBitsRec, *evdevBitsPtr;
+
+typedef struct {
+ int real_buttons;
+ int buttons;
+ /* XXX: CARD8 is required from some place
+ CARD8 map[EVDEV_MAXBUTTONS]; */
+
+ /* XXX: InputInfoPtr is from Xf86
+ void (*callback[EVDEV_MAXBUTTONS])(InputInfoPtr pInfo, int button, int value);*/
+} evdevBtnRec, *evdevBtnPtr;
+
+typedef struct {
+ int axes;
+ int v[ABS_MAX];
+ int old_x, old_y;
+ int count;
+ int min[ABS_MAX];
+ int max[ABS_MAX];
+ int map[ABS_MAX];
+ int scale[2];
+ int screen; /* Screen number for this device. */
+ Bool use_touch;
+ Bool touch;
+ Bool reset;
+} evdevAbsRec, *evdevAbsPtr;
+
+typedef struct {
+ int axes;
+ int v[REL_MAX];
+ int count;
+ int map[REL_MAX];
+ int btnMap[REL_MAX][2];
+} evdevRelRec, *evdevRelPtr;
+
+typedef struct {
+ int axes;
+ int v[ABS_MAX];
+} evdevAxesRec, *evdevAxesPtr;
+
+typedef struct {
+ char *xkb_rules;
+ char *xkb_model;
+ char *xkb_layout;
+ char *xkb_variant;
+ char *xkb_options;
+ /* XXX: XKB* includes are required
+ XkbComponentNamesRec xkbnames;
+ */
+} evdevKeyRec, *evdevKeyPtr;
+
+
+typedef struct _evdevState {
+ Bool can_grab;
+ Bool sync;
+ int mode; /* Either Absolute or Relative. */
+
+ evdevBtnPtr btn;
+ evdevAbsPtr abs;
+ evdevRelPtr rel;
+ evdevKeyPtr key;
+ evdevAxesPtr axes;
+} evdevStateRec, *evdevStatePtr;
+
+typedef struct _evdevDevice {
+ const char *name;
+ const char *phys;
+ const char *device;
+ int seen;
+/* XXX: InputInfoPtr is from xf86
+ InputInfoPtr pInfo;
+
+ int (*callback)(DeviceIntPtr cb_data, int what);
+ */
+
+ evdevBitsRec bits;
+ struct input_id id;
+
+ evdevStateRec state;
+
+ struct _evdevDevice *next;
+} evdevDeviceRec, *evdevDevicePtr;
+
+
+/* FUNCTIONS */
+int evdevGetFDForDevice (evdevDevicePtr driver);
typedef void (*EvdevReadInputProc) ();
int OpenEvdevInput (char *kbdEvdev,
diff --git a/src/evdev.c b/src/evdev.c
index e6b897f..a16b716 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -77,7 +77,6 @@ EvdevSigioReadInput(int sig)
UnblockSIGIO(wasset);
}
-#define BITS_PER_LONG (sizeof(long) * 8)
#define BIT(x) (1UL<<((x)%BITS_PER_LONG))
#define EVIOCGMASK _IOR('E', 0x91, unsigned long *)
@@ -94,37 +93,41 @@ OpenEvdevInput (char *KbdEvdev,
struct sigaction sa;
struct sigaction osa;
+ evdevDevicePtr KbdDevice;
+ evdevDevicePtr PtrDevice;
+
+
if (already_open)
return 1;
EvdevReadInput = readInput;
-
- kbd_fd = open(KbdEvdev, O_RDWR | O_NONBLOCK);
- if (kbd_fd == -1) {
- fprintf(stderr, "Unable to open keyboard device %s.\n", KbdEvdev);
- return 0;
- }
- ptr_fd = open(PtrEvdev, O_RDONLY | O_NONBLOCK);
- if (ptr_fd == -1) {
- fprintf(stderr, "Unable to open pointer device %s.\n", PtrEvdev);
- return 0;
- }
+ if (!(KbdDevice = Xcalloc(sizeof(*KbdDevice))))
+ return NULL;
+ if (!(PtrDevice = Xcalloc(sizeof(*PtrDevice))))
+ return NULL;
+
+ KbdDevice->device = KbdEvdev;
+ PtrDevice->device = PtrEvdev;
+
+ kbd_fd = evdevGetFDForDevice(KbdDevice);
+ ptr_fd = evdevGetFDForDevice(PtrDevice);
+
/*
* Register the fd to receive SIGIO signals
*/
if (fcntl(kbd_fd, F_SETFL, fcntl(kbd_fd, F_GETFL) | O_ASYNC) == -1)
- fprintf(stderr, "fcntl(%d, O_ASYNC): %s\n", kbd_fd, strerror(errno));
+ fprintf(stderr, "fcntl(%d, O_ASYNC): %s\n", kbd_fd, strerror(errno));
if (fcntl(kbd_fd, F_SETOWN, getpid()) == -1)
- fprintf(stderr, "fcntl(%d, F_SETOWN): %s\n", kbd_fd, strerror(errno));
+ fprintf(stderr, "fcntl(%d, F_SETOWN): %s\n", kbd_fd, strerror(errno));
/*
* Register the fd to receive SIGIO signals
*/
if (fcntl(ptr_fd, F_SETFL, fcntl(ptr_fd, F_GETFL) | O_ASYNC) == -1)
- fprintf(stderr, "fcntl(%d, O_ASYNC): %s\n", ptr_fd, strerror(errno));
+ fprintf(stderr, "fcntl(%d, O_ASYNC): %s\n", ptr_fd, strerror(errno));
if (fcntl(ptr_fd, F_SETOWN, getpid()) == -1)
- fprintf(stderr, "fcntl(%d, F_SETOWN): %s\n", ptr_fd, strerror(errno));
+ fprintf(stderr, "fcntl(%d, F_SETOWN): %s\n", ptr_fd, strerror(errno));
sigemptyset(&sa.sa_mask);
sigaddset(&sa.sa_mask, SIGIO);
diff-tree 0e75da26c80051a50401028e417aa965304b207b (from 3d3688990bff0fce7ba65aa564b7d4ec8cd67a1b)
Author: root <root at mt4.c3sl.ufpr.br>
Date: Wed Aug 23 17:05:27 2006 -0300
Added evdev_funcs.c file.
diff --git a/src/evdev_funcs.c b/src/evdev_funcs.c
new file mode 100644
index 0000000..7a9dcda
--- /dev/null
+++ b/src/evdev_funcs.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2006 by Tiago Vignatti
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Author: Tiago Vignatti (tv02 at c3sl.ufpr.br)
+ */
+
+#include "Xevdev.h"
+
+/* open() */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+int
+evdevGetFDForDevice (evdevDevicePtr device)
+{
+ int fd;
+
+ if (!device)
+ return -1;
+
+
+ if (device->device) {
+ SYSCALL(fd = open (device->device, O_RDWR | O_NONBLOCK));
+ if (fd == -1)
+ /* xf86Msg(X_ERROR, "%s (%d): Open failed: %s\n", __FILE__, __LINE__, strerror(errno)); */
+ fprintf(stderr, "Unable to open %s.\n",device->device);
+ return fd;
+ } else
+ return -1;
+}
+
diff-tree 3d3688990bff0fce7ba65aa564b7d4ec8cd67a1b (from dd29d058e1e9da0cb11bc697510ddb22b16ef8cd)
Author: root <root at mt4.c3sl.ufpr.br>
Date: Wed Aug 23 14:31:36 2006 -0300
Ignore some noise with .gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a505903
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,19 @@
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+libtool
+ltmain.sh
+missing
+stamp-h1
+x-input-evdev.pc
+
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644
index 0000000..a5425d8
--- /dev/null
+++ b/src/.gitignore
@@ -0,0 +1,5 @@
+.deps
+.libs
+evdev.lo
+libXevdev.la
+
More information about the xorg-commit
mailing list