Files
pcsx2/plugins/LilyPad/WindowsMouse.cpp
T
mattmenke 3a0ad40159 LilyPad: Experimental deadzone code. Old pressure sensitive button bindings must be rebound (DS3 buttons, XInput triggers).
Currently anything below deadzone is mapped to 0.  deadzone and above are mapped as if the control's true zero is 0 and 1/sensitivity is fully down (As opposed to deadzone being zero).  May change in the future.
Modified precompiled header to fix no-CRT build.
List of bindings noew automatically jumps to new bindings.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1914 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-09-25 08:36:42 +00:00

77 lines
1.8 KiB
C++

#include "Global.h"
#include "InputManager.h"
#include "VKey.h"
#include "WindowsMouse.h"
POINT WindowsMouse::origCursorPos;
POINT WindowsMouse::center;
WindowsMouse::WindowsMouse(DeviceAPI api, int hWheel, wchar_t *displayName, wchar_t *instanceID, wchar_t *deviceID) :
Device(api, MOUSE, displayName, instanceID, deviceID) {
int i;
for (i=0; i<5; i++) {
AddPhysicalControl(PSHBTN, i, i);
}
for (i=0; i<3+hWheel; i++) {
AddPhysicalControl(RELAXIS, i+5, i+5);
}
}
wchar_t *WindowsMouse::GetPhysicalControlName(PhysicalControl *control) {
wchar_t *names[9] = {
L"L Button",
L"R Button",
L"M Button",
L"Mouse 4",
L"Mouse 5",
L"X Axis",
L"Y Axis",
L"Y Wheel",
L"X Wheel"
};
if (control->id < 9) return names[control->id];
return Device::GetPhysicalControlName(control);
}
void WindowsMouse::UpdateButton(unsigned int button, int state) {
if (button > 4) return;
physicalControlState[button] = (state << 16);
}
void WindowsMouse::UpdateAxis(unsigned int axis, int delta) {
if (axis > 3) return;
// 1 mouse pixel = 1/8th way down.
physicalControlState[5+axis] += (delta<<(16 - 3*(axis < 2)));
}
void WindowsMouse::WindowResized(HWND hWnd) {
RECT r;
GetWindowRect(hWnd, &r);
ClipCursor(&r);
center.x = (r.left + r.right)/2;
center.y = (r.top + r.bottom)/2;
SetCursorPos(center.x, center.y);
}
void WindowsMouse::GetMouseCapture(HWND hWnd) {
SetCapture(hWnd);
ShowCursor(0);
GetCursorPos(&origCursorPos);
RECT r;
GetWindowRect(hWnd, &r);
ClipCursor(&r);
center.x = (r.left + r.right)/2;
center.y = (r.top + r.bottom)/2;
SetCursorPos(center.x, center.y);
}
void WindowsMouse::ReleaseMouseCapture() {
ClipCursor(0);
ReleaseCapture();
ShowCursor(1);
SetCursorPos(origCursorPos.x, origCursorPos.y);
}