Hi,
ich habe einige Anleitungen im Internet gefunden, damit die Remote unter XBMC funktioniert. Hier musste ich aber immer wieder nach dem Booten die Fernbedienung neu anlernen, was mir nicht wirklich gefallen hat. Nach ein wenig Recherche habe ich aber einige Einträge gefunden, die zusammen dann den reibungslosen Betrieb der Fernbedienung auch nach dem booten ermöglichten. Da ich einige Anfragen bekam, schreibe ich die Installation hier einmal zusammen:
Bluetooth Stack installieren:
sudo update-rc.d -f dbus defaults && sudo apt-get install bluez
sudo apt-get install xbmc-eventclients-ps3
Uinput Modul laden
Damit das Modul auch automatisch nach dem Booten wieder zur Verfügung steht kann man es unter Raspbmc in die Datei /etc/modules eintragen
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.
uinput
Nun die Fernbedienung suchen (Enter + Start gleichzeitig drücken und schnell weitermachen):
Nun sollte die Remote inkl. MAC-Adresse angezeigt werden. Diese MAC-Adresse (bei mir 00:24:33:98:7D:0A) wird nun dem System bekannt gemacht:
Zitat
bluez-test-device create 00:24:33:98:7D:0A
bluez-test-device trusted 00:24:33:98:7D:0A yes
Ob die Fernbedienung erkannt wurde, kann man mittels
anzeigen. Kommt hier eine Ausgabe, ist die Fernbedienung angelernt.
Nun muss Bluteooth an uinput noch die Tasten weiterleiten, Dazu legt man in /etc/bluetooth eine input.conf ab.
Wichtig dabei ist, das die MAC-Adresse angepasst wird!
# input.conf - kitlaan custom
# Configuration file for the input service
[General]
# This section contains options that are specific to a device
[00:24:33:98:7D:0A]
# This section is the PS3 Remote keymap. It is loaded when bluez starts.
# Use 'uinput.h' from bluez sources or '/usr/include/linux/input.h' for
# a list of possible KEY_* values.
#
[PS3 Remote Map]
0x16 = KEY_E # EJECT
0x64 = KEY_A # AUDIO
0x65 = KEY_Z # ANGLE
0x63 = KEY_T # SUBTITLE
0x0f = KEY_DELETE # CLEAR
0x28 = KEY_GRAVE # TIMER
0x00 = KEY_1 # NUM-1
0x01 = KEY_2 # NUM-2
0x02 = KEY_3 # NUM-3
0x03 = KEY_4 # NUM-4
0x04 = KEY_5 # NUM-5
0x05 = KEY_6 # NUM-6
0x06 = KEY_7 # NUM-7
0x07 = KEY_8 # NUM-8
0x08 = KEY_9 # NUM-9
0x09 = KEY_0 # NUM-0
0x81 = KEY_F7 # RED
0x82 = KEY_F8 # GREEN
0x80 = KEY_F9 # BLUE
0x83 = KEY_F10 # YELLOW
0x70 = KEY_I # DISPLAY
0x1a = KEY_S # TOP MENU
0x40 = KEY_M # POP UP/MENU
0x0e = KEY_ESC # RETURN
0x5c = KEY_C # TRIANGLE/OPTIONS
0x5d = KEY_BACKSPACE # CIRCLE/BACK
0x5f = KEY_TAB # SQUARE/VIEW
0x5e = KEY_SPACE # CROSS
0x54 = KEY_UP # UP
0x56 = KEY_DOWN # DOWN
0x57 = KEY_LEFT # LEFT
0x55 = KEY_RIGHT # RIGHT
0x0b = KEY_ENTER # 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 # PLAY
0x34 = KEY_F # SCAN FORWARD
0x30 = KEY_PAGEUP # PREVIOUS
0x38 = KEY_STOP # STOP
0x31 = KEY_PAGEDOWN # NEXT
0x60 = KEY_COMMA # SLOW/STEP BACK
0x39 = KEY_PAUSE # PAUSE
0x61 = KEY_DOT # SLOW/STEP FORWARD
0xff = KEY_MAX
Alles anzeigen
Nun hatte ich aber das Problem, das ich quasi vor jedem XBMC Start die Fernbedienung erst einmal benutzt haben musst, spricht ein Tastendruck erforderlich war. XBMC hat diese
sonst nicht erkannt. Hier half mir ein Thread hier aus dem Portal PS3 Remote und /dev/input. Mein besonderer Dank geht hier an seahawk1986, der ein Python Skript erstellt hat, welches dem XBMC das Device vorgaukelt. Dieses benötigt allerdings noch einige Python Pakete die zu
installieren sind:
Leider wird noch ein Paket python-uinput benötigt für welches ich kein Debian Paket gefunden habe. Deshalb habe ich es von Hand installiert:
cd /tmp
git clone https://github.com/tuomasjjrasanen/python-uinput
cd python-uinput
python setup.py install --prefix=/usr/local
Danach sollte das folgende Script in /usr/sbin/ps3remote.py abgelegt werden:
#!/usr/bin/python2.7
import sys
import os
import codecs
import fcntl
import gobject
import socket
import string
import struct
import datetime
import pyudev
import uinput
from pyudev.glib import GUDevMonitorObserver
class UdevEventWatchdog():
'''handle input devices using udev'''
def __init__(self):
global gobject
self.frontend_active = 0
self.env = os.environ
self.timer = None
events = []
for element in dir(uinput):
if element.startswith("KEY_") or element.startswith("BTN_") or element.startswith("REL_"):
events.append(eval("uinput.%s"%(element)))
self.uinputdev = uinput.Device(events, "ps3")
self.context = pyudev.Context()
self.monitor = pyudev.Monitor.from_netlink(self.context)
self.monitor.filter_by(subsystem='input')
self.devices = {}
self.paths = {}
# struct for kernel input devices on 64-Bit linux systems
#self.inputEventFormat = 'llHHi'
#self.inputEventSize = 24
# on 32-Bit systems try
self.inputEventFormat = 'iihhi'
self.inputEventSize = 16
# (untested)
self.get_event_devices()
def get_event_devices(self):
'''filter all connected input devices and watch an existing PS3 Remote device'''
for device in self.context.list_devices(subsystem='input'):
if device.sys_name.startswith('event') and device.parent['NAME'] == '"PS3 Remote Controller"':
#print("found PS3")
self.paths[device['DEVNAME']] = open(device['DEVNAME'],'rb')
self.devices[device['DEVNAME']] = gobject.io_add_watch(self.paths[device['DEVNAME']], gobject.IO_IN, self.evthandler)
fcntl.ioctl(self.paths[device['DEVNAME']].fileno(), 0x40044590, 1) #exclusive access to input device - so keypresses do not disturb other >
self.observer = GUDevMonitorObserver(self.monitor)
self.observer.connect('device-event',self.udev_event)
self.monitor.start()
print("started udev monitoring of input devices")
def udev_event(self,observer,action, device):
'''callback function to add/remove input devices'''
if action == "add" and 'DEVNAME' in device:
if device.sys_name.startswith('event') and device.parent['NAME'] == '"PS3 Remote Controller"':
self.paths[device['DEVNAME']] = open(device['DEVNAME'],'rb')
if not device['DEVNAME'] in self.devices:
self.devices[device['DEVNAME']] = gobject.io_add_watch(self.paths[device['DEVNAME']], gobject.IO_IN, self.evthandler)
fcntl.ioctl(self.paths[device['DEVNAME']].fileno(), 0x40044590, 1) #exclusive access to input device - so keypresses do not disturb ot>
elif action == "remove" and 'DEVNAME' in device:
try:
self.paths[device['DEVNAME']].close()
except:
pass
try:
gobject.source_remove(self.devices[device['DEVNAME']])
syslog.syslog("removed %s"%device['DEVNAME'])
del self.devices[device['DEVNAME']]
except:
pass #device already removed from watchlist
def evthandler(self,path, *args):
'''callback function to handle keys sent by inputdevices'''
try:
event = path.read(self.inputEventSize)
except:
#print('can not read from %s'%(path))
return False
(time1, time2, typeev, code, value) = struct.unpack(self.inputEventFormat, event)
if typeev == 0 and code == 0 and value == 0: # sync event
pass
else:
self.uinputdev.emit((typeev,code), value)
return True
if __name__ == '__main__':
devinput = UdevEventWatchdog()
gobject.MainLoop().run()
Alles anzeigen
Dieses Skript wird in /etc/rc.local eingetragen und das war es dann auch endlich:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
nohup python2.7 /usr/sbin/ps3remote.py &
exit 0
Alles anzeigen
Wer es brauchen kann, viel Spass damit
MfG
Quacks
Quellen:
PS3 Remote an RaspBMC
PS3 als input Device
PS3 input.conf
Installation uinput
History:
- Fehler im Python Skript korrigiert.