|
@@ -52,8 +52,8 @@ void ClientResize(HWND hWnd, int nWidth, int nHeight)
|
|
|
MoveWindow(hWnd,rcWindow.left, rcWindow.top, nWidth + ptDiff.x, nHeight + ptDiff.y, TRUE);
|
|
MoveWindow(hWnd,rcWindow.left, rcWindow.top, nWidth + ptDiff.x, nHeight + ptDiff.y, TRUE);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-Win32Core::Win32Core(PolycodeViewBase *view, int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate)
|
|
|
|
|
- : Core(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel, frameRate) {
|
|
|
|
|
|
|
+Win32Core::Win32Core(PolycodeViewBase *view, int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex)
|
|
|
|
|
+ : Core(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel, frameRate, monitorIndex) {
|
|
|
|
|
|
|
|
hWnd = *((HWND*)view->windowData);
|
|
hWnd = *((HWND*)view->windowData);
|
|
|
core = this;
|
|
core = this;
|
|
@@ -428,6 +428,62 @@ void Win32Core::handleKeyUp(LPARAM lParam, WPARAM wParam) {
|
|
|
unlockMutex(eventMutex);
|
|
unlockMutex(eventMutex);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#ifdef WINDOWS_TOUCH_SUPPORT
|
|
|
|
|
+
|
|
|
|
|
+void Win32Core::handleTouchEvent(LPARAM lParam, WPARAM wParam) {
|
|
|
|
|
+ lockMutex(eventMutex);
|
|
|
|
|
+
|
|
|
|
|
+ int iNumContacts = LOWORD(wParam);
|
|
|
|
|
+ HTOUCHINPUT hInput = (HTOUCHINPUT)lParam;
|
|
|
|
|
+ TOUCHINPUT *pInputs = new TOUCHINPUT[iNumContacts];
|
|
|
|
|
+
|
|
|
|
|
+ if(pInputs != NULL) {
|
|
|
|
|
+ if(GetTouchInputInfo(hInput, iNumContacts, pInputs, sizeof(TOUCHINPUT))) {
|
|
|
|
|
+
|
|
|
|
|
+ std::vector<TouchInfo> touches;
|
|
|
|
|
+ for(int i = 0; i < iNumContacts; i++) {
|
|
|
|
|
+ TOUCHINPUT ti = pInputs[i];
|
|
|
|
|
+ TouchInfo touchInfo;
|
|
|
|
|
+ touchInfo.id = (int) ti.dwID;
|
|
|
|
|
+
|
|
|
|
|
+ POINT pt;
|
|
|
|
|
+ pt.x = TOUCH_COORD_TO_PIXEL(ti.x);
|
|
|
|
|
+ pt.y = TOUCH_COORD_TO_PIXEL(ti.y);
|
|
|
|
|
+ ScreenToClient(hWnd, &pt);
|
|
|
|
|
+ touchInfo.position.x = pt.x;
|
|
|
|
|
+ touchInfo.position.y = pt.y;
|
|
|
|
|
+
|
|
|
|
|
+ touches.push_back(touchInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ for(int i = 0; i < iNumContacts; i++) {
|
|
|
|
|
+ TOUCHINPUT ti = pInputs[i];
|
|
|
|
|
+ if (ti.dwFlags & TOUCHEVENTF_UP) {
|
|
|
|
|
+ Win32Event newEvent;
|
|
|
|
|
+ newEvent.eventGroup = Win32Event::INPUT_EVENT;
|
|
|
|
|
+ newEvent.eventCode = InputEvent::EVENT_TOUCHES_ENDED;
|
|
|
|
|
+ newEvent.touches = touches;
|
|
|
|
|
+ win32Events.push_back(newEvent);
|
|
|
|
|
+ } else if(ti.dwFlags & TOUCHEVENTF_MOVE) {
|
|
|
|
|
+ Win32Event newEvent;
|
|
|
|
|
+ newEvent.eventGroup = Win32Event::INPUT_EVENT;
|
|
|
|
|
+ newEvent.eventCode = InputEvent::EVENT_TOUCHES_MOVED;
|
|
|
|
|
+ newEvent.touches = touches;
|
|
|
|
|
+ win32Events.push_back(newEvent);
|
|
|
|
|
+ } else if(ti.dwFlags & TOUCHEVENTF_DOWN) {
|
|
|
|
|
+ Win32Event newEvent;
|
|
|
|
|
+ newEvent.eventGroup = Win32Event::INPUT_EVENT;
|
|
|
|
|
+ newEvent.eventCode = InputEvent::EVENT_TOUCHES_BEGAN;
|
|
|
|
|
+ newEvent.touches = touches;
|
|
|
|
|
+ win32Events.push_back(newEvent);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ unlockMutex(eventMutex);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
void Win32Core::handleMouseMove(LPARAM lParam, WPARAM wParam) {
|
|
void Win32Core::handleMouseMove(LPARAM lParam, WPARAM wParam) {
|
|
|
lockMutex(eventMutex);
|
|
lockMutex(eventMutex);
|
|
|
Win32Event newEvent;
|
|
Win32Event newEvent;
|
|
@@ -485,6 +541,15 @@ void Win32Core::checkEvents() {
|
|
|
switch(event.eventGroup) {
|
|
switch(event.eventGroup) {
|
|
|
case Win32Event::INPUT_EVENT:
|
|
case Win32Event::INPUT_EVENT:
|
|
|
switch(event.eventCode) {
|
|
switch(event.eventCode) {
|
|
|
|
|
+ case InputEvent::EVENT_TOUCHES_BEGAN:
|
|
|
|
|
+ input->touchesBegan(event.touches, getTicks());
|
|
|
|
|
+ break;
|
|
|
|
|
+ case InputEvent::EVENT_TOUCHES_ENDED:
|
|
|
|
|
+ input->touchesEnded(event.touches, getTicks());
|
|
|
|
|
+ break;
|
|
|
|
|
+ case InputEvent::EVENT_TOUCHES_MOVED:
|
|
|
|
|
+ input->touchesMoved(event.touches, getTicks());
|
|
|
|
|
+ break;
|
|
|
case InputEvent::EVENT_MOUSEMOVE:
|
|
case InputEvent::EVENT_MOUSEMOVE:
|
|
|
input->setDeltaPosition(event.mouseX - lastMouseX , event.mouseY - lastMouseY);
|
|
input->setDeltaPosition(event.mouseX - lastMouseX , event.mouseY - lastMouseY);
|
|
|
lastMouseX = event.mouseX;
|
|
lastMouseX = event.mouseX;
|
|
@@ -511,77 +576,77 @@ void Win32Core::checkEvents() {
|
|
|
unlockMutex(eventMutex);
|
|
unlockMutex(eventMutex);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void Win32Core::handleAxisChange(GamepadDeviceEntry * device, int axisIndex, DWORD value) {
|
|
|
|
|
- if (axisIndex < 0 || axisIndex >= (int) device->numAxes) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- Gamepad_devicePrivate *devicePrivate = device->privateData;
|
|
|
|
|
- float floatVal = (value - devicePrivate->axisRanges[axisIndex][0]) / (float) (devicePrivate->axisRanges[axisIndex][1] - devicePrivate->axisRanges[axisIndex][0]) * 2.0f - 1.0f;
|
|
|
|
|
- input->joystickAxisMoved(axisIndex, floatVal, device->deviceID);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void Win32Core::handleButtonChange(GamepadDeviceEntry * device, DWORD lastValue, DWORD value) {
|
|
|
|
|
- Gamepad_devicePrivate *devicePrivate = device->privateData;
|
|
|
|
|
- unsigned int buttonIndex;
|
|
|
|
|
- for (buttonIndex = 0; buttonIndex < device->numButtons; buttonIndex++) {
|
|
|
|
|
- if ((lastValue ^ value) & (1 << buttonIndex)) {
|
|
|
|
|
- if(!!(value & (1 << buttonIndex))) {
|
|
|
|
|
- input->joystickButtonDown(buttonIndex, device->deviceID);
|
|
|
|
|
- } else {
|
|
|
|
|
- input->joystickButtonUp(buttonIndex, device->deviceID);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static void povToXY(DWORD pov, int * outX, int * outY) {
|
|
|
|
|
- if (pov == JOY_POVCENTERED) {
|
|
|
|
|
- *outX = *outY = 0;
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- if (pov > JOY_POVFORWARD && pov < JOY_POVBACKWARD) {
|
|
|
|
|
- *outX = 1;
|
|
|
|
|
-
|
|
|
|
|
- } else if (pov > JOY_POVBACKWARD) {
|
|
|
|
|
- *outX = -1;
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- *outX = 0;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (pov > JOY_POVLEFT || pov < JOY_POVRIGHT) {
|
|
|
|
|
- *outY = -1;
|
|
|
|
|
-
|
|
|
|
|
- } else if (pov > JOY_POVRIGHT && pov < JOY_POVLEFT) {
|
|
|
|
|
- *outY = 1;
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- *outY = 0;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void Win32Core::handlePOVChange(GamepadDeviceEntry * device, DWORD lastValue, DWORD value) {
|
|
|
|
|
-
|
|
|
|
|
- Gamepad_devicePrivate *devicePrivate = device->privateData;
|
|
|
|
|
-
|
|
|
|
|
- int lastX, lastY, newX, newY;
|
|
|
|
|
-
|
|
|
|
|
- if (devicePrivate->povXAxisIndex == -1 || devicePrivate->povYAxisIndex == -1) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- povToXY(lastValue, &lastX, &lastY);
|
|
|
|
|
- povToXY(value, &newX, &newY);
|
|
|
|
|
-
|
|
|
|
|
- if (newX != lastX) {
|
|
|
|
|
- input->joystickAxisMoved(devicePrivate->povXAxisIndex, newX, device->deviceID);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (newY != lastY) {
|
|
|
|
|
- input->joystickAxisMoved(devicePrivate->povYAxisIndex, newY, device->deviceID);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+void Win32Core::handleAxisChange(GamepadDeviceEntry * device, int axisIndex, DWORD value) {
|
|
|
|
|
+ if (axisIndex < 0 || axisIndex >= (int) device->numAxes) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Gamepad_devicePrivate *devicePrivate = device->privateData;
|
|
|
|
|
+ float floatVal = (value - devicePrivate->axisRanges[axisIndex][0]) / (float) (devicePrivate->axisRanges[axisIndex][1] - devicePrivate->axisRanges[axisIndex][0]) * 2.0f - 1.0f;
|
|
|
|
|
+ input->joystickAxisMoved(axisIndex, floatVal, device->deviceID);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void Win32Core::handleButtonChange(GamepadDeviceEntry * device, DWORD lastValue, DWORD value) {
|
|
|
|
|
+ Gamepad_devicePrivate *devicePrivate = device->privateData;
|
|
|
|
|
+ unsigned int buttonIndex;
|
|
|
|
|
+ for (buttonIndex = 0; buttonIndex < device->numButtons; buttonIndex++) {
|
|
|
|
|
+ if ((lastValue ^ value) & (1 << buttonIndex)) {
|
|
|
|
|
+ if(!!(value & (1 << buttonIndex))) {
|
|
|
|
|
+ input->joystickButtonDown(buttonIndex, device->deviceID);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ input->joystickButtonUp(buttonIndex, device->deviceID);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void povToXY(DWORD pov, int * outX, int * outY) {
|
|
|
|
|
+ if (pov == JOY_POVCENTERED) {
|
|
|
|
|
+ *outX = *outY = 0;
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (pov > JOY_POVFORWARD && pov < JOY_POVBACKWARD) {
|
|
|
|
|
+ *outX = 1;
|
|
|
|
|
+
|
|
|
|
|
+ } else if (pov > JOY_POVBACKWARD) {
|
|
|
|
|
+ *outX = -1;
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ *outX = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (pov > JOY_POVLEFT || pov < JOY_POVRIGHT) {
|
|
|
|
|
+ *outY = -1;
|
|
|
|
|
+
|
|
|
|
|
+ } else if (pov > JOY_POVRIGHT && pov < JOY_POVLEFT) {
|
|
|
|
|
+ *outY = 1;
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ *outY = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void Win32Core::handlePOVChange(GamepadDeviceEntry * device, DWORD lastValue, DWORD value) {
|
|
|
|
|
+
|
|
|
|
|
+ Gamepad_devicePrivate *devicePrivate = device->privateData;
|
|
|
|
|
+
|
|
|
|
|
+ int lastX, lastY, newX, newY;
|
|
|
|
|
+
|
|
|
|
|
+ if (devicePrivate->povXAxisIndex == -1 || devicePrivate->povYAxisIndex == -1) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ povToXY(lastValue, &lastX, &lastY);
|
|
|
|
|
+ povToXY(value, &newX, &newY);
|
|
|
|
|
+
|
|
|
|
|
+ if (newX != lastX) {
|
|
|
|
|
+ input->joystickAxisMoved(devicePrivate->povXAxisIndex, newX, device->deviceID);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (newY != lastY) {
|
|
|
|
|
+ input->joystickAxisMoved(devicePrivate->povYAxisIndex, newY, device->deviceID);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
|
|
void Win32Core::Gamepad_processEvents() {
|
|
void Win32Core::Gamepad_processEvents() {
|