Re: Web MIDI polyfill

On Fri, Dec 14, 2012 at 7:06 AM, Marcos Caceres <w3c@marcosc.com> wrote:

> So, here is my rewrite of how I think it should work (not done, but
> working nicely in Chrome):
> https://github.com/marcoscaceres/WebMIDIAPIShim/blob/gh-pages/WebMIDIAPI.js
>


> (note that I've changed the API a bit … now I need to sell you and the Web
> Audio WG on the changes :) )
>


It's going to take me a lot longer to fully grok this, and think through
the changes.  One thing I did spot - if I read this correctly, you're just
hashing the name as an id.  That won't work in common scenarios - many
users will have more than one of the same device (two identical
controllers, or two or more of the same MIDI hardware interfaces).  You
really have to hash the index of the port in with it, or at least the index
of ports-with-the-same-name.

It still needs some further integration with WebIDL's error handling. The
> only guidance I could give you is to try to follow the WebIDL spec (yes,
> WebIDL is fairly illegible … we need to fix that as a larger community).
>

"Fairly" is charitable.  :)


> The way I've been doing it is to create a fake element:
>
> var dispatcher = document.createElement('x-eventDispatcher');
>
> then I wrap:
> dispatcher.addEventListener(…)
> dispatcher.removeEventListener(…)
> dispatcher.dispatchEvent(…)
>
> It then handles everything for me.
>
> You are correct that in this instance it does not matter about the DOM
> Tree. See the link above to see it in action.
>

I still don't understand why this matters, given that it's not dispatching
on a DOM element?

This is going to be sooooo awesome if it gets implemented in browsers :)
>

WHEN.  Power of positive thinking.

-Chris

Received on Friday, 14 December 2012 21:27:21 UTC