/// <summary> /// Process key press events /// </summary> /// <param name="keyPressed"></param> public override void ProcessKeyPress(int keyPressed) { _logger.Debug("MediaPortal1RemoteHandling - ProcessKeyPress {0} {1}", keyPressed, ((Keys)keyPressed).ToString()); Action action = new Action(); //Try and get corresponding Action from key. //Some actions are mapped to KeyDown others to KeyPressed, try and handle both if (ActionTranslator.GetAction(-1, new Key(0, keyPressed), ref action)) { OnNewActionFromClient(action.wID.ToString()); } else { //See if it's mapped to KeyPressed instead if (keyPressed >= (int)Keys.A && keyPressed <= (int)Keys.Z) { keyPressed += 32; //convert to char code } if (ActionTranslator.GetAction(-1, new Key(keyPressed, 0), ref action)) { OnNewActionFromClient(action.wID.ToString()); } } }
/// <summary> /// Map a key press to an action /// </summary> /// <param name="keyPressed"></param> /// <returns></returns> public static Action MapToAction(int keyPressed) { var action = new Action(); if (ActionTranslator.GetAction(-1, new Key(0, keyPressed), ref action)) { return(action); } //See if it's mapped to KeyPressed instead if (keyPressed >= (int)Keys.A && keyPressed <= (int)Keys.Z) { keyPressed += 32; //convert to char code } if (ActionTranslator.GetAction(-1, new Key(keyPressed, 0), ref action)) { return(action); } return(null); }
/// <summary> /// When the browser has a key press, try and map it to an action and fire the on action /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void _callback_OnBrowserKeyPress(int keyPressed) { var action = new Action(); if (ActionTranslator.GetAction(-1, new Key(0, keyPressed), ref action)) { GUIWindowManager_OnNewAction(action); } else { //See if it's mapped to KeyPressed instead if (keyPressed >= (int)Keys.A && keyPressed <= (int)Keys.Z) { keyPressed += 32; //convert to char code } if (ActionTranslator.GetAction(-1, new Key(keyPressed, 0), ref action)) { GUIWindowManager_OnNewAction(action); } } }
public override void OnAction(Action action) { if (action.wID == Action.ActionType.ACTION_KEY_PRESSED) { // translate the action as if our window was the WINDOW_FULLSCREEN_VIDEO if (ActionTranslator.GetAction((int)Window.WINDOW_FULLSCREEN_VIDEO, action.m_key, ref action)) { if (action.wID == Action.ActionType.ACTION_SHOW_OSD) // handle the OSD action differently - we need to show our OSD { base.OnAction(action); if (GUIWindowManager.VisibleOsd == Window.WINDOW_OSD) { GUIWindowManager.VisibleOsd = (Window)GUIOnlineVideoOSD.WINDOW_ONLINEVIDEOS_OSD; } return; } else if (action.wID == Action.ActionType.ACTION_SHOW_GUI || action.wID == Action.ActionType.ACTION_NEXT_SUBTITLE) { return; // already handled by base class, but get's sent here again as keypress, so when we map it we must make sure not to handle it again } else if (action.wID == Action.ActionType.ACTION_VOLUME_UP || action.wID == Action.ActionType.ACTION_VOLUME_DOWN || action.wID == Action.ActionType.ACTION_VOLUME_MUTE) { // MediaPortal core sends this message to the Fullscreenwindow, we need to do it ourselves to make the Volume OSD show up GUIWindowManager.SendThreadCallback((p1, p2, o) => { Action showVolume = new Action(Action.ActionType.ACTION_SHOW_VOLUME, 0, 0); GUIWindowManager.OnAction(showVolume); return(0); }, 0, 0, null); return; } } } base.OnAction(action); }
private void Listener_XplMessageReceived(object sender, XplListener.XplEventArgs e) { if (e.XplMsg.Schema.msgClass.ToLower().Equals("hbeat") && e.XplMsg.Schema.msgType.ToLower().Equals("app")) { if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received HEARTBEAT"); } this._IsConnected = true; } else if (e.XplMsg.Schema.msgClass.ToLower().Equals("config")) { if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received CONFIG message"); } } else if ((e.XplMsg.Source.Vendor.ToLower().Equals(this.mVendorID.ToLower()) && e.XplMsg.Source.Device.ToLower().Equals(this.mDeviceID.ToLower())) && e.XplMsg.Source.Instance.ToLower().Equals(this.mInstanceID.ToLower())) { if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received ECHO"); } } else { if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: {0} - {1} - {2}", new object[] { e.XplMsg.Source.Vendor, e.XplMsg.Source.Device, e.XplMsg.Content }); } string str = e.XplMsg.Schema.msgClass.ToLower() + "." + e.XplMsg.Schema.msgType.ToLower(); string str11 = str; if (str11 != null) { if (!(str11 == "media.basic")) { if (!(str11 == "media.request")) { if (str11 == "remote.basic") { foreach (string str9 in e.XplMsg.GetParam(1, "keys").Split(new char[] { ',' })) { if (this.DoDebug) { Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic \"{0}\"", new object[] { str9 }); } if (Enum.IsDefined(typeof(GUIWindow.Window), str9.ToUpper())) { if (this.DoDebug) { Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic window name", new object[0]); } this.XPL_Send_Remote_Confirm_Message(e); int num8 = (int)Enum.Parse(typeof(GUIWindow.Window), str9.ToUpper()); if (!GUIWindowManager.ActiveWindow.Equals(num8)) { GUIWindowManager.SendThreadCallbackAndWait( new GUIWindowManager.Callback(this.ThreadMessageCallback), 1, num8, null); return; } break; } if (Enum.IsDefined(typeof(Keys), str9)) { if (this.DoDebug) { Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic key name", new object[0]); } this.XPL_Send_Remote_Confirm_Message(e); Key key = new Key(0, (int)Enum.Parse(typeof(Keys), str9)); Action action3 = new Action(); if (ActionTranslator.GetAction(GUIWindowManager.ActiveWindow, key, ref action3)) { GUIWindowManager.OnAction(action3); return; } } foreach (string str10 in Enum.GetNames(typeof(RemoteButton))) { if (str10.ToLower().Equals(str9.ToLower()) || str9.ToLower().Equals("remote_" + str10.ToLower())) { if (this.DoDebug) { Log.Info( "xPL_Connector.Listener_XplMessageReceived(): Received remote.basic remote key name \"{0}\"", new object[] { str9 }); } this.XPL_Send_Remote_Confirm_Message(e); if (!this.rHandler.MapAction((int)Enum.Parse(typeof(RemoteButton), str10)) && this.DoDebug) { Log.Info( "xPL_Connector.Listener_XplMessageReceived(): COULD NOT FIRE REMOTE ACTION (isLoaded = {0})", new object[] { this.rHandler.IsLoaded }); } break; } } int result = 0; int.TryParse(str9, out result); if (result != 0) { if (this.DoDebug) { Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic raw keycode", new object[0]); } this.XPL_Send_Remote_Confirm_Message(e); Key key2 = new Key(0, result); Action action4 = new Action(); if (ActionTranslator.GetAction(GUIWindowManager.ActiveWindow, key2, ref action4)) { GUIWindowManager.OnAction(action4); return; } break; } } } } else { switch (e.XplMsg.GetParam(1, "request")) { case "devinfo": this.XPL_SendDevInfo("xpl-stat"); return; case "devstate": if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player")) { this.XPL_SendPlayerDevstate("xpl-stat"); } return; case "mpinfo": if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player")) { this.XPL_SendPlayerMediaPlayerInfo("xpl-stat"); this.XPL_SendPlayerMediaPlayerInputInfo("xpl-stat"); } return; case "mptrnspt": if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player")) { this.XPL_SendPlayerTransportState("xpl-stat"); } return; case "mpmedia": if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player")) { this.XPL_SendMediaInfo("xpl-stat"); } return; case "mpconfig": if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player")) { this.XPL_SendPlayerMediaPlayerConfig("xpl-stat"); } return; case "mpqueue": return; } } } else { int num; switch (e.XplMsg.GetParam(1, "command").ToLower()) { case "record": case "position": case "chapter": case "power": case "reboot": case "input": case "options": return; case "play": { string path = e.XplMsg.GetParam(1, "url").ToLower(); if (!(path.Equals(string.Empty) & g_Player.Paused)) { if (path.Equals(g_Player.currentFileName) & g_Player.Paused) { g_Player.Pause(); if (this.DoDebug) { Log.Info( "xPLConnector_Listener_XplMessageReceived: Received media.basic play file command (unpause)", new object[0]); return; } return; } if (File.Exists(path) && !g_Player.currentFileName.Equals(path)) { GUIMessage message = new GUIMessage(); message.Message = GUIMessage.MessageType.GUI_MSG_PLAY_FILE; message.Label = path; GUIWindowManager.SendThreadMessage(message); if (!this.DoDebug) { return; } Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic play file command", new object[0]); } return; } g_Player.Pause(); if (this.DoDebug) { Log.Info( "xPLConnector_Listener_XplMessageReceived: Received media.basic play file command (unpause)", new object[0]); } return; } case "stop": { GUIMessage message2 = new GUIMessage(); message2.Message = GUIMessage.MessageType.GUI_MSG_STOP_FILE; GUIWindowManager.SendThreadMessage(message2); if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic stop command", new object[0]); } return; } case "pause": if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic pause command", new object[0]); } if (!g_Player.Paused) { g_Player.Pause(); } return; case "forward": { string str4 = e.XplMsg.GetParam(1, "speed").ToLower(); num = 0; if (!str4.Equals(string.Empty)) { num = int.Parse(str4.Replace("x", "")); break; } num = g_Player.Speed * 2; break; } case "rewind": { string str5 = e.XplMsg.GetParam(1, "speed").ToLower(); int num2 = 0; if (!str5.Equals(string.Empty)) { num2 = int.Parse(str5.Replace("x", "")); } else { num2 = Math.Abs(g_Player.Speed) * 2; } if (num2 > 0x20) { num2 = 0x20; } if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic rewind ({0}x) command", new object[] { num2 }); } g_Player.Speed = -num2; return; } case "next": Action action; if (!g_Player.IsDVD) { action = new Action(Action.ActionType.ACTION_NEXT_ITEM, 0f, 0f); } else { action = new Action(Action.ActionType.ACTION_NEXT_CHAPTER, 0f, 0f); } GUIGraphicsContext.OnAction(action); if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic next command", new object[0]); } return; case "back": Action action2; if (!g_Player.IsDVD) { action2 = new Action(Action.ActionType.ACTION_PREV_ITEM, 0f, 0f); } else { action2 = new Action(Action.ActionType.ACTION_PREV_CHAPTER, 0f, 0f); } GUIGraphicsContext.OnAction(action2); if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic back command", new object[0]); } return; case "mute": if (!(e.XplMsg.GetParam(1, "state").ToLower() == "on")) { if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic mute off command", new object[0]); } VolumeHandler.Instance.IsMuted = false; return; } if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic mute on command", new object[0]); } VolumeHandler.Instance.IsMuted = true; return; case "volume": { string str13; string s = e.XplMsg.GetParam(1, "level").ToLower(); if (((str13 = s.Substring(0, 1)) == null) || (!(str13 == "+") && !(str13 == "-"))) { int num7 = int.Parse(s); VolumeHandler.Instance.Volume = (VolumeHandler.Instance.Maximum / 100) * num7; if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic volume command", new object[0]); } return; } int volume = VolumeHandler.Instance.Volume; int num5 = int.Parse(s) * 0x28f; int num6 = volume + num5; if (num6 < 0) { num6 = 0; } if (num6 > 0xffdc) { num6 = 0xffdc; } VolumeHandler.Instance.Volume = num6; if (this.DoDebug) { Log.Info( "xPLConnector_Listener_XplMessageReceived: Received media.basic volume {0} command = orig = {1}, new = {2}, delta = {3}", new object[] { s, volume, num6, num5 }); } return; } default: return; } if (num > 0x20) { num = 0x20; } if (this.DoDebug) { Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic play forward ({0}x) command", new object[] { num }); } g_Player.Speed = num; } } } }
public override void OnAction(MediaPortal.GUI.Library.Action action) { if (action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_VOLUME_UP || action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_VOLUME_DOWN || action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_VOLUME_MUTE) { // MediaPortal core sends this message to the Fullscreenwindow, we need to do it ourselves to make the Volume OSD show up base.OnAction(new MediaPortal.GUI.Library.Action(MediaPortal.GUI.Library.Action.ActionType.ACTION_SHOW_VOLUME, 0, 0)); return; } else if (action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_CONTEXT_MENU) { OnShowContextMenu(); return; } else { MediaPortal.GUI.Library.Action translatedAction = new MediaPortal.GUI.Library.Action(); if (ActionTranslator.GetAction((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO, action.m_key, ref translatedAction)) { if (translatedAction.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_SHOW_OSD) { GUIPropertyManager.SetProperty("#Youtube.fm.FullScreen.ShowTitle", "false"); GUIPropertyManager.SetProperty("#Youtube.fm.FullScreen.ShowNextTitle", "false"); base.OnAction(translatedAction); if (GUIWindowManager.VisibleOsd == GUIWindow.Window.WINDOW_OSD) { GUIWindowManager.VisibleOsd = (GUIWindow.Window) 29055; } return; } if (translatedAction.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_ASPECT_RATIO) { base.OnAction(translatedAction); return; } } } if (action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_NEXT_ITEM || action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_NEXT_CHAPTER) { if (Youtube2MP.player.CurrentSong > -1) { Youtube2MP.player.PlayNext(); return; } if (Youtube2MP.temp_player.CurrentSong > -1) { Youtube2MP.temp_player.PlayNext(); return; } } if (action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_PREV_ITEM || action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_PREV_CHAPTER) { if (Youtube2MP.player.CurrentSong > -1) { Youtube2MP.player.PlayPrevious(); return; } if (Youtube2MP.temp_player.CurrentSong > -1) { Youtube2MP.temp_player.PlayPrevious(); return; } } base.OnAction(action); }