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 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
/**
* Interface for input devices. The defines for keyboard/system/mouse events
* here are for internal use in the KX module.
*
* $Id: SCA_IInputDevice.h,v 1.8 2004/10/16 11:41:48 kester Exp $
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef KX_INPUTDEVICE_H
#define KX_INPUTDEVICE_H
class SCA_InputEvent
{
public:
enum SCA_EnumInputs {
KX_NO_INPUTSTATUS = 0,
KX_JUSTACTIVATED,
KX_ACTIVE,
KX_JUSTRELEASED,
KX_MAX_INPUTSTATUS
};
SCA_InputEvent(SCA_EnumInputs status=KX_NO_INPUTSTATUS,int eventval=0)
: m_status(status),
m_eventval(eventval)
{
}
SCA_EnumInputs m_status;
int m_eventval;
};
class SCA_IInputDevice
{
public:
SCA_IInputDevice();
virtual ~SCA_IInputDevice();
enum KX_EnumInputs {
KX_NOKEY = 0,
// TIMERS
KX_TIMER0,
KX_TIMER1,
KX_TIMER2,
KX_TIMER3,
// SYSTEM
/* Moved to avoid clashes with KX_RETKEY */
KX_KEYBD,
KX_RAWKEYBD,
KX_REDRAW,
KX_INPUTCHANGE,
KX_QFULL,
KX_WINFREEZE,
KX_WINTHAW,
/* thaw is 11 */
/* move past retkey*/
KX_WINCLOSE = 14,
KX_WINQUIT,
KX_Q_FIRSTTIME,
/* sequence ends on 16 */
// standard keyboard
/* Because of the above preamble, KX_BEGINKEY is 15 ! This
* means that KX_RETKEY on 13d (0Dh)) will double up with
* KX_WINQUIT! Why is it 13? Because ascii 13d is Ctrl-M aka
* CR! Its little brother, LF has 10d (0Ah). This is
* dangerous, since the keyboards start scanning at
* KX_BEGINKEY. I think the keyboard system should push its
* key events instead of demanding the user to poll the
* table... But that's for another time... The fix for now is
* to move the above system events into a 'safe' (ie. unused)
* range. I am loathe to move it away from this 'magical'
* coincidence.. it's probably exploited somewhere. I hope the
* close and quit events don't mess up 'normal' kb code
* scanning.
* */
KX_BEGINKEY = 12,
KX_RETKEY = 13,
KX_SPACEKEY = 32,
KX_PADASTERKEY = 42,
KX_COMMAKEY = 44,
KX_MINUSKEY = 45,
KX_PERIODKEY = 46,
KX_ZEROKEY = 48,
KX_ONEKEY, // =49
KX_TWOKEY,
KX_THREEKEY,
KX_FOURKEY,
KX_FIVEKEY,
KX_SIXKEY,
KX_SEVENKEY,
KX_EIGHTKEY,
KX_NINEKEY, // = 57
KX_AKEY = 97,
KX_BKEY,
KX_CKEY,
KX_DKEY,
KX_EKEY,
KX_FKEY,
KX_GKEY,
KX_HKEY,
KX_IKEY,
KX_JKEY,
KX_KKEY,
KX_LKEY,
KX_MKEY,
KX_NKEY, // =110
KX_OKEY,
KX_PKEY,
KX_QKEY,
KX_RKEY,
KX_SKEY,
KX_TKEY,
KX_UKEY,
KX_VKEY,
KX_WKEY,
KX_XKEY, // =120
KX_YKEY,
KX_ZKEY, // =122
KX_CAPSLOCKKEY, // 123
KX_LEFTCTRLKEY, // 124
KX_LEFTALTKEY,
KX_RIGHTALTKEY,
KX_RIGHTCTRLKEY,
KX_RIGHTSHIFTKEY,
KX_LEFTSHIFTKEY,// 129
KX_ESCKEY, // 130
KX_TABKEY, //131
KX_LINEFEEDKEY, // 132
KX_BACKSPACEKEY,
KX_DELKEY,
KX_SEMICOLONKEY, // 135
KX_QUOTEKEY, //136
KX_ACCENTGRAVEKEY, //137
KX_SLASHKEY, //138
KX_BACKSLASHKEY,
KX_EQUALKEY,
KX_LEFTBRACKETKEY,
KX_RIGHTBRACKETKEY, // 142
KX_LEFTARROWKEY, // 145
KX_DOWNARROWKEY,
KX_RIGHTARROWKEY,
KX_UPARROWKEY, // 148
KX_PAD2 ,
KX_PAD4 ,
KX_PAD6 ,
KX_PAD8 ,
KX_PAD1 ,
KX_PAD3 ,
KX_PAD5 ,
KX_PAD7 ,
KX_PAD9 ,
KX_PADPERIOD,
KX_PADSLASHKEY,
KX_PAD0 ,
KX_PADMINUS,
KX_PADENTER,
KX_PADPLUSKEY,
KX_F1KEY ,
KX_F2KEY ,
KX_F3KEY ,
KX_F4KEY ,
KX_F5KEY ,
KX_F6KEY ,
KX_F7KEY ,
KX_F8KEY ,
KX_F9KEY ,
KX_F10KEY,
KX_F11KEY,
KX_F12KEY,
KX_PAUSEKEY,
KX_INSERTKEY,
KX_HOMEKEY ,
KX_PAGEUPKEY,
KX_PAGEDOWNKEY,
KX_ENDKEY,
// MOUSE
KX_BEGINMOUSE,
KX_BEGINMOUSEBUTTONS,
KX_LEFTMOUSE,
KX_MIDDLEMOUSE,
KX_RIGHTMOUSE,
KX_ENDMOUSEBUTTONS,
KX_WHEELUPMOUSE,
KX_WHEELDOWNMOUSE,
KX_MOUSEX,
KX_MOUSEY,
KX_ENDMOUSE,
KX_MAX_KEYS
} ; // enum
protected:
/**
m_eventStatusTables are two tables that contain current and previous
status of all events
*/
SCA_InputEvent m_eventStatusTables[2][SCA_IInputDevice::KX_MAX_KEYS];
/**
m_currentTable is index for m_keyStatusTable that toggle between 0 or 1
*/
int m_currentTable;
void ClearStatusTable(int tableid);
public:
virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode);
/**
* Count active events(active and just_activated)
*/
virtual int GetNumActiveEvents();
/**
* Get the number of ramping events (just_activated, just_released)
*/
virtual int GetNumJustEvents();
virtual void HookEscape();
/* Next frame: we calculate the new key states. This goes as follows:
*
* KX_NO_INPUTSTATUS -> KX_NO_INPUTSTATUS
* KX_JUSTACTIVATED -> KX_ACTIVE
* KX_ACTIVE -> KX_ACTIVE
* KX_JUSTRELEASED -> KX_NO_INPUTSTATUS
*
* Getting new events provides the
* KX_NO_INPUTSTATUS->KX_JUSTACTIVATED and
* KX_ACTIVE->KX_JUSTRELEASED transitions.
*/
virtual void NextFrame();
};
#endif //KX_INPUTDEVICE_H
|