From: Edd Dumbill <edd@usefulinc.com>
To: Peter Klausler <peter@klausler.com>
Cc: Charles Bueche <charles@bueche.ch>,
BlueZ Developers List <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] Logitech MX900 mouse with Dell Inspiron 8600
Date: Tue, 02 Dec 2003 16:01:47 +0000 [thread overview]
Message-ID: <1070380907.19169.55.camel@saag> (raw)
In-Reply-To: <1070380522.19169.52.camel@saag>
[-- Attachment #1: Type: text/plain, Size: 388 bytes --]
On Tue, 2003-12-02 at 15:55, Edd Dumbill wrote:
> Hmm, I'd thought I'd sent this to the list, but obviously didn't.
> Here's a patch for Peter's bthid stuff to work with the uinput driver in
> Linux 2.6. Use at your own risk. I had it going OK with an Apple
> keyboard and MS mouse.
And if I'd attached the patch first time, it would have been truly
impressive.
Here we are.
-- Edd
[-- Attachment #2: bthid-uinput.diff --]
[-- Type: text/x-patch, Size: 6689 bytes --]
Only in bthid: bthid
Only in bthid.orig: fake.c
diff -ur bthid.orig/hid.c bthid/hid.c
--- bthid.orig/hid.c 2003-09-08 16:01:35.000000000 +0100
+++ bthid/hid.c 2003-11-15 21:51:31.000000000 +0000
@@ -565,6 +565,7 @@
case 0xb5: butt = KEY_NEXTSONG; break;
case 0xb6: butt = KEY_PREVIOUSSONG; break;
case 0xb7: butt = KEY_STOPCD; break;
+ case 0xb8: butt = KEY_EJECTCD; break; /* Apple kbd */
case 0xcd: butt = KEY_PLAYPAUSE; break;
case 0xe2: butt = KEY_MUTE; break;
case 0xe9: butt = KEY_VOLUMEUP; break;
diff -ur bthid.orig/main.c bthid/main.c
--- bthid.orig/main.c 2003-11-06 01:20:03.000000000 +0000
+++ bthid/main.c 2003-11-15 21:14:37.000000000 +0000
@@ -781,9 +781,6 @@
int scan_mode = 0;
int listen_mode = 0;
-
- out_path = "/dev/input/bluetooth-in";
-
for (argi = 1; argi < argc; argi++)
if (argv [argi][0] != '-')
break;
@@ -791,8 +788,6 @@
daemonize = 0;
else if (!strcmp (argv [argi], "-v"))
verbosity++;
- else if (!strcmp (argv [argi], "-o") && argi < argc-1)
- out_path = argv [++argi];
else if (!strcmp (argv [argi], "-l"))
listen_mode = 1;
else if (!strcmp (argv [argi], "-s"))
@@ -822,7 +817,6 @@
" -n don't become daemon\n"
" -l listen for incoming connections\n"
" -s scan for devices\n"
- " -o output device (%s)\n"
" -b reverse mouse buttons 2 and 5\n"
" -B ms keyboard debounce time (millisecs)\n"
" -a authentication link mode\n"
@@ -833,8 +827,7 @@
" -d Dvorak keyboard and system\n"
" -D Dvorak keyboard on QWERTY system\n"
" -r attempt automatic reconnection\n"
- " -v verbose mode (-v -v is extra)\n",
- out_path);
+ " -v verbose mode (-v -v is extra)\n");
return EXIT_FAILURE;
}
Only in bthid.orig: make.fake
diff -ur bthid.orig/Makefile bthid/Makefile
--- bthid.orig/Makefile 2003-06-17 17:32:07.000000000 +0100
+++ bthid/Makefile 2003-11-15 21:22:25.000000000 +0000
@@ -1,41 +1,34 @@
BTHID_C = global.c sock.c kb.c main.c out.c sdp.c hid.c
BTHID_HDRS = global.h hid.h sock.h kb.h out.h sdp.h hid.h
-EXTRA = README Makefile make.fake fake.c \
- bluetooth-hid bthid-modules msblue.def
+EXTRA = README Makefile \
+ bluetooth-hid msblue.def
SHIP = $(BTHID_C) $(BTHID_HDRS) $(EXTRA)
BTHID_RELS = $(BTHID_C:.c=.o)
CFLAGS = -O -Wall -Wno-parentheses
-MODINSTDIR = /lib/modules/`uname -r`/kernel/drivers/input
-world: bthid fake.o
+world: bthid
bthid: $(BTHID_RELS)
cc -o $@ $(BTHID_RELS) -lbluetooth
$(BTHID_RELS): $(BTHID_HDRS)
-fake.o: fake.c
- make -f make.fake $@
-
-install: bthid fake.o
+install: bthid
[ -c /dev/input/mice ] || \
mknod -m 644 /dev/input/mice c 13 63
- [ -c /dev/input/bluetooth-in ] || \
- mknod -m 644 /dev/input/bluetooth-in c 250 0
+ [ -c /dev/input/uinput ] || \
+ mknod -m 644 /dev/input/bluetooth-in c 10 223
install -m u=rwxs,go=rxs -o pmk -g os bthid /usr/local/bin
- install -m u=rw,go=r -o root -g root fake.o $(MODINSTDIR)
install -m u=rwx,go=rx -o root -g root bluetooth-hid /etc/init.d
- install -m u=rw,go=r -o root -g root bthid-modules /etc/modutils
install -m u=rw,go=r -o root -g root msblue.def /usr/share/hotkeys
(cd /etc/rc2.d; \
rm -f S90bluetooth-hid; \
ln -s ../init.d/bluetooth-hid S90bluetooth-hid)
- update-modules
clean:
rm -f $(BTHID_RELS)
clobber: clean
- rm -f fake.o bthid
+ rm -f bthid
bthid.tar.gz: $(SHIP)
rm -f bthid.tar bthid.tar.gz
diff -ur bthid.orig/out.c bthid/out.c
--- bthid.orig/out.c 2003-01-19 00:58:05.000000000 +0000
+++ bthid/out.c 2003-11-15 21:16:01.000000000 +0000
@@ -3,58 +3,84 @@
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
+#include <stdio.h>
#include <errno.h>
+
+#include <asm/types.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
/*
* Output to the pseudo-input device
*/
-#define MAX_BUFF 1024
+char *out_path;
-char *out_path;
-
-static int out_fd = -1;
-static int out_ct;
-static char out_buff [MAX_BUFF];
+static int out_fd=-1;
void
-out_open (void) {
- if (out_fd < 0 && out_path) {
- out_fd = open (out_path, O_WRONLY | O_NDELAY);
- if (out_fd < 0) {
- syslog (LOG_ERR, "can't open %s: %s",
- out_path, strerror (errno));
- out_path = 0;
- }
- }
+out_open(void)
+{
+ struct uinput_user_dev device;
+ int aux;
+
+ if (out_fd >=0)
+ return;
+
+ out_fd = open ("/dev/input/uinput", O_RDWR);
+ if (out_fd < 0) {
+ syslog (LOG_ERR, "can't open %s: %s",
+ out_path, strerror (errno));
+ out_path = 0;
+ }
+
+ strcpy(device.name, "Bluetooth device");
+ device.id.bustype = BUS_USB;
+ device.id.vendor = 2;
+ device.id.product = 3;
+ device.id.version = 4;
+ ioctl(out_fd, UI_SET_EVBIT, EV_KEY);
+ ioctl(out_fd, UI_SET_EVBIT, EV_REL);
+
+ /* set key events we can generate (in this case, all) */
+ for (aux = 0; aux < KEY_MAX; aux++)
+ ioctl(out_fd, UI_SET_KEYBIT, aux);
+
+ for (aux = REL_X; aux <= REL_MISC; aux++)
+ ioctl(out_fd, UI_SET_RELBIT, aux);
+
+ /* write down information for creating a new device */
+ if (write(out_fd, &device, sizeof(struct uinput_user_dev)) < 0) {
+ syslog (LOG_ERR, "can't write device description: %s",
+ strerror (errno));
+ close(out_fd);
+ out_fd=0;
+ return;
+ }
+
+ /* actually creates the device */
+ ioctl(out_fd, UI_DEV_CREATE);
}
+static struct input_event event;
+
void
out_event (int evt, int which, int amount) {
- out_buff [out_ct++] = evt;
- out_buff [out_ct++] = which;
- out_buff [out_ct++] = which >> 8;
- out_buff [out_ct++] = amount;
- if (out_ct == MAX_BUFF)
- out_ct = 0;
-}
+ if (out_fd < 0)
+ return;
+ memset(&event, 0, sizeof(struct input_event));
-void
-out_flush (void) {
+ event.code = which;
+ event.type = evt;
+ event.value = amount;
- int n;
+ write(out_fd, &event, sizeof(struct input_event));
+}
- if (!out_ct)
- return;
- if (out_fd >= 0) {
- n = write (out_fd, out_buff, out_ct);
- if (n != out_ct) {
- syslog (LOG_ERR, "error writing to %s: %s",
- out_path, strerror (errno));
- close (out_fd);
- out_fd = -1;
- }
- }
- out_ct = 0;
+void out_flush (void) {
+ memset(&event, 0, sizeof(struct input_event));
+ event.type = EV_SYN;
+ write(out_fd, &event, sizeof(struct input_event));
}
diff -ur bthid.orig/out.h bthid/out.h
--- bthid.orig/out.h 2003-01-19 00:56:33.000000000 +0000
+++ bthid/out.h 2003-11-15 21:14:44.000000000 +0000
@@ -5,8 +5,6 @@
* Output to the pseudo-input device
*/
-extern char *out_path;
-
void out_open (void);
void out_event (int /*event*/, int /*which*/, int /*amount*/);
void out_flush (void);
next prev parent reply other threads:[~2003-12-02 16:01 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-30 14:12 [Bluez-devel] Logitech MX900 mouse with Dell Inspiron 8600 Charles Bueche
2003-11-30 18:51 ` Charles Bueche
2003-12-01 15:38 ` Peter Klausler
2003-12-02 15:55 ` Edd Dumbill
2003-12-02 16:01 ` Edd Dumbill [this message]
2003-12-03 20:18 ` Charles Bueche
2003-12-03 20:35 ` Marcel Holtmann
2003-12-04 8:53 ` Olivier Bornet
2003-12-04 13:52 ` Marcel Holtmann
2003-12-04 13:57 ` Olivier Bornet
2003-12-04 14:10 ` Marcel Holtmann
2003-12-04 16:35 ` Olivier Bornet
2003-12-04 17:03 ` Marcel Holtmann
2003-12-09 20:31 ` Charles Bueche
2003-12-09 22:42 ` Olivier Bornet
2003-12-10 8:12 ` Charles Bueche
2003-12-10 8:30 ` Olivier Bornet
2003-12-13 15:56 ` Charles Bueche
2003-12-13 16:39 ` Marcel Holtmann
2003-12-13 18:51 ` Charles Bueche
2003-12-13 19:04 ` Marcel Holtmann
2003-12-14 13:55 ` Charles Bueche
2003-12-14 14:22 ` Marcel Holtmann
2003-12-14 20:01 ` Charles Bueche
2003-12-14 20:09 ` Marcel Holtmann
2003-12-10 1:41 ` Marcel Holtmann
2003-12-02 17:39 ` Marcel Holtmann
2003-12-02 17:42 ` Peter Klausler
2003-12-02 17:56 ` Marcel Holtmann
2003-12-03 10:10 ` Stephen Crane
2003-12-03 13:06 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1070380907.19169.55.camel@saag \
--to=edd@usefulinc.com \
--cc=bluez-devel@lists.sourceforge.net \
--cc=charles@bueche.ch \
--cc=peter@klausler.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.