Platform_Win32_Input_MouseDevice.cpp
Go to the documentation of this file.00001 //*** Platform_Win32_Input_MouseDevice.cpp *** 00002 00003 #include "Platform_Win32_Input_MouseDevice.h" 00004 00005 #define WIN32_LEAN_AND_MEAN 00006 #define VC_EXTRALEAN 00007 #include <windows.h> 00008 00009 #include "Platform_Win32_Input.h" 00010 #include "Platform_OS.h" 00011 00012 //*** Constructor *** 00013 00014 Platform_Win32_Input_MouseDevice::Platform_Win32_Input_MouseDevice(struct HWND__* windowHandle): 00015 windowHandle_(windowHandle) 00016 { 00017 } 00018 00019 00020 //*** Destructor *** 00021 00022 Platform_Win32_Input_MouseDevice::~Platform_Win32_Input_MouseDevice() 00023 { 00024 } 00025 00026 00027 00028 //*** GetPosition *** 00029 00030 void Platform_Win32_Input_MouseDevice::GetPosition(float& x, float& y) const 00031 { 00032 // Retrieve new mouse position 00033 POINT point; 00034 point.x=0; 00035 point.y=0; 00036 BOOL ret=GetCursorPos(&point); 00037 if (!ret) 00038 { 00039 Platform::GetPlatform_OS()->OutputDebugText("Couldn't get mouse cursor\n"); 00040 } 00041 00042 ScreenToClient(windowHandle_, &point); 00043 x=(float)point.x; 00044 y=(float)point.y; 00045 } 00046 00047 00048 //*** IsLeftButtonDown *** 00049 00050 bool Platform_Win32_Input_MouseDevice::IsLeftButtonDown() const 00051 { 00052 if ((Platform::GetPlatform_OS() && Platform::GetPlatform_OS()->HasFocus()) && GetAsyncKeyState(0x01)!=0) 00053 { 00054 return true; 00055 } 00056 00057 return false; 00058 } 00059 00060 00061 //*** IsRightButtonDown *** 00062 00063 bool Platform_Win32_Input_MouseDevice::IsRightButtonDown() const 00064 { 00065 if ((Platform::GetPlatform_OS() && Platform::GetPlatform_OS()->HasFocus()) && GetAsyncKeyState(0x02)!=0) 00066 { 00067 return true; 00068 } 00069 00070 return false; 00071 } 00072
Reproduction/republishing of any material on this site without permission is strictly prohibited.
