InputDeviceMapper Plugin (2 Viewers)

mzemina

Retired Team Member
  • Premium Supporter
  • February 23, 2005
    2,065
    14
    Tulsa, OK
    Home Country
    United States of America United States of America
    What not look at HIP (Human Interface Programmer - ByRemote) - you can go here; http://www.byremote.com.au/

    It maybe able to provide what you are looking for. They have their own forum also.
     

    Eggert

    MP Donator
  • Premium Supporter
  • May 23, 2005
    70
    6
    kaburke - thank you for giving it a try.

    mzemina - I will test it, thanks.

    But I really would prefer the InputDeviceEventMapper because I think it's the better and cleaner way. So - if you know how to do this with InputDeviceEventMapper let me know - I will visit this thread frequently.
    An option for each command would be great:
    "send this command to
    1.) MediaPortal only
    2.) system"

    Maybe you've got some ideas how to do this easily.
    Thank you in advance :)
    Eggert
     

    T-Square

    Portal Member
    May 19, 2005
    17
    0
    Minden Germany
    Home Country
    Germany Germany
    Hi Kaburke,

    I've connected some buttons to the 4 free input pins at the printer port.
    Because I use the printer port anyhow for my LCD, this is a very easy possibility to have up to 31 buttons on my HTPC.
    Code:
          eingang = IO.m_Port.Tasten(0x378+1);
    	  
          if(eingang == 15 /*01111 Keine Taste gedrückt*/)
          {
          }
          else if(eingang == 14 /*PIN 15*/)
          {
            action = new Action(Action.ActionType.ACTION_PREV_ITEM, 0, 0);
            GUIGraphicsContext.OnAction(action);
          }
          else if(eingang == 13 /*PIN 13*/)
          {
            action = new Action(Action.ActionType.ACTION_PLAY, 0, 0);
            GUIGraphicsContext.OnAction(action);
          }
          else if(eingang == 12 /*PIN 13+15*/)
          {
            action = new Action(Action.ActionType.ACTION_NEXT_ITEM, 0, 0);
            GUIGraphicsContext.OnAction(action);
          }
          else if(eingang == 11 /*PIN 12*/)
          {
          	/*4er Reihe ganz rechts*/
            action = new Action(Action.ActionType.ACTION_PREVIOUS_MENU, 0, 0);
            GUIGraphicsContext.OnAction(action);
          }
          else if(eingang == 10 /*PIN 12+15*/)
          {
            action = new Action(Action.ActionType.ACTION_MOVE_UP, 0, 0);
            GUIGraphicsContext.OnAction(action);
          }
          else if(eingang ==  9 /*PIN 12+13*/)
          {
            action = new Action(Action.ActionType.ACTION_MOVE_RIGHT, 0, 0);
            GUIGraphicsContext.OnAction(action);
          }
          else if(eingang ==  8 /*PIN 12+13+15*/)
          {
            action = new Action(Action.ActionType.ACTION_SELECT_ITEM, 0, 0);
            GUIGraphicsContext.OnAction(action);
          }
          else if(eingang ==  7 /*PIN 10*/)
          {
            action = new Action(Action.ActionType.ACTION_MOVE_DOWN, 0, 0);
            GUIGraphicsContext.OnAction(action);
          }
          else if(eingang ==  6 /*PIN 10+15*/)
          {
            action = new Action(Action.ActionType.ACTION_MOVE_LEFT, 0, 0);
            GUIGraphicsContext.OnAction(action);
          }

    I've implemented this stupid button polling by myself somewhere in the sourcecode (just a quick and dirty trial).

    But of course I have to compile this again everytime when there is a new MP version
    and I have no configuration (mapping) file at the moment.
    So this solution is not very comfortable.

    Do you think that there is any chance to add such button support in your plugin?

    Regards

    T-Square
     

    kaburke

    Portal Pro
    March 4, 2005
    64
    0
    Alberta, Canada
    T-Square,
    I assume this line:
    Code:
    eingang = IO.m_Port.Tasten(0x378+1);
    is what actually is doing the polling, and the rest is just your button mappings?

    Assuming that my above assumption is correct (and I'm fairly certain it is - the code doesn't seem overly complex), all that needs to be done is to write a small device plugin to be used with InputDeviceMapper. There is a HOW-TO here (it's on the InputDeviceMapper download page). You can also look at the LiveDriveIR source for reference. If you are having trouble, let me know and I can either give you a hand or throw one together for you (I won't be able to test it, but if you would give me a hand in that area...).
     

    kaburke

    Portal Pro
    March 4, 2005
    64
    0
    Alberta, Canada
    Eggert,

    Sorry, I havben't been able to think of a solution (beyond some 3rd party software that may exist). Right now, the key presses are sent to the system - the only reason MediaPortal responds is because it is the active application (i.e., mapping an event to a keystroke is exactly the same as pressing that particular key on the keyboard). So, if the is another application waiting for a keystroke (e.g., WinAmp with global hotkeys enabled), that application will receive the event as well as the active application (in our case, usually MediaPortal). I don't know if you can use that information to help you, but it does mean if you have another programme listening globally for CTRL+F9 (or whatever keystroke), it should receive it when InputDeviceMapper sends it.
     

    T-Square

    Portal Member
    May 19, 2005
    17
    0
    Minden Germany
    Home Country
    Germany Germany
    Hi kaburke,

    thanks for your quick answer.
    Yes you are right
    Code:
    eingang = IO.m_Port.Tasten(0x378+1);
    is just the polling of the printer port and all the rest is the key mapping, which is anyhow done by your plugin.
    So I'll try to write a small device plugin for that.
    Thanks for your hint.

    Regards

    T-Square
     

    kaburke

    Portal Pro
    March 4, 2005
    64
    0
    Alberta, Canada
    Code:
    eingang = IO.m_Port.Tasten(0x378+1);
    Does the above code block and wait for input, or does it just check the current value on the port and then expect you to check if a value was actually sent?
     

    T-Square

    Portal Member
    May 19, 2005
    17
    0
    Minden Germany
    Home Country
    Germany Germany
    Code:
    eingang = IO.m_Port.Tasten(0x378+1);
    just reads the input pins from the printer port (Pin10,11,12,13 and 15).
    PIN11 is Bit4 at address 0x378+1 (printer statusport), PIN10 is Bit3, PIN12 is Bit2, PIN13 is Bit1 and PIN15 is Bit0.
    If a button is pressed the Bit changes from 1 to 0 (Bit4 changes from 0 to 1 because PIN11 is hardware inverted).
    No button pressed is 15 decimal (01111 binary).
    With these 5 inputs a very simple button matrix with up to 31 buttons can be connected.

    But to answer your question:
    This just checks the current state of the port.
    A button event is any change of this input (one change for button down and one for button up).
     

    T-Square

    Portal Member
    May 19, 2005
    17
    0
    Minden Germany
    Home Country
    Germany Germany
    Hi Kaburke,

    yesterday I finally found time to write a pluggin for the LPT buttons.
    As you told, it was more or less easy to do.
    Thanks for your advice and for your great plugin.

    This makes my life much easier because I now can setup the keymapping
    very comfortable with your InputDeviceEventMapper.
    I'll make some futher improvements to my plugin and make some values
    adjustable in the setup (polltime, printer port, button repeat time) and that's it.
    After that it could be used by anyone else who's interrested in it.
    This is the easiest way to connect button to a HTPC and controll MediaPortal with it.

    I like to have some important buttons in my HTPC case (Navigation, Forward, Play/Stop,
    Reverse, etc.), because this gives the whole thing a HiFi look and feel.

    Thanks

    T-Square :D
     

    Users who are viewing this thread

    Top Bottom