Temporary mouse pos add + other stuff
This commit is contained in:
parent
78f47cd3ae
commit
6f9483041b
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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
|
Loading…
Reference in New Issue