summaryrefslogtreecommitdiff
path: root/plugins/peopsxgl/key.c
blob: 76f86734f24e9636810554695eadd5f8f51c9e9e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/***************************************************************************
                          key.c  -  description
                             -------------------
    begin                : Sun Mar 08 2009
    copyright            : (C) 1999-2009 by Pete Bernert
    web                  : www.pbernert.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version. See also the license.txt file for *
 *   additional informations.                                              *
 *                                                                         *
 ***************************************************************************/

#include "stdafx.h"

#define _IN_KEY

#include "externals.h"
#include "menu.h"
#include "texture.h"
#include "draw.h"
#include "fps.h"

////////////////////////////////////////////////////////////////////////
// KeyBoard handler stuff
////////////////////////////////////////////////////////////////////////

uint32_t   ulKeybits = 0;

////////////////////////////////////////////////////////////////////////
// keyboard handler (UNIX)
////////////////////////////////////////////////////////////////////////
#ifdef _MACGL
#define VK_INSERT      114
#define VK_HOME        115
#define VK_PRIOR       116
#define VK_NEXT        121
#define VK_END         119
#define VK_DEL         117
#define VK_F5          96
#else
#define VK_INSERT      65379
#define VK_HOME        65360
#define VK_PRIOR       65365
#define VK_NEXT        65366
#define VK_END         65367
#define VK_DEL         65535
#define VK_F5          65474
#endif

void GPUkeypressed(int keycode)
{
/* arrives via the input plugin, so who knows what thread you're in */
    switch(keycode)
     {
      case VK_F5:
       bSnapShot=1;
      break;

      // maybe could somehow handle alt+enter
      /*case XK_k:
       //GPUclose();
       bFullScreen = ( bFullScreen != 0 ? 0 : 1 );
       GPUopen(disp, "2");
      break;*/
			 
#ifndef _MACGL
      case XK_section:
       bUseFrameSkip=!bUseFrameSkip;
       bUseFrameLimit=!bUseFrameLimit;
       iFrameLimit = ( iFrameLimit != 0 ? 0 : 2 );
      break;
#endif

      case VK_INSERT:
       ulKeybits|=KEY_RESETTEXSTORE;
       if(iBlurBuffer) iBlurBuffer=0;
       else            iBlurBuffer=1;
       break;

      case VK_DEL:
       if(ulKeybits&KEY_SHOWFPS)
        {
         ulKeybits&=~KEY_SHOWFPS;
         HideText();
         DestroyPic();
        }
       else
        {
         ulKeybits|=KEY_SHOWFPS;
         szDispBuf[0]=0;
         BuildDispMenu(0);

        }
       break;

      case VK_PRIOR: BuildDispMenu(-1);            break;
      case VK_NEXT:  BuildDispMenu( 1);            break;
      case VK_END:   SwitchDispMenu( 1);           break;
      case VK_HOME:  SwitchDispMenu(-1);           break;
#if defined (_MACGL)
      default: { void HandleKey(int keycode); HandleKey(keycode); };
#endif
     }

}

void InitKeyHandler(void)
{
}

void ExitKeyHandler(void)
{
}

////////////////////////////////////////////////////////////////////////
// reset stuff on special keyboard commands
////////////////////////////////////////////////////////////////////////

void ResetStuff(void)
{
 ResetTextureArea(TRUE);
 ulKeybits&=~KEY_RESETTEXSTORE;

 if(ulKeybits&KEY_BLACKWHITE)
  {
   if(bUseFixes) {bUseFixes=FALSE;dwActFixes=0;}
   else          {bUseFixes=TRUE; dwActFixes=dwCfgFixes;}
   SetExtGLFuncs();
   if(iFrameLimit==2) SetAutoFrameCap();
   ulKeybits&=~KEY_BLACKWHITE;
  }

 if(ulKeybits&KEY_RESETFILTER)
  {
   if(ulKeybits&KEY_STEPDOWN)
        iFilterType--;
   else iFilterType++;
   if(iFilterType>6) iFilterType=0;
   if(iFilterType<0) iFilterType=6;
   SetExtGLFuncs();
   ulKeybits&=~(KEY_RESETFILTER|KEY_STEPDOWN);
   BuildDispMenu(0);
  }

 if(ulKeybits&KEY_RESETOPAQUE)
  {
   bOpaquePass=!bOpaquePass;
   SetExtGLFuncs();
   ulKeybits&=~KEY_RESETOPAQUE;
   BuildDispMenu(0);
  }

 if(ulKeybits&KEY_RESETADVBLEND)
  {
   bAdvancedBlend=!bAdvancedBlend;
   SetExtGLFuncs();
   ulKeybits&=~KEY_RESETADVBLEND;
   BuildDispMenu(0);
  }

 if(ulKeybits&KEY_RESETDITHER)
  {
   bDrawDither=!bDrawDither;
   if(bDrawDither)  glEnable(GL_DITHER);
   else             glDisable(GL_DITHER);
   ulKeybits&=~KEY_RESETDITHER;
   BuildDispMenu(0);
  }

 if(ulKeybits & KEY_TOGGLEFBTEXTURE)
  {
   if(ulKeybits&KEY_STEPDOWN)
        iFrameTexType--;
   else iFrameTexType++;
   if(iFrameTexType>3) iFrameTexType=0;
   if(iFrameTexType<0) iFrameTexType=3;
   if(gTexFrameName!=0)
    glDeleteTextures(1, &gTexFrameName);
   gTexFrameName=0;
   ulKeybits&=~(KEY_TOGGLEFBTEXTURE|KEY_STEPDOWN);
  }

 if(ulKeybits & KEY_TOGGLEFBREAD)
  {
   if(ulKeybits&KEY_STEPDOWN)
        iFrameReadType--;
   else iFrameReadType++;
   if(iFrameReadType>4) iFrameReadType=0;
   if(iFrameReadType<0) iFrameReadType=4;
   if(iFrameReadType==4) bFullVRam=TRUE;
   else                  bFullVRam=FALSE;
   iRenderFVR=0;
   ulKeybits&=~(KEY_TOGGLEFBREAD|KEY_STEPDOWN);
  }
}