Temporary mouse pos add + other stuff

This commit is contained in:
Dander7BD 2014-02-14 11:26:50 +01:00
parent 78f47cd3ae
commit 6f9483041b
5 changed files with 43 additions and 7 deletions

View File

@ -56,7 +56,6 @@ namespace DanBias
//--------------------------------------------------------------------------------------
DanBiasClientReturn DanBiasGame::Initiate(DanBiasGameDesc& desc)
{
WindowShell::CreateConsoleWindow();
//if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT())))
if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC()))
@ -151,7 +150,21 @@ namespace DanBias
DanBiasGame::Result DanBiasGame::Update(float deltaTime)
{
data.inputObj->Update();
{ // updating mouse input
POINT mousePos;
GetCursorPos( &mousePos );
RECT windowVertex;
GetWindowRect( data.window->GetHWND(), &windowVertex );
float mouseNormalisedX = (float)(mousePos.x - windowVertex.left);
mouseNormalisedX /= (float)(windowVertex.right - windowVertex.left);
float mouseNormalisedY = (float)(mousePos.y - windowVertex.top);
mouseNormalisedY /= (float)(windowVertex.bottom - windowVertex.top);
data.inputObj->Update( mouseNormalisedX, mouseNormalisedY );
}
if( data.serverOwner )
{

View File

@ -56,7 +56,7 @@ bool LanMenuState::Init(Network::NetworkClient* nwClient)
// create guiElements
ButtonRectangle<LanMenuState*> *guiElements;
//0.5f, 0.2f, 0.3f, 0.1f,
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Connect", Float3(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
this->privData->guiElements.AddButton( guiElements );

View File

@ -73,8 +73,7 @@ GameClientState::ClientState MainState::Update(float deltaTime, InputClass* KeyI
{
MouseInput mouseState;
{
mouseState.x = KeyInput->GetPitch();
mouseState.y = KeyInput->GetYaw();
KeyInput->GetMousePos( mouseState.x, mouseState.y );
mouseState.mouseButtonPressed = KeyInput->IsMousePressed();
}

View File

@ -5,6 +5,8 @@ InputClass::InputClass()
m_directInput = NULL;
m_keyboard = NULL;
m_mouse = NULL;
mousePosX = 0.0f;
mousePosY = 0.0f;
}
InputClass::~InputClass()
@ -128,6 +130,13 @@ bool InputClass::Update()
return true;
}
bool InputClass::Update( float mousePosX, float mousePosY )
{
this->mousePosX = mousePosX;
this->mousePosY = mousePosY;
return this->Update();
}
bool InputClass::ReadKeyboard()
{
HRESULT result;
@ -198,3 +207,15 @@ bool InputClass::IsKeyPressed(int key)
return false;
}
void InputClass::SetMousePos( float x, float y )
{
this->mousePosX = y;
this->mousePosY = x;
}
void InputClass::GetMousePos( float &x, float &y )
{
x = this->mousePosX;
y = this->mousePosY;
}

View File

@ -14,8 +14,6 @@
#include <dinput.h>
class InputClass
{
private:
@ -26,6 +24,8 @@ private:
unsigned char m_keyboardState[256];
DIMOUSESTATE m_mouseState;
float mousePosX, mousePosY;
bool ReadKeyboard();
bool ReadMouse();
@ -40,6 +40,7 @@ public:
//read the mouse and keyboard and send back
// delta mouse pos and if any button is pressed
bool Update();
bool Update( float mousePosX, float mousePosY );
bool IsKeyPressed(int key);
bool IsMousePressed();
@ -48,6 +49,8 @@ public:
float GetYaw();
float GetPitch();
void SetMousePos( float x, float y );
void GetMousePos( float &x, float &y );
};
#endif