diff --git a/Code/Game/GameClient/DanBiasGame_Impl.cpp b/Code/Game/GameClient/DanBiasGame_Impl.cpp index 3a3149d7..f5ff4232 100644 --- a/Code/Game/GameClient/DanBiasGame_Impl.cpp +++ b/Code/Game/GameClient/DanBiasGame_Impl.cpp @@ -60,8 +60,8 @@ namespace DanBias ~DanBiasGamePrivateData() { - SafeDeleteInstance( this->sharedStateContent.mouseDevice ); - SafeDeleteInstance( this->sharedStateContent.keyboardDevice ); + //SafeDeleteInstance( this->sharedStateContent.mouseDevice ); + //SafeDeleteInstance( this->sharedStateContent.keyboardDevice ); } } data; } @@ -273,6 +273,9 @@ LRESULT CALLBACK WindowCallBack(HWND handle, UINT message, WPARAM wParam, LPARAM case WM_DESTROY: PostQuitMessage( 0 ); break; + case WM_INPUT: + message = 0; + break; default: break; } diff --git a/Code/Game/GameClient/GameClient.vcxproj.user b/Code/Game/GameClient/GameClient.vcxproj.user index 4b847ee6..2e28d6f7 100644 --- a/Code/Game/GameClient/GameClient.vcxproj.user +++ b/Code/Game/GameClient/GameClient.vcxproj.user @@ -1,7 +1,7 @@  - false + true $(OutDir) diff --git a/Code/Game/GameClient/GameClientState/GamingUI.cpp b/Code/Game/GameClient/GameClientState/GamingUI.cpp index 222f81c0..56b8f98f 100644 --- a/Code/Game/GameClient/GameClientState/GamingUI.cpp +++ b/Code/Game/GameClient/GameClientState/GamingUI.cpp @@ -161,7 +161,7 @@ void GamingUI::ReadKeyInput() //send delta mouse movement { static const float mouseSensitivity = Radian( 1.0f ); - ::Input::Struct::SAIPoint2D deltaPos; + ::Input::Struct::SAIPointFloat2D deltaPos; this->mouseInput->GetDeltaPosition( deltaPos ); this->camera->PitchDown( deltaPos.y * mouseSensitivity );; diff --git a/Code/Game/GameClient/GameClientState/LanMenuState.cpp b/Code/Game/GameClient/GameClientState/LanMenuState.cpp index 6f72014d..8cca6cf4 100644 --- a/Code/Game/GameClient/GameClientState/LanMenuState.cpp +++ b/Code/Game/GameClient/GameClientState/LanMenuState.cpp @@ -92,7 +92,7 @@ GameClientState::ClientState LanMenuState::Update( float deltaTime ) { MouseInput mouseState; { - ::Input::Struct::SAIPoint2D pos; + ::Input::Struct::SAIPointInt2D pos; this->privData->mouseInput->GetPixelPosition( pos ); mouseState.x = pos.x; diff --git a/Code/Game/GameClient/GameClientState/LobbyAdminState.cpp b/Code/Game/GameClient/GameClientState/LobbyAdminState.cpp index bac7e4cb..312f1c41 100644 --- a/Code/Game/GameClient/GameClientState/LobbyAdminState.cpp +++ b/Code/Game/GameClient/GameClientState/LobbyAdminState.cpp @@ -63,7 +63,7 @@ GameClientState::ClientState LobbyAdminState::Update( float deltaTime ) { MouseInput mouseState; { - ::Input::Struct::SAIPoint2D pos; + ::Input::Struct::SAIPointInt2D pos; this->privData->mouseInput->GetPixelPosition( pos ); mouseState.x = pos.x; diff --git a/Code/Game/GameClient/GameClientState/LobbyState.cpp b/Code/Game/GameClient/GameClientState/LobbyState.cpp index 3db9b341..c47febbe 100644 --- a/Code/Game/GameClient/GameClientState/LobbyState.cpp +++ b/Code/Game/GameClient/GameClientState/LobbyState.cpp @@ -63,7 +63,7 @@ GameClientState::ClientState LobbyState::Update( float deltaTime ) { MouseInput mouseState; { - ::Input::Struct::SAIPoint2D pos; + ::Input::Struct::SAIPointInt2D pos; this->privData->mouseInput->GetPixelPosition( pos ); mouseState.x = pos.x; diff --git a/Code/Game/GameClient/GameClientState/MainState.cpp b/Code/Game/GameClient/GameClientState/MainState.cpp index 91248ab4..a057ab74 100644 --- a/Code/Game/GameClient/GameClientState/MainState.cpp +++ b/Code/Game/GameClient/GameClientState/MainState.cpp @@ -81,8 +81,8 @@ GameClientState::ClientState MainState::Update( float deltaTime ) { MouseInput mouseState; { - ::Input::Struct::SAIPoint2D pos; - this->privData->mouseInput->GetPixelPosition( pos ); + ::Input::Struct::SAIPointFloat2D pos; + this->privData->mouseInput->GetNormalizedPosition( pos ); this->privData->mousePos.x = mouseState.x = pos.x; this->privData->mousePos.y = mouseState.y = pos.y; diff --git a/Code/Misc/Input/Include/Win32/Win32Mouse.h b/Code/Misc/Input/Include/Win32/Win32Mouse.h index e36d83b6..d0ecd2ca 100644 --- a/Code/Misc/Input/Include/Win32/Win32Mouse.h +++ b/Code/Misc/Input/Include/Win32/Win32Mouse.h @@ -40,6 +40,7 @@ namespace Input RAWINPUTDEVICE device; Struct::SAIPointInt2D windowSize; bool isActive; + Struct::SAIPointInt2D winCursPos; }; } diff --git a/Code/Misc/Input/Main.cpp b/Code/Misc/Input/Main.cpp index 77792f1a..eab968aa 100644 --- a/Code/Misc/Input/Main.cpp +++ b/Code/Misc/Input/Main.cpp @@ -12,18 +12,45 @@ #include #include "Include\Input.h" -#include "..\WindowManager\WindowShell.h" +#include "WindowShell.h" using namespace std; +using namespace Input; +using namespace Input::Enum; -int main(int agrc, char*args) +Input::Keyboard* keyboard = 0; +Input::Mouse* mouse = 0; + +void KeyPress(Input::Enum::SAKI key, Input::Keyboard* sender) { - WindowShell::CreateWin(WindowShell::WINDOW_INIT_DESC()); + if(key == SAKI_A) + { + if(mouse->IsActive()) mouse->Deactivate(); + else mouse->Activate(); + + } +} - Input::Keyboard* app = Input::InputManager::Instance()->CreateKeyboardDevice(); - app->Deactivate(); +void MouseVelocity(Input::Struct::SAIPointInt2D vel, Input::Mouse* sender) +{ + int i = vel.Length(); + if(abs(i) > 2) + i = 0; +} + +int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow) +{ std::wstring text; - app->BindTextTarget( &text ); + + WindowShell::CreateWin(WindowShell::WINDOW_INIT_DESC()); + WindowShell::CreateConsoleWindow(); + keyboard = Input::InputManager::Instance()->CreateKeyboardDevice(WindowShell::GetHWND()); + mouse = Input::InputManager::Instance()->CreateMouseDevice(WindowShell::GetHWND()); + + mouse->AddOnMouseMoveVelocityCallback(MouseVelocity); + keyboard->BindTextTarget( &text ); + keyboard->AddOnKeyPressCallback(KeyPress); + int oldLen = 0; while (WindowShell::Frame()) @@ -31,8 +58,11 @@ int main(int agrc, char*args) if(text.length() != oldLen) { wprintf(text.c_str()); + oldLen =text.length(); } } system("pause"); + + return cmdShow; } \ No newline at end of file diff --git a/Code/Misc/Input/Source/Win32/Win32Input.cpp b/Code/Misc/Input/Source/Win32/Win32Input.cpp index 72d519d2..30ebf7ab 100644 --- a/Code/Misc/Input/Source/Win32/Win32Input.cpp +++ b/Code/Misc/Input/Source/Win32/Win32Input.cpp @@ -17,6 +17,7 @@ using namespace Input::Struct; using namespace Input::Typedefs; Win32Input *Win32Input::instance = 0; +TRACKMOUSEEVENT tme; LRESULT Win32Input::RawInputParser(HWND h, LPARAM l) { @@ -93,6 +94,18 @@ LRESULT CALLBACK Win32Input::RawWindowCallback(HWND h, UINT m, WPARAM w, LPARAM break; case WM_CREATE: Win32Input::instance->WindowActivate(true); + //tme.cbSize=sizeof(tme); + //tme.dwFlags=TME_HOVER; + //tme.hwndTrack=h;//hanlde of window you want the mouse over message for. + //tme.dwHoverTime=HOVER_DEFAULT; + //if(TrackMouseEvent(&tme) == FALSE) + //{ } + break; + case WM_MOUSEHOVER: + //val = 0; + break; + case WM_MOUSELEAVE: + //val = 0; break; } @@ -100,14 +113,14 @@ LRESULT CALLBACK Win32Input::RawWindowCallback(HWND h, UINT m, WPARAM w, LPARAM } void Win32Input::WindowActivate(bool activate) { - if(activate) - { - ShowCursor(0); - } - else - { - ShowCursor(1); - } + //if(activate) + //{ + // ShowCursor(0); + //} + //else + //{ + // ShowCursor(1); + //} } diff --git a/Code/Misc/Input/Source/Win32/Win32Mouse.cpp b/Code/Misc/Input/Source/Win32/Win32Mouse.cpp index 801772b6..c7bc9bf2 100644 --- a/Code/Misc/Input/Source/Win32/Win32Mouse.cpp +++ b/Code/Misc/Input/Source/Win32/Win32Mouse.cpp @@ -145,6 +145,8 @@ void Win32Mouse::Deactivate () if(RegisterRawInputDevices(&d, 1, sizeof(RAWINPUTDEVICE))) { this->isActive = false; + SetCursorPos(this->winCursPos.x, this->winCursPos.y); + ShowCursor(TRUE); } } @@ -219,6 +221,12 @@ bool Win32Mouse::Create() if(RegisterRawInputDevices(&this->device, 1, sizeof(RAWINPUTDEVICE)) == TRUE) { this->isActive = true; + POINT p; + GetCursorPos(&p); + this->winCursPos.x = p.x; + this->winCursPos.y = p.y; + ShowCursor(FALSE); + return true; }