Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mgoldberg
Reel Rookie

message port for roInput not firing any events

I'm trying to handle remote control input, but I'm only seeing "invalid" for the message bound to an "roInput" object.

Do I need to add any flag to the manifest, I saw you need to for deep link launching but not sure about input events, nor could I find any examples of handling remote control input.

msgPort = CreateObject("roMessagePort")
input = CreateObject("roInput")
input.setMessagePort(msgPort)

while (true)
msg = wait(500, msgPort)

if type(msg) = "roInputEvent" then
print "got some input event yo"
if msg.IsInput()
info = msg.GetInfo()
print "Received input: "; FormatJSON(info)
end if
end if
0 Kudos
2 REPLIES 2
renojim
Community Streaming Expert

Re: message port for roInput not firing any events

Did you read the documentation?  It's not for receiving button presses from the remote control.

"An roInput object can be used to receive events sent from a network client using the External Control Protocol (ECP), as described in External Control API."

https://developer.roku.com/docs/references/brightscript/components/roinput.md

The reason you only see invalid events is because the wait statement times out before any events are received.  If you want to wait forever you should have wait(0, msgPort).  Your loop is going to be printing the invalid events twice a second.

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
mgoldberg
Reel Rookie

Re: message port for roInput not firing any events

Thanks for pointing out my error, I found an example in SimpleAnimatedSprite that works, I needed to bind the message port to the screen, and then listen for "roUniversalControlEvent" events.

0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.