Revision: 5882 Author: pebender Date: Mon Nov 30 22:25:53 2009 Log: - Updated the Bluez PS3 patch.
http://code.google.com/p/minimyth/source/detail?r=5882 Added: /trunk/gar-minimyth/script/lib/bluez/files/bluez-4.58-ps3remote_20091128.patch Deleted: /trunk/gar-minimyth/script/lib/bluez/files/bluez-4.58-ps3_bd_remote.patch Modified: /trunk/gar-minimyth/script/lib/bluez/Makefile /trunk/gar-minimyth/script/lib/bluez/checksums ======================================= --- /dev/null +++ /trunk/gar-minimyth/script/lib/bluez/files/bluez-4.58-ps3remote_20091128.patch Mon Nov 30 22:25:53 2009 @@ -0,0 +1,1205 @@ +diff -Naur bluez-4.58-old/input/device.c bluez-4.58-new/input/device.c +--- bluez-4.58-old/input/device.c 2009-05-09 02:31:01.000000000 -0700 ++++ bluez-4.58-new/input/device.c 2009-11-30 22:18:20.000000000 -0800 +@@ -465,14 +465,14 @@ + + static gboolean fake_hid_connect(struct input_conn *iconn, GError **err) + { +- struct fake_hid *fhid = iconn->fake->priv; ++ struct fake_hid *fhid = iconn->fake->hidd; + + return fhid->connect(iconn->fake, err); + } + + static int fake_hid_disconnect(struct input_conn *iconn) + { +- struct fake_hid *fhid = iconn->fake->priv; ++ struct fake_hid *fhid = iconn->fake->hidd; + + return fhid->disconnect(iconn->fake); + } +@@ -603,7 +603,7 @@ + } + + static int hidp_add_connection(const struct input_device *idev, +- const struct input_conn *iconn) ++ struct input_conn *iconn) + { + struct hidp_connadd_req *req; + struct fake_hid *fake_hid; +@@ -639,8 +639,12 @@ + fake = g_new0(struct fake_input, 1); + fake->connect = fake_hid_connect; + fake->disconnect = fake_hid_disconnect; +- fake->priv = fake_hid; ++ fake->hidd = fake_hid; ++ bacpy(&fake->ba_src, &idev->src); ++ bacpy(&fake->ba_dst, &idev->dst); ++ fake->idle_timeout = iconn->timeout; + err = fake_hid_connadd(fake, iconn->intr_io, fake_hid); ++ iconn->fake = fake; + goto cleanup; + } + +@@ -787,7 +791,7 @@ + struct input_device *idev = user_data; + int flags; + +- info("Input: disconnect %s", idev->path); ++ debug("Input: disconnect %s", idev->path); + + flags = removal ? (1 << HIDP_VIRTUAL_CABLE_UNPLUG) : 0; + +@@ -1291,3 +1295,15 @@ + + return 0; + } ++ ++void input_device_request_disconnect(const bdaddr_t *src, const bdaddr_t *dst) ++{ ++ struct input_device *idev = find_device(src, dst); ++ ++ if (!idev) ++ return; ++ ++ // or call disconnect() ? ++ device_request_disconnect(idev->device, NULL); ++} ++ +diff -Naur bluez-4.58-old/input/device.h bluez-4.58-new/input/device.h +--- bluez-4.58-old/input/device.h 2009-04-22 18:40:04.000000000 -0700 ++++ bluez-4.58-new/input/device.h 2009-11-30 22:18:20.000000000 -0800 +@@ -29,6 +29,7 @@ + + struct input_device; + struct input_conn; ++struct fake_hid; + + struct fake_input { + int flags; +@@ -36,9 +37,14 @@ + int uinput; /* uinput socket */ + int rfcomm; /* RFCOMM socket */ + uint8_t ch; /* RFCOMM channel number */ ++ int idle_timeout; ++ guint timer; + gboolean (*connect) (struct input_conn *iconn, GError **err); + int (*disconnect) (struct input_conn *iconn); ++ bdaddr_t ba_src, ba_dst; ++ struct fake_hid *hidd; + void *priv; ++ guint sid_in; + }; + + int fake_input_register(DBusConnection *conn, struct btd_device *device, +@@ -53,3 +59,5 @@ + int input_device_set_channel(const bdaddr_t *src, const bdaddr_t *dst, int psm, + GIOChannel *io); + int input_device_close_channels(const bdaddr_t *src, const bdaddr_t *dst); ++void input_device_request_disconnect(const bdaddr_t *src, const bdaddr_t *dst); ++ +diff -Naur bluez-4.58-old/input/fakehid.c bluez-4.58-new/input/fakehid.c +--- bluez-4.58-old/input/fakehid.c 2009-04-22 18:40:04.000000000 -0700 ++++ bluez-4.58-new/input/fakehid.c 2009-11-30 22:18:20.000000000 -0800 +@@ -48,8 +48,479 @@ + #include "fakehid.h" + #include "uinput.h" + ++static int fake_hid_common_connect(struct fake_input *fake, GError **err); ++static int fake_hid_common_disconnect(struct fake_input *fake); ++static gboolean fake_hid_common_timeout(gpointer data); ++ ++/* Possible inputs, based off of keys in uinput.h */ ++#define ENTRY(x) [x] = #x ++static char *uinput_map[] = { ++ ENTRY(KEY_ESC), ++ ENTRY(KEY_1), ++ ENTRY(KEY_2), ++ ENTRY(KEY_3), ++ ENTRY(KEY_4), ++ ENTRY(KEY_5), ++ ENTRY(KEY_6), ++ ENTRY(KEY_7), ++ ENTRY(KEY_8), ++ ENTRY(KEY_9), ++ ENTRY(KEY_0), ++ ENTRY(KEY_MINUS), ++ ENTRY(KEY_EQUAL), ++ ENTRY(KEY_BACKSPACE), ++ ENTRY(KEY_TAB), ++ ENTRY(KEY_Q), ++ ENTRY(KEY_W), ++ ENTRY(KEY_E), ++ ENTRY(KEY_R), ++ ENTRY(KEY_T), ++ ENTRY(KEY_Y), ++ ENTRY(KEY_U), ++ ENTRY(KEY_I), ++ ENTRY(KEY_O), ++ ENTRY(KEY_P), ++ ENTRY(KEY_LEFTBRACE), ++ ENTRY(KEY_RIGHTBRACE), ++ ENTRY(KEY_ENTER), ++ ENTRY(KEY_LEFTCTRL), ++ ENTRY(KEY_A), ++ ENTRY(KEY_S), ++ ENTRY(KEY_D), ++ ENTRY(KEY_F), ++ ENTRY(KEY_G), ++ ENTRY(KEY_H), ++ ENTRY(KEY_J), ++ ENTRY(KEY_K), ++ ENTRY(KEY_L), ++ ENTRY(KEY_SEMICOLON), ++ ENTRY(KEY_APOSTROPHE), ++ ENTRY(KEY_GRAVE), ++ ENTRY(KEY_LEFTSHIFT), ++ ENTRY(KEY_BACKSLASH), ++ ENTRY(KEY_Z), ++ ENTRY(KEY_X), ++ ENTRY(KEY_C), ++ ENTRY(KEY_V), ++ ENTRY(KEY_B), ++ ENTRY(KEY_N), ++ ENTRY(KEY_M), ++ ENTRY(KEY_COMMA), ++ ENTRY(KEY_DOT), ++ ENTRY(KEY_SLASH), ++ ENTRY(KEY_RIGHTSHIFT), ++ ENTRY(KEY_KPASTERISK), ++ ENTRY(KEY_LEFTALT), ++ ENTRY(KEY_SPACE), ++ ENTRY(KEY_CAPSLOCK), ++ ENTRY(KEY_F1), ++ ENTRY(KEY_F2), ++ ENTRY(KEY_F3), ++ ENTRY(KEY_F4), ++ ENTRY(KEY_F5), ++ ENTRY(KEY_F6), ++ ENTRY(KEY_F7), ++ ENTRY(KEY_F8), ++ ENTRY(KEY_F9), ++ ENTRY(KEY_F10), ++ ENTRY(KEY_NUMLOCK), ++ ENTRY(KEY_SCROLLLOCK), ++ ENTRY(KEY_KP7), ++ ENTRY(KEY_KP8), ++ ENTRY(KEY_KP9), ++ ENTRY(KEY_KPMINUS), ++ ENTRY(KEY_KP4), ++ ENTRY(KEY_KP5), ++ ENTRY(KEY_KP6), ++ ENTRY(KEY_KPPLUS), ++ ENTRY(KEY_KP1), ++ ENTRY(KEY_KP2), ++ ENTRY(KEY_KP3), ++ ENTRY(KEY_KP0), ++ ENTRY(KEY_KPDOT), ++ ++ ENTRY(KEY_ZENKAKUHANKAKU), ++ ENTRY(KEY_102ND), ++ ENTRY(KEY_F11), ++ ENTRY(KEY_F12), ++ ENTRY(KEY_RO), ++ ENTRY(KEY_KATAKANA), ++ ENTRY(KEY_HIRAGANA), ++ ENTRY(KEY_HENKAN), ++ ENTRY(KEY_KATAKANAHIRAGANA), ++ ENTRY(KEY_MUHENKAN), ++ ENTRY(KEY_KPJPCOMMA), ++ ENTRY(KEY_KPENTER), ++ ENTRY(KEY_RIGHTCTRL), ++ ENTRY(KEY_KPSLASH), ++ ENTRY(KEY_SYSRQ), ++ ENTRY(KEY_RIGHTALT), ++ ENTRY(KEY_LINEFEED), ++ ENTRY(KEY_HOME), ++ ENTRY(KEY_UP), ++ ENTRY(KEY_PAGEUP), ++ ENTRY(KEY_LEFT), ++ ENTRY(KEY_RIGHT), ++ ENTRY(KEY_END), ++ ENTRY(KEY_DOWN), ++ ENTRY(KEY_PAGEDOWN), ++ ENTRY(KEY_INSERT), ++ ENTRY(KEY_DELETE), ++ ENTRY(KEY_MACRO), ++ ENTRY(KEY_MUTE), ++ ENTRY(KEY_VOLUMEDOWN), ++ ENTRY(KEY_VOLUMEUP), ++ ENTRY(KEY_POWER), ++ ENTRY(KEY_KPEQUAL), ++ ENTRY(KEY_KPPLUSMINUS), ++ ENTRY(KEY_PAUSE), ++ ++ ENTRY(KEY_KPCOMMA), ++ ENTRY(KEY_HANGEUL), ++ ENTRY(KEY_HANGUEL), ++ ENTRY(KEY_HANJA), ++ ENTRY(KEY_YEN), ++ ENTRY(KEY_LEFTMETA), ++ ENTRY(KEY_RIGHTMETA), ++ ENTRY(KEY_COMPOSE), ++ ++ ENTRY(KEY_STOP), ++ ENTRY(KEY_AGAIN), ++ ENTRY(KEY_PROPS), ++ ENTRY(KEY_UNDO), ++ ENTRY(KEY_FRONT), ++ ENTRY(KEY_COPY), ++ ENTRY(KEY_OPEN), ++ ENTRY(KEY_PASTE), ++ ENTRY(KEY_FIND), ++ ENTRY(KEY_CUT), ++ ENTRY(KEY_HELP), ++ ENTRY(KEY_MENU), ++ ENTRY(KEY_CALC), ++ ENTRY(KEY_SETUP), ++ ENTRY(KEY_SLEEP), ++ ENTRY(KEY_WAKEUP), ++ ENTRY(KEY_FILE), ++ ENTRY(KEY_SENDFILE), ++ ENTRY(KEY_DELETEFILE), ++ ENTRY(KEY_XFER), ++ ENTRY(KEY_PROG1), ++ ENTRY(KEY_PROG2), ++ ENTRY(KEY_WWW), ++ ENTRY(KEY_MSDOS), ++ ENTRY(KEY_COFFEE), ++ ENTRY(KEY_SCREENLOCK), ++ ENTRY(KEY_DIRECTION), ++ ENTRY(KEY_CYCLEWINDOWS), ++ ENTRY(KEY_MAIL), ++ ENTRY(KEY_BOOKMARKS), ++ ENTRY(KEY_COMPUTER), ++ ENTRY(KEY_BACK), ++ ENTRY(KEY_FORWARD), ++ ENTRY(KEY_CLOSECD), ++ ENTRY(KEY_EJECTCD), ++ ENTRY(KEY_EJECTCLOSECD), ++ ENTRY(KEY_NEXTSONG), ++ ENTRY(KEY_PLAYPAUSE), ++ ENTRY(KEY_PREVIOUSSONG), ++ ENTRY(KEY_STOPCD), ++ ENTRY(KEY_RECORD), ++ ENTRY(KEY_REWIND), ++ ENTRY(KEY_PHONE), ++ ENTRY(KEY_ISO), ++ ENTRY(KEY_CONFIG), ++ ENTRY(KEY_HOMEPAGE), ++ ENTRY(KEY_REFRESH), ++ ENTRY(KEY_EXIT), ++ ENTRY(KEY_MOVE), ++ ENTRY(KEY_EDIT), ++ ENTRY(KEY_SCROLLUP), ++ ENTRY(KEY_SCROLLDOWN), ++ ENTRY(KEY_KPLEFTPAREN), ++ ENTRY(KEY_KPRIGHTPAREN), ++ ENTRY(KEY_NEW), ++ ENTRY(KEY_REDO), ++ ++ ENTRY(KEY_F13), ++ ENTRY(KEY_F14), ++ ENTRY(KEY_F15), ++ ENTRY(KEY_F16), ++ ENTRY(KEY_F17), ++ ENTRY(KEY_F18), ++ ENTRY(KEY_F19), ++ ENTRY(KEY_F20), ++ ENTRY(KEY_F21), ++ ENTRY(KEY_F22), ++ ENTRY(KEY_F23), ++ ENTRY(KEY_F24), ++ ++ ENTRY(KEY_PLAYCD), ++ ENTRY(KEY_PAUSECD), ++ ENTRY(KEY_PROG3), ++ ENTRY(KEY_PROG4), ++ ENTRY(KEY_SUSPEND), ++ ENTRY(KEY_CLOSE), ++ ENTRY(KEY_PLAY), ++ ENTRY(KEY_FASTFORWARD), ++ ENTRY(KEY_BASSBOOST), ++ ENTRY(KEY_PRINT), ++ ENTRY(KEY_HP), ++ ENTRY(KEY_CAMERA), ++ ENTRY(KEY_SOUND), ++ ENTRY(KEY_QUESTION), ++ ENTRY(KEY_EMAIL), ++ ENTRY(KEY_CHAT), ++ ENTRY(KEY_SEARCH), ++ ENTRY(KEY_CONNECT), ++ ENTRY(KEY_FINANCE), ++ ENTRY(KEY_SPORT), ++ ENTRY(KEY_SHOP), ++ ENTRY(KEY_ALTERASE), ++ ENTRY(KEY_CANCEL), ++ ENTRY(KEY_BRIGHTNESSDOWN), ++ ENTRY(KEY_BRIGHTNESSUP), ++ ENTRY(KEY_MEDIA), ++ ++ ENTRY(KEY_SWITCHVIDEOMODE), ++ ENTRY(KEY_KBDILLUMTOGGLE), ++ ENTRY(KEY_KBDILLUMDOWN), ++ ENTRY(KEY_KBDILLUMUP), ++ ++ ENTRY(KEY_SEND), ++ ENTRY(KEY_REPLY), ++ ENTRY(KEY_FORWARDMAIL), ++ ENTRY(KEY_SAVE), ++ ENTRY(KEY_DOCUMENTS), ++ ++ ENTRY(KEY_BATTERY), ++ ++ ENTRY(KEY_BLUETOOTH), ++ ENTRY(KEY_WLAN), ++ ENTRY(KEY_UWB), ++ ++ ENTRY(KEY_UNKNOWN), ++ ++ ENTRY(KEY_VIDEO_NEXT), ++ ENTRY(KEY_VIDEO_PREV), ++ ENTRY(KEY_BRIGHTNESS_CYCLE), ++ ENTRY(KEY_BRIGHTNESS_ZERO), ++ ENTRY(KEY_DISPLAY_OFF), ++ ++ ENTRY(KEY_WIMAX), ++ ++ ENTRY(BTN_MISC), ++ ENTRY(BTN_0), ++ ENTRY(BTN_1), ++ ENTRY(BTN_2), ++ ENTRY(BTN_3), ++ ENTRY(BTN_4), ++ ENTRY(BTN_5), ++ ENTRY(BTN_6), ++ ENTRY(BTN_7), ++ ENTRY(BTN_8), ++ ENTRY(BTN_9), ++ ++ ENTRY(BTN_MOUSE), ++ ENTRY(BTN_LEFT), ++ ENTRY(BTN_RIGHT), ++ ENTRY(BTN_MIDDLE), ++ ENTRY(BTN_SIDE), ++ ENTRY(BTN_EXTRA), ++ ENTRY(BTN_FORWARD), ++ ENTRY(BTN_BACK), ++ ENTRY(BTN_TASK), ++ ++ ENTRY(BTN_JOYSTICK), ++ ENTRY(BTN_TRIGGER), ++ ENTRY(BTN_THUMB), ++ ENTRY(BTN_THUMB2), ++ ENTRY(BTN_TOP), ++ ENTRY(BTN_TOP2), ++ ENTRY(BTN_PINKIE), ++ ENTRY(BTN_BASE), ++ ENTRY(BTN_BASE2), ++ ENTRY(BTN_BASE3), ++ ENTRY(BTN_BASE4), ++ ENTRY(BTN_BASE5), ++ ENTRY(BTN_BASE6), ++ ENTRY(BTN_DEAD), ++ ++ ENTRY(BTN_GAMEPAD), ++ ENTRY(BTN_A), ++ ENTRY(BTN_B), ++ ENTRY(BTN_C), ++ ENTRY(BTN_X), ++ ENTRY(BTN_Y), ++ ENTRY(BTN_Z), ++ ENTRY(BTN_TL), ++ ENTRY(BTN_TR), ++ ENTRY(BTN_TL2), ++ ENTRY(BTN_TR2), ++ ENTRY(BTN_SELECT), ++ ENTRY(BTN_START), ++ ENTRY(BTN_MODE), ++ ENTRY(BTN_THUMBL), ++ ENTRY(BTN_THUMBR), ++ ++ ENTRY(BTN_DIGI), ++ ENTRY(BTN_TOOL_PEN), ++ ENTRY(BTN_TOOL_RUBBER), ++ ENTRY(BTN_TOOL_BRUSH), ++ ENTRY(BTN_TOOL_PENCIL), ++ ENTRY(BTN_TOOL_AIRBRUSH), ++ ENTRY(BTN_TOOL_FINGER), ++ ENTRY(BTN_TOOL_MOUSE), ++ ENTRY(BTN_TOOL_LENS), ++ ENTRY(BTN_TOUCH), ++ ENTRY(BTN_STYLUS), ++ ENTRY(BTN_STYLUS2), ++ ENTRY(BTN_TOOL_DOUBLETAP), ++ ENTRY(BTN_TOOL_TRIPLETAP), ++ ++ ENTRY(BTN_WHEEL), ++ ENTRY(BTN_GEAR_DOWN), ++ ENTRY(BTN_GEAR_UP), ++ ++ ENTRY(KEY_OK), ++ ENTRY(KEY_SELECT), ++ ENTRY(KEY_GOTO), ++ ENTRY(KEY_CLEAR), ++ ENTRY(KEY_POWER2), ++ ENTRY(KEY_OPTION), ++ ENTRY(KEY_INFO), ++ ENTRY(KEY_TIME), ++ ENTRY(KEY_VENDOR), ++ ENTRY(KEY_ARCHIVE), ++ ENTRY(KEY_PROGRAM), ++ ENTRY(KEY_CHANNEL), ++ ENTRY(KEY_FAVORITES), ++ ENTRY(KEY_EPG), ++ ENTRY(KEY_PVR), ++ ENTRY(KEY_MHP), ++ ENTRY(KEY_LANGUAGE), ++ ENTRY(KEY_TITLE), ++ ENTRY(KEY_SUBTITLE), ++ ENTRY(KEY_ANGLE), ++ ENTRY(KEY_ZOOM), ++ ENTRY(KEY_MODE), ++ ENTRY(KEY_KEYBOARD), ++ ENTRY(KEY_SCREEN), ++ ENTRY(KEY_PC), ++ ENTRY(KEY_TV), ++ ENTRY(KEY_TV2), ++ ENTRY(KEY_VCR), ++ ENTRY(KEY_VCR2), ++ ENTRY(KEY_SAT), ++ ENTRY(KEY_SAT2), ++ ENTRY(KEY_CD), ++ ENTRY(KEY_TAPE), ++ ENTRY(KEY_RADIO), ++ ENTRY(KEY_TUNER), ++ ENTRY(KEY_PLAYER), ++ ENTRY(KEY_TEXT), ++ ENTRY(KEY_DVD), ++ ENTRY(KEY_AUX), ++ ENTRY(KEY_MP3), ++ ENTRY(KEY_AUDIO), ++ ENTRY(KEY_VIDEO), ++ ENTRY(KEY_DIRECTORY), ++ ENTRY(KEY_LIST), ++ ENTRY(KEY_MEMO), ++ ENTRY(KEY_CALENDAR), ++ ENTRY(KEY_RED), ++ ENTRY(KEY_GREEN), ++ ENTRY(KEY_YELLOW), ++ ENTRY(KEY_BLUE), ++ ENTRY(KEY_CHANNELUP), ++ ENTRY(KEY_CHANNELDOWN), ++ ENTRY(KEY_FIRST), ++ ENTRY(KEY_LAST), ++ ENTRY(KEY_AB), ++ ENTRY(KEY_NEXT), ++ ENTRY(KEY_RESTART), ++ ENTRY(KEY_SLOW), ++ ENTRY(KEY_SHUFFLE), ++ ENTRY(KEY_BREAK), ++ ENTRY(KEY_PREVIOUS), ++ ENTRY(KEY_DIGITS), ++ ENTRY(KEY_TEEN), ++ ENTRY(KEY_TWEN), ++ ENTRY(KEY_VIDEOPHONE), ++ ENTRY(KEY_GAMES), ++ ENTRY(KEY_ZOOMIN), ++ ENTRY(KEY_ZOOMOUT), ++ ENTRY(KEY_ZOOMRESET), ++ ENTRY(KEY_WORDPROCESSOR), ++ ENTRY(KEY_EDITOR), ++ ENTRY(KEY_SPREADSHEET), ++ ENTRY(KEY_GRAPHICSEDITOR), ++ ENTRY(KEY_PRESENTATION), ++ ENTRY(KEY_DATABASE), ++ ENTRY(KEY_NEWS), ++ ENTRY(KEY_VOICEMAIL), ++ ENTRY(KEY_ADDRESSBOOK), ++ ENTRY(KEY_MESSENGER), ++ ENTRY(KEY_DISPLAYTOGGLE), ++ ENTRY(KEY_SPELLCHECK), ++ ENTRY(KEY_LOGOFF), ++ ++ ENTRY(KEY_DOLLAR), ++ ENTRY(KEY_EURO), ++ ++ ENTRY(KEY_FRAMEBACK), ++ ENTRY(KEY_FRAMEFORWARD), ++ ENTRY(KEY_CONTEXT_MENU), ++ ENTRY(KEY_MEDIA_REPEAT), ++ ++ ENTRY(KEY_DEL_EOL), ++ ENTRY(KEY_DEL_EOS), ++ ENTRY(KEY_INS_LINE), ++ ENTRY(KEY_DEL_LINE), ++ ++ ENTRY(KEY_FN), ++ ENTRY(KEY_FN_ESC), ++ ENTRY(KEY_FN_F1), ++ ENTRY(KEY_FN_F2), ++ ENTRY(KEY_FN_F3), ++ ENTRY(KEY_FN_F4), ++ ENTRY(KEY_FN_F5), ++ ENTRY(KEY_FN_F6), ++ ENTRY(KEY_FN_F7), ++ ENTRY(KEY_FN_F8), ++ ENTRY(KEY_FN_F9), ++ ENTRY(KEY_FN_F10), ++ ENTRY(KEY_FN_F11), ++ ENTRY(KEY_FN_F12), ++ ENTRY(KEY_FN_1), ++ ENTRY(KEY_FN_2), ++ ENTRY(KEY_FN_D), ++ ENTRY(KEY_FN_E), ++ ENTRY(KEY_FN_F), ++ ENTRY(KEY_FN_S), ++ ENTRY(KEY_FN_B), ++ ++ ENTRY(KEY_BRL_DOT1), ++ ENTRY(KEY_BRL_DOT2), ++ ENTRY(KEY_BRL_DOT3), ++ ENTRY(KEY_BRL_DOT4), ++ ENTRY(KEY_BRL_DOT5), ++ ENTRY(KEY_BRL_DOT6), ++ ENTRY(KEY_BRL_DOT7), ++ ENTRY(KEY_BRL_DOT8), ++ ENTRY(KEY_BRL_DOT9), ++ ENTRY(KEY_BRL_DOT10), ++ ++ ENTRY(KEY_MAX) ++}; ++ + #define PS3_FLAGS_MASK 0xFFFFFF00 + ++struct ps3remote_data { ++ unsigned int lastkey; ++ unsigned int lastval; ++ unsigned int lastmask; ++}; ++ + enum ps3remote_special_keys { + PS3R_BIT_PS = 0, + PS3R_BIT_ENTER = 3, +@@ -92,6 +563,8 @@ + [PS3R_BIT_SELECT] = 0x50, + }; + ++static const char *ps3remote_mapname = "PS3 Remote Map"; ++ + static unsigned int ps3remote_keymap[] = { + [0x16] = KEY_EJECTCD, + [0x64] = KEY_AUDIO, +@@ -147,10 +620,38 @@ + [0xff] = KEY_MAX, + }; + +-static int ps3remote_decode(char *buff, int size, unsigned int *value) ++static int ps3remote_uinput = -1; ++ ++static gboolean uinput_sendkey(int uinput, unsigned int key, ++ unsigned int value) ++{ ++ struct uinput_event event; ++ ++ memset(&event, 0, sizeof(event)); ++ gettimeofday(&event.time, NULL); ++ event.type = EV_KEY; ++ event.code = key; ++ event.value = value; ++ if (write(uinput, &event, sizeof(event)) != sizeof(event)) { ++ error("Error writing to uinput device"); ++ return FALSE; ++ } ++ ++ memset(&event, 0, sizeof(event)); ++ gettimeofday(&event.time, NULL); ++ event.type = EV_SYN; ++ event.code = SYN_REPORT; ++ if (write(uinput, &event, sizeof(event)) != sizeof(event)) { ++ error("Error writing to uinput device"); ++ return FALSE; ++ } ++ ++ return TRUE; ++} ++ ++static int ps3remote_decode(char *buff, int size, unsigned int *value, ++ struct ps3remote_data *ps3data) + { +- static unsigned int lastkey = 0; +- static unsigned int lastmask = 0; + unsigned int i, mask; + int retval; + guint8 key; +@@ -165,17 +666,18 @@ + + /* first, check flags */ + for (i = 0; i < 24; i++) { +- if ((lastmask & (1 << i)) == (mask & (1 << i))) ++ if ((ps3data->lastmask & (1 << i)) == (mask & (1 << i))) + continue; + if (ps3remote_bits[i] == 0) + goto error; + retval = ps3remote_keymap[ps3remote_bits[i]]; +- if (mask & (1 << i)) ++ if (mask & (1 << i)) { + /* key pressed */ + *value = 1; +- else ++ } else { + /* key released */ + *value = 0; ++ } + + goto out; + } +@@ -183,20 +685,21 @@ + *value = buff[11]; + if (buff[11] == 1) { + retval = ps3remote_keymap[key]; +- } else +- retval = lastkey; ++ } else { ++ retval = ps3data->lastkey; ++ } + + if (retval == KEY_RESERVED) + goto error; + if (retval == KEY_MAX) + return retval; + +- lastkey = retval; ++ ps3data->lastkey = retval; + + out: + fflush(stdout); + +- lastmask = mask; ++ ps3data->lastmask = mask; + + return retval; + +@@ -204,8 +707,8 @@ + error("ps3remote: unrecognized sequence [%#x][%#x][%#x][%#x] [%#x]," + "last: [%#x][%#x][%#x][%#x]", + buff[2], buff[3], buff[4], buff[5], buff[11], +- lastmask >> 16, lastmask >> 8 & 0xff, +- lastmask & 0xff, lastkey); ++ ps3data->lastmask >> 16, ps3data->lastmask >> 8 & 0xff, ++ ps3data->lastmask & 0xff, ps3data->lastkey); + return -1; + } + +@@ -213,19 +716,28 @@ + gpointer data) + { + struct fake_input *fake = data; +- struct uinput_event event; ++ struct ps3remote_data *ps3data = fake->priv; + unsigned int key, value = 0; + gsize size; + char buff[50]; +- +- if (cond & G_IO_NVAL) +- return FALSE; ++ ++ if (cond & G_IO_NVAL) { ++ goto failed; ++ } + + if (cond & (G_IO_HUP | G_IO_ERR)) { +- error("Hangup or error on rfcomm server socket"); ++ if (ps3data) ++ error("Hangup or error on ps3remote server socket"); + goto failed; + } + ++ /* reset the timeout if needed */ ++ if (fake->timer) { ++ g_source_remove(fake->timer); ++ fake->timer = g_timeout_add_seconds(fake->idle_timeout, ++ fake_hid_common_timeout, fake); ++ } ++ + memset(buff, 0, sizeof(buff)); + + if (g_io_channel_read(chan, buff, sizeof(buff), &size) != +@@ -234,55 +746,106 @@ + goto failed; + } + +- key = ps3remote_decode(buff, size, &value); +- if (key == KEY_RESERVED) { +- error("Got invalid key from decode"); +- goto failed; +- } else if (key == KEY_MAX) ++ key = ps3remote_decode(buff, size, &value, ps3data); ++ debug("Got key: %d [%d]", key, value); ++ if (key == KEY_RESERVED || key == KEY_MAX) + return TRUE; + +- memset(&event, 0, sizeof(event)); +- gettimeofday(&event.time, NULL); +- event.type = EV_KEY; +- event.code = key; +- event.value = value; +- if (write(fake->uinput, &event, sizeof(event)) != sizeof(event)) { +- error("Error writing to uinput device"); +- goto failed; ++ if (key == KEY_HOMEPAGE) { ++ /* delay transmit of this key til release, assuming possible turn-off */ ++ if (ps3data->lastkey == KEY_HOMEPAGE && ++ value == 0 && ps3data->lastval == 1) { ++ debug("homepage key released"); ++ uinput_sendkey(fake->uinput, key, 1); ++ uinput_sendkey(fake->uinput, key, 0); ++ } + } +- +- memset(&event, 0, sizeof(event)); +- gettimeofday(&event.time, NULL); +- event.type = EV_SYN; +- event.code = SYN_REPORT; +- if (write(fake->uinput, &event, sizeof(event)) != sizeof(event)) { +- error("Error writing to uinput device"); ++ else if (!uinput_sendkey(fake->uinput, key, value)) { + goto failed; + } ++ ++ ps3data->lastkey = key; ++ ps3data->lastval = value; + + return TRUE; + + failed: +- ioctl(fake->uinput, UI_DEV_DESTROY); +- close(fake->uinput); +- fake->uinput = -1; ++ g_source_remove(fake->timer); ++ g_source_remove(fake->sid_in); + g_io_channel_unref(fake->io); + + return FALSE; + } + ++static gboolean ps3remote_connect(struct fake_input *fake, GError **err) ++{ ++ struct ps3remote_data *ps3data; ++ char devaddr[18]; ++ GKeyFile *config; ++ GError *cfgerr; ++ ++ ps3data = g_new0(struct ps3remote_data, 1); ++ fake->priv = ps3data; ++ ++ ba2str(&fake->ba_dst, devaddr); ++ debug("Processing PS3 device: %s", devaddr); ++ ++ /* Load config file */ ++ config = g_key_file_new(); ++ cfgerr = NULL; ++ if (!g_key_file_load_from_file(config, CONFIGDIR "/input.conf", 0, &cfgerr)) { ++ g_error_free(cfgerr); ++ } else { ++ if (g_key_file_has_group(config, devaddr)) { ++ int timeout; ++ ++ cfgerr = NULL; ++ timeout = g_key_file_get_integer(config, devaddr, ++ "IdleTimeout", &cfgerr); ++ if (cfgerr) { ++ g_error_free(cfgerr); ++ } else { ++ fake->idle_timeout = timeout * 60; ++ debug("[%s] Using timeout of %d seconds", ++ devaddr, fake->idle_timeout); ++ } ++ } ++ ++ g_key_file_free(config); ++ } ++ ++ return fake_hid_common_connect(fake, err); ++} ++ ++static int ps3remote_disconnect(struct fake_input *fake) ++{ ++ debug("Disconnecting PS3 remote"); ++ ++ g_free(fake->priv); ++ fake->priv = NULL; ++ ++ return fake_hid_common_disconnect(fake); ++} ++ + static int ps3remote_setup_uinput(struct fake_input *fake, + struct fake_hid *fake_hid) + { + struct uinput_dev dev; + int i; + +- fake->uinput = open("/dev/input/uinput", O_RDWR); +- if (fake->uinput < 0) { +- fake->uinput = open("/dev/uinput", O_RDWR); +- if (fake->uinput < 0) { +- fake->uinput = open("/dev/misc/uinput", O_RDWR); +- if (fake->uinput < 0) { ++ if (ps3remote_uinput >= 0) { ++ fake->uinput = ps3remote_uinput; ++ return 0; ++ } ++ ++ debug("Setting up PS3 Remote uinput"); ++ ++ ps3remote_uinput = open("/dev/input/uinput", O_RDWR); ++ if (ps3remote_uinput < 0) { ++ ps3remote_uinput = open("/dev/uinput", O_RDWR); ++ if (ps3remote_uinput < 0) { ++ ps3remote_uinput = open("/dev/misc/uinput", O_RDWR); ++ if (ps3remote_uinput < 0) { + error("Error opening uinput device file"); + return 1; + } +@@ -295,13 +858,13 @@ + dev.id.vendor = fake_hid->vendor; + dev.id.product = fake_hid->product; + +- if (write(fake->uinput, &dev, sizeof(dev)) != sizeof(dev)) { ++ if (write(ps3remote_uinput, &dev, sizeof(dev)) != sizeof(dev)) { + error("Error creating uinput device"); + goto err; + } + + /* enabling key events */ +- if (ioctl(fake->uinput, UI_SET_EVBIT, EV_KEY) < 0) { ++ if (ioctl(ps3remote_uinput, UI_SET_EVBIT, EV_KEY) < 0) { + error("Error enabling uinput device key events"); + goto err; + } +@@ -309,43 +872,78 @@ + /* enabling keys */ + for (i = 0; i < 256; i++) + if (ps3remote_keymap[i] != KEY_RESERVED) +- if (ioctl(fake->uinput, UI_SET_KEYBIT, +- ps3remote_keymap[i]) < 0) { +- error("Error enabling uinput key %i", +- ps3remote_keymap[i]); ++ if (ioctl(ps3remote_uinput, UI_SET_KEYBIT, ps3remote_keymap[i]) < 0) { ++ error("Error enabling uinput key %i", ps3remote_keymap[i]); + goto err; + } + + /* creating the device */ +- if (ioctl(fake->uinput, UI_DEV_CREATE) < 0) { ++ if (ioctl(ps3remote_uinput, UI_DEV_CREATE) < 0) { + error("Error creating uinput device"); + goto err; + } + ++ fake->uinput = ps3remote_uinput; ++ + return 0; + + err: +- close(fake->uinput); ++ close(ps3remote_uinput); ++ ps3remote_uinput = -1; ++ + return 1; + } + + static gboolean fake_hid_common_connect(struct fake_input *fake, GError **err) + { ++ if (fake->idle_timeout > 0) { ++ debug("Creating timeout"); ++ fake->timer = g_timeout_add_seconds(fake->idle_timeout, ++ fake_hid_common_timeout, fake); ++ } ++ + return TRUE; + } + + static int fake_hid_common_disconnect(struct fake_input *fake) + { ++ if (fake->timer) { ++ debug("Destroying timer"); ++ g_source_remove(fake->timer); ++ fake->timer = 0; ++ } ++ + return 0; + } + ++static gboolean fake_hid_common_timeout(gpointer data) ++{ ++ struct fake_input *fake = data; ++ ++ debug("Disconnecting device because of timeout"); ++ input_device_request_disconnect(&fake->ba_src, &fake->ba_dst); ++ ++ fake->timer = 0; ++ return FALSE; ++} ++ + static struct fake_hid fake_hid_table[] = { + /* Sony PS3 remote device */ + { + .vendor = 0x054c, + .product = 0x0306, +- .connect = fake_hid_common_connect, +- .disconnect = fake_hid_common_disconnect, ++ .connect = ps3remote_connect, ++ .disconnect = ps3remote_disconnect, ++ .event = ps3remote_event, ++ .setup_uinput = ps3remote_setup_uinput, ++ }, ++ ++ /* Blu-Link PS3 remote device */ ++ { ++ .vendor = 0x0609, ++ .product = 0x0306, ++ .connect = ps3remote_connect, ++ .disconnect = ps3remote_disconnect, + .event = ps3remote_event, + .setup_uinput = ps3remote_setup_uinput, + }, +@@ -373,6 +971,11 @@ + int fake_hid_connadd(struct fake_input *fake, GIOChannel *intr_io, + struct fake_hid *fake_hid) + { ++ if (!fake_hid->connect(fake, NULL)) { ++ error("Error connecting device"); ++ return ENOMEM; ++ } ++ + if (fake_hid->setup_uinput(fake, fake_hid)) { + error("Error setting up uinput"); + return ENOMEM; +@@ -380,8 +983,74 @@ + + fake->io = g_io_channel_ref(intr_io); + g_io_channel_set_close_on_unref(fake->io, TRUE); +- g_io_add_watch(fake->io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, ++ fake->sid_in = g_io_add_watch(fake->io, ++ G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, + (GIOFunc) fake_hid->event, fake); + + return 0; + } ++ ++void fake_hid_init(GKeyFile *config) ++{ ++ /* Load PS3 keymap */ ++ if (config && g_key_file_has_group(config, ps3remote_mapname)) { ++ GHashTable *maphash; ++ int i; ++ GError *err; ++ ***The diff for this file has been truncated for email.*** ======================================= --- /trunk/gar-minimyth/script/lib/bluez/files/bluez-4.58-ps3_bd_remote.patch Sun Nov 15 12:11:12 2009 +++ /dev/null @@ -1,583 +0,0 @@ -diff -Naur bluez-4.58-old/input/device.c bluez-4.58-new/input/device.c ---- bluez-4.58-old/input/device.c 2009-05-09 02:31:01.000000000 -0700 -+++ bluez-4.58-new/input/device.c 2009-11-15 04:42:56.000000000 -0800 -@@ -83,18 +83,6 @@ - struct input_device *idev; - }; - --struct input_device { -- DBusConnection *conn; -- char *path; -- bdaddr_t src; -- bdaddr_t dst; -- uint32_t handle; -- guint dc_id; -- char *name; -- struct btd_device *device; -- GSList *connections; --}; -- - GSList *devices = NULL; - - static struct input_device *find_device_by_path(GSList *list, const char *path) -@@ -640,6 +628,7 @@ - fake->connect = fake_hid_connect; - fake->disconnect = fake_hid_disconnect; - fake->priv = fake_hid; -+ fake->idev = idev; - err = fake_hid_connadd(fake, iconn->intr_io, fake_hid); - goto cleanup; - } -@@ -1103,15 +1092,16 @@ - - static struct input_conn *input_conn_new(struct input_device *idev, - const char *uuid, const char *alias, -- int timeout) -+ struct input_dev_conf *conf) - { - struct input_conn *iconn; - - iconn = g_new0(struct input_conn, 1); -- iconn->timeout = timeout; -+ iconn->timeout = conf->timeout; - iconn->uuid = g_strdup(uuid); - iconn->alias = g_strdup(alias); - iconn->idev = idev; -+ idev->conf = conf; - - return iconn; - } -@@ -1119,7 +1109,7 @@ - int input_device_register(DBusConnection *conn, struct btd_device *device, - const char *path, const bdaddr_t *src, - const bdaddr_t *dst, const char *uuid, -- uint32_t handle, int timeout) -+ uint32_t handle, struct input_dev_conf *conf) - { - struct input_device *idev; - struct input_conn *iconn; -@@ -1132,7 +1122,7 @@ - devices = g_slist_append(devices, idev); - } - -- iconn = input_conn_new(idev, uuid, "hid", timeout); -+ iconn = input_conn_new(idev, uuid, "hid", conf); - if (!iconn) - return -EINVAL; - -diff -Naur bluez-4.58-old/input/device.h bluez-4.58-new/input/device.h ---- bluez-4.58-old/input/device.h 2009-04-22 18:40:04.000000000 -0700 -+++ bluez-4.58-new/input/device.h 2009-11-15 04:42:56.000000000 -0800 -@@ -27,7 +27,22 @@ - #define L2CAP_PSM_HIDP_CTRL 0x11 - #define L2CAP_PSM_HIDP_INTR 0x13 - --struct input_device; -+struct input_dev_conf { -+ int timeout; -+ int ps3remote_compat; -+}; -+struct input_device { -+ DBusConnection *conn; -+ char *path; -+ bdaddr_t src; -+ bdaddr_t dst; -+ uint32_t handle; -+ guint dc_id; -+ char *name; -+ struct btd_device *device; -+ struct input_dev_conf *conf; -+ GSList *connections; -+}; - struct input_conn; - - struct fake_input { -@@ -39,6 +54,10 @@ - gboolean (*connect) (struct input_conn *iconn, GError **err); - int (*disconnect) (struct input_conn *iconn); - void *priv; -+ void *data; -+ const struct input_device * idev; -+ guint sid_in; -+ guint sid_out; - }; - - int fake_input_register(DBusConnection *conn, struct btd_device *device, -@@ -47,7 +66,7 @@ - int input_device_register(DBusConnection *conn, struct btd_device *device, - const char *path, const bdaddr_t *src, - const bdaddr_t *dst, const char *uuid, -- uint32_t handle, int timeout); -+ uint32_t handle, struct input_dev_conf *conf); - int input_device_unregister(const char *path, const char *uuid); - - int input_device_set_channel(const bdaddr_t *src, const bdaddr_t *dst, int psm, -diff -Naur bluez-4.58-old/input/fakehid.c bluez-4.58-new/input/fakehid.c ---- bluez-4.58-old/input/fakehid.c 2009-04-22 18:40:04.000000000 -0700 -+++ bluez-4.58-new/input/fakehid.c 2009-11-15 04:42:56.000000000 -0800 -@@ -31,11 +31,13 @@ - #include <unistd.h> - #include <stdlib.h> - #include <sys/types.h> -+#include <sys/stat.h> - - #include <bluetooth/bluetooth.h> - #include <bluetooth/l2cap.h> - #include <bluetooth/hidp.h> - #include <bluetooth/sdp.h> -+#include <bluetooth/hci.h> - - #include <glib.h> - #include <dbus/dbus.h> -@@ -92,7 +94,7 @@ - [PS3R_BIT_SELECT] = 0x50, - }; - --static unsigned int ps3remote_keymap[] = { -+static unsigned int ps3keymap_def[] = { - [0x16] = KEY_EJECTCD, - [0x64] = KEY_AUDIO, - [0x65] = KEY_ANGLE, -@@ -145,12 +147,64 @@ - [0x39] = KEY_PAUSE, - [0x61] = KEY_FRAMEFORWARD, /* slow/step forward */ - [0xff] = KEY_MAX, -+}, ps3keymap_alt[] = { -+ [0x16] = KEY_EJECTCD, -+ [0x64] = KEY_A, /* audio */ -+ [0x65] = KEY_Z, /* angle */ -+ [0x63] = KEY_T, /* subtitle */ -+ [0x0f] = KEY_DELETE, /* clear */ -+ [0x28] = KEY_END, /* timer */ -+ [0x00] = KEY_1, -+ [0x01] = KEY_2, -+ [0x02] = KEY_3, -+ [0x03] = KEY_4, -+ [0x04] = KEY_5, -+ [0x05] = KEY_6, -+ [0x06] = KEY_7, -+ [0x07] = KEY_8, -+ [0x08] = KEY_9, -+ [0x09] = KEY_0, -+ [0x81] = KEY_F7, /* red */ -+ [0x82] = KEY_F8, /* green */ -+ [0x83] = KEY_F9, /* yellow */ -+ [0x80] = KEY_F10, /* blue */ -+ [0x70] = KEY_D, /* display */ -+ [0x1a] = KEY_MENU, /* top menu */ -+ [0x40] = KEY_F11, /* pop up/menu */ -+ [0x0e] = KEY_ESC, /* return */ -+ [0x5c] = KEY_F12, /* options/triangle */ -+ [0x5d] = KEY_BACK, /* back/circle */ -+ [0x5f] = KEY_V, /* view/square */ -+ [0x5e] = KEY_X, /* cross */ -+ [0x54] = KEY_UP, -+ [0x56] = KEY_DOWN, -+ [0x57] = KEY_LEFT, -+ [0x55] = KEY_RIGHT, -+ [0x0b] = KEY_ENTER, -+ [0x5a] = KEY_F1, /* L1 */ -+ [0x58] = KEY_F2, /* L2 */ -+ [0x51] = KEY_F3, /* L3 */ -+ [0x5b] = KEY_F4, /* R1 */ -+ [0x59] = KEY_F5, /* R2 */ -+ [0x52] = KEY_F6, /* R3 */ -+ [0x43] = KEY_HOMEPAGE, /* PS button */ -+ [0x50] = KEY_INSERT, /* select */ -+ [0x53] = KEY_HOME, /* start */ -+ [0x33] = KEY_R, /* scan back */ -+ [0x32] = KEY_PLAY, -+ [0x34] = KEY_F, /* scan forward */ -+ [0x30] = KEY_PAGEDOWN, /* prev */ -+ [0x38] = KEY_STOP, -+ [0x31] = KEY_PAGEUP, /* next */ -+ [0x60] = KEY_COMMA, /* slow/step back */ -+ [0x39] = KEY_PAUSE, -+ [0x61] = KEY_DOT, /* slow/step forward */ -+ [0xff] = KEY_MAX, - }; - --static int ps3remote_decode(char *buff, int size, unsigned int *value) -+static int ps3remote_decode(char *buff, int size, unsigned int *value, -+ struct ps3remote_data *ps3) - { -- static unsigned int lastkey = 0; -- static unsigned int lastmask = 0; - unsigned int i, mask; - int retval; - guint8 key; -@@ -165,11 +219,11 @@ - - /* first, check flags */ - for (i = 0; i < 24; i++) { -- if ((lastmask & (1 << i)) == (mask & (1 << i))) -+ if ((ps3->lastmask & (1 << i)) == (mask & (1 << i))) - continue; - if (ps3remote_bits[i] == 0) - goto error; -- retval = ps3remote_keymap[ps3remote_bits[i]]; -+ retval = ps3->keymap[ps3remote_bits[i]]; - if (mask & (1 << i)) - /* key pressed */ - *value = 1; -@@ -182,21 +236,21 @@ - - *value = buff[11]; - if (buff[11] == 1) { -- retval = ps3remote_keymap[key]; -+ retval = ps3->keymap[key]; - } else -- retval = lastkey; -+ retval = ps3->lastkey; - - if (retval == KEY_RESERVED) - goto error; - if (retval == KEY_MAX) - return retval; - -- lastkey = retval; -+ ps3->lastkey = retval; - - out: - fflush(stdout); - -- lastmask = mask; -+ ps3->lastmask = mask; - - return retval; - -@@ -204,22 +258,69 @@ - error("ps3remote: unrecognized sequence [%#x][%#x][%#x][%#x] [%#x]," - "last: [%#x][%#x][%#x][%#x]", - buff[2], buff[3], buff[4], buff[5], buff[11], -- lastmask >> 16, lastmask >> 8 & 0xff, -- lastmask & 0xff, lastkey); -+ ps3->lastmask >> 16, ps3->lastmask >> 8 & 0xff, -+ ps3->lastmask & 0xff, ps3->lastkey); - return -1; - } -+static gboolean ps3remote_sendkey(int uinput, unsigned int key, -+ unsigned int value) -+{ -+ struct uinput_event event; -+ -+ memset(&event, 0, sizeof(event)); -+ gettimeofday(&event.time, NULL); -+ event.type = EV_KEY; -+ event.code = key; -+ event.value = value; -+ if (write(uinput, &event, sizeof(event)) != sizeof(event)) { -+ error("Error writing to uinput device"); -+ return FALSE; -+ } - -+ memset(&event, 0, sizeof(event)); -+ gettimeofday(&event.time, NULL); -+ event.type = EV_SYN; -+ event.code = SYN_REPORT; -+ if (write(uinput, &event, sizeof(event)) != sizeof(event)) { -+ error("Error writing to uinput device"); -+ return FALSE; -+ } -+ return TRUE; -+} -+static gboolean ps3remote_out(GIOChannel *chan, GIOCondition cond, -+ gpointer data) -+{ -+ struct ps3remote_data *ps3 = ((struct fake_input *)data)->data; -+ const struct input_device *idev = ((struct fake_input *)data)->idev; -+ uint16_t to = (ps3->timeout < 5) ? 15 : ps3->timeout; -+ gulong ms; -+ -+ if(g_timer_elapsed(ps3->timer,&ms) > to) { -+ DBG("idle timeout, disconnecting BT channel"); -+ device_request_disconnect(idev->device, NULL); -+ return FALSE; -+ } else -+ usleep(750); -+ return TRUE; -+} - static gboolean ps3remote_event(GIOChannel *chan, GIOCondition cond, - gpointer data) - { - struct fake_input *fake = data; -- struct uinput_event event; -+ struct ps3remote_data *ps3 = (struct ps3remote_data *)fake->data; - unsigned int key, value = 0; - gsize size; - char buff[50]; - -- if (cond & G_IO_NVAL) -- return FALSE; -+ g_timer_start(ps3->timer); -+ if (cond & G_IO_NVAL) { -+ if(ps3->lastkey == KEY_HOMEPAGE && ps3->lastval == 1) -+ DBG("Remote turned off"); -+ else -+ DBG("Remote disconnected [%u:%u]", ps3->lastkey, -+ ps3->lastval); -+ goto failed; -+ } - - if (cond & (G_IO_HUP | G_IO_ERR)) { - error("Hangup or error on rfcomm server socket"); -@@ -234,40 +335,36 @@ - goto failed; - } - -- key = ps3remote_decode(buff, size, &value); -+ key = ps3remote_decode(buff, size, &value, ps3); - if (key == KEY_RESERVED) { - error("Got invalid key from decode"); - goto failed; - } else if (key == KEY_MAX) - return TRUE; - -- memset(&event, 0, sizeof(event)); -- gettimeofday(&event.time, NULL); -- event.type = EV_KEY; -- event.code = key; -- event.value = value; -- if (write(fake->uinput, &event, sizeof(event)) != sizeof(event)) { -- error("Error writing to uinput device"); -+ /* Delaying key till release, assuming possible turn-off */ -+ if(key == KEY_HOMEPAGE) { -+ if(value == 0 && ps3->lastkey == KEY_HOMEPAGE -+ && ps3->lastval == 1) { -+ ps3remote_sendkey(fake->uinput, key, 1); -+ ps3remote_sendkey(fake->uinput, key, 0); -+ } else -+ DBG("Delayed: %u:%u (%u:%u)", key, value, -+ ps3->lastkey, ps3->lastval); -+ } else if(!ps3remote_sendkey(fake->uinput, key, value)) - goto failed; -- } -- -- memset(&event, 0, sizeof(event)); -- gettimeofday(&event.time, NULL); -- event.type = EV_SYN; -- event.code = SYN_REPORT; -- if (write(fake->uinput, &event, sizeof(event)) != sizeof(event)) { -- error("Error writing to uinput device"); -- goto failed; -- } - -+ ps3->lastkey = key; -+ ps3->lastval = value; -+ DBG("Passed key %u:%u", key, value); - return TRUE; - - failed: -- ioctl(fake->uinput, UI_DEV_DESTROY); -- close(fake->uinput); -- fake->uinput = -1; -+ g_timer_stop(ps3->timer); -+ g_source_remove(fake->sid_in); -+ g_source_remove(fake->sid_out); - g_io_channel_unref(fake->io); -- -+ DBG("Event failed"); - return FALSE; - } - -@@ -275,8 +372,20 @@ - struct fake_hid *fake_hid) - { - struct uinput_dev dev; -+ struct ps3remote_data *ps3 = (struct ps3remote_data *)fake->data; -+ struct stat sbuf; - int i; - -+ /* check if uinput already open */ -+ if(fake->uinput > 0) { -+ if(!(i=fstat(fake->uinput, &sbuf))) { -+ DBG("input %d is opened", fake->uinput); -+ return 0; -+ } else -+ DBG("fstat(%d): error[%d]: %s", fake->uinput, i, -+ strerror(errno)); -+ } -+ /* create uinput device */ - fake->uinput = open("/dev/input/uinput", O_RDWR); - if (fake->uinput < 0) { - fake->uinput = open("/dev/uinput", O_RDWR); -@@ -308,11 +417,11 @@ - - /* enabling keys */ - for (i = 0; i < 256; i++) -- if (ps3remote_keymap[i] != KEY_RESERVED) -+ if (ps3->keymap[i] != KEY_RESERVED) - if (ioctl(fake->uinput, UI_SET_KEYBIT, -- ps3remote_keymap[i]) < 0) { -+ ps3->keymap[i]) < 0) { - error("Error enabling uinput key %i", -- ps3remote_keymap[i]); -+ ps3->keymap[i]); - goto err; - } - -@@ -328,6 +437,19 @@ - close(fake->uinput); - return 1; - } -+static gboolean ps3remote_connect(struct fake_input *fake, GError **err) -+{ -+ if(!fake->data) { -+ struct ps3remote_data *ps3 = g_new0(struct ps3remote_data, 1); -+ ps3->timer = g_timer_new(); -+ ps3->timeout = fake->idev->conf->timeout; -+ ps3->keymap = (fake->idev->conf -+ && fake->idev->conf->ps3remote_compat)? -+ ps3keymap_alt : ps3keymap_def; -+ fake->data = ps3; -+ } -+ return TRUE; -+} - - static gboolean fake_hid_common_connect(struct fake_input *fake, GError **err) - { -@@ -344,10 +466,12 @@ - { - .vendor = 0x054c, - .product = 0x0306, -- .connect = fake_hid_common_connect, -+ .connect = ps3remote_connect, - .disconnect = fake_hid_common_disconnect, - .event = ps3remote_event, -+ .oevent = ps3remote_out, - .setup_uinput = ps3remote_setup_uinput, -+ .fakes = NULL, - }, - - { }, -@@ -369,10 +493,34 @@ - - return NULL; - } -+struct fake_input * fake_find_input(GSList *list, -+ const struct input_device *idev) -+{ -+ GSList *l; -+ -+ if(!list) -+ return NULL; -+ for (l = list; l; l = l->next) { -+ struct fake_input *fake = l->data; -+ -+ if (fake->idev == idev) -+ return fake; -+ } -+ return NULL; -+} - - int fake_hid_connadd(struct fake_input *fake, GIOChannel *intr_io, - struct fake_hid *fake_hid) - { -+ struct fake_input *finput; -+ -+ if((finput = fake_find_input(fake_hid->fakes, fake->idev))) { -+ g_free(fake); -+ fake = finput; -+ } else { -+ fake_hid->fakes = g_slist_append(fake_hid->fakes, fake); -+ } -+ fake_hid->connect(fake,NULL); - if (fake_hid->setup_uinput(fake, fake_hid)) { - error("Error setting up uinput"); - return ENOMEM; -@@ -380,8 +528,10 @@ - - fake->io = g_io_channel_ref(intr_io); - g_io_channel_set_close_on_unref(fake->io, TRUE); -- g_io_add_watch(fake->io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, -- (GIOFunc) fake_hid->event, fake); -- -+ fake->sid_in = g_io_add_watch(fake->io, -+ G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, -+ (GIOFunc) fake_hid->event, fake); -+ fake->sid_out = g_io_add_watch(fake->io, G_IO_OUT, -+ (GIOFunc) fake_hid->oevent, fake); - return 0; - } -diff -Naur bluez-4.58-old/input/fakehid.h bluez-4.58-new/input/fakehid.h ---- bluez-4.58-old/input/fakehid.h 2009-02-25 12:14:11.000000000 -0800 -+++ bluez-4.58-new/input/fakehid.h 2009-11-15 04:42:56.000000000 -0800 -@@ -30,7 +30,18 @@ - gboolean (*connect) (struct fake_input *fake_input, GError **err); - int (*disconnect) (struct fake_input *fake_input); - gboolean (*event) (GIOChannel *chan, GIOCondition cond, gpointer data); -+ gboolean (*oevent) (GIOChannel *chan, GIOCondition cond, gpointer data); - int (*setup_uinput) (struct fake_input *fake, struct fake_hid *fake_hid); -+ GSList *fakes; -+}; -+ -+struct ps3remote_data { -+ unsigned int lastkey; -+ unsigned int lastval; -+ unsigned int lastmask; -+ GTimer * timer; -+ uint16_t timeout; -+ unsigned int * keymap; - }; - - struct fake_hid *get_fake_hid(uint16_t vendor, uint16_t product); -diff -Naur bluez-4.58-old/input/input.conf bluez-4.58-new/input/input.conf ---- bluez-4.58-old/input/input.conf 2008-08-05 14:14:56.000000000 -0700 -+++ bluez-4.58-new/input/input.conf 2009-11-15 04:42:56.000000000 -0800 -@@ -4,6 +4,14 @@ - # particular interface - [General] - --# Set idle timeout (in minutes) before the connection will -+# Set idle timeout (in seconds) before the connection will - # be disconnect (defaults to 0 for no timeout) - #IdleTimeout=30 -+ -+## -+# Section for options, specific to Sony PS3 BD Remote driver -+[PS3 Remote] -+ -+# Set keymap to generic keycodes/scancodes, in order -+# to be compatible with old XInput driver. -+#Compat=1 -diff -Naur bluez-4.58-old/input/manager.c bluez-4.58-new/input/manager.c ---- bluez-4.58-old/input/manager.c 2009-08-16 11:43:34.000000000 -0700 -+++ bluez-4.58-new/input/manager.c 2009-11-15 04:42:56.000000000 -0800 -@@ -42,7 +42,7 @@ - #include "server.h" - #include "manager.h" - --static int idle_timeout = 0; -+static struct input_dev_conf idev_conf; - - static DBusConnection *connection = NULL; - static GSList *adapters = NULL; -@@ -72,7 +72,7 @@ - device_get_address(device, &dst); - - return input_device_register(connection, device, path, &src, &dst, -- HID_UUID, rec->handle, idle_timeout * 60); -+ HID_UUID, rec->handle, &idev_conf); - } - - static void hid_device_remove(struct btd_device *device) -@@ -175,9 +175,17 @@ - { - GError *err = NULL; - -+ memset(&idev_conf,0,sizeof(struct input_dev_conf)); - if (config) { -- idle_timeout = g_key_file_get_integer(config, "General", -- "IdleTimeout", &err); -+ idev_conf.timeout = g_key_file_get_integer(config, -+ "General", "IdleTimeout", &err); -+ if (err) { -+ debug("input.conf: %s", err->message); -+ g_error_free(err); -+ } -+ idev_conf.ps3remote_compat = -+ g_key_file_get_integer(config, -+ "PS3 Remote", "Compat", &err); - if (err) { - debug("input.conf: %s", err->message); - g_error_free(err); ======================================= --- /trunk/gar-minimyth/script/lib/bluez/Makefile Sun Nov 15 12:11:12 2009 +++ /trunk/gar-minimyth/script/lib/bluez/Makefile Mon Nov 30 22:25:53 2009 @@ -3,7 +3,7 @@ CATEGORIES = lib MASTER_SITES = http://www.kernel.org/pub/linux/bluetooth/ DISTFILES = $(DISTNAME).tar.gz -PATCHFILES = $(DISTNAME)-ps3_bd_remote.patch +PATCHFILES = $(DISTNAME)-ps3remote_20091128.patch LICENSE = GPL2 DESCRIPTION = ======================================= --- /trunk/gar-minimyth/script/lib/bluez/checksums Sun Nov 15 12:11:12 2009 +++ /trunk/gar-minimyth/script/lib/bluez/checksums Mon Nov 30 22:25:53 2009 @@ -1,2 +1,2 @@ 858ce4c3d16b42542da9eb3f97c8ad23 download/bluez-4.58.tar.gz -5ee20570edc35195c1be1fd38b9d5716 download/bluez-4.58-ps3_bd_remote.patch +eba4001adce1ccd90c5427fea6b76ed8 download/bluez-4.58-ps3remote_20091128.patch -- You received this message because you are subscribed to the Google Groups "minimyth-commits" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/minimyth-commits?hl=en.
