Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
rymawby
Level 7

Implementing text input from companion app keyboard

I'm currently trying to implement keyboard input from the Roku companion app (tested iOS and from commandline) into a custom application (note - this is a legacy app and is not using Scenegraph). I am using a Roku 4 with 7.1 firmware.

Within the event loop whenever a keypress is sent I am using that value to calculate the ascii of the character being pressed.

So something like:

if type(msg) = "roUniversalControlEvent" then
keyID = msg.getInt()
.
.
.
end if


The problems I have found are
- ascii presses conflict with other presses - for example the OK button being released is 106 which is also lowercase j. (this can be worked around by taking the release IDs - values ranging from 132 - 227 and deducting 100 to get the ascii value)
- when q or z are pressed I am receiving the exact same keyIDs. I have also tested this on the command line. So:

curl -d '' http://<MY_IP>:8060/keypress/Lit_q

and
curl -d '' http://<MY_IP>:8060/keypress/Lit_z


Both come up with keyIDs of 113 (press) and 213 (release).

Has anyone else successfully implemented text input from the companion app? Have I implemented this correctly?

The documentation I used was from: https://sdkdocs.roku.com/display/sdkdoc ... sKeyValues

Thanks in advance.
---
Blogging Roku stuff at http://rymawby.com
---
0 Kudos
3 Replies
TheEndless
Level 7

Re: Implementing text input from companion app keyboard

"rymawby" wrote:
Has anyone else successfully implemented text input from the companion app?

I have. If you change it so you only process literal keys on release, and track the last key press, then you can compare the two to determine if it's a literal key press or a standard key release. If the value is less than 100, you know it's not a literal key release. If the value is greater than 100, then subtract 100 and compare that value to the last key event you received. If they're equal, then you can assume it's a literal key release, and process it as such.

That sounds horribly convoluted, but hopefully it makes enough sense for you to be able to decipher it.. Smiley Wink
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
ljunkie
Level 7

Re: Implementing text input from companion app keyboard

"TheEndless" wrote:
"rymawby" wrote:
Has anyone else successfully implemented text input from the companion app?

I have. If you change it so you only process literal keys on release, and track the last key press, then you can compare the two to determine if it's a literal key press or a standard key release. If the value is less than 100, you know it's not a literal key release. If the value is greater than 100, then subtract 100 and compare that value to the last key event you received. If they're equal, then you can assume it's a literal key release, and process it as such.

That sounds horribly convoluted, but hopefully it makes enough sense for you to be able to decipher it.. Smiley Wink


I was trying to find simple way to explain this too, as it's exactly what we do. Nice work Smiley Happy

edit: forgot to mention, the q/z key keyboard event sending the same keyID is a known bug: viewtopic.php?f=34&t=92074&p=516847
0 Kudos
rymawby
Level 7

Re: Implementing text input from companion app keyboard

Cheers guys for your input!

That is how I implemented with deducting 100 - seems like it would've been handier having some kind of different event - but it works!

My main issue was the q/z error - thanks for pointing out it is a known issue.

Thanks again for taking the time to reply.

Ry.
---
Blogging Roku stuff at http://rymawby.com
---
0 Kudos