[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] Multimedia Keys & Notification



I would like to make a proposal. 

There has been a lot of talk about multimedia keys recently, and I would like to make a suggestion for the addition of a new message.  This new message would be sent to the application when a multimedia key is pressed on a multimedia enabled keyboard, a remote control (if you have an IR remote driver), or another application.  An application would send this to separate the API from the actual application that renders the media (audio or video), allowing a separation of APIs and allowing the user to use whichever front-end they prefer.  Also, maximum flexibility and interoperability for future and unforeseeable usages should be maximized.

The messages would be the same type of messages you would get via evnt_mesag() with a new message type, maybe AP_MEDIA (don't care about the name of the #define).  No scan-codes (since multimedia keys are normally a sequence of codes that the application would have difficulty interpreting) or any other keyboard-dependent information would need to be sent to the user application.  The OS should abstract this information for the programmer.  Application events would be sent to the top-most application that is waiting on multimedia events - indicated via a new EVENT flag to evnt_multi() or a new wind_set() flag.  I like the wind_set() flag idea better.

Examples of Global multimedia messages might be the Web Browser, Lock Screen, Email, Full-Screen, Maximize, or Application-Switch keys on a multimedia keyboard, or "TV" button on an IR Remote.  It should be possible for applications to generate these to launch your "preferred" application and generate these events for special purposes (perhaps a special application switcher with fancy special effects, etc - the switch-app-key would execute an app which would perform some animation and generate the switch-app-action to finish it, details on how sending the multimedia-key-events and the multimedia-actions they can be mapped to, are open to speculation and discussion).

Examples of Application specific keys would be Play, Pause, Next Track, Skip to Track ##, Eject, double-size, and things of that sort.

Some events would be sent to the application only if there was an application waiting to receive multimedia events, and could be handled by the OS itself otherwise, for example, Volume Up, Volume Down, and MUTE could be handled by adjusting the master volume and mute of the sound system independently of any applications.  Likewise Eject could open the first CD-ROM drive if no application wanted multimedia events.  Applications could even resend the message back to the OS to have the OS do whatever the mapped global event should be (this won't loop).

In this scheme, the device drivers would report the events to the AES (this part needs further development) which would dispatch the event accordingly depending on the type of event, if any applications were waiting on multimedia events, and finally, the control panel for global events.  There would be two classes of events, global events, and application events.  Global events would perform an action, such as switching windows, iconifying the top window, or executing a program.  The exact action would be configured through a control panel or CPX and the OS (or maybe the Desktop or the CPX) would handle this itself. 

I was also considering a new signal, which would be ignored if the application didn't have a handler for it, which would tell the application that a new AES message was waiting for it, sort of an AIO type of thing.  I freely admit this idea is a sub-optimal HACK, but would work, and in some situations, better than kqueue() - like if you need constant processing and event handling is completely secondary and you don't want to make OS calls to look for events.  This was one of my suggestions years ago when I was looking for a solution to unify the event loop, but the non-multitasking ROM-AES made this problematic. 

The signal would break the program out of select() or any other call, and you could check a variable, that the signal handler would modify, to see if you needed to read a new message via appl_read().  Since you can't tell the AES what events you want, another thread or process would call evnt_multi() if you needed those events and send the data to you via appl_write().  Otherwise, you only need to look at AES messages when told.  This would work even for applications that were busy processing audio (like an mp3 player) in a tight loop and didn't otherwise need event processing and the overhead of calling evnt_multi() or other OS calls constantly, since the entire GUI interface could be implemented in a separate process that simply sent messages to the application.  This could remove a lot of polling for applications that really need constant processing and separate threads instead of an event loop.  Its less ideal if there are constant AES events, but this scheme could work for things like TOSWIN as well.

No front-end need show at all if you have a multimedia keyboard or IR remote and the above extensions as front-ends could be completely separate from the actual player, or simply enhanced with additional multimedia keys/remote/messages from other applications such as your IRC client, web browser, etc.

All comments welcome.

Thanks,
Evan