2009-08-11, 21:20
erhnam Wrote:I wrote a howto. It's only in Dutch but most of the commands are there. Here's the link:Any chance that u translate it to english?
http://www.strengholt-online.nl/playstat...-xbmc/221/
erhnam Wrote:I wrote a howto. It's only in Dutch but most of the commands are there. Here's the link:Any chance that u translate it to english?
http://www.strengholt-online.nl/playstat...-xbmc/221/
Asure Wrote:I started out from your blog post (i'm dutch) before i came to the XBMC forums
Can you tell me your distro ? It's not mentioned in the posting.
Also, why use cakemote in the end of the blog post ?
The 'old bdremote' part is to run only bdremote with a paired remote, and lirc to connect to it. For me, paired or not, bdremote will never pick up the remote, and send nothing to lirc.. (ubuntu 9.04) so that's why it's important to know your distro
/etc/init.d/bluetooth stop
./bdremoted -p 8888 -t 30 -a 00:21:4F:B2:3E:13 -r 10 -d200 -n -t 1
[code]det=0, port=8888, tmout=1, rep=10, deb=200, addr=00:21:4F:B2:3E:13
BTBD remote connected.
54 , 01 , 00000010
single
processing!
processing1!
done!
E:54 , 01 , 00000010
FF , 01 , 00000030
multiple, 00000010, 00000030, 00000020
-snip, 1 minute later, timeout kicks in
BTBD receiver exited with: -1
BTBD try to reconnect.
cd /usr/share/python-support/xbmc-eventclients-common/xbmc/
wget [url]http://www.xbmc.org/trac/export/22189/branches/linuxport/XBMC/tools/EventClients/Clients/PS3%20Sixaxis%20Controller/ps3d.py[/url]
edit ps3_remote.py to use correct bluetooth.png
/usr/share/pixmaps/xbmc/bluetooth.png
./ps3_remote.py localhost
Searching for BD Remote Control
(Hold Start + Enter on remote to make it discoverable)
BD Remote Control (00:21:4F:B2:3E:13) in range
Found BD Remote Control with address 00:21:4F:B2:3E:13
Attempting to pair with remote
Remote Paired.
ctrl-c
modprobe hidp
./ps3d.py 00:21:4F:B2:3E:13 127.0.0.1
Zeroconf support disabled. To enable, install the following Python modules:
dbus, gobject, avahi
Connecting to Bluetooth device: 00:21:4F:B2:3E:13
Connecting to : 127.0.0.1
Starting HID daemon
--- bluez-4.47/input/fakehid.c 2009-04-23 03:40:04.000000000 +0200
+++ bluez-4.47-my/input/fakehid.c 2009-08-16 13:23:09.000000000 +0200
@@ -94,11 +94,11 @@
static unsigned int ps3remote_keymap[] = {
[0x16] = KEY_EJECTCD,
- [0x64] = KEY_AUDIO,
- [0x65] = KEY_ANGLE,
- [0x63] = KEY_SUBTITLE,
- [0x0f] = KEY_CLEAR,
- [0x28] = KEY_TIME,
+ [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,
@@ -109,41 +109,41 @@
[0x07] = KEY_8,
[0x08] = KEY_9,
[0x09] = KEY_0,
- [0x81] = KEY_RED,
- [0x82] = KEY_GREEN,
- [0x80] = KEY_BLUE,
- [0x83] = KEY_YELLOW,
- [0x70] = KEY_INFO, /* display */
+ [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_CONTEXT_MENU, /* pop up/menu */
+ [0x40] = KEY_F11, /* pop up/menu */
[0x0e] = KEY_ESC, /* return */
- [0x5c] = KEY_OPTION, /* options/triangle */
+ [0x5c] = KEY_F12, /* options/triangle */
[0x5d] = KEY_BACK, /* back/circle */
- [0x5f] = KEY_SCREEN, /* view/square */
- [0x5e] = BTN_0, /* cross */
+ [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] = BTN_TL, /* L1 */
- [0x58] = BTN_TL2, /* L2 */
- [0x51] = BTN_THUMBL, /* L3 */
- [0x5b] = BTN_TR, /* R1 */
- [0x59] = BTN_TR2, /* R2 */
- [0x52] = BTN_THUMBR, /* R3 */
+ [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_SELECT,
- [0x53] = BTN_START,
- [0x33] = KEY_REWIND, /* scan back */
+ [0x50] = KEY_INSERT, /* select */
+ [0x53] = KEY_HOME, /* start */
+ [0x33] = KEY_R, /* scan back */
[0x32] = KEY_PLAY,
- [0x34] = KEY_FORWARD, /* scan forward */
- [0x30] = KEY_PREVIOUS,
- [0x38] = KEY_STOP,
- [0x31] = KEY_NEXT,
- [0x60] = KEY_FRAMEBACK, /* slow/step back */
- [0x39] = KEY_PAUSE,
- [0x61] = KEY_FRAMEFORWARD, /* slow/step forward */
+ [0x34] = KEY_F, /* scan forward */
+ [0x30] = KEY_PAGEDOWN, /* next */
+ [0x38] = KEY_STOP, /* stop */
+ [0x31] = KEY_PAGEUP, /* previous */
+ [0x60] = KEY_COMMA, /* slow/step back */
+ [0x39] = KEY_PLAYPAUSE, /* pause */
+ [0x61] = KEY_DOT, /* slow/step forward */
[0xff] = KEY_MAX,
};
@@ -208,18 +208,49 @@
lastmask & 0xff, 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_event(GIOChannel *chan, GIOCondition cond,
gpointer data)
{
+ static unsigned int lastkey = 0;
+ static unsigned int lastval = 0;
struct fake_input *fake = data;
- struct uinput_event event;
unsigned int key, value = 0;
gsize size;
char buff[50];
- if (cond & G_IO_NVAL)
- return FALSE;
+ if (cond & G_IO_NVAL) {
+ if(lastkey == KEY_HOMEPAGE && lastval == 1) {
+ DBG("ps3remote_event: Remote turned off");
+ goto failed;
+ } else {
+ DBG("ps3remote_event: Remote unpaired [%u:%u]", lastkey, lastval);
+ goto failed;
+ }
+ }
if (cond & (G_IO_HUP | G_IO_ERR)) {
error("Hangup or error on rfcomm server socket");
@@ -240,26 +271,18 @@
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 && lastkey == KEY_HOMEPAGE && lastval == 1) {
+ ps3remote_sendkey(fake->uinput, key, 1);
+ ps3remote_sendkey(fake->uinput, key, 0);
+ } else
+ DBG("ps3remote_event: Delayed: %u:%u (%u:%u)", key, value, lastkey, 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;
- }
-
+ lastkey = key;
+ lastval = value;
+ DBG("ps3remote_event: %u:%u", key, value);
return TRUE;
failed:
@@ -267,7 +290,7 @@
close(fake->uinput);
fake->uinput = -1;
g_io_channel_unref(fake->io);
-
+ DBG("ps3remote_event: !!!!");
return FALSE;
}
<keymap>
<global>
<keyboard>
<insert>Queue</insert>
<a>AudioNextLanguage</a>
<x>Close</x>
<f1>VolumeDown</f1>
<f4>VolumeUp</f4>
<f2>SetVolume(50)</f2>
<f3>SetVolume(75)</f3>
<d>FullScreen</d>
<t>ActivateWindow(Favourites)</t>
<f7>XBMC.ActivateWindow(MyMusic)</f7>
<f8>XBMC.ActivateWindow(MyVideos)</f8>
<f9>XBMC.ActivateWindow(MyPictures)</f9>
<f10>XBMC.ActivateWindow(Weather)</f10>
<f11>ContextMenu</f11>
<end>XBMC.ActivateWindow(ShutdownMenu)</end>
</keyboard>
</global>
<FullscreenVideo>
<keyboard>
<f12>NextSubtitle</f12>
<menu>ShowVideoMenu</menu>
</keyboard>
</FullscreenVideo>
</keymap>
Asure Wrote:I didn't have any accelleration in desktop, so i was assuming i'd need to figure out another way to get it to work. Even though the glx shows up in X logs. Guess desktop wasn't using it ?
Trex6662k5: Are you running 9.04 with working bdremoted/lirc ? Or another flavor of linux ?
Edit: Guess i needed to switch on 'use restricted drivers' if google is correct:
https://help.ubuntu.com/community/Binary...wto/Nvidia
if xbmc.previous_key == "43":
remote.close()
xbmc.send_notification("Notice", "Disconnecting Remote")
#!/bin/bash
while [ 1 ]
do
/usr/share/python-support/xbmc-eventclients-common/xbmc/ps3_remote.py localhost
done
Asure Wrote:Let me be the first to say: Great first post Ruff !Thanks %)
Asure Wrote:Sidenote: I fixed up the notifications since eventserver is somewhat broken, and it now only sends a notification on connect and exit. (otherwise it beeps all the time on each eventserver-notification message)I also noticed that it is somewhat broken, that's why I became determined to hack bluez. That is - when xbmc sees new input device - all events sent by eventclient are ignored by event server. It only detects Hello/bye packets, and all key events are lost in vain (timed out).
Still, a version that times out would be cleaner.. need to brush up my python-skillz..
Asure Wrote:I've given up. I went to back to the drawing board, minimal hardy, removed the nvidia stuff, dropped in glx-190 and compiled from svn after manually adding vpdau devel stuff. That worked great, with vdpau working. Except, bluetooth fails to work for me for some reason i don't understand. No errors in any logs. Tried 3 dongles, all blink, rebooted several times etc..