#include <InputSystem.h>
Public Types | |
enum | InputAction { Forward, Backward, Up, Down, SlideLeft, SlideRight, TurnLeft, TurnRight, TurnUp, TurnDown } |
Public Member Functions | |
~InputSystem (void) | |
void | timer (unsigned int delay) |
void | keyDown (int key) |
void | keyUp (int key) |
void | mouseMotion (unsigned int delay, int x, int y) |
void | mousePress (int button, int x, int y) |
void | mouseRelease (int button, int x, int y) |
Static Public Member Functions | |
InputSystem * | getInstance (void) |
Private Member Functions | |
InputSystem (void) | |
Private Attributes | |
int | m_keyTurnLeft |
int | m_keyTurnRight |
int | m_keySlideLeft |
int | m_keySlideRight |
int | m_keyForward |
int | m_keyBackward |
int | m_keyUp |
int | m_keyDown |
int | m_keyRun |
int | m_keyJump |
int | m_keyCrouch |
int | m_keyFire |
bool | m_turnLeft |
bool | m_turnRight |
bool | m_slideLeft |
bool | m_slideRight |
bool | m_forward |
bool | m_backward |
bool | m_up |
bool | m_down |
bool | m_run |
bool | m_jump |
bool | m_crouch |
bool | m_fire |
|
Definition at line 18 of file InputSystem.h.
|
|
Definition at line 54 of file InputSystem.cpp.
00054 { 00055 } |
|
Definition at line 18 of file InputSystem.cpp. References m_backward, m_crouch, m_down, m_fire, m_forward, m_jump, m_keyBackward, m_keyCrouch, m_keyDown, m_keyFire, m_keyForward, m_keyJump, m_keyRun, m_keySlideLeft, m_keySlideRight, m_keyTurnLeft, m_keyTurnRight, m_keyUp, m_run, m_slideLeft, m_slideRight, m_turnLeft, m_turnRight, and m_up.
00018 { 00019 00020 // Create keyboard action mappings 00021 m_keyTurnLeft = SDLK_LEFT; 00022 m_keyTurnRight = SDLK_RIGHT; 00023 m_keySlideLeft = SDLK_a; 00024 m_keySlideRight = SDLK_d; 00025 m_keyForward = SDLK_w; 00026 m_keyBackward = SDLK_s; 00027 m_keyUp = SDLK_x; 00028 m_keyDown = SDLK_c; 00029 m_keyRun = SDLK_LSHIFT; 00030 m_keyJump = SDLK_SPACE; 00031 m_keyCrouch = SDLK_c; 00032 m_keyFire = SDLK_LCTRL; 00033 00034 m_turnLeft = false; 00035 m_turnRight = false; 00036 m_slideLeft = false; 00037 m_slideRight = false; 00038 m_forward = false; 00039 m_backward = false; 00040 m_up = false; 00041 m_down = false; 00042 m_run = false; 00043 m_jump = false; 00044 m_crouch = false; 00045 m_fire = false; 00046 } |
|
Definition at line 63 of file InputSystem.cpp.
00063 { 00064 static InputSystem instance; 00065 return &instance; 00066 } |
|
Definition at line 116 of file InputSystem.cpp. References m_backward, m_crouch, m_down, m_forward, m_jump, m_keyBackward, m_keyCrouch, m_keyDown, m_keyForward, m_keyJump, m_keyRun, m_keySlideLeft, m_keySlideRight, m_keyTurnLeft, m_keyTurnRight, m_keyUp, m_run, m_slideLeft, m_slideRight, m_turnLeft, m_turnRight, and m_up.
00116 { 00117 if(key == m_keyTurnLeft) { 00118 m_turnLeft = true; 00119 } 00120 if(key == m_keyTurnRight) { 00121 m_turnRight = true; 00122 } 00123 if(key == m_keySlideLeft) { 00124 m_slideLeft = true; 00125 } 00126 if(key == m_keySlideRight) { 00127 m_slideRight = true; 00128 } 00129 if(key == m_keyForward) { 00130 m_forward = true; 00131 } 00132 if(key == m_keyBackward) { 00133 m_backward = true; 00134 } 00135 if(key == m_keyUp) { 00136 m_up = true; 00137 } 00138 if(key == m_keyDown) { 00139 m_down = true; 00140 } 00141 if(key == m_keyRun) { 00142 m_run = true; 00143 } 00144 if(key == m_keyJump) { 00145 m_jump = true; 00146 } 00147 if(key == m_keyCrouch) { 00148 m_crouch = true; 00149 } 00150 00151 // Escape press 00152 if(key == 27) { 00153 CoreEngine::getInstance()->shutdown(); 00154 } 00155 } |
|
Definition at line 163 of file InputSystem.cpp. References m_backward, m_crouch, m_down, m_forward, m_jump, m_keyBackward, m_keyCrouch, m_keyDown, m_keyForward, m_keyJump, m_keyRun, m_keySlideLeft, m_keySlideRight, m_keyTurnLeft, m_keyTurnRight, m_keyUp, m_run, m_slideLeft, m_slideRight, m_turnLeft, m_turnRight, and m_up.
00163 { 00164 if(key == m_keyTurnLeft) { 00165 m_turnLeft = false; 00166 } 00167 if(key == m_keyTurnRight) { 00168 m_turnRight = false; 00169 } 00170 if(key == m_keySlideLeft) { 00171 m_slideLeft = false; 00172 } 00173 if(key == m_keySlideRight) { 00174 m_slideRight = false; 00175 } 00176 if(key == m_keyForward) { 00177 m_forward = false; 00178 } 00179 if(key == m_keyBackward) { 00180 m_backward = false; 00181 } 00182 if(key == m_keyUp) { 00183 m_up = false; 00184 } 00185 if(key == m_keyDown) { 00186 m_down = false; 00187 } 00188 if(key == m_keyRun) { 00189 m_run = false; 00190 } 00191 if(key == m_keyJump) { 00192 m_jump = false; 00193 } 00194 if(key == m_keyCrouch) { 00195 m_crouch = false; 00196 } 00197 } |
|
Definition at line 205 of file InputSystem.cpp. References TurnDown, TurnLeft, TurnRight, and TurnUp.
00205 { 00206 // 00207 // Variables 00208 // 00209 int halfX = CoreEngine::getInstance()->getResolutionWidth() / 2; 00210 int halfY = CoreEngine::getInstance()->getResolutionHeight() / 2; 00211 int dx = mathutils::absi(halfX - x); 00212 int dy = mathutils::absi(halfY - y); 00213 00214 // Calculate mouse movements 00215 if(x < halfX) { 00216 CoreEngine::getInstance()->action(TurnLeft, dx, delay); 00217 } else if(x > halfX) { 00218 CoreEngine::getInstance()->action(TurnRight, dx, delay); 00219 } 00220 00221 if(y < halfY) { 00222 CoreEngine::getInstance()->action(TurnUp, dy, delay); 00223 } else if(y > halfY) { 00224 CoreEngine::getInstance()->action(TurnDown, dy, delay); 00225 } 00226 } |
|
Definition at line 234 of file InputSystem.cpp. References m_fire.
00234 { 00235 //printf("Mouse press\n"); 00236 m_fire = true; 00237 } |
|
Definition at line 245 of file InputSystem.cpp. References m_fire.
00245 { 00246 //printf("Mouse release\n"); 00247 m_fire = false; 00248 } |
|
Definition at line 74 of file InputSystem.cpp. References Backward, Down, Forward, m_backward, m_crouch, m_down, m_fire, m_forward, m_jump, m_run, m_slideLeft, m_slideRight, m_turnLeft, m_turnRight, m_up, SlideLeft, SlideRight, TurnLeft, TurnRight, and Up.
00074 { 00075 // Keyboard input 00076 if(m_forward) { 00077 CoreEngine::getInstance()->action(Forward, 0, 0); 00078 } 00079 if(m_backward) { 00080 CoreEngine::getInstance()->action(Backward, 0, 0); 00081 } 00082 if(m_turnLeft) { 00083 CoreEngine::getInstance()->action(TurnLeft, 0, 0); 00084 } 00085 if(m_turnRight) { 00086 CoreEngine::getInstance()->action(TurnRight, 0, 0); 00087 } 00088 if(m_slideLeft) { 00089 CoreEngine::getInstance()->action(SlideLeft, 0, 0); 00090 } 00091 if(m_slideRight) { 00092 CoreEngine::getInstance()->action(SlideRight, 0, 0); 00093 } 00094 if(m_up) { 00095 CoreEngine::getInstance()->action(Up, 0, 0); 00096 } 00097 if(m_down) { 00098 CoreEngine::getInstance()->action(Down, 0, 0); 00099 } 00100 if(m_run) { 00101 } 00102 if(m_jump) { 00103 } 00104 if(m_crouch) { 00105 } 00106 if(m_fire) { 00107 } 00108 } |
|
Definition at line 79 of file InputSystem.h. Referenced by InputSystem(), keyDown(), keyUp(), and timer(). |
|
Definition at line 84 of file InputSystem.h. Referenced by InputSystem(), keyDown(), keyUp(), and timer(). |
|
Definition at line 81 of file InputSystem.h. Referenced by InputSystem(), keyDown(), keyUp(), and timer(). |
|
Definition at line 85 of file InputSystem.h. Referenced by InputSystem(), mousePress(), mouseRelease(), and timer(). |
|
Definition at line 78 of file InputSystem.h. Referenced by InputSystem(), keyDown(), keyUp(), and timer(). |
|
Definition at line 83 of file InputSystem.h. Referenced by InputSystem(), keyDown(), keyUp(), and timer(). |
|
Definition at line 65 of file InputSystem.h. Referenced by InputSystem(), keyDown(), and keyUp(). |
|
Definition at line 70 of file InputSystem.h. Referenced by InputSystem(), keyDown(), and keyUp(). |
|
Definition at line 67 of file InputSystem.h. Referenced by InputSystem(), keyDown(), and keyUp(). |
|
Definition at line 71 of file InputSystem.h. Referenced by InputSystem(). |
|
Definition at line 64 of file InputSystem.h. Referenced by InputSystem(), keyDown(), and keyUp(). |
|
Definition at line 69 of file InputSystem.h. Referenced by InputSystem(), keyDown(), and keyUp(). |
|
Definition at line 68 of file InputSystem.h. Referenced by InputSystem(), keyDown(), and keyUp(). |
|
Definition at line 62 of file InputSystem.h. Referenced by InputSystem(), keyDown(), and keyUp(). |
|
Definition at line 63 of file InputSystem.h. Referenced by InputSystem(), keyDown(), and keyUp(). |
|
Definition at line 60 of file InputSystem.h. Referenced by InputSystem(), keyDown(), and keyUp(). |
|
Definition at line 61 of file InputSystem.h. Referenced by InputSystem(), keyDown(), and keyUp(). |
|
Definition at line 66 of file InputSystem.h. Referenced by InputSystem(), keyDown(), and keyUp(). |
|
Definition at line 82 of file InputSystem.h. Referenced by InputSystem(), keyDown(), keyUp(), and timer(). |
|
Definition at line 76 of file InputSystem.h. Referenced by InputSystem(), keyDown(), keyUp(), and timer(). |
|
Definition at line 77 of file InputSystem.h. Referenced by InputSystem(), keyDown(), keyUp(), and timer(). |
|
Definition at line 74 of file InputSystem.h. Referenced by InputSystem(), keyDown(), keyUp(), and timer(). |
|
Definition at line 75 of file InputSystem.h. Referenced by InputSystem(), keyDown(), keyUp(), and timer(). |
|
Definition at line 80 of file InputSystem.h. Referenced by InputSystem(), keyDown(), keyUp(), and timer(). |