a6365c4928bae37167548f5a527aedad9c9d736e
[sgx.git] / pvr / tools / hotkey.c
1 /**********************************************************************
2  *
3  * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful but, except
10  * as otherwise stated in writing, without any warranty; without even the
11  * implied warranty of merchantability or fitness for a particular purpose.
12  * See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * The full GNU General Public License is included in this distribution in
19  * the file called "COPYING".
20  *
21  * Contact Information:
22  * Imagination Technologies Ltd. <gpl-support@imgtec.com>
23  * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
24  *
25  ******************************************************************************/
26
27 #include "img_types.h"
28 #include "pvr_debug.h"
29 #include "dbgdrvif.h"
30 #include "dbgdriv.h"
31 #include "hotkey.h"
32 #include "hostfunc.h"
33
34 u32 g_ui32HotKeyFrame = 0xFFFFFFFF;
35 IMG_BOOL g_bHotKeyPressed = IMG_FALSE;
36 IMG_BOOL g_bHotKeyRegistered = IMG_FALSE;
37
38 struct PRIVATEHOTKEYDATA g_PrivateHotKeyData;
39
40 void ReadInHotKeys(void)
41 {
42         g_PrivateHotKeyData.ui32ScanCode = 0x58;
43         g_PrivateHotKeyData.ui32ShiftState = 0x0;
44
45         HostReadRegistryDWORDFromString("DEBUG\\Streams", "ui32ScanCode",
46                                         &g_PrivateHotKeyData.ui32ScanCode);
47         HostReadRegistryDWORDFromString("DEBUG\\Streams", "ui32ShiftState",
48                                         &g_PrivateHotKeyData.ui32ShiftState);
49 }
50
51 void RegisterKeyPressed(u32 dwui32ScanCode, struct HOTKEYINFO *pInfo)
52 {
53         struct DBG_STREAM *psStream;
54
55         PVR_UNREFERENCED_PARAMETER(pInfo);
56
57         if (dwui32ScanCode == g_PrivateHotKeyData.ui32ScanCode) {
58                 PVR_DPF(PVR_DBG_MESSAGE, "PDUMP Hotkey pressed !\n");
59
60                 psStream = (struct DBG_STREAM *)
61                                 g_PrivateHotKeyData.sHotKeyInfo.pvStream;
62
63                 if (!g_bHotKeyPressed) {
64
65                         g_ui32HotKeyFrame = psStream->ui32Current + 2;
66
67                         g_bHotKeyPressed = IMG_TRUE;
68                 }
69         }
70 }
71
72 void ActivateHotKeys(struct DBG_STREAM *psStream)
73 {
74
75         ReadInHotKeys();
76
77         if (!g_PrivateHotKeyData.sHotKeyInfo.hHotKey)
78                 if (g_PrivateHotKeyData.ui32ScanCode != 0) {
79                         PVR_DPF(PVR_DBG_MESSAGE,
80                                  "Activate HotKey for PDUMP.\n");
81
82                         g_PrivateHotKeyData.sHotKeyInfo.pvStream = psStream;
83
84                         DefineHotKey(g_PrivateHotKeyData.ui32ScanCode,
85                                      g_PrivateHotKeyData.ui32ShiftState,
86                                      &g_PrivateHotKeyData.sHotKeyInfo);
87                 } else {
88                         g_PrivateHotKeyData.sHotKeyInfo.hHotKey = 0;
89                 }
90 }
91
92 void DeactivateHotKeys(void)
93 {
94         if (g_PrivateHotKeyData.sHotKeyInfo.hHotKey != 0) {
95                 PVR_DPF(PVR_DBG_MESSAGE, "Deactivate HotKey.\n");
96
97                 RemoveHotKey(g_PrivateHotKeyData.sHotKeyInfo.hHotKey);
98                 g_PrivateHotKeyData.sHotKeyInfo.hHotKey = 0;
99         }
100 }