Dinovo Mediapad LCD support in Input service
PATCH 1/1 Dinovo Mediapad LCD support in Input service
Hello all,
Here is a patch against bluez-utils 3.19 to enable support for the Dinovo Mediapad LCD. Originally, I implemented this in hidd, but since hidd is "dead" I've revised my patch.
This patch also addresses a bug in common/dbus.c where a pointer goes unchecked and caused a segfault or two during my testing.
Regards,
Tim
common/dbus.c +4 -2
@@ -524,8 +524,10 @@dbus_watch_handle (watch, flags); -if (dbus_connection_get_dispatch_status (info->conn) ==DBUS_DISPATCH_DATA_REMAINS ) -g_timeout_add (DISPATCH_TIMEOUT , message_dispatch_cb, info->conn); +if (info) { +if (dbus_connection_get_dispatch_status (info->conn) ==DBUS_DISPATCH_DATA_REMAINS ) +g_timeout_add (DISPATCH_TIMEOUT , message_dispatch_cb, info->conn); + }return TRUE; }
input/Makefile.am +6 -3
@@ -2,8 +2,10 @@ if INPUTSERVICE if CONFIGFILES confdir = $(sysconfdir)/bluetooth +conf_DATA = input.service -conf_DATA = input.service +dbusdir = $(sysconfdir)/dbus-1/system.d +dbus_DATA = dinovo.conf endif servicedir = $(libdir)/bluetooth
@@ -12,7 +14,8 @@ bluetoothd_service_input_SOURCES = main.c \ manager.h manager.c error.h error.c \ - server.h server.c device.h device.c storage.h storage.c + server.h server.c device.h device.c storage.h storage.c \ + logitech_mediapad.c LDADD = $(top_builddir)/common/libhelper.a \ @GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@
@@ -22,6 +25,6 @@ INCLUDES = -I$(top_srcdir)/common -EXTRA_DIST = input.service input-api.txt test-input +EXTRA_DIST = input.service dinovo.conf input-api.txt test-input MAINTAINERCLEANFILES = Makefile.in
input/Makefile.in +43 -16
132 lines not on this page · raw message
input/device.c +22 -7
@@ -52,6 +52,7 @@#include "error.h" #include "manager.h" #include "storage.h" +#include "logitech_mediapad.h" #define INPUT_DEVICE_INTERFACE "org.bluez.input.Device"
@@ -64,6 +65,7 @@int rfcomm;/* RFCOMM socket */ int uinput;/* uinput socket */ uint8_t ch;/* RFCOMM channel number */ +gpointer misc;/* Misc. Device-dependant state data */ };struct device {
@@ -174,11 +176,11 @@ioctl (fd,UI_SET_EVBIT ,EV_KEY );ioctl (fd,UI_SET_EVBIT ,EV_REL );ioctl (fd,UI_SET_EVBIT ,EV_REP ); +ioctl (fd,UI_SET_EVBIT ,EV_LED ); -ioctl (fd,UI_SET_KEYBIT ,KEY_UP ); -ioctl (fd,UI_SET_KEYBIT ,KEY_PAGEUP ); -ioctl (fd,UI_SET_KEYBIT ,KEY_DOWN ); -ioctl (fd,UI_SET_KEYBIT ,KEY_PAGEDOWN ); +for (err=KEY_RESERVED ;err <=KEY_UNKNOWN ;err++) +ioctl (fd,UI_SET_KEYBIT ,err); + err =0 ;if (ioctl (fd,UI_DEV_CREATE ,NULL ) <0 ) { err = errno;
@@ -621,9 +623,10 @@ } err =ioctl (ctl,HIDPCONNADD , &req); + cleanup:close (ctl); - +if (req.rd_data)free (req.rd_data);
@@ -665,12 +668,15 @@ } idev->intr_sk = isk; + err =hidp_connadd (&idev->src, &idev->dst, idev->ctrl_sk, idev->intr_sk, idev->name); +if (err <0 ) goto failed; idev->intr_watch =create_watch (idev->intr_sk, intr_watch_cb, idev); idev->ctrl_watch =create_watch (idev->ctrl_sk, ctrl_watch_cb, idev); + dbus_connection_emit_signal(idev->conn, idev->path, INPUT_DEVICE_INTERFACE,
@@ -1318,13 +1324,22 @@int input_device_connadd (bdaddr_t *src,bdaddr_t *dst) {struct device *idev; -int err; +int err =0 ; idev =find_device (src, dst);if (!idev)return -ENOENT ; - err =hidp_connadd (src, dst, idev->ctrl_sk, idev->intr_sk, idev->name); +if (!strcmp (idev->name,"Logitech Bluetooth Mediapad" ) || !strcmp (idev->name,"Logitech Mediapad" )) { + idev->fake = g_new0(struct fake_input,1); err = 0; + idev->fake->uinput =uinput_create (idev->name); + idev->fake->misc =logitech_mediapad_init (idev->intr_sk,idev->fake->uinput); + idev->fake->io =g_io_channel_unix_new (idev->intr_sk); +g_io_channel_set_close_on_unref (idev->fake->io, TRUE); +g_io_add_watch (idev->fake->io,G_IO_IN |G_IO_ERR |G_IO_HUP |G_IO_NVAL , + (GIOFunc ) logitech_mediapad_io_cb, idev->fake->misc); + }else err =hidp_connadd (src, dst, idev->ctrl_sk, idev->intr_sk, idev->name); +if (err <0 ) {close (idev->ctrl_sk);close (idev->intr_sk);
input/dinovo.conf +18 -0
@@ -0,0 +1,18 @@ +<!-- This configuration file specifies the required security policies + for the Logitech Dinovo MediaPad driver. --> + +<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> +<busconfig> + <!-- ../system.conf have denied everything, so we just punch some holes --> + + <policy user="root"> + <allow own="com.hentenaar.Dinovo.MediaPad"/> + </policy> + + <policy at_console="true"> + <allow send_path="/com/hentenaar"/> + <allow send_destination="com.hentenaar.Dinovo.MediaPad" /> + <allow receive_sender="com.hentenaar.Dinovo.MediaPad"/> + </policy> +</busconfig>
input/logitech_mediapad.c +571 -0
571 lines not on this page · raw message
input/logitech_mediapad.h +7 -0
@@ -0,0 +1,7 @@ +#ifndef LOGITECH_MEDIAPAD_H +#define LOGITECH_MEDIAPAD_H + +gpointer logitech_mediapad_init (int isk,int uinput_fd); +gboolean logitech_mediapad_io_cb (GIOChannel *chan,GIOCondition cond,gpointer data); + +#endif
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel