mirror of https://github.com/PCSX2/pcsx2.git
LilyPad: Fixed a bug in list of bindings when go to config screen after running Pcsx2 for a bit, and some devices enabled on the config screen were not enabled in game (Either due to focus issues, or, more probably, due to mouse API not being disabled, but not running with mouse focus).
Also bug fix for cursor clipping rectangle not being reset after window resize. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@870 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
8b3c30d2ce
commit
f5f3ff97a5
|
@ -1502,6 +1502,18 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM l
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns 0 if pad doesn't exist due to mtap settings, as a convenience.
|
||||||
|
int GetPadString(wchar_t *string, unsigned int port, unsigned int slot) {
|
||||||
|
if (!slot) {
|
||||||
|
wsprintfW(string, L"Pad %i", port+1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wsprintfW(string, L"Pad %i-%i", port+1, slot+1);
|
||||||
|
if (!config.multitap[port]) return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void UpdatePadPages() {
|
void UpdatePadPages() {
|
||||||
HPROPSHEETPAGE pages[10];
|
HPROPSHEETPAGE pages[10];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -1511,13 +1523,7 @@ void UpdatePadPages() {
|
||||||
for (int slot=0; slot<4; slot++) {
|
for (int slot=0; slot<4; slot++) {
|
||||||
if (config.padConfigs[port][slot].type == DisabledPad) continue;
|
if (config.padConfigs[port][slot].type == DisabledPad) continue;
|
||||||
wchar_t title[20];
|
wchar_t title[20];
|
||||||
if (!slot) {
|
if (!GetPadString(title, port, slot)) continue;
|
||||||
wsprintfW(title, L"Pad %i", port+1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!config.multitap[port]) continue;
|
|
||||||
wsprintfW(title, L"Pad %i-%i", port+1, slot+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
PROPSHEETPAGE psp;
|
PROPSHEETPAGE psp;
|
||||||
ZeroMemory(&psp, sizeof(psp));
|
ZeroMemory(&psp, sizeof(psp));
|
||||||
|
@ -1570,16 +1576,11 @@ void UpdatePadList(HWND hWnd) {
|
||||||
int slot;
|
int slot;
|
||||||
int port;
|
int port;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
wchar_t *strings[] = {L"Disabled", L"Dualshock 2", L"Guitar"};
|
wchar_t *padTypes[] = {L"Disabled", L"Dualshock 2", L"Guitar"};
|
||||||
for (port=0; port<2; port++) {
|
for (port=0; port<2; port++) {
|
||||||
for (slot = 0; slot<4; slot++) {
|
for (slot = 0; slot<4; slot++) {
|
||||||
wchar_t text[100];
|
wchar_t text[20];
|
||||||
if (!slot)
|
if (!GetPadString(text, port, slot)) continue;
|
||||||
wsprintf(text, L"Pad %i", port+1);
|
|
||||||
else {
|
|
||||||
if (!config.multitap[port]) continue;
|
|
||||||
wsprintf(text, L"Pad %i-%i", port+1, slot+1);
|
|
||||||
}
|
|
||||||
LVITEM item;
|
LVITEM item;
|
||||||
item.iItem = index;
|
item.iItem = index;
|
||||||
item.iSubItem = 0;
|
item.iSubItem = 0;
|
||||||
|
@ -1594,7 +1595,7 @@ void UpdatePadList(HWND hWnd) {
|
||||||
|
|
||||||
item.iSubItem = 1;
|
item.iSubItem = 1;
|
||||||
if (2 < (unsigned int)config.padConfigs[port][slot].type) config.padConfigs[port][slot].type = Dualshock2Pad;
|
if (2 < (unsigned int)config.padConfigs[port][slot].type) config.padConfigs[port][slot].type = Dualshock2Pad;
|
||||||
item.pszText = strings[config.padConfigs[port][slot].type];
|
item.pszText = padTypes[config.padConfigs[port][slot].type];
|
||||||
ListView_SetItem(hWndList, &item);
|
ListView_SetItem(hWndList, &item);
|
||||||
|
|
||||||
item.iSubItem = 2;
|
item.iSubItem = 2;
|
||||||
|
@ -1845,37 +1846,41 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L
|
||||||
int index = ListView_GetNextItem(hWndList, -1, LVNI_SELECTED);
|
int index = ListView_GetNextItem(hWndList, -1, LVNI_SELECTED);
|
||||||
int port1, slot1, port2, slot2;
|
int port1, slot1, port2, slot2;
|
||||||
if (!ListIndexToPortAndSlot(index, &port1, &slot1)) break;
|
if (!ListIndexToPortAndSlot(index, &port1, &slot1)) break;
|
||||||
//HMENU hMenu = CreateMenu();
|
|
||||||
HMENU hMenu = CreatePopupMenu();
|
HMENU hMenu = CreatePopupMenu();
|
||||||
if (!hMenu) break;
|
if (!hMenu) break;
|
||||||
|
MENUITEMINFOW info;
|
||||||
for (port2=1; port2>=0; port2--) {
|
for (port2=1; port2>=0; port2--) {
|
||||||
for (slot2 = 3; slot2>=0; slot2--) {
|
for (slot2 = 3; slot2>=0; slot2--) {
|
||||||
if (port2 == port1 && slot2 == slot1) continue;
|
wchar_t text[40];
|
||||||
wchar_t text[100];
|
wchar_t pad[20];
|
||||||
if (!slot2)
|
if (!GetPadString(pad, port2, slot2)) continue;
|
||||||
wsprintf(text, L"Swap with Pad %i", port2+1);
|
|
||||||
else {
|
|
||||||
if (!config.multitap[port2]) continue;
|
|
||||||
wsprintf(text, L"Swap with Pad %i-%i", port2+1, slot2+1);
|
|
||||||
}
|
|
||||||
MENUITEMINFOW info;
|
|
||||||
memset(&info, 0, sizeof(info));
|
|
||||||
info.cbSize = sizeof(info);
|
info.cbSize = sizeof(info);
|
||||||
info.fMask = MIIM_STRING | MIIM_ID;
|
info.fMask = MIIM_STRING | MIIM_ID;
|
||||||
info.wID = 0x10000 + port2+2*slot2;
|
|
||||||
info.dwTypeData = text;
|
info.dwTypeData = text;
|
||||||
info.cch = wcslen(text);
|
if (port2 == port1 && slot2 == slot1) {
|
||||||
InsertMenuItemW(hMenu, 0, 1, &info);
|
int index = GetMenuItemCount(hMenu);
|
||||||
|
wsprintfW(text, L"Clear %s Bindings", pad);
|
||||||
|
info.wID = -1;
|
||||||
|
InsertMenuItemW(hMenu, index, 1, &info);
|
||||||
|
info.fMask = MIIM_TYPE;
|
||||||
|
info.fType = MFT_SEPARATOR;
|
||||||
|
InsertMenuItemW(hMenu, index, 1, &info);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
info.wID = port2+2*slot2;
|
||||||
|
wsprintfW(text, L"Swap with %s", pad);
|
||||||
|
InsertMenuItemW(hMenu, 0, 1, &info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
POINT pos;
|
POINT pos;
|
||||||
GetCursorPos(&pos);
|
GetCursorPos(&pos);
|
||||||
int res = TrackPopupMenuEx(hMenu, TPM_NONOTIFY|TPM_RETURNCMD, pos.x, pos.y, hWndProp, 0);
|
short res = TrackPopupMenuEx(hMenu, TPM_NONOTIFY|TPM_RETURNCMD, pos.x, pos.y, hWndProp, 0);
|
||||||
DestroyMenu(hMenu);
|
DestroyMenu(hMenu);
|
||||||
|
if (!res) break;
|
||||||
if (res > 0) {
|
if (res > 0) {
|
||||||
slot2 = res - 0x10000;
|
slot2 = res / 2;
|
||||||
port2 = slot2&1;
|
port2 = res&1;
|
||||||
slot2 >>= 1;
|
|
||||||
PadConfig padCfgTemp = config.padConfigs[port1][slot1];
|
PadConfig padCfgTemp = config.padConfigs[port1][slot1];
|
||||||
config.padConfigs[port1][slot1] = config.padConfigs[port2][slot2];
|
config.padConfigs[port1][slot1] = config.padConfigs[port2][slot2];
|
||||||
config.padConfigs[port2][slot2] = padCfgTemp;
|
config.padConfigs[port2][slot2] = padCfgTemp;
|
||||||
|
@ -1884,10 +1889,20 @@ INT_PTR CALLBACK GeneralDialogProc(HWND hWnd, unsigned int msg, WPARAM wParam, L
|
||||||
dm->devices[i]->pads[port1][slot1] = dm->devices[i]->pads[port2][slot2];
|
dm->devices[i]->pads[port1][slot1] = dm->devices[i]->pads[port2][slot2];
|
||||||
dm->devices[i]->pads[port2][slot2] = bindings;
|
dm->devices[i]->pads[port2][slot2] = bindings;
|
||||||
}
|
}
|
||||||
UpdatePadPages();
|
|
||||||
UpdatePadList(hWnd);
|
|
||||||
PropSheet_Changed(hWndProp, hWnd);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
for (int i=0; i<dm->numDevices; i++) {
|
||||||
|
free(dm->devices[i]->pads[port1][slot1].bindings);
|
||||||
|
for (int j=0; j<dm->devices[i]->pads[port1][slot1].numFFBindings; j++) {
|
||||||
|
free(dm->devices[i]->pads[port1][slot1].ffBindings[j].axes);
|
||||||
|
}
|
||||||
|
free(dm->devices[i]->pads[port1][slot1].ffBindings);
|
||||||
|
memset(&dm->devices[i]->pads[port1][slot1], 0, sizeof(dm->devices[i]->pads[port1][slot1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UpdatePadPages();
|
||||||
|
UpdatePadList(hWnd);
|
||||||
|
PropSheet_Changed(hWndProp, hWnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1906,6 +1921,10 @@ int CALLBACK PropSheetProc(HWND hWnd, UINT msg, LPARAM lParam) {
|
||||||
void CALLBACK PADconfigure() {
|
void CALLBACK PADconfigure() {
|
||||||
// Can end up here without PadConfigure() being called first.
|
// Can end up here without PadConfigure() being called first.
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
|
// Can also end up here after running emulator a bit, and possibly
|
||||||
|
// disabling some devices due to focus changes, or releasing mouse.
|
||||||
|
RefreshEnabledDevices(0);
|
||||||
|
|
||||||
memset(hWnds, 0, sizeof(hWnds));
|
memset(hWnds, 0, sizeof(hWnds));
|
||||||
|
|
||||||
PROPSHEETPAGE psp;
|
PROPSHEETPAGE psp;
|
||||||
|
|
|
@ -909,6 +909,11 @@ u8 CALLBACK PADstartPoll(int port) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int IsDualshock2(u8 port, u8 slot) {
|
||||||
|
return config.padConfigs[query.port][query.slot].type == Dualshock2Pad ||
|
||||||
|
(config.padConfigs[query.port][query.slot].type == GuitarPad && config.GH2);
|
||||||
|
}
|
||||||
|
|
||||||
u8 CALLBACK PADpoll(u8 value) {
|
u8 CALLBACK PADpoll(u8 value) {
|
||||||
DEBUG_IN(value);
|
DEBUG_IN(value);
|
||||||
if (query.lastByte+1 >= query.numBytes) {
|
if (query.lastByte+1 >= query.numBytes) {
|
||||||
|
@ -1038,9 +1043,14 @@ u8 CALLBACK PADpoll(u8 value) {
|
||||||
break;
|
break;
|
||||||
// QUERY_MODEL_AND_MODE
|
// QUERY_MODEL_AND_MODE
|
||||||
case 0x45:
|
case 0x45:
|
||||||
if (config.padConfigs[query.port][query.slot].type != GuitarPad || config.GH2) SET_FINAL_RESULT(queryModelDS2)
|
if (IsDualshock2(query.port, query.slot)) {
|
||||||
else SET_FINAL_RESULT(queryModelDS1);
|
SET_FINAL_RESULT(queryModelDS2)
|
||||||
query.response[5] = pad->mode != MODE_DIGITAL;
|
}
|
||||||
|
else {
|
||||||
|
SET_FINAL_RESULT(queryModelDS1);
|
||||||
|
}
|
||||||
|
// Not digital mode.
|
||||||
|
query.response[5] = (pad->mode & 0xF) != 1;
|
||||||
break;
|
break;
|
||||||
// QUERY_ACT
|
// QUERY_ACT
|
||||||
case 0x46:
|
case 0x46:
|
||||||
|
@ -1062,7 +1072,12 @@ u8 CALLBACK PADpoll(u8 value) {
|
||||||
break;
|
break;
|
||||||
// SET_DS2_NATIVE_MODE
|
// SET_DS2_NATIVE_MODE
|
||||||
case 0x4F:
|
case 0x4F:
|
||||||
SET_RESULT(setNativeMode);
|
if (IsDualshock2(query.port, query.slot)) {
|
||||||
|
SET_RESULT(setNativeMode);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SET_FINAL_RESULT(setNativeMode);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
query.numBytes = 0;
|
query.numBytes = 0;
|
||||||
|
@ -1140,6 +1155,7 @@ u8 CALLBACK PADpoll(u8 value) {
|
||||||
pad->vibrate[query.lastByte-2] = value;
|
pad->vibrate[query.lastByte-2] = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
// SET_DS2_NATIVE_MODE
|
||||||
case 0x4F:
|
case 0x4F:
|
||||||
if (query.lastByte == 3 || query.lastByte == 4) {
|
if (query.lastByte == 3 || query.lastByte == 4) {
|
||||||
pad->umask[query.lastByte-3] = value;
|
pad->umask[query.lastByte-3] = value;
|
||||||
|
|
|
@ -226,15 +226,15 @@ BEGIN
|
||||||
GROUPBOX "Pads",IDC_STATIC,7,140,410,67
|
GROUPBOX "Pads",IDC_STATIC,7,140,410,67
|
||||||
CONTROL "Port 1 Multitap",IDC_MULTITAP1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,152,63,10
|
CONTROL "Port 1 Multitap",IDC_MULTITAP1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,152,63,10
|
||||||
CONTROL "Port 2 Multitap",IDC_MULTITAP2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,164,63,10
|
CONTROL "Port 2 Multitap",IDC_MULTITAP2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,164,63,10
|
||||||
CONTROL "",IDC_PAD_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_TABSTOP,81,152,183,48,WS_EX_CLIENTEDGE
|
CONTROL "",IDC_PAD_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_TABSTOP,81,151,183,50,WS_EX_CLIENTEDGE
|
||||||
COMBOBOX IDC_PAD_TYPE,270,153,140,41,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
COMBOBOX IDC_PAD_TYPE,270,152,140,41,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
||||||
CONTROL "Use analog mode whenever possible",IDC_ANALOG_START1,
|
CONTROL "Use analog mode whenever possible",IDC_ANALOG_START1,
|
||||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,170,132,10
|
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,169,132,10
|
||||||
GROUPBOX "Device Diagnostics",IDC_STATIC,7,211,201,99
|
GROUPBOX "Device Diagnostics",IDC_STATIC,7,211,201,99
|
||||||
CONTROL "",IDC_LIST,"SysListView32",LVS_LIST | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_VSCROLL | WS_TABSTOP,15,224,185,61,WS_EX_CLIENTEDGE
|
CONTROL "",IDC_LIST,"SysListView32",LVS_LIST | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_VSCROLL | WS_TABSTOP,15,224,185,61,WS_EX_CLIENTEDGE
|
||||||
PUSHBUTTON "Test Device",ID_TEST,86,289,57,15
|
PUSHBUTTON "Test Device",ID_TEST,86,289,57,15
|
||||||
PUSHBUTTON "Refresh",ID_REFRESH,152,289,48,15
|
PUSHBUTTON "Refresh",ID_REFRESH,152,289,48,15
|
||||||
GROUPBOX "Miscellaneous",IDC_STATIC,216,211,201,35
|
GROUPBOX "Miscellaneous",IDC_STATIC,216,211,201,34
|
||||||
CONTROL "Use GS thread (Recommended)",IDC_GS_THREAD_INPUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,221,221,116,10
|
CONTROL "Use GS thread (Recommended)",IDC_GS_THREAD_INPUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,221,221,116,10
|
||||||
CONTROL "Disable screensaver",IDC_DISABLE_SCREENSAVER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,221,232,80,10
|
CONTROL "Disable screensaver",IDC_DISABLE_SCREENSAVER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,221,232,80,10
|
||||||
CONTROL "Local volume control",IDC_VISTA_VOLUME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,221,77,10
|
CONTROL "Local volume control",IDC_VISTA_VOLUME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,221,77,10
|
||||||
|
|
|
@ -111,8 +111,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static POINT rawOrigCursorPos;
|
|
||||||
|
|
||||||
class RawInputMouse : public WindowsMouse {
|
class RawInputMouse : public WindowsMouse {
|
||||||
public:
|
public:
|
||||||
HANDLE hDevice;
|
HANDLE hDevice;
|
||||||
|
@ -135,8 +133,7 @@ public:
|
||||||
// EatWndProc fail. In all other cases, no unmatched initialization/cleanup
|
// EatWndProc fail. In all other cases, no unmatched initialization/cleanup
|
||||||
// lines.
|
// lines.
|
||||||
if (!rawMouseActivatedCount++) {
|
if (!rawMouseActivatedCount++) {
|
||||||
GetCursorPos(&rawOrigCursorPos);
|
GetMouseCapture(hWnd);
|
||||||
ShowCursor(0);
|
|
||||||
if (!rawKeyboardActivatedCount && !EatWndProc(hWnd, RawInputWndProc)) {
|
if (!rawKeyboardActivatedCount && !EatWndProc(hWnd, RawInputWndProc)) {
|
||||||
Deactivate();
|
Deactivate();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -157,9 +154,8 @@ public:
|
||||||
active = 0;
|
active = 0;
|
||||||
rawMouseActivatedCount --;
|
rawMouseActivatedCount --;
|
||||||
if (!rawMouseActivatedCount) {
|
if (!rawMouseActivatedCount) {
|
||||||
ShowCursor(1);
|
|
||||||
ReleaseRawMice();
|
ReleaseRawMice();
|
||||||
SetCursorPos(rawOrigCursorPos.x, rawOrigCursorPos.y);
|
ReleaseMouseCapture();
|
||||||
if (!rawKeyboardActivatedCount) {
|
if (!rawKeyboardActivatedCount) {
|
||||||
ReleaseExtraProc(RawInputWndProc);
|
ReleaseExtraProc(RawInputWndProc);
|
||||||
}
|
}
|
||||||
|
@ -225,6 +221,11 @@ ExtraWndProcResult RawInputWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||||
memset(dev->physicalControlState, 0, sizeof(int) * dev->numPhysicalControls);
|
memset(dev->physicalControlState, 0, sizeof(int) * dev->numPhysicalControls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (uMsg == WM_SIZE && rawMouseActivatedCount) {
|
||||||
|
// Doesn't really matter for raw mice, as I disable legacy stuff, but shouldn't hurt.
|
||||||
|
WindowsMouse::WindowResized(hWnd);
|
||||||
|
}
|
||||||
|
|
||||||
return CONTINUE_BLISSFULLY;
|
return CONTINUE_BLISSFULLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,20 +79,10 @@ public:
|
||||||
Deactivate();
|
Deactivate();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
GetMouseCapture(hWnd);
|
||||||
|
|
||||||
SetCapture(hWnd);
|
|
||||||
ShowCursor(0);
|
|
||||||
|
|
||||||
GetCursorPos(&origCursorPos);
|
|
||||||
active = 1;
|
active = 1;
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
wmm = this;
|
wmm = this;
|
||||||
AllocState();
|
AllocState();
|
||||||
|
|
||||||
|
@ -102,10 +92,7 @@ public:
|
||||||
void Deactivate() {
|
void Deactivate() {
|
||||||
FreeState();
|
FreeState();
|
||||||
if (active) {
|
if (active) {
|
||||||
ClipCursor(0);
|
ReleaseMouseCapture();
|
||||||
ReleaseCapture();
|
|
||||||
ShowCursor(1);
|
|
||||||
SetCursorPos(origCursorPos.x, origCursorPos.y);
|
|
||||||
if (!wmk)
|
if (!wmk)
|
||||||
ReleaseExtraProc(WindowsMessagingWndProc);
|
ReleaseExtraProc(WindowsMessagingWndProc);
|
||||||
active = 0;
|
active = 0;
|
||||||
|
@ -179,6 +166,9 @@ ExtraWndProcResult WindowsMessagingWndProc(HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||||
wmm->UpdateAxis(3, ((int)wParam>>16)/WHEEL_DELTA);
|
wmm->UpdateAxis(3, ((int)wParam>>16)/WHEEL_DELTA);
|
||||||
return NO_WND_PROC;
|
return NO_WND_PROC;
|
||||||
}
|
}
|
||||||
|
else if (uMsg == WM_SIZE && wmm->active) {
|
||||||
|
WindowsMouse::WindowResized(hWnd);
|
||||||
|
}
|
||||||
// Taken care of elsewhere. When binding, killing focus means stop reading input.
|
// Taken care of elsewhere. When binding, killing focus means stop reading input.
|
||||||
// When running PCSX2, I release all mouse and keyboard input elsewhere.
|
// When running PCSX2, I release all mouse and keyboard input elsewhere.
|
||||||
/*else if (uMsg == WM_KILLFOCUS) {
|
/*else if (uMsg == WM_KILLFOCUS) {
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#include "VKey.h"
|
#include "VKey.h"
|
||||||
#include "WindowsMouse.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) :
|
WindowsMouse::WindowsMouse(DeviceAPI api, int hWheel, wchar_t *displayName, wchar_t *instanceID, wchar_t *deviceID) :
|
||||||
Device(api, MOUSE, displayName, instanceID, deviceID) {
|
Device(api, MOUSE, displayName, instanceID, deviceID) {
|
||||||
int i;
|
int i;
|
||||||
|
@ -41,4 +44,32 @@ void WindowsMouse::UpdateAxis(unsigned int axis, int delta) {
|
||||||
physicalControlState[5+axis] += (delta<<(16 - 3*(axis < 2)));
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -3,8 +3,16 @@
|
||||||
// Shared functionality for WM and RAW keyboards.
|
// Shared functionality for WM and RAW keyboards.
|
||||||
class WindowsMouse : public Device {
|
class WindowsMouse : public Device {
|
||||||
public:
|
public:
|
||||||
POINT origCursorPos;
|
// Used by GetMouseCapture()/ReleaseMouseCapture()
|
||||||
POINT center;
|
// Static because can have multiple raw mice active at once,
|
||||||
|
// and only get/release capture once.
|
||||||
|
static POINT origCursorPos;
|
||||||
|
static POINT center;
|
||||||
|
|
||||||
|
static void GetMouseCapture(HWND hWnd);
|
||||||
|
static void WindowResized(HWND hWnd);
|
||||||
|
static void ReleaseMouseCapture();
|
||||||
|
|
||||||
// hWheel variable lets me display no horizontal wheel for raw input, just to make it clear
|
// hWheel variable lets me display no horizontal wheel for raw input, just to make it clear
|
||||||
// that it's not supported.
|
// that it's not supported.
|
||||||
WindowsMouse(DeviceAPI api, int hWheel, wchar_t *displayName, wchar_t *instanceID=0, wchar_t *deviceID=0);
|
WindowsMouse(DeviceAPI api, int hWheel, wchar_t *displayName, wchar_t *instanceID=0, wchar_t *deviceID=0);
|
||||||
|
|
Loading…
Reference in New Issue