diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index de22ee2e1..f0fa13403 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1093,18 +1093,6 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int); */ typedef void (* GLFWdropfun)(GLFWwindow*,int,const char**); -/*! @brief The function signature for touch callbacks. - * @param[in] window The window that received the event. - * @param[in] touch The touch that triggered the event. - * @param[in] action One of @ref GLFW_PRESS, @c GLFW_MOVE or @ref GLFW_RELEASE. - * @param[in] xpos The new x-coordinate of the touch. - * @param[in] ypos The new y-coordinate of the touch. - * @ingroup input - * - * @sa glfwSetTouchCallback - */ -typedef void (* GLFWtouchfun)(GLFWwindow*, int, int, double, double); - /*! @brief Touch point info. * * This describes the touch point info. @@ -1131,6 +1119,16 @@ typedef struct GLFWtouch double y; } GLFWtouch; +/*! @brief The function signature for touch callbacks. +* @param[in] window The window that received the event. +* @param[in] touchPoints All valid touch points +* @param[in] count The number of valid touch points +* @ingroup event +* +* @sa glfwSetTouchCallback +*/ +typedef void(*GLFWtouchfun)(GLFWwindow*, GLFWtouch*, int); + /*! @brief The function signature for monitor configuration callbacks. * * This is the function signature for monitor configuration callback functions. diff --git a/src/input.c b/src/input.c index e9fc3792f..9f2d5bcca 100644 --- a/src/input.c +++ b/src/input.c @@ -135,10 +135,10 @@ void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths) window->callbacks.drop((GLFWwindow*) window, count, paths); } -void _glfwInputTouch(_GLFWwindow* window, int id, int action, double xpos, double ypos) +void _glfwInputTouch(_GLFWwindow* window, GLFWtouch* touchPoints, int count) { if (window->callbacks.touch) - window->callbacks.touch((GLFWwindow*)window, id, action, xpos, ypos); + window->callbacks.touch((GLFWwindow*)window, touchPoints, count); } void _glfwInputJoystickChange(int joy, int event) diff --git a/src/internal.h b/src/internal.h index 6a3c23406..726ad1409 100644 --- a/src/internal.h +++ b/src/internal.h @@ -927,13 +927,11 @@ void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered); /*! @brief Notifies shared code of a touch start/end event. * @param[in] window The window that received the event. -* @param[in] id Touch point id -* @param[in] action One of @c GLFW_PRESS, @c GLFW_MOVE or @c GLFW_RELEASE. -* @param[in] xpos The new x-coordinate of the touch. -* @param[in] ypos The new y-coordinate of the touch. +* @param[in] touchPoints All valid touch points +* @param[in] count The numer of valid touch points * @ingroup event */ -void _glfwInputTouch(_GLFWwindow* window, int id, int action, double xpos, double ypos); +void _glfwInputTouch(_GLFWwindow* window, GLFWtouch* touchPoints, int count); /*! @ingroup event */ diff --git a/src/win32_window.c b/src/win32_window.c index cd0b5f517..2549f8f18 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -841,7 +841,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, GLFWtouch* touchPoints = calloc(count, sizeof(GLFWtouch)); //Count valid points - int valid_count = 0; + int validCount = 0; for (i = 0; i < count; i++) { @@ -867,20 +867,17 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, else action = GLFW_REPEAT; - touchPoints[valid_count].id = (int)inputs[i].dwID; - touchPoints[valid_count].action = action; - touchPoints[valid_count].x = inputs[i].x / 100.0 - xpos; - touchPoints[valid_count].y = inputs[i].y / 100.0 - ypos; + touchPoints[validCount].id = (int)inputs[i].dwID; + touchPoints[validCount].action = action; + touchPoints[validCount].x = inputs[i].x / 100.0 - xpos; + touchPoints[validCount].y = inputs[i].y / 100.0 - ypos; - valid_count++; - - _glfwInputTouch(window, - (int) inputs[i].dwID, - action, - inputs[i].x / 100.0 - xpos, - inputs[i].y / 100.0 - ypos); + validCount++; } + if(validCount > 0) + _glfwInputTouch(window, touchPoints, validCount); + _glfw_CloseTouchInputHandle((HTOUCHINPUT) lParam); free(touchPoints); diff --git a/tests/events.c b/tests/events.c index 621914dcb..7e495305a 100644 --- a/tests/events.c +++ b/tests/events.c @@ -486,14 +486,17 @@ static void joystick_callback(int joy, int event) } } -static void touch_callback(GLFWwindow* window, int id, int action, double x, double y) +static void touch_callback(GLFWwindow* window, GLFWtouch* touchPoints, int count) { - printf("%08x at %0.3f: Touch %i %s at position %0.3f %0.3f\n", - counter++, - glfwGetTime(), - id, - get_action_name(action), - x, y); + printf("Priting info about all touch points"); + for (int i = 0; i < count; ++i) { + printf("%08x at %0.3f: Touch %i %s at position %0.3f %0.3f\n", + counter++, + glfwGetTime(), + touchPoints[i].id, + get_action_name(touchPoints[i].action), + touchPoints[i].x, touchPoints[i].y); + } } int main(int argc, char** argv)