0

Brightscript handling keyboard sequences

Hi - I'm trying to trigger videos using an HID-emulating RFID reader connected to a LS423. 

In BrightAuthor, I can use USB events to trigger based on receiving a string of characters, eg 8045e79ca714d81<cr>.

For various reasons I want to do the same in Brightscript and not use BrightAuthor.  I've tried using a SequenceMatcher, per the examples in the manual, but I can't attach that to a roKeyboard object.

Line / Code:

59: if not kb.SetMatcher(matcher)
60:   stop
61: end if

Error log:

[ 36.027] Script runtime error: Member function not found in BrightScript Component or interface. (runtime error &hf4) in SD:/autorun.brs(59)

Any clues? 

Thanks in advance.

Dan

 

1 comment

  • 0
    Avatar
    Dan Sloane

    Sorted... for future reference, listen for keyboard presses until you get a delimeter (in my case a carriage return, ASCII 13) then output the string...

    My regex checks are probably unnecessary as the tags and tag reader only ever output base 16 characters.

     

    Function TagListener(messageHandler as Object) as String

    'Regex for hex only
    isHex = CreateObject("roRegex", "[a-fA-F0-9]+", "i")

    tagID = ""

    while true
    msg = wait(0,messageHandler)

    if type(msg) = "roKeyboardPress" then
       if isHex.IsMatch(chr(msg)) then
           tagID = tagID + chr(msg)
       else if msg=13 then
           file = TagHandler(tagID)   
           print "File: "; file
           return file
           tagID=""
       endif
    endif
    endwhile

    End Function

     

Please sign in to leave a comment.