[Finished] [MP1-4795] Add keyboard support to HID handler (1 Viewer)

Stéphane Lenclud

Development Group
  • Team MediaPortal
  • April 29, 2013
    2,563
    1,288
    Germany Germany
    Country flag
    It's optionally configurable in the plugin though but agree it's far from perfect, like you said best solution would be published actions by plugins so that the HID handlers can read those out and map
    I might be working on that at some point.
     

    Rick164

    Super User
  • Team MediaPortal
  • Super User
  • January 7, 2006
    1,335
    1,005
    Netherlands Netherlands
    Country flag
    Nice :)

    Some plugins might break with this change so will make a small keyboard wrapper class for SharpLibHid which they can then optionally use as there's no example documentation for it judging by their project page.
     

    Stéphane Lenclud

    Development Group
  • Team MediaPortal
  • April 29, 2013
    2,563
    1,288
    Germany Germany
    Country flag
    no example documentation
    See: https://sharplibhid.codeplex.com/SourceControl/latest#MainForm.cs
    You could checkout the code and run that HID Demo if you wanted to set a few breakpoints to see how that works.
    I'm the owner of that project.

    You can only have one WM_INPUT registration per process I believe. So you need to hook into the WndProc from MP and call libhid.ProcessInput from there.
    Then you should get events providing that you registered to OnHidEvent.
     

    Rick164

    Super User
  • Team MediaPortal
  • Super User
  • January 7, 2006
    1,335
    1,005
    Netherlands Netherlands
    Country flag
    Some minor issues so far with showing dialogs when using WM_INPUT, when setting a keyChar to show a Mediaportal keyboard dialog (for search) there's a 5-10s delay before it allows for input.
    Will try the subscribe to WndProc of MP instead and see if that helps :)
     

    Stéphane Lenclud

    Development Group
  • Team MediaPortal
  • April 29, 2013
    2,563
    1,288
    Germany Germany
    Country flag
    there's a 5-10s delay before it allows for input
    That should not be. Sounds like you are getting stuck on a mutex for some reason.
    I tried yesterday the Auto3D plugin and that works nicely. Though I think you could make the code even simpler since there are left over from not using SharpLibHid.
    Checkout the Auto3D source code on GitHub specifically that HIDInput.cs file.
    Basically it registers for Window Messages through Application.AddMessageFilter.
    Then it uses SharpLibHid when in Configure but not when in MediaPortal.
    In theory you should be able to use SharpLibHid in both cases.
    The difference is that you need to register devices only from Configure and not from MediaPortal.
     

    Rick164

    Super User
  • Team MediaPortal
  • Super User
  • January 7, 2006
    1,335
    1,005
    Netherlands Netherlands
    Country flag
    Had some time and tried to implement that in the AudioSwitcher but it adds some complexity and additional libraries where as if it were to be built-in to Mediaportal would make it re-usable for all plugins.
    Any possibility for the new HID handler could forward it to the OnMessage event that is currently in place for legacy support?

    It would not provide any modifier key readouts as that is currently not possible with OnMessage event but wouldn't break any plugins or require updating them which for some might not be possible due to the developers no longer being active :)
    Other solution might be to expand the OnMessage event to include more information like the modifier keys if possible or a new one to subscribe to which offers that.
     

    Stéphane Lenclud

    Development Group
  • Team MediaPortal
  • April 29, 2013
    2,563
    1,288
    Germany Germany
    Country flag
    Any possibility for the new HID handler could forward it to the OnMessage event that is currently in place for legacy support?
    It sure is possible but it sounds like a major pain. If a user has a dependency on a plug-in that's not being supported anymore she can stick to an older version of MP1.

    Had some time and tried to implement that in the AudioSwitcher
    Could you get it to work? You would need to use the same SharpLibHid version that's used by the MP version you are targeting.
    MP1.15 is using SharpLibHid v1.3.1.

    if it were to be built-in to Mediaportal would make it re-usable for all plugins.
    It does not need to. However ideally plug-in should not have to deal with key handling themselves.
    Here is the way it should be done:
    • Have a framework that let plug-ins publish their own actions.
    • Plug-ins actions can then be mapped to keys much like built-in actions.
    • Plug-ins can then handle actions rather than keys.
    Until this is done however you should use SharpLibHid.
     

    Rick164

    Super User
  • Team MediaPortal
  • Super User
  • January 7, 2006
    1,335
    1,005
    Netherlands Netherlands
    Country flag
    Believe when I tried it Mediaportal it would still receive the key command as well as it had no way of cancelling that out, will re-check with latest build and test compatibility as MyAnime3 now uses the OnMessage event as well for its live filtering :) :

    https://github.com/japanesemediaman...er/MyAnimePlugin3/Windows/MainWindow.cs#L2441

    If this makes the cut for 1.16 will it still allow for the above message handling or does it need to use sharplibhid (i.e. no backwards compatibility option) ?
    As an extra dependency for plugins this might be small problem if you have multiple plugins using it at some point (overwriting each others)
     
    Last edited:

    Rick164

    Super User
  • Team MediaPortal
  • Super User
  • January 7, 2006
    1,335
    1,005
    Netherlands Netherlands
    Country flag
    Few things I noticed setup wise:

    - No keyboard HID by default

    You don't get HID keyboard on by default and classic preset only includes gamepad / mce.

    Before the keyboard bindings were present by default, while the old area (General -> Keys and sounds) is there it might be a surprise for some to find their default key bindings are no longer working.
    Option might be to keep HID keyboard on by default and set it either full or another which includes the default keyboard bindings.

    - Option to capture key input

    Old keyboard area had the option to capture a key as this made it easier to setup and especially for non-standard keys (< and >) it might not be possible to find them because of obscure name or just not in the default list.

    hid_keyboard_settings.PNG



    - Backwards compatibility with plugins

    Used MyAnime3 as a test here and indeed no longer works there to capture key input like before with the built-in Mediaportal function, the issue we talked about before.

    This is something we definitely need to test with a lot more plugins which rely on this as I'm gonna give SharpHID a go for Myanime 3 but probably won't be an option for every plugin that uses these events :)

    For AtmoLight this will only require a small documentation update but other than that it worked as expected when mapping keys to its teletext colors.
     
    Last edited:

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    C Hauppauge HVR-1265 -- does it work with MP1? MediaPortal 1 Talk 0
    ajs MP2Web - MP1 compatibility MediaPortal 1 20
    T MadVR + LAV Filters, Perfect in MPC-BE, Bad in MP1 MediaPortal 1 Talk 12
    P MP2: US user, OTA - can NOT get SchedulesDirect plugin to work on MP1 or MP2 --> how do I get OTA schedule? General 5
    framug [solved] Some changes/fix in MP1 configuration client and server Submit: code patches (MediaPortal/TV-Server/etc.) 14
    S TV-Server MP1 - Automatic search doesn't work Installation, configuration support 2
    C Streaming/transcoding MP2 vs MP1? General 1
    ajs [fixed] 5015: Improving the MP1 installer, providing nicer GUI :) MediaPortal 1 138
    C Streaming to clients over Wifi. MP1 or MP2? Newcomers Forum 0
    S Shortcuts MP1 My Recorded & TV Guide General 10
    azzuro [WiP] MP1-4999 - Big changes with many related change at once by Sebastiii MediaPortal 1 12
    ajs [Help Us!] MP1 X64 Version MediaPortal 1 20
    joecrow How about a Launcher plugin for MP1? MediaPortal 1 6
    wizard123 [solved] MP1 Build help MediaPortal 1 21
    ajs [News] MediaPortal 1 - 1.24 Released! News and Announcements 3
    CyberSimian [fixed] MP1-4990 : Improve horizontal scrolling in the EPG MediaPortal 1 10
    azzuro [WiP] MP1-5019: Replace MySQL with MariaDB MediaPortal 1 40
    catalpa Umsteiger von MP1: Schwierigkeiten Allgemeines Support- und Diskussionsforum 17
    CyberSimian [solved] MP1-4976 Built-in skin variables for current date MediaPortal 1 8
    rbo [solved] Umsteiger MP1 zu MP2 Allgemeines Support- und Diskussionsforum 67
    azzuro [Info] MP2 TVE inside MP1 repo MediaPortal 2 12
    G MP1 TV Server "failed to upgrade the database" using MS Sql Server Installation, configuration support 3
    lisag Can I get MP1 to open in the Recorded TV screen? MediaPortal 1 Talk 2
    M MP1 stops responding after Starting Plugins General Support 14
    R Problem with MP1 and WifiRemote Skins and Plugins Installer (MPEI) 8
    Similar threads

























    Top Bottom