New input system integrations
This commit is contained in:
parent
536f1a69da
commit
61ce9a9a3e
|
@ -292,54 +292,50 @@ void GameState::ChangeState( ClientState next )
|
||||||
void GameState::ReadKeyInput()
|
void GameState::ReadKeyInput()
|
||||||
{
|
{
|
||||||
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_W) )
|
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_W) )
|
||||||
{
|
{ // move forward
|
||||||
this->privData->nwClient->Send( Protocol_PlayerMovementForward() );
|
this->privData->nwClient->Send( Protocol_PlayerMovementForward() );
|
||||||
this->privData->key_forward = true;
|
this->privData->key_forward = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_S) )
|
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_S) )
|
||||||
{
|
{ // move backward
|
||||||
this->privData->nwClient->Send( Protocol_PlayerMovementBackward() );
|
this->privData->nwClient->Send( Protocol_PlayerMovementBackward() );
|
||||||
this->privData->key_backward = true;
|
this->privData->key_backward = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( this->privData->mouseInput->IsKeyPressed(DIK_A) )
|
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_A) )
|
||||||
{
|
{ // strafe left
|
||||||
//if( !this->privData->key_strafeLeft )
|
|
||||||
{
|
|
||||||
this->privData->nwClient->Send( Protocol_PlayerMovementLeft() );
|
this->privData->nwClient->Send( Protocol_PlayerMovementLeft() );
|
||||||
this->privData->key_strafeLeft = true;
|
this->privData->key_strafeLeft = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
this->privData->key_strafeLeft = false;
|
|
||||||
|
|
||||||
if( this->privData->mouseInput->IsKeyPressed(DIK_D) )
|
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_D) )
|
||||||
{
|
{ // strafe right
|
||||||
//if( !this->privData->key_strafeRight )
|
|
||||||
{
|
|
||||||
this->privData->nwClient->Send( Protocol_PlayerMovementRight() );
|
this->privData->nwClient->Send( Protocol_PlayerMovementRight() );
|
||||||
this->privData->key_strafeRight = true;
|
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;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
this->privData->key_strafeRight = false;
|
|
||||||
|
|
||||||
//send delta mouse movement
|
//send delta mouse movement
|
||||||
{
|
{
|
||||||
static const float mouseSensitivity = Radian( 1.0f );
|
static const float mouseSensitivity = Radian( 1.0f );
|
||||||
this->privData->camera.PitchDown( this->privData->mouseInput->GetPitch() * mouseSensitivity );
|
::Input::Struct::SAIPoint2D deltaPos;
|
||||||
float yaw = this->privData->mouseInput->GetYaw();
|
this->privData->mouseInput->GetDeltaPosition( deltaPos );
|
||||||
//if( yaw != 0.0f ) //This made the camera reset to a specific rotation.
|
|
||||||
|
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
|
// 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;
|
Protocol_PlayerShot playerShot;
|
||||||
playerShot.primaryPressed = true;
|
playerShot.primaryPressed = true;
|
||||||
|
@ -348,12 +344,7 @@ void GameState::ReadKeyInput()
|
||||||
this->privData->nwClient->Send( playerShot );
|
this->privData->nwClient->Send( playerShot );
|
||||||
this->privData->key_Shoot = true;
|
this->privData->key_Shoot = true;
|
||||||
}
|
}
|
||||||
}
|
else if( this->privData->mouseInput->IsBtnDown(::Input::Enum::SAMI_MouseRightBtn) )
|
||||||
else
|
|
||||||
this->privData->key_Shoot = false;
|
|
||||||
if( this->privData->mouseInput->IsKeyPressed(DIK_X) )
|
|
||||||
{
|
|
||||||
if( !this->privData->key_Shoot )
|
|
||||||
{
|
{
|
||||||
Protocol_PlayerShot playerShot;
|
Protocol_PlayerShot playerShot;
|
||||||
playerShot.primaryPressed = false;
|
playerShot.primaryPressed = false;
|
||||||
|
@ -362,12 +353,7 @@ void GameState::ReadKeyInput()
|
||||||
this->privData->nwClient->Send( playerShot );
|
this->privData->nwClient->Send( playerShot );
|
||||||
this->privData->key_Shoot = true;
|
this->privData->key_Shoot = true;
|
||||||
}
|
}
|
||||||
}
|
else if( this->privData->mouseInput->IsBtnDown(::Input::Enum::SAMI_MouseMiddleBtn) )
|
||||||
else
|
|
||||||
this->privData->key_Shoot = false;
|
|
||||||
if( this->privData->mouseInput->IsKeyPressed(DIK_C) )
|
|
||||||
{
|
|
||||||
if( !this->privData->key_Shoot )
|
|
||||||
{
|
{
|
||||||
Protocol_PlayerShot playerShot;
|
Protocol_PlayerShot playerShot;
|
||||||
playerShot.primaryPressed = false;
|
playerShot.primaryPressed = false;
|
||||||
|
@ -376,33 +362,18 @@ void GameState::ReadKeyInput()
|
||||||
this->privData->nwClient->Send( playerShot );
|
this->privData->nwClient->Send( playerShot );
|
||||||
this->privData->key_Shoot = true;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this->privData->key_Jump = false;
|
|
||||||
|
|
||||||
|
|
||||||
// DEGUG KEYS
|
#ifdef _DEBUG // DEGUG KEYS
|
||||||
|
|
||||||
// Reload shaders
|
// 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 )
|
if( !this->privData->key_Reload_Shaders )
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
|
||||||
Graphics::API::ReloadShaders();
|
Graphics::API::ReloadShaders();
|
||||||
#endif
|
|
||||||
this->privData->key_Reload_Shaders = true;
|
this->privData->key_Reload_Shaders = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,7 +381,7 @@ void GameState::ReadKeyInput()
|
||||||
this->privData->key_Reload_Shaders = false;
|
this->privData->key_Reload_Shaders = false;
|
||||||
|
|
||||||
// toggle wire frame render
|
// 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 )
|
if( !this->privData->key_Wireframe_Toggle )
|
||||||
{
|
{
|
||||||
|
@ -420,8 +391,8 @@ void GameState::ReadKeyInput()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this->privData->key_Wireframe_Toggle = false;
|
this->privData->key_Wireframe_Toggle = false;
|
||||||
// !DEGUG KEYS
|
|
||||||
// TODO: implement sub-menu
|
#endif // !DEGUG KEYS
|
||||||
}
|
}
|
||||||
|
|
||||||
const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState::NetEvent &message )
|
const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState::NetEvent &message )
|
||||||
|
|
|
@ -6,20 +6,23 @@ using namespace ::DanBias::Client;
|
||||||
using namespace ::Oyster::Network;
|
using namespace ::Oyster::Network;
|
||||||
using namespace ::GameLogic;
|
using namespace ::GameLogic;
|
||||||
using namespace ::Utility::Value;
|
using namespace ::Utility::Value;
|
||||||
|
using namespace ::Input;
|
||||||
|
|
||||||
GamingUI::GamingUI() :
|
GamingUI::GamingUI() :
|
||||||
GameStateUI()
|
GameStateUI()
|
||||||
{
|
{
|
||||||
/* Should never be called! */
|
/* Should never be called! */
|
||||||
this->input = nullptr;
|
this->mouseInput = nullptr;
|
||||||
|
this->keyboardInput = nullptr;
|
||||||
this->netClient = nullptr;
|
this->netClient = nullptr;
|
||||||
this->camera = 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()
|
GameStateUI()
|
||||||
{
|
{
|
||||||
this->input = input;
|
this->mouseInput = mouseInput;
|
||||||
|
this->keyboardInput = keyboardInput;
|
||||||
this->netClient = connection;
|
this->netClient = connection;
|
||||||
this->camera = camera;
|
this->camera = camera;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define DANBIAS_CLIENT_GAMING_UI_H
|
#define DANBIAS_CLIENT_GAMING_UI_H
|
||||||
|
|
||||||
#include "GameStateUI.h"
|
#include "GameStateUI.h"
|
||||||
#include "L_inputClass.h"
|
#include "Input.h"
|
||||||
#include "Camera_FPSV2.h"
|
#include "Camera_FPSV2.h"
|
||||||
|
|
||||||
namespace DanBias { namespace Client
|
namespace DanBias { namespace Client
|
||||||
|
@ -10,7 +10,7 @@ namespace DanBias { namespace Client
|
||||||
class GamingUI : public GameStateUI
|
class GamingUI : public GameStateUI
|
||||||
{
|
{
|
||||||
public:
|
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();
|
virtual ~GamingUI();
|
||||||
|
|
||||||
UIState Update( float deltaTime );
|
UIState Update( float deltaTime );
|
||||||
|
@ -21,7 +21,8 @@ namespace DanBias { namespace Client
|
||||||
bool Release();
|
bool Release();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InputClass *input;
|
::Input::Mouse *mouseInput;
|
||||||
|
::Input::Keyboard *keyboardInput;
|
||||||
::Oyster::Network::NetworkClient *netClient;
|
::Oyster::Network::NetworkClient *netClient;
|
||||||
Camera_FPSV2 *camera;
|
Camera_FPSV2 *camera;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue