I’ve written a simple program that renders a screen, with a message wait loop for input and exit from the program. I listen for roUniversalControlEvent and pick up on all the button presses… except the home key.
The problem is that when the home key is pressed, the Brightscript console prints that the program has exited, but instead of returning to the home page it just creates a black screen. Almost any button press will produce a sound, but you are still stuck at the black screen. Through much experimentation, I discovered that if I press the netflix button, wait for a moment, then press the home button, I can recover the home screen.
Since I’m not allowed to handle the home key, I don’t know what to do to fix this. The main program code is below.
Any ideas on why the firmware isn’t taking me fully back to the home screen?
David
sub showChannelSGScreen()
screen = CreateObject(“roScreen”)
port = CreateObject(“roMessagePort”)
screen.SetMessagePort(port)
width = screen.GetWidth()
height = screen.GetHeight()
white = &hDDDDDDFF
dark_gray = &h919498FF
green = &h00FF00FF
black = &h000000FF
blue = &h007C9C7F
fontRegistry = CreateObject(“roFontRegistry”)
font = fontRegistry.GetDefaultFont()
instructionFont = fontRegistry.GetDefaultFont(90,true,false)
number_width = width / 4
number_height = height / 2
screen.finish()
state = 2
notFinished = true
offset = 40
print “Entering CHOOSE A DIE rendering loop”
while notFinished
screen.DrawRect(0, 0, width,height,white)
screen.DrawText(“CHOOSE A DIE”,width / 4 + 100, height / 4,blue, instructionFont)
upper_x = 0
upper_y = number_height - 25
if state = 0
upper_x = 0 + (number_width / 2) - offset
else if state = 1
upper_x = number_width + (number_width / 2) - offset
else if state = 2
upper_x = (number_width * 2) + (number_width / 2) - offset
else if state = 3
upper_x = (number_width * 3) + (number_width / 2) - offset
else
print "unexpected state: " + StrI(state)
end if
screen.DrawRect(upper_x, upper_y,100,100,dark_gray)
screen.DrawText(“2”, 0 + (number_width / 2), number_height, black, font)
screen.DrawText(“6”, number_width + (number_width / 2), number_height, black, font)
screen.DrawText(“8”, (number_width * 2) + (number_width / 2), number_height, black, font)
screen.DrawText(“20”, (number_width * 3) + (number_width / 2), number_height, black, font)
screen.finish()
print “Entering CHOOSE A DIE input loop”
msg = wait(0, port) ’ wait for a message
if type(msg) = “roUniversalControlEvent” then
if(msg.isPress()) then
print “key:” + StrI(msg.GetKey())
if msg.getKey() = 4
if state > 0
state = state - 1
endif
else if msg.getKey() = 3
if state > 0
state = state - 1
endif
else if msg.getKey() = 5
if state < 3
state = state + 1
endif
else if msg.getKey() = 2
if state < 3
state = state + 1
endif
else if msg.getKey() = 6
notFinished = false
else if msg.getKey() = 0
return
endif
endif
endif
end while
…
end sub
