Generic Keyboard/Remote Input Plugin (2 Viewers)

smith69085

Portal Member
May 7, 2009
23
1
I'm currently using an old version of this plug-in with MP 1.1 final. I'v been having trouble with the new version of Keyboard input saying its not compatible with MP1.1 and the old version i am using at the moment is not working too well either, randomly gives up after a while and the green home button messes up full screen mode.

Will a new version be released soon or is there a fix/workaround?
 

rsenden

Portal Pro
August 22, 2006
88
108
Rotterdam, NL
Home Country
Netherlands Netherlands
Hi all,

I'm currently looking into the sources that SilentException stored in SVN and working on the following:
  • Some more clean-up of the code
  • Fix some bugs in the current code-base:
    • Duplicate key problem (keys handled both by KeyboardInputPlugin and MediaPortal standard keymap)
    • It looks like a simple Alt+<key> isn't handled by the plug-in (note that Alt together with Control and/or Shift modifier keys is handled)
    • Anything else?
  • Create a MediaPortal Extension Installer package
  • Test the plug-in on my own HTPC system

The new version will basically have the same functionality as the last version by SilentException. Most notably:
  • MediaPortal 1.1.0 is supported
  • Most keys (with or without Control, Alt and Shift modifier keys) should be mappable. Win-key will not be supported as a modifier key in this version.

I hope to have a new (test) version out in a couple of days, not sure though whether the listed bugs will be fixed by then.

A request to all of you; if you have a working keyboard.xml for your remote, please upload it to SVN at https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/KeyboardInputPlugin/Release/InputDeviceMappings/defaults/Remote/<remote name>/keyboard.xml (or send it to me).

Update: An early test version containing the bugs mentioned above is available at https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/KeyboardInputPlugin/MPE/KeyboardInputPlugin.mpe1. I haven't tested this version myself yet, so only use it if you really need to.
 

rsenden

Portal Pro
August 22, 2006
88
108
Rotterdam, NL
Home Country
Netherlands Netherlands
What about a more permanent solution to loosing keybindings as reported here? Dunno if that's impossible though.

Do you mean the solution involving changing the LowLevelHooksTimeout registry entry? The plug-in currently uses keyboard hooks to intercept key presses; if the value for LowLevelHooksTimeout is too low the hook will simply not be invoked.

So, as I understand it, there is nothing we can do at code level to fix this issue without doing the registry change. Seems like this is a common issue with Windows 7 (not just for this plug-in) where the value for this registry entry has been lowered. For example, in my XP installation the value is set to 5000ms.

The 'more permanent' solution that I can implement is to do this registry change automatically during installation via the MediaPortal Extension Installer.
 

1stdead

Portal Pro
February 1, 2008
1,089
139
Copenhagen
Home Country
Denmark Denmark
It wasn't even in my registry. I've added it because SilentException told me to.
I don't know if this is caused by that. But sometimes even mouse, keyboard, remote does not work. When using mouse right button left button is excecuted. Happens not only in MP but in windows. Only solution is to restart windows.
 

rsenden

Portal Pro
August 22, 2006
88
108
Rotterdam, NL
Home Country
Netherlands Netherlands
I've released a new beta version of KeyboardInputPlugin 2.4.0.0. The MediaPortal Extension Installer version can be downloaded at https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/KeyboardInputPlugin/MPE/KeyboardInputPlugin.mpe1. If you've previously installed the KeyboardInputPlugin MPE package, you may need to uninstall it and clear the MPE installation cache.

You can also download the full package containing sources and release as a GNU tarball from http://mp-plugins.svn.sourceforge.net/viewvc/mp-plugins/trunk/plugins/KeyboardInputPlugin/?view=tar for manual installation. Please note that the HISTORY.HTML and README.HTML files may not be completely up to date yet.

Changes in this version are as follows:
  • Extensive code clean-up.
  • Simplified key processing.
  • Win-keys can be used as modifiers again.
  • Looks like the plug-in can intercept almost all keystrokes, at least in the test program; from simple keystrokes like 'A' to key combinations like Ctrl-Alt-Shift-Win-A. Within MediaPortal it looks like you can even override system keys like Win+E.
  • Keys handled by the plug-in will not be passed on to MediaPortal, so no need to remove the MediaPortal keymap.xml file.
  • Keys not handled by the plug-in will be passed on to MediaPortal, other plug-ins and/or Windows. So Keyboard.xml and keymap.xml supplement each other, and keys like Win+E will have their usual behavior even when the plug-in is active (unless the key combination has been redefined in KeyboardInputPlugin).

By looking at the code (don't have my MediaPortal installation at hand right now) I think we still need to look at the following:
  • I think the plug-in will intercept keystrokes even when MediaPortal is running in the background; if possible we should probably check if MP has focus (for example in KeyboardInputPluginMain.KeyboardHandler_IsActiveIndicator method). This is already handled by KeyboardInputPluginMain.form_Activated/form_Deactivate.
  • It looks like other keyboard hooks will not be invoked if a key combination is handled by the plug-in; I'm not sure whether we should want this or not. Changing this would require copying MP's Hook.cs into our project and modifying the InternalHookDelegate method to always invoke CallNextHookEx (and at the end return 1 if e.Handled==true, otherwise return result of CallNextHookEx).
  • We simply ignore (pass through) modifier key presses, and only check for currently pressed modifier keys whenever any other key is pressed. In theory this could cause an application to see for example just an Alt keypress if the user presses Alt+X (if Alt+X is handled by the plug-in), which could cause strange behavior. I haven't seen any strange behavior during testing, but we should double check this. Double checked, seems to work correctly
  • We still need to fix the keyboard hook de-activation problem on Windows 7. Some possible solutions:
    • Fix using registry hack: Not needed; fixed at code level
      • Automatic installation of registry hack during MPE install. This poses a problem; the registry entry is under HKCU, but the installer is run as Administrator I think. So we would need to find out the user that is used to run MediaPortal and update the registry key under HKU\<user>.
      • Manual installation of registry hack by installing a .reg-file that users can manually run (as the MediaPortal user).
      • Detection and auto-install of the registry hack from the plug-in. However, the registry hack requires a restart.
    • Fix at code level:
      • Maybe running the keyboard hook in a separate high-priority thread can help solve the problem; we're currently probably running as part of the MP UI thread, and due to that may have to wait until MP has processed a message before the keyboard hook can be invoked by Windows. Probably fix below is enough; if not we could still implement this in addition.
      • Automatically detect when the keyboard hook becomes inactive and re-enable it. For example, set lastHookKeyDownTime to the current time on hook invocation, and implement IPluginReceiver.WndProc, setting lastWndProcKeyDownTime to the current time on WM_KEYDOWN/WM_SYSKEYDOWN messages. Compare these times, and if necessary (lastHookKeyDownTime<lastWndProcKeyDownTime, before updating lastWndProcKeyDownTime to current time) restart the keyboard hook. WndProc may not see all key presses that are usually handled by the plug-in (and has some other problems that prevent us from using it instead of a keyboard hook) so the plug-in may skip a few key presses, but at least you won't have to restart MediaPortal. Implemented in new version (to be released in a few days)

Please test this version on your system and give us your feedback on how it works. Have fun!
 

RetroZA

Portal Member
July 1, 2008
22
0
Cape Town
Home Country
South Africa South Africa
Thanks, this works great! I bought a cheap remote to use with mediaportal and nothing was working. Couldn't be easier with this. Every buttons works perfectly now. Great work! :)
 

rsenden

Portal Pro
August 22, 2006
88
108
Rotterdam, NL
Home Country
Netherlands Netherlands
Hi all,

I've been doing some more work and testing on the plug-in. I've now also implemented automatic recovery of the keyboard hook if it gets disabled by Windows, for example due to a high CPU load. In order to test this I still have to try to reproduce the original problem though (does anybody know a good tool to generate a high CPU load that works in Windows 7?).

I've checked in the updated source code into SVN; once I've finished testing I will release a new final version. Compared to previous versions:
  • Handling of pressed keys seem to work better than ever.
  • Support for Ctrl, Shift, Alt and Win-keys as modifier keys, virtually all key combinations seem to be supported.
  • Keys that are handled by the plug-in will not be passed on to MediaPortal and/or the system (for example Win+E), so no 'duplicate key handling' problems, and no need to remove the MediaPortal keymap.xml.
  • Keys that are not handled by the plug-in will be passed on to MediaPortal and/or the system, so they will keep their original behavior.
  • Plug-in is only active if MediaPortal has focus; the plug-in won't intercept and handle any key presses if MediaPortal is running in the background.
  • As mentioned above, the plug-in will automatically re-enable the keyboard hook if it has been disabled by Windows for any reason.

So, stay tuned and expect to see the new version in a couple of days...

For upcoming releases, we need your help as well! If you have created a working mapping for your remote control, please send me a description of your remote together with your keyboard.xml file (from %AppData%\Team MediaPortal\MediaPortal\InputDeviceMappings). You can also add it to SVN yourself if you have access, at https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/KeyboardInputPlugin/Release/InputDeviceMappings/examples/<remotename>/keyboard.xml.

Kind regards,
Ruud
 

rsenden

Portal Pro
August 22, 2006
88
108
Rotterdam, NL
Home Country
Netherlands Netherlands
Hi all,

I have now released KeyboardInputPlugin version 2.4.0.0 stable. See the first post for details. If you have any questions or remarks about this version, please let me know.

Kind regards,
Ruud
 

Users who are viewing this thread

Top Bottom