First of all, thank you for this great idea/script. Perfect for those waiting for an iPhone
I own a Nokia E61 (Image:
http://www.about-nokia.com/blog/media/1/...ia_e61.jpg) and had problems installing your sis-files. After some research, I found out that my mobile can't "digest" python packages above version 1.9.6. So I got the right package from
https://garage.maemo.org/frs/?group_id=854 and installed everything without errors.
Unfortunately, the E61 has a whole keyboard and for typing numbers one has to hold a modifier key. So I changed your script to use some of the standard keys (like in the original script: EKeyDownArrow, EKey8...) AND scancodes.
In order to find out the scancode for each key, I wrote a tiny python script that shows it on key press.
Code:
import appuifw,e32,graphics
body=graphics.Image.new((176,208))
def keys(x):
if x['type']==3:
body.clear()
body.text((50,80),u'button ' + x['scancode'].__str__(),0x0000ff,font=u'Alb17b')
canvas.blit(body)
appuifw.app.body=canvas=appuifw.Canvas(event_callback=keys)
body.clear(0xff0000)
canvas.blit(body)
e32.Ao_lock().wait()
And here the modified "XBMCRemotev2":
Code:
# XBMC Remote v2b
# with Events (less resource consumming)
# default ip:port
xbmc = u"192.168.0.10:80"
# background image route
background = u'e:\\Python\\bkg.png'
import appuifw
from graphics import *
import globalui
import e32
from key_codes import *
import urllib2
keyboard_state={}
last_keycode=0
#Imagen de fondo
def set_theme():
global bkg_img
bkg_img = Image.open(background)
handle_redraw(())
def handle_redraw(rect):
global bkg_img
if bkg_img:
canvas.blit(bkg_img)
def optionsHost():
global xbmc
xbmc = appuifw.query(u"Set xbmc host:port", "text", xbmc)
def optionsTheme():
global background
background = appuifw.query(u"Set Theme", "text", background)
set_theme()
def quit():
appuifw.app.set_exit()
def MyCommand(cmd):
urllib2.urlopen('http://'+xbmc+'/xbmcCmds/xbmcHttp?command=' + cmd)
def SendKey(k):
MyCommand('sendKey(' + k.__str__() + ')')
def MyAction(act):
MyCommand('ExecBuiltIn¶meter=XBMC.Action(' + act + ')')
#CustomActions
def PreviousMenu():
MyAction('PreviousMenu')
def ShowInfo():
MyAction('Info')
def Rewind():
MyAction('Rewind')
def FastForward():
MyAction('FastForward')
def VolumeUp():
MyAction('VolumeUp')
def VolumeDown():
MyAction('VolumeDown')
def SkipPrevious():
MyAction('SkipPrevious')
def SkipNext():
MyAction('SkipNext')
def Play():
MyAction('Play')
def Stop():
MyAction('Stop')
def Mute():
MyAction('Mute')
def AspectRatio():
MyAction('AspectRatio')
def ShowSubtitles():
MyAction('ShowSubtitles')
def MyFSSwitch():
MyCommand('action(199)')
#key mapping (e.g. 49 = 'R')
hotkeys = {
49: Rewind,
50: FastForward,
51: VolumeUp,
54: VolumeDown,
52: SkipPrevious,
53: SkipNext,
55: Play,
56: Stop,
57: Mute,
65: AspectRatio,
83: ShowSubtitles,
122: ShowInfo}
#eventhandler for keypresses
def keys(x):
if x['type']==3:
sc = x['scancode']
hotkeys.get(sc,lambda: print 'Not assigned')()
def exit_btn_cmd():
MyAction('OSD')
MyAction('ContextMenu')
appuifw.app.menu = [(u"Set XBMC host", optionsHost), (u"Set Theme", optionsTheme), (u"Exit", quit)]
appuifw.app.exit_key_handler=exit_btn_cmd
appuifw.app.screen='full'
appuifw.app.title=u'S60 XBMC Remote'
# extended Canvas constructor
canvas=appuifw.Canvas(event_callback=keys,redraw_callback=handle_redraw)
# set the application body to canvas
appuifw.app.body=canvas
# commands
#Left
canvas.bind(EKeyLeftArrow,lambda:SendKey(272))
#Right
canvas.bind(EKeyRightArrow,lambda:SendKey(273))
#Down
canvas.bind(EKeyDownArrow,lambda:SendKey(271))
#Right
canvas.bind(EKeyUpArrow,lambda:SendKey(270))
#Select
canvas.bind(EKeySelect,lambda:SendKey(256))
#Backspace -> Previous Dir
canvas.bind(EKeyBackspace,lambda:SendKey(257))
#Space -> Previous Menu
canvas.bind(EKeySpace,PreviousMenu)
canvas.bind(EKeyNo,lambda:quit())
canvas.bind(EKey0,MyFSSwitch)
#Workaround to establish WLAN connection at start
MyCommand('')
lock=e32.Ao_lock()
set_theme()
lock.wait()
I do not attach these scripts as files, because I never code Python and expect that you will certainly find some mistakes and improvements. So this is not meant to be an out-of-the-box solution for everyone.