New Versions of InputDeviceMapper of LiveDriveIR (2 Viewers)

kaburke

Portal Pro
March 4, 2005
64
0
Alberta, Canada
Mr. Mitchell said:
Code:
************** Exception Text **************
System.Runtime.InteropServices.SEHException: External component has thrown an exception.
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   ...

I'm not sure what is happening. I looked over the code and all seems fine. Is there some way (through logging etc.) that you can pin down exectly where the exception is first being seen by InputDeviceMapper?

Mr. Mitchell said:
- It would be nice to have a way to "import" all the keys that are used in keymap.xml in one go. Right now I added the keys manually and I forgot a few. It would be nice if I could just press "Get keys from Keymap.xml" and then the keys list would be filled automatically.

I understand that this would be convenient, but it would go against the intended model for InputDeviceMapper. Indeed, the idea of mapping events to keystrokes goes againts the intended model, but (perhaps unfortunately) MediaPortal has certain limitations.

Perhaps I should give a brief explanation of the intended model. PLEASE NOTE THAT THIS DISCUSSION IS IN NO WAY MEANT TO BE A CITICISM OF THE EXISTING/PAST/FUTURE MODEL OF MEDIAPORTAL. This is simply my opinion - it is not neccessarily correct, nor better than any other proposed model. Having said that....

MediaPortal should not deal directly with user input. Rather it should be driven by events (let's call them Actions) that are triggered by a User Input layer (preferrably implemented as a plugin). All user input devices, be they keyboards, mice, remotes, etc, should pass their User Input Device events (e.g., keypress events) to this User Input layer, which would map said Input Device Events to a particular Action, and then fire that Action off to MediaPortal. This would separate MediaPortal from any particular control mechanism, allowing easy development of new user input interfaces.

Now, in case it was not obvious, it was my intent that InputDeviceMapper be the described User Input Layer (not that I expect it to be adopted as an official part of MediaPortal - it was intended for my own use, and for the use of those who found it useful). Having said that, strictly speaking, InputDeviceMapper should not pass any keystrokes to MeadiPortal, only Actions. Hence, it would be inappropriate to import keystrokes from the Keymap file.

Having said that, there are certain limitations. For better or worse MediaPortal does not operate strictly on Actions - some features can only be controlled by the keyboard (or, more strictly, by keypress events). In order to accomodate this, I allowed Input Device Events to be mapped to keystrokes.

The end result... I'm not going to integrate the functionality to import the Keymap file into InputDeviceMapper, as I believe that it would be to much a departure from the intended model. However, I would be willing to create a separate helper/utility application that takes a keymap file as input and generates an InputDeviceMapper compatible UserInputMappings.xml file, if people are interested.

Mr. Mitchell said:
- When I click on the Configure plugins button I don't see my deviceplugin listed. It implements the IInputDevicePlugin interface, but the header "Check the device plugins you want to enabled" suggests that all deviceplugins should be listed and not only the ones that have a configuration.

I have decided to leave things the way they are for now, mainly because changing it would mean that I would have versioning issues (old plugins would not neccessarily work with the new InputDeviceMapper). If you want to be able to disable the plugin, without it having a configuration screen, implement IConfigurableInputDevicePlugin but display a message indicating there is nothing to configure when ShowPlugin() is called.
 

Mr.Mitchell

Retired Team Member
  • Premium Supporter
  • May 13, 2004
    227
    0
    the Netherlands
    kaburke said:
    Mr. Mitchell said:
    Code:
    ************** Exception Text **************
    System.Runtime.InteropServices.SEHException: External component has thrown an exception.
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       ...

    I'm not sure what is happening. I looked over the code and all seems fine. Is there some way (through logging etc.) that you can pin down exectly where the exception is first being seen by InputDeviceMapper?
    I found the cause of the problem but I am not sure on how to solve it. A search on the internet on the exception gave some hint that it could be related to EnableVisualStyles. So I commented out that call in the configuration program and the exception did not occur anymore. But removing that call makes the application lose it's XP look.

    The end result... I'm not going to integrate the functionality to import the Keymap file into InputDeviceMapper, as I believe that it would be to much a departure from the intended model. However, I would be willing to create a separate helper/utility application that takes a keymap file as input and generates an InputDeviceMapper compatible UserInputMappings.xml file, if people are interested.
    Actually I started out with mapping the keys on my remote to actions, but I ran into a problem that I can not add multiple actions to a button. For example I have PageUp/PageDown buttons. These buttons should most of the time have pageup/down functionality, but when viewing pictures I want them to be zoom in/out. I tried to assign both actions to the same key but that was not possible. So that is why I decided to switch to keymapping instead of actionmapping for most keycommands.

    A helper utility would be nice, but since normally you only setup your remote once I could live without.
     

    mbuzina

    Retired Team Member
  • Premium Supporter
  • April 11, 2005
    2,839
    726
    Germany
    Home Country
    Germany Germany
    Mr.Mitchell said:
    kaburke said:
    Mr. Mitchell said:
    Code:
    ************** Exception Text **************
    System.Runtime.InteropServices.SEHException: External component has thrown an exception.
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       ...

    I'm not sure what is happening. I looked over the code and all seems fine. Is there some way (through logging etc.) that you can pin down exectly where the exception is first being seen by InputDeviceMapper?
    I found the cause of the problem but I am not sure on how to solve it. A search on the internet on the exception gave some hint that it could be related to EnableVisualStyles. So I commented out that call in the configuration program and the exception did not occur anymore. But removing that call makes the application lose it's XP look.

    Strange... I added an X10 Device Plugin as well (I did not know of Mr. Mitchel) and it shows the exact same behoviour...

    But that aside, I have a few ideas for the Mapper code as well (and I am offering some coding help).

    • - I would like to specify different actions for the same Device Event depending on the current window or even control in MP. This would "save" keys on my remote.
      - Additionally I would like to implement a T9 word entry on the numbers of the remote. That would allow you to perform searches only using the remote. I think best would be to have a standard word list and (for ListControls) being able to use the underlying values as a word list.
    By the way, thanks for the plugin, it saved me a lot of coding time (my plugin is more than short ;-).
     

    tomtom21000

    Retired Team Member
  • Premium Supporter
  • April 22, 2004
    1,226
    120
    Germany
    mbuzina said:
    • - I would like to specify different actions for the same Device Event depending on the current window or even control in MP. This would "save" keys on my remote.
      - Additionally I would like to implement a T9 word entry on the numbers of the remote. That would allow you to perform searches only using the remote. I think best would be to have a standard word list and (for ListControls) being able to use the underlying values as a word list.
    By the way, thanks for the plugin, it saved me a lot of coding time (my plugin is more than short ;-).

    Just in case you don´t know this, too ;)

    Smirnof is/was working on t9 support for a new virtual keyboard. he is often on the irc channel. maybe you can join forces. or look for the according thread hear on the forum.

    tomtom
     

    kaburke

    Portal Pro
    March 4, 2005
    64
    0
    Alberta, Canada
    mbuzina said:
    - I would like to specify different actions for the same Device Event depending on the current window or even control in MP. This would "save" keys on my remote.

    This is something I have wanted to do for quite a while. Unfortunately, I haven't had the time to dedicate to researching how it would work. I have an "ideal" model, but I am unsure how that model would mesh with MediaPortal in practice.

    Ideally, all "pages" in MediaPortal would be plugins, preferably with some interface or inheritance parent that is common to all (and unique) to all pages. This, or some form of it, may be how pages are handled in MediaPortal, but, as I said, I haven't had any time to look into it.

    Assuming that all of the pages were at least plugins (if not plugins with a common/unique ancestor), in config mode InputDeviceMapper would scan the plugins, and allow configurations to be created for each separate page it finds, as well as a "default" configuration. In app mode, when InputDeviceMapper received an event, it would look up the configuration for the active page, and then use that configuration to find the correct Action to send to MediaPortal.

    Ideally, within the configuration for a given page, one would be able to specify an action on another page (e.g., on my configuration for the Weather Page, the direction and selection buttons may control what weather map I'm looking at, but I can still map the Play/Pause etc. to control my music).

    Further, it would be ideal if each page defined and exposed it's own actions, rather than all of the pages relying on one common Action group. This way a new page could create complex activities without needing to rely on having an Action created in a global repository.

    Finally, there could be a global Action repository that can be inherited/used by any page that chooses to do so. This would mean, rather than having separate (for e.g.) PLAY_MUSIC and PLAY_MOVIE actions, there would be a global PLAY action that would behave differently depending on whether or not the music page or video page is active. (This last point could conflict with the previous paragraph, and I'm not entirely convinced of its usefulness. I think I would be inclined to simply rely on the functionality of the previous paragraph and omit the global Action repository idea. I merely mention it here because I have not yet made up my mind.)

    mbuzina said:
    - Additionally I would like to implement a T9 word entry on the numbers of the remote. That would allow you to perform searches only using the remote. I think best would be to have a standard word list and (for ListControls) being able to use the underlying values as a word list.

    I agree that this functionality would be nice, but I think it is beyond the scope of InputDeviceMapper. InputDeviceMapper only concerns itself with translating Input Device Events into Actions. I believe the "correct" method to implement this feature would be to have a separate plugin for text input that is controlled by Actions, which InputDeviceMapper could certainly pass to it (though, obviously, not necessarily).

    mbuzina said:
    Mr.Mitchell said:
    kaburke said:
    Mr. Mitchell said:
    Code:
    ************** Exception Text **************
    System.Runtime.InteropServices.SEHException: External component has thrown an exception.
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       ...

    I'm not sure what is happening. I looked over the code and all seems fine. Is there some way (through logging etc.) that you can pin down exectly where the exception is first being seen by InputDeviceMapper?
    I found the cause of the problem but I am not sure on how to solve it. A search on the internet on the exception gave some hint that it could be related to EnableVisualStyles. So I commented out that call in the configuration program and the exception did not occur anymore. But removing that call makes the application lose it's XP look.

    I have been meaning to change my model for the handle() method. The change would have no external affect (no plugins would have to change), and there would not be any difference in functionality, but I think the change would prevent the above error. It seems that the error isn't in InputDeviceMapper or any plugin, but I do think my (pending) modification would eliminate the case that creates this error. I am busy for the next little while, but I will try to get the change up in the next couple of weeks.

    Finally, my code is (obviously) open source, so anyone should feel free to change/improve/adapt it as they see fit. All I would ask is that you:

    • 1) keep any new incarnations of InputDeviceMapper compatible with existing Input Device Plugins
      2) if possible, not create an incarnation that allows Input Device Plugins that are incompatible with the original InputDeviceMapper
      3) create a new code "tree" for any new incarnations (i.e., don't create a new InputDeviceMapper and call it InputDeviceMapper v1.0 - rename it to reflect your change - e.g., InputDevicePageMapper). I may at some point decide to incorporate an alternate incarnation into the "main" branch, but I don't want to get into any code/version confusions.

    Please feel free to comment/question/respond to my ideas as expressed in this post.
     

    Mr.Mitchell

    Retired Team Member
  • Premium Supporter
  • May 13, 2004
    227
    0
    the Netherlands
    Ok, I got some progress for the SEHException.

    First of all this problem is caused by Visual styles. If the visual styles are disabled the problem does not occur. You can disable these visual styles by commenting the call to Application.EnableVisualStyles(); in Startup.cs in the Mediaportal.Configuration project. The bad thing is that the application loses it's XP look.

    According to some texts on the internet it should be possible to use Visual styles with an Applicaiotn manifest instead of the call to Application.EnableVisualStyles(). But I got no clue on how make such a manifest. This would probably be the best solution.

    I did some more research to pinpoint the cause of the problem. I noticed that the exception only occurred when I pressed a button the remote that was mapped to a Key. The exception would NOT occur when I press a key that was mapped to an Action or that was not mapped at all. So it means that the problem only occurs when handling Keys when in the Configuration application.

    Since I don't see a use to handle keys in the configuration program I decided to "disable" the Handle method when in the Configuration application. I came up with the following workaround.

    EDIT: Scratch that workaround, it breaks the learning :-(. Going to figure out how to make an application manifest.
     

    kaburke

    Portal Pro
    March 4, 2005
    64
    0
    Alberta, Canada
    Mr. Mitchell said:
    EDIT: Scratch that workaround, it breaks the learning :-(. Going to figure out how to make an application manifest.

    As mentioned in my last post, I think I have a workaround - I just don't have time today to implement it. Basically, the handle() method shouldn't try to send Actions/Keystrokes to MediaPortal if it's in config mode. This can be accomplished by making the "main" part of handle() a private method (callit MethodA() for now) and having the start() method assign MethodA() to the learningDelgate (I don't remember its name at the moment). You must make sure MethodA() always return false for this to function proprly.

    Actually - hang on 5 minutes. If I have time to type this, I should have time to make the change. I'll post when it's up.
     

    Mr.Mitchell

    Retired Team Member
  • Premium Supporter
  • May 13, 2004
    227
    0
    the Netherlands
    mbuzina said:
    Strange... I added an X10 Device Plugin as well (I did not know of Mr.Mitchell) and it shows the exact same behoviour...
    I had a look at your plugin. I have a small suggestion. I think it would be good to also add the address of the remote to the string that is sent to the InputDeviceMapper. That way if people have more than 1 X10 remote (e.g. Medion and Marmitek) they can program both remotes seperately, which is needed since both remotes have a different layout.

    For completness sake my X10Input deviceplugin can be found here: http://www.xs4all.nl/~wetering/mp/ I would call it final if the SEHException thing has been solved.
     

    kaburke

    Portal Pro
    March 4, 2005
    64
    0
    Alberta, Canada
    The new version of InputDeviceMapper (v0.4.3) is available. This version should no longer throw the SEHException. The new verision is available at the usual location, here.

    Mr. Mitchell said:
    I had a look at your plugin. I have a small suggestion. I think it would be good to also add the address of the remote to the string that is sent to the InputDeviceMapper. That way if people have more than 1 X10 remote (e.g. Medion and Marmitek) they can program both remotes seperately, which is needed since both remotes have a different layout.
    I assume you are talking about mbuzina's plugin? If not let me know and I will respond.

    Finally, I want to, again, thank everyone for their continued support of InputDeviceMapper. I appreciate the feedback/bug finding, and I hope that I will be able to continue improving InputDeviceMapper to further meet your needs.
     

    Users who are viewing this thread

    Top Bottom