diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 923e53fc..8691436d 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -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 ) { diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp index c4d2b41d..0d92ee72 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp @@ -56,7 +56,7 @@ bool LanMenuState::Init(Network::NetworkClient* nwClient) // create guiElements ButtonRectangle *guiElements; - //0.5f, 0.2f, 0.3f, 0.1f, + guiElements = new ButtonRectangle( 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 ); diff --git a/Code/Game/DanBiasGame/GameClientState/MainState.cpp b/Code/Game/DanBiasGame/GameClientState/MainState.cpp index 3c82fc05..aefb4b26 100644 --- a/Code/Game/DanBiasGame/GameClientState/MainState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/MainState.cpp @@ -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(); } diff --git a/Code/Input/L_inputClass.cpp b/Code/Input/L_inputClass.cpp index 5fd15a54..03271333 100644 --- a/Code/Input/L_inputClass.cpp +++ b/Code/Input/L_inputClass.cpp @@ -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; +} \ No newline at end of file diff --git a/Code/Input/L_inputClass.h b/Code/Input/L_inputClass.h index 08358135..8ed8e528 100644 --- a/Code/Input/L_inputClass.h +++ b/Code/Input/L_inputClass.h @@ -14,8 +14,6 @@ #include - - 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 \ No newline at end of file