2007-07-21, 05:45
Is there any way to invoke character presses in the virtual keyboard using the web API? I tried sending the code F000 (as defined in key.h) + the ASCII code, but this did nothing.
#!/usr/bin/python
import socket,threading,urllib,time, sys
import curses
XBOX_IP = '192.168.1.101'
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(1)
def SubthreadProcStarter(url,port):
subThread = threading.Thread(target=SubthreadProc, args=(url,port))
subThread.setDaemon(True)
subThread.start()
subThread.join(1.0)
def SubthreadProc(url,key):
try:
newurl = url+str(0xF100+key)
urllib.urlopen(newurl).close()
except:
pass
url = 'http://'+XBOX_IP+'/xbmcCmds/xbmcHttp?command=sendkey¶meter='
mapping = {263:0x108,10:0x0D,339:0x21,338:0x22,360:0x23,262:0x24,260:0x25,259:0x26,261:0x27,258:0x28,331:0x2D,330:0x2E}
while 1:
try:
c = stdscr.getch()
if c == -1:
curses.nocbreak()
stdscr.keypad(0)
curses.echo()
curses.endwin()
break
if mapping.has_key(c):
c = mapping[c] -0x100
if c <= 255:
print c
SubthreadProcStarter(url,c)
# Enter character and enter command are different?
if c == 13-256:
SubthreadProcStarter(url,10)
# Escape character and escape command are different?
if c == 27:
SubthreadProcStarter(url,27-256)
except: pass
Asteron Wrote:For keyboard input you have to use 0xF100 + ascii value.