Inputdevice Manager for MP2 (2 Viewers)

Timhoh1234

Portal Pro
September 29, 2015
252
90
Home Country
Germany Germany
Wow, nice to see some movement coming in here. @osre I see your're from "development group", yould be great, if you can finalize this plugin.
As I understood Freaky it's just fine tuning and Gui optimization, 90% finished. Many people really need this one!!! :):)
 

osre

Retired Team Member
  • Premium Supporter
  • December 14, 2014
    775
    387
    Home Country
    Germany Germany
    In the short term I won't invest too much time into the GUI (no workflow rework), but at least I will make some cleanup, and I'm defenetally looking into deleting mappings.
     

    CyberSimian

    Test Group
  • Team MediaPortal
  • June 10, 2013
    2,875
    1,804
    Southampton
    Home Country
    United Kingdom United Kingdom
    the green "Start" button also Switches Window state from Maximized to Normal and back. Not sure where this Comes from, since the key Code for this button is "LWin"
    Not quite true. The Hama START button sends the key combination WIN_ALT_ENTER.

    This key combination causes a problem for the "Centarea HID" for MP1. I think (not sure) that the processing code for the Centarea HID ignores the WIN part of the key combination, and interprets the key as ALT_ENTER, which (of course) causes MP to alternate between windowed and fullscreen. :(

    For the Centarea HID, I was able to circumvent this problem by defining the START button in the config file to look for keycode ALT_ENTER (not WIN_ALT_ENTER), and then display the Home panel when detected (but at the cost of ALT_ENTER on a keyboard no longer switching MP between windowed and fullscreen).

    -- from CyberSimian in the UK
     

    osre

    Retired Team Member
  • Premium Supporter
  • December 14, 2014
    775
    387
    Home Country
    Germany Germany
    the green "Start" button also Switches Window state from Maximized to Normal and back. Not sure where this Comes from, since the key Code for this button is "LWin"
    Not quite true. The Hama START button sends the key combination WIN_ALT_ENTER.

    This key combination causes a problem for the "Centarea HID" for MP1. I think (not sure) that the processing code for the Centarea HID ignores the WIN part of the key combination, and interprets the key as ALT_ENTER, which (of course) causes MP to alternate between windowed and fullscreen. :(

    For the Centarea HID, I was able to circumvent this problem by defining the START button in the config file to look for keycode ALT_ENTER (not WIN_ALT_ENTER), and then display the Home panel when detected (but at the cost of ALT_ENTER on a keyboard no longer switching MP between windowed and fullscreen).

    -- from CyberSimian in the UK
    Yes, I can confirm this now.
    But the window switching seems to Interrupt the Input handling of the InputManagerPlugin, so it sees the keys as single ones somehow.
    But may be the MP" core impl can look for win button so it must not be pressed to Switch window.
     

    osre

    Retired Team Member
  • Premium Supporter
  • December 14, 2014
    775
    387
    Home Country
    Germany Germany
    Found the reason why LMenu and Enter keys were not visible to the InputmanagerPlugin.
    As soon as LWin is down, LMenu (Alt) and Enter do not raise the KEY_DOWN, but the SYSTEMKEY_DOWN message (I think this is always true for Alt)
    Since this message was ignored it did not work.
    Fixed this as well now.

    @morpheus_xx :
    I made a hack in InputMapper class to prevent window switching when HAMA Start button is pressed:
    Since I'm working on FreekyJ's fork, and it is a bit hakky, I would not push it without confirmation:
    C#:
    public static class InputMapper
      {
        public static Key MapSpecialKey(KeyEventArgs args)
        {
          return MapSpecialKey(args.KeyCode, args.Alt, args.Shift, args.Control);
        }
    
        private static class Keyboard
        {
          [Flags]
          private enum KeyStates
          {
            None = 0,
            Down = 1,
            Toggled = 2
          }
    
          [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
          private static extern short GetKeyState(int keyCode);
    
          private static KeyStates GetKeyState(Keys key)
          {
            KeyStates state = KeyStates.None;
    
            short retVal = GetKeyState((int)key);
    
            //If the high-order bit is 1, the key is down
            //otherwise, it is up.
            if ((retVal & 0x8000) == 0x8000)
              state |= KeyStates.Down;
    
            //If the low-order bit is 1, the key is toggled.
            if ((retVal & 1) == 1)
              state |= KeyStates.Toggled;
    
            return state;
          }
    
          public static bool IsKeyDown(Keys key)
          {
            return KeyStates.Down == (GetKeyState(key) & KeyStates.Down);
          }
    
          public static bool IsKeyToggled(Keys key)
          {
            return KeyStates.Toggled == (GetKeyState(key) & KeyStates.Toggled);
          }
        }
    
        public static Key MapSpecialKey(Keys keycode, bool alt, bool shift, bool control)
        {
          switch (keycode)
          {
            case Keys.Add:
              if (alt)
                return Key.VolumeUp;
              break;
            case Keys.Subtract:
              if (alt)
                return Key.VolumeDown;
              break;
            case Keys.Cancel:
              return Key.Escape;
            case Keys.Clear:
              return Key.Clear;
            case Keys.Delete:
              return Key.Delete;
            case Keys.Insert:
              return Key.Insert;
            case Keys.Enter:
              if (!Keyboard.IsKeyDown(Keys.LWin))
              {
                if (alt)
                  return Key.Fullscreen;
                return Key.Ok;
              }
              break;
            case Keys.Back:
              return Key.BackSpace;
            case Keys.Escape:
              return Key.Escape;
    
            case Keys.MediaNextTrack:
              return Key.Next;
            case Keys.MediaPlayPause:
              return Key.PlayPause;
            case Keys.MediaPreviousTrack:
              return Key.Previous;
            case Keys.MediaStop:
              return Key.Stop;
            case Keys.Pause:
              return Key.Pause;
            case Keys.Play:
              return Key.Play;
    
            case Keys.VolumeMute:
              return Key.Mute;
            case Keys.VolumeDown:
              return Key.VolumeDown;
            case Keys.VolumeUp:
              return Key.VolumeUp;
    
            case Keys.Up:
              return Key.Up;
            case Keys.Down:
              return Key.Down;
            case Keys.Left:
              return Key.Left;
            case Keys.Right:
              return Key.Right;
    
            case Keys.PageUp:
              return Key.PageUp;
            case Keys.PageDown:
              return Key.PageDown;
    
            case Keys.Home:
              return Key.Home;
            case Keys.End:
              return Key.End;
    
            case Keys.Apps:
              return Key.ContextMenu;
            case Keys.Zoom:
              return Key.ZoomMode;
    
            case Keys.Sleep:
              return Key.Power;
    
            case Keys.F1:
              return Key.F1;
            case Keys.F2:
              return Key.F2;
            case Keys.F3:
              return Key.F3;
            case Keys.F4:
              if (alt)
                return Key.Close;
              return Key.F4;
            case Keys.F5:
              return Key.F5;
            case Keys.F6:
              return Key.F6;
            case Keys.F7:
              return Key.F7;
            case Keys.F8:
              return Key.F8;
            case Keys.F9:
              return Key.F9;
            case Keys.F10:
              return Key.F10;
            case Keys.F11:
              return Key.F11;
            case Keys.F12:
              return Key.F12;
            case Keys.F13:
              return Key.F13;
            case Keys.F14:
              return Key.F14;
            case Keys.F15:
              return Key.F15;
            case Keys.F16:
              return Key.F16;
            case Keys.F17:
              return Key.F17;
            case Keys.F18:
              return Key.F18;
            case Keys.F19:
              return Key.F19;
            case Keys.F20:
              return Key.F20;
            case Keys.F21:
              return Key.F21;
            case Keys.F22:
              return Key.F22;
            case Keys.F23:
              return Key.F23;
            case Keys.F24:
              return Key.F24;
    
            case Keys.X:
              if (control)
                return Key.Cut;
              break;
            case Keys.C:
              if (control)
                return Key.Copy;
              break;
            case Keys.V:
              if (control)
                return Key.Paste;
              break;
          }
          return Key.None;
        }
    
        public static Key MapPrintableKeys(char keyChar)
        {
          if (keyChar >= (char)32)
            return new Key(keyChar);
          return Key.None;
        }
      }

    But it is working.
    Actual Change is in line 70 of the Code above.
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    Looks quite safe to include. Some minor simplification: you might use "GetKeyState(key).HasFlag(KeyStates.Toggled);" as shorter comparision.
     

    osre

    Retired Team Member
  • Premium Supporter
  • December 14, 2014
    775
    387
    Home Country
    Germany Germany
    Looks quite safe to include. Some minor simplification: you might use "GetKeyState(key).HasFlag(KeyStates.Toggled);" as shorter comparision.
    The Keyboard class is actually copy paste.
    So should I push it to the fork, and when I'm done it gets merged into current dev branch along with the plugin?
    My work is nearly done. Woks quite nice so far.
     

    osre

    Retired Team Member
  • Premium Supporter
  • December 14, 2014
    775
    387
    Home Country
    Germany Germany
    As far as I can say the plugin working now.
    Changes:
    [Fix] also react on WM_SYSKEYDOWN, this allows combinations with "Alt" key
    [Fix] All mapped keys for an Action must be pressed, not only 1
    [Feature] delete mappings by selection it from the list (with confirmation)
    [Fix] moved Add/Done button to bottom of Screen so they don't overlay with mappings list
    [Fix] Added text wrapping to the head line Labels so all the text can be read now
    [Change] changed Button Texts: "Done/Cancel" -> "Done", "Add" -> "Add mapping"
    [Cleanup] Some General Code cleanup

    The General workflow is the same.
    I will push the changes soon, and prepare a new Archive with the binaries.
    There is also a Change in the SckinEngine InputMapper class, but this is only for additional compatibility with the HAMA remote and is not required for the plugin.

    I know there were more requests for Features/changes, but I think by this we have an working Version that can be released.
     

    Users who are viewing this thread

    Top Bottom