RemoteControlDevice.cs
changeset 3 db8e6a25d6bc
parent 2 505a13a09336
child 4 eed66dfd9848
     1.1 --- a/RemoteControlDevice.cs	Tue Nov 04 19:49:34 2014 +0100
     1.2 +++ b/RemoteControlDevice.cs	Tue Nov 04 20:58:19 2014 +0100
     1.3 @@ -69,34 +69,101 @@
     1.4  		Unknown
     1.5  	}
     1.6  
     1.7 +    /// <summary>
     1.8 +    /// 
     1.9 +    /// </summary>
    1.10 +    public enum MceButton
    1.11 +    {
    1.12 +        Null                    =   0x00, //Not defined by the specs
    1.13 +        GreenStart              =   0x0D,
    1.14 +        ClosedCaptioning        =   0x2B,
    1.15 +        Teletext                =   0x5A,
    1.16 +        TeletextRed             =   0x5B,
    1.17 +        TeletextGreen           =   0x5C,
    1.18 +        TeletextYellow          =   0x5D,
    1.19 +        TeletextBlue            =   0x5E,
    1.20 +        LiveTv                  =   0x25,
    1.21 +        Music                   =   0x47,
    1.22 +        RecordedTv              =   0x48,
    1.23 +        Pictures                =   0x49,
    1.24 +        Videos                  =   0x4A,
    1.25 +        FmRadio                 =   0x50,
    1.26 +        Extras                  =   0x3C,
    1.27 +        ExtrasApp               =   0x3D,
    1.28 +        DvdMenu                 =   0x24,
    1.29 +        DvdAngle                =   0x4B,
    1.30 +        DvdAudio                =   0x4C,
    1.31 +        DvdSubtitle             =   0x4D,
    1.32 +        Eject                   =   0x28,
    1.33 +        DvdTopMenu              =   0x43,
    1.34 +        Ext0                    =   0x32,
    1.35 +        Ext1                    =   0x33,
    1.36 +        Ext2                    =   0x34,
    1.37 +        Ext3                    =   0x35,
    1.38 +        Ext4                    =   0x36,
    1.39 +        Ext5                    =   0x37,
    1.40 +        Ext6                    =   0x38,
    1.41 +        Ext7                    =   0x39,
    1.42 +        Ext8                    =   0x3A,
    1.43 +        Ext9                    =   0x80,
    1.44 +        Ext10                   =   0x81,
    1.45 +        Ext11                   =   0x6F,
    1.46 +        Zoom                    =   0x27,
    1.47 +        ChannelInput            =   0x42,
    1.48 +        SubAudio                =   0x2D,
    1.49 +        Channel10               =   0x3E,
    1.50 +        Channel11               =   0x3F,
    1.51 +        Channel12               =   0x40,
    1.52 +        Display                 =   0x4F,
    1.53 +        Kiosk                   =   0x6A,
    1.54 +        NetworkSelection        =   0x2C,
    1.55 +        BlueRayTool             =   0x78,
    1.56 +        ChannelInfo             =   0x41,
    1.57 +        VideoSelection          =   0x61                
    1.58 +    }
    1.59 +
    1.60  
    1.61  	#region RemoteControlEventArgs
    1.62  
    1.63  	public class RemoteControlEventArgs : EventArgs
    1.64  	{
    1.65 -		RemoteControlButton _rcb;
    1.66 +        RemoteControlButton _rcb;
    1.67  		InputDevice _device;
    1.68 +        MceButton iMceButton;
    1.69  
    1.70 -		public RemoteControlEventArgs(RemoteControlButton rcb, InputDevice device)
    1.71 +        public RemoteControlEventArgs(RemoteControlButton rcb, InputDevice device)
    1.72  		{
    1.73 +            iMceButton = MceButton.Null;
    1.74  			_rcb = rcb;
    1.75  			_device = device;
    1.76  		}
    1.77  
    1.78 +        public RemoteControlEventArgs(MceButton mce, InputDevice device)
    1.79 +        {
    1.80 +            iMceButton = mce;
    1.81 +            _rcb = RemoteControlButton.Unknown;
    1.82 +            _device = device;
    1.83 +        }
    1.84  
    1.85  		public RemoteControlEventArgs()
    1.86  		{
    1.87 +            iMceButton = MceButton.Null;
    1.88  			_rcb = RemoteControlButton.Unknown;
    1.89  			_device = InputDevice.Key;
    1.90  		}
    1.91  
    1.92 -
    1.93  		public RemoteControlButton Button
    1.94  		{
    1.95  			get { return _rcb;  }
    1.96  			set { _rcb = value; }
    1.97  		}
    1.98  
    1.99 +        public MceButton MceButton
   1.100 +        {
   1.101 +            get { return iMceButton; }
   1.102 +            set { iMceButton = value; }
   1.103 +        }
   1.104 +
   1.105  		public InputDevice Device
   1.106  		{
   1.107  			get { return _device;  }
   1.108 @@ -231,22 +298,6 @@
   1.109  		private const int APPCOMMAND_MEDIA_CHANNEL_UP   = 51;
   1.110  		private const int APPCOMMAND_MEDIA_CHANNEL_DOWN = 52;
   1.111  
   1.112 -		private const int RAWINPUT_DETAILS				= 0x209;
   1.113 -		private const int RAWINPUT_GUIDE				= 0x8D;
   1.114 -		private const int RAWINPUT_TVJUMP				= 0x25;
   1.115 -		private const int RAWINPUT_STANDBY				= 0x82;
   1.116 -		private const int RAWINPUT_OEM1					= 0x80;
   1.117 -		private const int RAWINPUT_OEM2					= 0x81;
   1.118 -		private const int RAWINPUT_MYTV					= 0x46;
   1.119 -		private const int RAWINPUT_MYVIDEOS				= 0x4A;
   1.120 -		private const int RAWINPUT_MYPICTURES			= 0x49;
   1.121 -		private const int RAWINPUT_MYMUSIC				= 0x47;
   1.122 -		private const int RAWINPUT_RECORDEDTV			= 0x48;
   1.123 -		private const int RAWINPUT_DVDANGLE				= 0x4B;
   1.124 -		private const int RAWINPUT_DVDAUDIO				= 0x4C;
   1.125 -		private const int RAWINPUT_DVDMENU				= 0x24;
   1.126 -		private const int RAWINPUT_DVDSUBTITLE			= 0x4D;
   1.127 -
   1.128  		private const int RIM_TYPEMOUSE					= 0;
   1.129  		private const int RIM_TYPEKEYBOARD				= 1;
   1.130  		private const int RIM_TYPEHID					= 2;
   1.131 @@ -498,57 +549,13 @@
   1.132                      int rawData = bRawData[1]; //Get button code
   1.133                      Debug.WriteLine("HID " + raw.hid.dwCount + "/" + raw.hid.dwSizeHid + ":" + bRawData[0].ToString("X2") + bRawData[1].ToString("X2"));
   1.134  
   1.135 -					switch (rawData)
   1.136 -					{
   1.137 -						case RAWINPUT_DETAILS:
   1.138 -							rcb = RemoteControlButton.Details;
   1.139 -							break;
   1.140 -						case RAWINPUT_GUIDE:
   1.141 -							rcb = RemoteControlButton.Guide;
   1.142 -							break;
   1.143 -						case RAWINPUT_TVJUMP:
   1.144 -							rcb = RemoteControlButton.TVJump;
   1.145 -							break;
   1.146 -						case RAWINPUT_STANDBY:
   1.147 -							rcb = RemoteControlButton.StandBy;
   1.148 -							break;
   1.149 -						case RAWINPUT_OEM1:
   1.150 -							rcb = RemoteControlButton.OEM1;
   1.151 -							break;
   1.152 -						case RAWINPUT_OEM2:
   1.153 -							rcb = RemoteControlButton.OEM2;
   1.154 -							break;
   1.155 -						case RAWINPUT_MYTV:
   1.156 -							rcb = RemoteControlButton.MyTV;
   1.157 -							break;
   1.158 -						case RAWINPUT_MYVIDEOS:
   1.159 -							rcb = RemoteControlButton.MyVideos;
   1.160 -							break;
   1.161 -						case RAWINPUT_MYPICTURES:
   1.162 -							rcb = RemoteControlButton.MyPictures;
   1.163 -							break;
   1.164 -						case RAWINPUT_MYMUSIC:
   1.165 -							rcb = RemoteControlButton.MyMusic;
   1.166 -							break;
   1.167 -						case RAWINPUT_RECORDEDTV:
   1.168 -							rcb = RemoteControlButton.RecordedTV;
   1.169 -							break;
   1.170 -						case RAWINPUT_DVDANGLE:
   1.171 -							rcb = RemoteControlButton.DVDAngle;
   1.172 -							break;
   1.173 -						case RAWINPUT_DVDAUDIO:
   1.174 -							rcb = RemoteControlButton.DVDAudio;
   1.175 -							break;
   1.176 -						case RAWINPUT_DVDMENU:
   1.177 -							rcb = RemoteControlButton.DVDMenu;
   1.178 -							break;
   1.179 -						case RAWINPUT_DVDSUBTITLE:
   1.180 -							rcb = RemoteControlButton.DVDSubtitle;
   1.181 -							break;
   1.182 -					}
   1.183 -
   1.184 -					if (rcb != RemoteControlButton.Unknown && this.ButtonPressed != null)
   1.185 -						this.ButtonPressed(this, new RemoteControlEventArgs(rcb, GetDevice(message.LParam.ToInt32())));
   1.186 +                    if (Enum.IsDefined(typeof(MceButton), rawData) && rawData!=0) //Our button is a known MCE button
   1.187 +                    {
   1.188 +                        if (this.ButtonPressed != null) //What's that?
   1.189 +                        {
   1.190 +                            this.ButtonPressed(this, new RemoteControlEventArgs((MceButton)rawData, GetDevice(message.LParam.ToInt32())));
   1.191 +                        }
   1.192 +                    }
   1.193  				}
   1.194  				else if(raw.header.dwType == RIM_TYPEMOUSE)
   1.195  				{