[mythtv-users] Need some help with a PSP remote control
Brian Wallen
bwallen at gmail.com
Fri Apr 4 03:15:40 UTC 2008
First off, I want to say that this question may be outside the scope
of this list. If it is, just tell me and I'll ask somewhere else.
I couldn't find in my searches a remote control for mythfrontend
designed specifically for the PSP, so I decided to take a crack at it
myself. I decided to use lua (a scripting language) to create it, just
for the ease of use (read: I'm not a good programmer). I can get my
PSP to connect to my frontend on port 6546, but it won't send the
command I tell it to (in this case, jump mainmenu). The PSP outputs
that it sends 13 bytes, which is correct, but nothing ever happens on
my frontend. Could anyone with a little lua knowledge lend a hand? For
those of you with a PSP, please feel free to test my script. You'll
need the latest lua player, and the script needs to go in
/psp/game/luaplayer/applications/mythtv/index.lua on your memory
stick. You'll also need to change the IP address you're connecting to
from mine to yours. Thanks!
BTW, I stole much of the code from a sample WLAN script that came with
the psp lua player download.
white = Color.new(255, 255, 255)
offscreen = Image.createEmpty(480, 272)
offscreen:clear(Color.new(0, 0, 0))
y = 0
x = 0
function graphicsPrint(text)
for i = 1, string.len(text) do
char = string.sub(text, i, i)
if char == "\n" then
y = y + 8
x = 0
elseif char ~= "\r" then
offscreen:print(x, y, char, white)
x = x + 8
end
end
screen:blit(0, 0, offscreen)
screen.waitVblankStart()
screen.flip()
end
function graphicsPrintln(text)
graphicsPrint(text .. "\n")
end
-- init WLAN and choose connection config
Wlan.init()
configs = Wlan.getConnectionConfigs()
graphicsPrintln("available connections:")
graphicsPrintln("")
for key, value in ipairs(configs) do
graphicsPrintln(key .. ": " .. value)
end
graphicsPrintln("")
graphicsPrintln("using first connection...")
Wlan.useConnectionConfig(1)
-- start connection and wait until it is connected
graphicsPrintln("waiting for WLAN init and determining IP address...")
while true do
ipAddress = Wlan.getIPAddress()
if ipAddress then break end
System.sleep(100)
end
graphicsPrintln("the PSP IP address is: " .. ipAddress)
graphicsPrintln("")
graphicsPrintln("connecting to frontend...")
socket, error = Socket.connect("192.168.1.17", 6546)
while not socket:isConnected() do System.sleep(100) end
graphicsPrintln("connected to " .. tostring(socket))
-- send request
graphicsPrintln("jumping to main menu...")
bytesSent = socket:send("jump mainmenu")
graphicsPrintln("sent " .. bytesSent .. " bytes")
Wlan.term()
More information about the mythtv-users
mailing list