diff -Naur kbdd.orig/Makefile kbdd/Makefile --- kbdd.orig/Makefile 2006-01-03 20:25:30.000000000 +0000 +++ kbdd/Makefile 2006-01-04 07:15:58.000000000 +0000 @@ -4,6 +4,12 @@ VERSION = \"V0.10\" CFLAGS += -DVERSION=$(VERSION) +# for N770 add dbus glib bindings +CFLAGS+= -DN770=1 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include +#`pkg-config dbus-glib-1 --cflags` +LDFLAGS+= -ldbus-glib-1 -ldbus-1 -lglib-2.0 +# `pkg-config dbus-glib-1 --libs` + # for use with LIRC, uncomment the following two lines # CFLAGS += -DUSELIRC # LDFLAGS += -llirc_client diff -Naur kbdd.orig/dev_uinput.c kbdd/dev_uinput.c --- kbdd.orig/dev_uinput.c 2006-01-03 20:25:32.000000000 +0000 +++ kbdd/dev_uinput.c 2006-01-04 07:04:57.000000000 +0000 @@ -33,6 +33,23 @@ #define BUS_RS232 0x13 +#ifdef N770 +#include +#include +#define DBUS_API_SUBJECT_TO_CHANGE +#include +DBusConnection *conn=NULL; +DBusMessage *msg_dispon = NULL; +DBusMessage *msg_dispblpause = NULL; +DBusError dbus_error; +dbus_bool_t dresult; +#define MCE_SERVICE "com.nokia.mce" +#define MCE_REQUEST_PATH "/com/nokia/mce/request" +#define MCE_REQUEST_IF "com.nokia.mce.request" +#define MCE_PREVENT_BLANK_REQ "req_display_blanking_pause" +#define MCE_DISPLAY_ON_REQ "req_display_state_on" +#endif + int dev_uinput_init(void) { @@ -81,14 +98,48 @@ close(fd); return -1; } - +#ifdef N770 + dbus_error_init(&dbus_error); + conn = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error); + if (!conn) fprintf(stderr,"cannot initialise DBUS system connection\n"); + msg_dispon = dbus_message_new_method_call(MCE_SERVICE, + MCE_REQUEST_PATH, + MCE_REQUEST_IF, + MCE_DISPLAY_ON_REQ); + msg_dispblpause = dbus_message_new_method_call(MCE_SERVICE, + MCE_REQUEST_PATH, + MCE_REQUEST_IF, + MCE_PREVENT_BLANK_REQ); +#endif return fd; } int dev_uinput_key(int fd, unsigned short code, int pressed) { struct uinput_event event; - +#ifdef N770 +DBusMessage *msg=NULL; +static time_t last_msg_time=0; +time_t curr_time=time(NULL); + if (conn && ((curr_time-last_msg_time)>59)){ + /* unblank display as it may be already off */ + msg=msg_dispon; + } + else if (conn && ((curr_time-last_msg_time)>5)){ + /* prevent blanking each 5 seconds */ + msg=msg_dispblpause; + } + if (msg){ // ok we should send something + // flush if message is still in queue + // doesn't work, private data //if (msg->locked) + dbus_connection_flush(conn); //flush queue, just to be sure last message was sent + dresult = dbus_connection_send (conn, msg, NULL); + last_msg_time=curr_time; + if (!dresult) fprintf(stderr,"cannot send DBUS message\n"); + // we reuse message so no unref // dbus_message_unref(msg); + // flush could block now, do later // dbus_connection_flush(conn); + } +#endif memset(&event, 0, sizeof(event)); event.type = EV_KEY; event.code = code; @@ -101,4 +152,8 @@ { ioctl(fd, UI_DEV_DESTROY); close(fd); +#ifdef N770 + if (msg_dispon) dbus_message_unref(msg_dispon); + if (msg_dispblpause) dbus_message_unref(msg_dispblpause); +#endif }