hi object fun: list processing question

    Feb 29 2012 | 9:16 pm
    I am working on a way to use the [hi] object on the Mac to detect key presses and releases, much like the key and keyup objects do already (I want to detect key presses/releases when Max is not in focus though, thus the need for the hi object).
    I have deciphered the output of the hi object so that I can get a list of hex symbols of the currently held keys. For each new key press or release, I get a new list. For example:
    'q' held down: 14 'w' held down: 1A 'q' held down, then 'w' held down while still holding 'q' down: 1A 14 'w' held down, then 'q' held down while still holding 'q' down: 14 1A (in other words, the list order represents the sequence of when the keys were originally pressed) nothing held down: 0
    So what is the best way to be able to easily track this continually changing list of symbols, to be able to detect new keys that are pressed, as well as keys that are released? I have a feeling one of Peter Elsea's Lobjects is going to help me here (though not sure which!), but curious if there is a way to easily do it with built in Max objects too...

    • Mar 01 2012 | 8:35 am
      I think it's one of the ejies that does list change status - so you can convert these into a particular member of a list, and if it's then removed from the list you get a "-1" at that position in the list.
    • Mar 01 2012 | 3:45 pm
      Thanks - I think it's ej.lchange you're talking about, but it doesn't tell you where the list changes, only that it has changed. Also, it's a Java-based external, which in my specific case I can't use...
    • Mar 01 2012 | 9:52 pm
      Is Lcomp what you are after? There's also L==, but it doesn't tell you where the list changes either.
    • Mar 01 2012 | 10:15 pm
      Thanks - but not quite what I needed. Turns out I just sorted it out on my own, using two instances of zl.filter:
      In the first instance, put the "old" list of key symbols in its right inlet, and the new list of symbols in its left -- that gives me the "new" keypress symbols out of the leftmost outlet.
      In the second instance of zl.filter, put the "new" list of key symbols in the right inlet, and the "old" list in left -- that gives me the keys that *were* on, but that are now off, in other words, the keyups.
      There's a bit more detail than that, but basically that's the gist of it.