CecTray: don't use lazy loading for the main controller, but pass the instance. bugzi...
[deb_libcec.git] / src / LibCecTray / controller / applications / internal / WMCController.cs
... / ...
CommitLineData
1/*
2 * This file is part of the libCEC(R) library.
3 *
4 * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved.
5 * libCEC(R) is an original work, containing original code.
6 *
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
8 *
9 * This program is dual-licensed; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 *
23 *
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
26 *
27 * For more information contact:
28 * Pulse-Eight Licensing <license@pulse-eight.com>
29 * http://www.pulse-eight.com/
30 * http://www.pulse-eight.net/
31 */
32
33using System;
34using CecSharp;
35using LibCECTray.Properties;
36using LibCECTray.settings;
37
38namespace LibCECTray.controller.applications.@internal
39{
40 internal class WMCController : ApplicationController
41 {
42 public WMCController(CECController controller) :
43 base(controller,
44 Resources.application_windows_media_center,
45 "ehshell",
46 "ehshell.exe",
47 Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\..\ehome")
48 {
49 IsInternal = true;
50 }
51
52 public override ApplicationAction DefaultValue(CecKeypress key)
53 {
54 KeyInput keyInput = new KeyInput(null);
55 switch (key.Keycode)
56 {
57 case CecUserControlCode.RightUp:
58 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_RIGHT);
59 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_UP);
60 break;
61 case CecUserControlCode.LeftUp:
62 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_LEFT);
63 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_UP);
64 break;
65 case CecUserControlCode.Up:
66 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_UP);
67 break;
68 case CecUserControlCode.RightDown:
69 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_RIGHT);
70 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_DOWN);
71 break;
72 case CecUserControlCode.LeftDown:
73 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_LEFT);
74 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_DOWN);
75 break;
76 case CecUserControlCode.Down:
77 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_DOWN);
78 break;
79 case CecUserControlCode.Left:
80 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_LEFT);
81 break;
82 case CecUserControlCode.Right:
83 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_RIGHT);
84 break;
85 case CecUserControlCode.Select:
86 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_RETURN);
87 break;
88 case CecUserControlCode.Exit:
89 case CecUserControlCode.SamsungReturn:
90 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_BACK);
91 break;
92 case CecUserControlCode.RootMenu:
93 case CecUserControlCode.SetupMenu:
94 case CecUserControlCode.ContentsMenu:
95 case CecUserControlCode.FavoriteMenu:
96 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_MENU);
97 break;
98 case CecUserControlCode.Number0:
99 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_NUMPAD0);
100 break;
101 case CecUserControlCode.Number1:
102 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_NUMPAD1);
103 break;
104 case CecUserControlCode.Number2:
105 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_NUMPAD2);
106 break;
107 case CecUserControlCode.Number3:
108 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_NUMPAD3);
109 break;
110 case CecUserControlCode.Number4:
111 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_NUMPAD4);
112 break;
113 case CecUserControlCode.Number5:
114 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_NUMPAD5);
115 break;
116 case CecUserControlCode.Number6:
117 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_NUMPAD6);
118 break;
119 case CecUserControlCode.Number7:
120 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_NUMPAD7);
121 break;
122 case CecUserControlCode.Number8:
123 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_NUMPAD8);
124 break;
125 case CecUserControlCode.Number9:
126 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_NUMPAD9);
127 break;
128 case CecUserControlCode.Dot:
129 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_SELECT);
130 break;
131 case CecUserControlCode.Enter:
132 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_RETURN);
133 break;
134 case CecUserControlCode.Clear:
135 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_CLEAR);
136 break;
137 case CecUserControlCode.F1Blue:
138 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_F1);
139 break;
140 case CecUserControlCode.F2Red:
141 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_F2);
142 break;
143 case CecUserControlCode.F3Green:
144 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_F3);
145 break;
146 case CecUserControlCode.F4Yellow:
147 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_F4);
148 break;
149 case CecUserControlCode.F5:
150 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_F5);
151 break;
152 case CecUserControlCode.ChannelUp:
153 case CecUserControlCode.PageUp:
154 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_MEDIA_NEXT_TRACK);
155 break;
156 case CecUserControlCode.ChannelDown:
157 case CecUserControlCode.PageDown:
158 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_MEDIA_PREV_TRACK);
159 break;
160 case CecUserControlCode.VolumeUp:
161 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_VOLUME_UP);
162 break;
163 case CecUserControlCode.VolumeDown:
164 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_VOLUME_DOWN);
165 break;
166 case CecUserControlCode.Mute:
167 case CecUserControlCode.MuteFunction:
168 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_VOLUME_MUTE);
169 break;
170 case CecUserControlCode.Play:
171 case CecUserControlCode.PlayFunction:
172 case CecUserControlCode.Pause:
173 case CecUserControlCode.PausePlayFunction:
174 case CecUserControlCode.PauseRecord:
175 case CecUserControlCode.PauseRecordFunction:
176 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_MEDIA_PLAY_PAUSE);
177 break;
178 case CecUserControlCode.Stop:
179 case CecUserControlCode.StopFunction:
180 case CecUserControlCode.StopRecord:
181 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_MEDIA_STOP);
182 break;
183 case CecUserControlCode.Rewind:
184 case CecUserControlCode.Backward:
185 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_LEFT);
186 break;
187 case CecUserControlCode.Forward:
188 case CecUserControlCode.FastForward:
189 keyInput.AddKey(WindowsAPI.VirtualKeyCode.VK_RIGHT);
190 break;
191
192 //currently unmapped
193 //case CecUserControlCode.NextFavorite:
194 //case CecUserControlCode.PreviousChannel:
195 //case CecUserControlCode.SoundSelect:
196 //case CecUserControlCode.InputSelect:
197 //case CecUserControlCode.DisplayInformation:
198 //case CecUserControlCode.Help:
199 //case CecUserControlCode.Record:
200 //case CecUserControlCode.Eject:
201 //case CecUserControlCode.Angle:
202 //case CecUserControlCode.SubPicture:
203 //case CecUserControlCode.VideoOnDemand:
204 //case CecUserControlCode.ElectronicProgramGuide:
205 //case CecUserControlCode.TimerProgramming:
206 //case CecUserControlCode.RecordFunction:
207 //case CecUserControlCode.RestoreVolumeFunction:
208 //case CecUserControlCode.TuneFunction:
209 //case CecUserControlCode.SelectMediaFunction:
210 //case CecUserControlCode.SelectAVInputFunction:
211 //case CecUserControlCode.SelectAudioInputFunction:
212 //case CecUserControlCode.Data:
213 //default:
214 // break;
215 }
216
217 return keyInput.Empty() ? null : keyInput;
218 }
219 }
220}