2 * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "inputManager.h"
22 /// ***** Private Variables *****
32 static const int keySize = 323;
33 static State keyState[keySize];
35 /// ***** Initializers/Cleaners *****
39 for(int i=0; i< keySize; i++)
47 /// ***** Public Methods *****
53 for(int i=0; i< keySize; i++)
55 if(keyState[i] == wasR)
57 else if(keyState[i] == wasP)
61 while(SDL_PollEvent(&event))
66 keyState[event.key.keysym.sym] = wasR;
69 keyState[event.key.keysym.sym] = wasP;
75 bool input::isPressed(Uint8 key)
77 return keyState[key] == isP || keyState[key] == wasP;
79 bool input::isReleased(Uint8 key)
81 return keyState[key] == isR || keyState[key] == wasR;
84 bool input::wasPressed(Uint8 key)
86 return keyState[key] == wasP;
88 bool input::wasReleased(Uint8 key)
90 return keyState[key] == wasR;