Debian Codegraph @

win32/plugins/peopsxgl/winsrc/key.c

raw
1 /***************************************************************************
2 key.c - description
3 -------------------
4 begin : Sun Mar 08 2009
5 copyright : (C) 1999-2009 by Pete Bernert
6 web : www.pbernert.com
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. See also the license.txt file for *
15 * additional informations. *
16 * *
17 ***************************************************************************/
18
19 //*************************************************************************//
20 // History of changes:
21 //
22 // 2009/03/08 - Pete
23 // - generic cleanup for the Peops release
24 //
25 //*************************************************************************//
26
27 #include "stdafx.h"
28
29 #define _IN_KEY
30
31 #include "externals.h"
32 #include "menu.h"
33 #include "texture.h"
34 #include "draw.h"
35 #include "fps.h"
36
37 ////////////////////////////////////////////////////////////////////////
38 // KeyBoard handler stuff
39 ////////////////////////////////////////////////////////////////////////
40
41 uint32_t ulKeybits;
42
43 static WNDPROC pOldWinProc=0;
44 char szGPUKeys[7];
45
46 ////////////////////////////////////////////////////////////////////////
47 // keyboard handler (WINDOWS)
48 ////////////////////////////////////////////////////////////////////////
49
50 LRESULT CALLBACK key_winproc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
51 {
52 switch(message)
53 {
54 case WM_SYSCOMMAND:
55 if(iNoScreenSaver && wParam==SC_SCREENSAVE) return 0L;
56 break;
57
58 case WM_KEYDOWN:
59 if(wParam==(WPARAM)szGPUKeys[1]) {ulKeybits|=KEY_RESETTEXSTORE;break;}
60 break;
61
62 case WM_SYSKEYUP:
63 if(wParam==VK_RETURN) bChangeWinMode=TRUE;
64 break;
65
66 case WM_KEYUP:
67 if(wParam==(WPARAM)szGPUKeys[0])
68 {
69 if(ulKeybits&KEY_SHOWFPS)
70 {
71 ulKeybits&=~KEY_SHOWFPS;
72 HideText();
73 DestroyPic();
74 }
75 else
76 {
77 ulKeybits|=KEY_SHOWFPS;
78 szDispBuf[0]=0;
79 BuildDispMenu(0);
80 }
81 break;
82 }
83 if(wParam==(WPARAM)szGPUKeys[1]) {ShowGpuPic();break;}
84 if(wParam==(WPARAM)szGPUKeys[2]) {SwitchDispMenu(-1); break;}
85 if(wParam==(WPARAM)szGPUKeys[3]) {SwitchDispMenu( 1); break;}
86 if(wParam==(WPARAM)szGPUKeys[4])
87 {
88 if(GetAsyncKeyState(VK_SHIFT)&32768)
89 {
90 if(iBlurBuffer) iBlurBuffer=0;
91 else iBlurBuffer=1;
92 }
93 BuildDispMenu(-1);
94 break;
95 }
96 if(wParam==(WPARAM)szGPUKeys[5]) {BuildDispMenu( 1); break;}
97
98 }
99 return pOldWinProc( hwnd, message, wParam, lParam );
100 }
101
102 ////////////////////////////////////////////////////////////////////////
103
104 void InitKeyHandler(void)
105 {
106 if(!pOldWinProc)
107 {
108 pOldWinProc = (WNDPROC)GetWindowLong(hWWindow, GWL_WNDPROC );
109 SetWindowLong(hWWindow, GWL_WNDPROC, (long)key_winproc);
110 }
111 }
112
113 ////////////////////////////////////////////////////////////////////////
114
115 void ExitKeyHandler(void)
116 {
117 if(pOldWinProc)
118 SetWindowLong(hWWindow,GWL_WNDPROC, // set old proc
119 (long)pOldWinProc);
120 pOldWinProc = 0;
121 }
122
123 ////////////////////////////////////////////////////////////////////////
124 // reset stuff on special keyboard commands
125 ////////////////////////////////////////////////////////////////////////
126
127 void ResetStuff(void)
128 {
129 ResetTextureArea(TRUE);
130 ulKeybits&=~KEY_RESETTEXSTORE;
131
132 if(ulKeybits&KEY_BLACKWHITE)
133 {
134 if(bUseFixes) {bUseFixes=FALSE;dwActFixes=0;}
135 else {bUseFixes=TRUE; dwActFixes=dwCfgFixes;}
136 SetExtGLFuncs();
137 if(iFrameLimit==2) SetAutoFrameCap();
138 ulKeybits&=~KEY_BLACKWHITE;
139 }
140
141 if(ulKeybits&KEY_RESETFILTER)
142 {
143 if(ulKeybits&KEY_STEPDOWN)
144 iFilterType--;
145 else iFilterType++;
146 if(iFilterType>6) iFilterType=0;
147 if(iFilterType<0) iFilterType=6;
148 SetExtGLFuncs();
149 ulKeybits&=~(KEY_RESETFILTER|KEY_STEPDOWN);
150 BuildDispMenu(0);
151 }
152
153 if(ulKeybits&KEY_RESETOPAQUE)
154 {
155 bOpaquePass=!bOpaquePass;
156 SetExtGLFuncs();
157 ulKeybits&=~KEY_RESETOPAQUE;
158 BuildDispMenu(0);
159 }
160
161 if(ulKeybits&KEY_RESETADVBLEND)
162 {
163 bAdvancedBlend=!bAdvancedBlend;
164 SetExtGLFuncs();
165 ulKeybits&=~KEY_RESETADVBLEND;
166 BuildDispMenu(0);
167 }
168
169 if(ulKeybits&KEY_RESETDITHER)
170 {
171 bDrawDither=!bDrawDither;
172 if(bDrawDither) glEnable(GL_DITHER);
173 else glDisable(GL_DITHER);
174 ulKeybits&=~KEY_RESETDITHER;
175 BuildDispMenu(0);
176 }
177
178 if(ulKeybits & KEY_TOGGLEFBTEXTURE)
179 {
180 if(ulKeybits&KEY_STEPDOWN)
181 iFrameTexType--;
182 else iFrameTexType++;
183 if(iFrameTexType>3) iFrameTexType=0;
184 if(iFrameTexType<0) iFrameTexType=3;
185 if(gTexFrameName!=0)
186 glDeleteTextures(1, &gTexFrameName);
187 gTexFrameName=0;
188 ulKeybits&=~(KEY_TOGGLEFBTEXTURE|KEY_STEPDOWN);
189 }
190
191 if(ulKeybits & KEY_TOGGLEFBREAD)
192 {
193 if(ulKeybits&KEY_STEPDOWN)
194 iFrameReadType--;
195 else iFrameReadType++;
196 if(iFrameReadType>4) iFrameReadType=0;
197 if(iFrameReadType<0) iFrameReadType=4;
198 if(iFrameReadType==4) bFullVRam=TRUE;
199 else bFullVRam=FALSE;
200 iRenderFVR=0;
201 ulKeybits&=~(KEY_TOGGLEFBREAD|KEY_STEPDOWN);
202 }
203 }