Bundling of touch points for one callback complete.

This commit is contained in:
eriksunden 2017-02-22 20:23:45 +01:00
parent 99da7e171b
commit 685b3a9170
5 changed files with 34 additions and 38 deletions

View File

@ -1093,18 +1093,6 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
*/ */
typedef void (* GLFWdropfun)(GLFWwindow*,int,const char**); 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. /*! @brief Touch point info.
* *
* This describes the touch point info. * This describes the touch point info.
@ -1131,6 +1119,16 @@ typedef struct GLFWtouch
double y; double y;
} GLFWtouch; } 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. /*! @brief The function signature for monitor configuration callbacks.
* *
* This is the function signature for monitor configuration callback functions. * This is the function signature for monitor configuration callback functions.

View File

@ -135,10 +135,10 @@ void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
window->callbacks.drop((GLFWwindow*) window, count, 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) 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) void _glfwInputJoystickChange(int joy, int event)

View File

@ -927,13 +927,11 @@ void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered);
/*! @brief Notifies shared code of a touch start/end event. /*! @brief Notifies shared code of a touch start/end event.
* @param[in] window The window that received the event. * @param[in] window The window that received the event.
* @param[in] id Touch point id * @param[in] touchPoints All valid touch points
* @param[in] action One of @c GLFW_PRESS, @c GLFW_MOVE or @c GLFW_RELEASE. * @param[in] count The numer of valid touch points
* @param[in] xpos The new x-coordinate of the touch.
* @param[in] ypos The new y-coordinate of the touch.
* @ingroup event * @ingroup event
*/ */
void _glfwInputTouch(_GLFWwindow* window, int id, int action, double xpos, double ypos); void _glfwInputTouch(_GLFWwindow* window, GLFWtouch* touchPoints, int count);
/*! @ingroup event /*! @ingroup event
*/ */

View File

@ -841,7 +841,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
GLFWtouch* touchPoints = calloc(count, sizeof(GLFWtouch)); GLFWtouch* touchPoints = calloc(count, sizeof(GLFWtouch));
//Count valid points //Count valid points
int valid_count = 0; int validCount = 0;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
@ -867,20 +867,17 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
else else
action = GLFW_REPEAT; action = GLFW_REPEAT;
touchPoints[valid_count].id = (int)inputs[i].dwID; touchPoints[validCount].id = (int)inputs[i].dwID;
touchPoints[valid_count].action = action; touchPoints[validCount].action = action;
touchPoints[valid_count].x = inputs[i].x / 100.0 - xpos; touchPoints[validCount].x = inputs[i].x / 100.0 - xpos;
touchPoints[valid_count].y = inputs[i].y / 100.0 - ypos; touchPoints[validCount].y = inputs[i].y / 100.0 - ypos;
valid_count++; validCount++;
_glfwInputTouch(window,
(int) inputs[i].dwID,
action,
inputs[i].x / 100.0 - xpos,
inputs[i].y / 100.0 - ypos);
} }
if(validCount > 0)
_glfwInputTouch(window, touchPoints, validCount);
_glfw_CloseTouchInputHandle((HTOUCHINPUT) lParam); _glfw_CloseTouchInputHandle((HTOUCHINPUT) lParam);
free(touchPoints); free(touchPoints);

View File

@ -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", printf("Priting info about all touch points");
counter++, for (int i = 0; i < count; ++i) {
glfwGetTime(), printf("%08x at %0.3f: Touch %i %s at position %0.3f %0.3f\n",
id, counter++,
get_action_name(action), glfwGetTime(),
x, y); touchPoints[i].id,
get_action_name(touchPoints[i].action),
touchPoints[i].x, touchPoints[i].y);
}
} }
int main(int argc, char** argv) int main(int argc, char** argv)