I'm trying to improve USBUIRT support in MediaPortal.
It learns in two ways (which seems correct):
1) it uses UUIRTLearnIR to learn new codes to be transmitted to an STB later, and
2) it uses the normal UUIRTSetReceiveCallback with a receive call back to learn codes that are mapped to internal commands (never to be transmitted).
This is all well and good, but here's what I'm trying to do:
When Windows Media Center learns a code, the UI interaction is like this:
1. "Press button '0' and hold it"
<waits till you press and hold it>
2. "Keep holding button '0'"
<learns button '0' while you're holding it - seems to take ~ 2 secs>
3. "Release button '0'"
<ACTUALLY WAITS UNTIL YOU RELEASE IT>
4. goto 1. with next button.
I'm trying to do the same.
Now so far I have 1 and 2 working okay. I even have a progress callback that updates message 2 with ". . . " where each dot indicates 10% progress.
But I'm stuck on 3. I'm sending the user this "release" message after learning is finished, but now I want to actually wait until they really release the button.
To do this I am trying to use UUIRTSetReceiveCallback with a little callback that resets a little 200ms timer every time it gets called with the SAME code as the Learn routine returned.
This way, I just loop while testing if the timer timed out - when it does I know that that button wasn't held in the last 200ms.
Question 1: How do I compare the receive callback's string with the string learnt from the learn process, so I know its the same button just learnt that's being held?
I know from your documentation that they are not the same, that the learn code contains more info needed for transmitting, and the receive code is just long enough to be unique - but are they comparable at all?
Question 2: Even if I can do this, does my routine make sense?
I'm assuming the callback will be called more often that once every 200ms with the button code as long as the user continues to hold the button. Good assumption?
Question 3: Is there a better way to detect when the button actually gets released some time after the learn method has returned.