#include "rSDL.h"
#include "tString.h"
#include "defs.h"
#include "tLinkedList.h"
#include "tLocale.h"
#include "tSafePTR.h"
Go to the source code of this file.
Classes | |
class | uAction |
class | uActionPlayer |
class | uActionCamera |
class | uActionGlobal |
class | uBind |
class | uInput |
possible input channels (keys, mouse movement/buttons, joystick) More... | |
class | uBindPlayer |
class | uActionGlobalFunc |
class | uPlayerPrototype |
Defines | |
#define | uMAX_PLAYERS 8 |
#define | uMAX_ACTIONS 300 |
timeout value for double binds; second keypress for the same action gets ignored from a different key when within the timeout | |
Typedefs | |
typedef bool | ACTION_FUNC (REAL x) |
Functions | |
void | su_InputConfig (int player) |
void | su_InputConfigCamera (int player) |
void | su_InputConfigGlobal () |
bool | su_HandleEvent (SDL_Event &e, bool delayed) |
void | su_HandleDelayedEvents () |
void | su_InputSync () |
void | su_ClearKeys () |
void | su_KeyInit () |
void | su_JoystickInit () |
Variables | |
bool | su_mouseGrab |
REAL | su_doubleBindTimeout |
true if the mouse cursor is to be confined into the window |
#define uMAX_ACTIONS 300 |
timeout value for double binds; second keypress for the same action gets ignored from a different key when within the timeout
Definition at line 47 of file uInput.h.
Referenced by uAction::uAction().
#define uMAX_PLAYERS 8 |
Definition at line 38 of file uInput.h.
Referenced by uPlayerPrototype::PlayerConfig(), and uPlayerPrototype::uPlayerPrototype().
typedef bool ACTION_FUNC(REAL x) |
void su_ClearKeys | ( | ) |
Definition at line 1367 of file uInput.cpp.
References uBind::Activate(), uInput::GetBind(), uInput::GetPressed(), uInput::SetPressed(), and su_inputs.
Referenced by do_chat(), and uMenu::OnEnter().
01369 { 01370 // clears stored keypresses 01371 for ( uInputs::const_iterator i = su_inputs.begin(); i != su_inputs.end(); ++i ) 01372 { 01373 uInput * input = *i; 01374 uBind * bind = input->GetBind(); 01375 if ( input->GetPressed() > 0 && bind ) 01376 { 01377 bind->Activate( -1, su_delayed ); 01378 input->SetPressed( 0 ); 01379 } 01380 }
void su_HandleDelayedEvents | ( | ) |
Definition at line 1274 of file uInput.cpp.
References uBind::HanldeDelayed(), and su_inputs.
Referenced by gGame::GameLoop(), and su_HandleEvent().
01276 { 01277 // nothing to do 01278 if ( !su_delayed ) 01279 { 01280 return; 01281 } 01282 01283 su_delayed = false; 01284 01285 for ( uInputs::const_iterator i = su_inputs.begin(); i != su_inputs.end(); ++i ) 01286 { 01287 uBind * bind = (*i)->GetBind(); 01288 if ( bind ) 01289 { 01290 bind->HanldeDelayed(); 01291 } 01292 }
bool su_HandleEvent | ( | SDL_Event & | e, | |
bool | delayed | |||
) |
Definition at line 1294 of file uInput.cpp.
References uBind::act, uBind::Activate(), uInput::GetBind(), uTransformEventInfo::input, uBind::IsDoubleBind(), uTransformEventInfo::needsRepeat, uInput::SetPressed(), su_HandleDelayedEvents(), su_TransformEvent(), uAction::type, uAction::uINPUT_ANALOG, and uTransformEventInfo::value.
Referenced by gMemuItemConsole::Event(), gGame::GameLoop(), and uMenu::HandleEvent().
01295 { 01296 #ifndef DEDICATED 01297 if ( su_delayed && !delayed ) 01298 { 01299 su_HandleDelayedEvents(); 01300 } 01301 01302 su_delayed = delayed; 01303 01304 // transform events 01305 bool ret = false; 01306 01307 std::vector< uTransformEventInfo > events; 01308 su_TransformEvent( e, events ); 01309 01310 for ( std::vector< uTransformEventInfo >::const_iterator i = events.begin(); i != events.end(); ++i ) 01311 { 01312 uTransformEventInfo info = *i; 01313 01314 if ( info.input ) 01315 { 01316 // store input state for later repeat 01317 if ( info.needsRepeat ) 01318 { 01319 info.input->SetPressed( info.value > 0 ? info.value : 0 ); 01320 } 01321 01322 // activate binding 01323 uBind * bind = info.input->GetBind(); 01324 if ( bind ) 01325 { 01326 if ( bind->IsDoubleBind( info.input ) ) 01327 { 01328 return true; 01329 } 01330 01331 if ( info.needsRepeat && bind->act && bind->act->type == uAction::uINPUT_ANALOG ) 01332 { 01333 info.value *= ts*key_sensitivity; 01334 } 01335 01336 ret |= bind->Activate( info.value, delayed ); 01337 } 01338 } 01339 } 01340 01341 return ret; 01342 #endif 01343 return false;
void su_InputConfig | ( | int | player | ) |
Definition at line 1244 of file uInput.cpp.
References uPlayerPrototype::Name(), uPlayerPrototype::PlayerConfig(), s_InputConfigGeneric(), and tOutput::SetTemplateParameter().
Referenced by sg_PlayerMenu().
01245 { 01246 01247 tOutput name; 01248 name.SetTemplateParameter(1, ePlayer+1); 01249 name.SetTemplateParameter(2, uPlayerPrototype::PlayerConfig(ePlayer)->Name()); 01250 name << "$input_for_player"; 01251 01252 s_InputConfigGeneric(ePlayer,s_playerActions,name);
void su_InputConfigCamera | ( | int | player | ) |
Definition at line 1254 of file uInput.cpp.
References uPlayerPrototype::Name(), uPlayerPrototype::PlayerConfig(), s_InputConfigGeneric(), and tOutput::SetTemplateParameter().
Referenced by sg_PlayerMenu().
01255 { 01256 01257 tOutput name; 01258 name.SetTemplateParameter(1, uPlayerPrototype::PlayerConfig(player)->Name()); 01259 name << "$camera_controls"; 01260 01261 s_InputConfigGeneric(player,s_cameraActions,name);
void su_InputConfigGlobal | ( | ) |
Definition at line 1263 of file uInput.cpp.
References s_InputConfigGeneric().
Referenced by MainMenu().
01264 { 01265 s_InputConfigGeneric(-1,s_globalActions,"$input_items_global");
void su_InputSync | ( | ) |
Definition at line 1345 of file uInput.cpp.
References uBind::act, uBind::Activate(), uInput::GetBind(), uInput::GetPressed(), REAL, su_inputs, tSysTimeFloat(), uAction::type, and uAction::uINPUT_ANALOG.
Referenced by gGame::GameLoop().
01346 { 01347 double time=tSysTimeFloat(); 01348 ts=REAL(time-lastTime); 01349 01350 //static REAL tsSmooth=0; 01351 //tsSmooth+=REAL(ts*.1); 01352 //tsSmooth/=REAL(1.1); 01353 lastTime=time; 01354 01355 // key repeat 01356 for ( uInputs::const_iterator i = su_inputs.begin(); i != su_inputs.end(); ++i ) 01357 { 01358 uInput * input = *i; 01359 uBind * bind = input->GetBind(); 01360 if ( input->GetPressed() > 0 && bind && 01361 bind->act && bind->act->type == uAction::uINPUT_ANALOG ) 01362 { 01363 bind->Activate( ts * key_sensitivity * input->GetPressed(), su_delayed ); 01364 } 01365 }
void su_JoystickInit | ( | ) |
Definition at line 662 of file uInput.cpp.
References su_GetJoystickInput().
Referenced by main().
00664 { 00665 su_GetJoystickInput(); 00666 SDL_JoystickEventState( SDL_ENABLE );
void su_KeyInit | ( | ) |
Definition at line 267 of file uInput.cpp.
References su_GetKeyInput(), and su_GetMouseInput().
Referenced by main().
00269 { 00270 su_GetKeyInput(); 00271 su_GetMouseInput();
true if the mouse cursor is to be confined into the window
Definition at line 717 of file uInput.cpp.
Referenced by uBind::IsDoubleBind().
bool su_mouseGrab |
Definition at line 41 of file uInput.cpp.