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**);
/*! @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.

View File

@ -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)

View File

@ -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
*/

View File

@ -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);

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("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(),
id,
get_action_name(action),
x, y);
touchPoints[i].id,
get_action_name(touchPoints[i].action),
touchPoints[i].x, touchPoints[i].y);
}
}
int main(int argc, char** argv)