New input system integrations

This commit is contained in:
Dander7BD 2014-02-20 16:55:34 +01:00
parent 536f1a69da
commit 61ce9a9a3e
3 changed files with 66 additions and 91 deletions

View File

@ -292,117 +292,88 @@ void GameState::ChangeState( ClientState next )
void GameState::ReadKeyInput()
{
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_W) )
{
{ // move forward
this->privData->nwClient->Send( Protocol_PlayerMovementForward() );
this->privData->key_forward = true;
}
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_S) )
{
{ // move backward
this->privData->nwClient->Send( Protocol_PlayerMovementBackward() );
this->privData->key_backward = true;
}
if( this->privData->mouseInput->IsKeyPressed(DIK_A) )
{
//if( !this->privData->key_strafeLeft )
{
this->privData->nwClient->Send( Protocol_PlayerMovementLeft() );
this->privData->key_strafeLeft = true;
}
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_A) )
{ // strafe left
this->privData->nwClient->Send( Protocol_PlayerMovementLeft() );
this->privData->key_strafeLeft = true;
}
else
this->privData->key_strafeLeft = false;
if( this->privData->mouseInput->IsKeyPressed(DIK_D) )
{
//if( !this->privData->key_strafeRight )
{
this->privData->nwClient->Send( Protocol_PlayerMovementRight() );
this->privData->key_strafeRight = true;
}
}
else
this->privData->key_strafeRight = false;
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_D) )
{ // strafe right
this->privData->nwClient->Send( Protocol_PlayerMovementRight() );
this->privData->key_strafeRight = true;
}
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_Space) )
{ // jump
this->privData->nwClient->Send( Protocol_PlayerJump() );
this->privData->key_Jump = true;
}
//send delta mouse movement
{
static const float mouseSensitivity = Radian( 1.0f );
this->privData->camera.PitchDown( this->privData->mouseInput->GetPitch() * mouseSensitivity );
float yaw = this->privData->mouseInput->GetYaw();
//if( yaw != 0.0f ) //This made the camera reset to a specific rotation.
::Input::Struct::SAIPoint2D deltaPos;
this->privData->mouseInput->GetDeltaPosition( deltaPos );
this->privData->camera.PitchDown( deltaPos.y * mouseSensitivity );;
//if( deltaPos.x != 0.0f ) //This made the camera reset to a specific rotation. Why?
{
this->privData->nwClient->Send( Protocol_PlayerLeftTurn(yaw * mouseSensitivity) );
this->privData->nwClient->Send( Protocol_PlayerLeftTurn(deltaPos.x * mouseSensitivity) );
}
}
// shoot
if( this->privData->mouseInput->IsKeyPressed(DIK_Z) )
if( this->privData->mouseInput->IsBtnDown(::Input::Enum::SAMI_MouseLeftBtn) )
{
if( !this->privData->key_Shoot )
{
Protocol_PlayerShot playerShot;
playerShot.primaryPressed = true;
playerShot.secondaryPressed = false;
playerShot.utilityPressed = false;
this->privData->nwClient->Send( playerShot );
this->privData->key_Shoot = true;
}
}
else
this->privData->key_Shoot = false;
if( this->privData->mouseInput->IsKeyPressed(DIK_X) )
{
if( !this->privData->key_Shoot )
{
Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false;
playerShot.secondaryPressed = true;
playerShot.utilityPressed = false;
this->privData->nwClient->Send( playerShot );
this->privData->key_Shoot = true;
}
}
else
this->privData->key_Shoot = false;
if( this->privData->mouseInput->IsKeyPressed(DIK_C) )
{
if( !this->privData->key_Shoot )
{
Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false;
playerShot.secondaryPressed = false;
playerShot.utilityPressed = true;
this->privData->nwClient->Send( playerShot );
this->privData->key_Shoot = true;
}
}
else
this->privData->key_Shoot = false;
// jump
if( this->privData->mouseInput->IsKeyPressed(DIK_SPACE) )
{
if(!this->privData->key_Jump)
{
this->privData->nwClient->Send( Protocol_PlayerJump() );
this->privData->key_Jump = true;
}
Protocol_PlayerShot playerShot;
playerShot.primaryPressed = true;
playerShot.secondaryPressed = false;
playerShot.utilityPressed = false;
this->privData->nwClient->Send( playerShot );
this->privData->key_Shoot = true;
}
else
this->privData->key_Jump = false;
else if( this->privData->mouseInput->IsBtnDown(::Input::Enum::SAMI_MouseRightBtn) )
{
Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false;
playerShot.secondaryPressed = true;
playerShot.utilityPressed = false;
this->privData->nwClient->Send( playerShot );
this->privData->key_Shoot = true;
}
else if( this->privData->mouseInput->IsBtnDown(::Input::Enum::SAMI_MouseMiddleBtn) )
{
Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false;
playerShot.secondaryPressed = false;
playerShot.utilityPressed = true;
this->privData->nwClient->Send( playerShot );
this->privData->key_Shoot = true;
}
// DEGUG KEYS
#ifdef _DEBUG // DEGUG KEYS
// Reload shaders
if( this->privData->mouseInput->IsKeyPressed(DIK_R) )
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_R) )
{
if( !this->privData->key_Reload_Shaders )
{
#ifdef _DEBUG
Graphics::API::ReloadShaders();
#endif
this->privData->key_Reload_Shaders = true;
}
}
@ -410,7 +381,7 @@ void GameState::ReadKeyInput()
this->privData->key_Reload_Shaders = false;
// toggle wire frame render
if( this->privData->mouseInput->IsKeyPressed(DIK_T) )
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_T) )
{
if( !this->privData->key_Wireframe_Toggle )
{
@ -420,8 +391,8 @@ void GameState::ReadKeyInput()
}
else
this->privData->key_Wireframe_Toggle = false;
// !DEGUG KEYS
// TODO: implement sub-menu
#endif // !DEGUG KEYS
}
const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState::NetEvent &message )

View File

@ -6,20 +6,23 @@ using namespace ::DanBias::Client;
using namespace ::Oyster::Network;
using namespace ::GameLogic;
using namespace ::Utility::Value;
using namespace ::Input;
GamingUI::GamingUI() :
GameStateUI()
{
/* Should never be called! */
this->input = nullptr;
this->mouseInput = nullptr;
this->keyboardInput = nullptr;
this->netClient = nullptr;
this->camera = nullptr;
}
GamingUI::GamingUI( InputClass *input, NetworkClient *connection, Camera_FPSV2 *camera ) :
GamingUI::GamingUI( Mouse *mouseInput, Keyboard *keyboardInput, NetworkClient *connection, Camera_FPSV2 *camera ) :
GameStateUI()
{
this->input = input;
this->mouseInput = mouseInput;
this->keyboardInput = keyboardInput;
this->netClient = connection;
this->camera = camera;
}

View File

@ -2,7 +2,7 @@
#define DANBIAS_CLIENT_GAMING_UI_H
#include "GameStateUI.h"
#include "L_inputClass.h"
#include "Input.h"
#include "Camera_FPSV2.h"
namespace DanBias { namespace Client
@ -10,7 +10,7 @@ namespace DanBias { namespace Client
class GamingUI : public GameStateUI
{
public:
GamingUI( InputClass *input, ::Oyster::Network::NetworkClient *connection, Camera_FPSV2 *camera );
GamingUI( ::Input::Mouse *mouseInput, ::Input::Keyboard *keyboardInput, ::Oyster::Network::NetworkClient *connection, Camera_FPSV2 *camera );
virtual ~GamingUI();
UIState Update( float deltaTime );
@ -21,7 +21,8 @@ namespace DanBias { namespace Client
bool Release();
private:
InputClass *input;
::Input::Mouse *mouseInput;
::Input::Keyboard *keyboardInput;
::Oyster::Network::NetworkClient *netClient;
Camera_FPSV2 *camera;