diff --git a/examples/pen.c b/examples/pen.c index c4cc3a017..a5f209650 100644 --- a/examples/pen.c +++ b/examples/pen.c @@ -74,9 +74,11 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, glfwSetWindowShouldClose(window, GLFW_TRUE); } -static void pen_callback(GLFWwindow* window, int pressure) +static void pen_callback(GLFWwindow* window, int pressure, int x, int y) { fprintf(stderr, "pressure -- %d --\n", pressure); + fprintf (stderr, "xPosition -- %d --\n", x); + fprintf(stderr, "yPosition -- %d --\n", y); } int main(void) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index dea3ea7bc..220a59213 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1279,27 +1279,21 @@ typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int); */ typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int); -/*! @brief The function signature for pen --button-- callbacks. +/*! @brief The function signature for pen --pressure-- callbacks. * -* This is the function signature for pen --button-- callback functions. +* This is the function signature for pen --pressure-- callback functions. * * @param[in] window The window that received the event. -* @param[in] button The [pen button](@ref buttons) that was pressed or +* @param[in] pressure The [pen pressure](@ref pressure) that was pressed or * released. -* @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. -* @param[in] mods Bit field describing which [modifier keys](@ref mods) were -* held down. -* +* * * @sa @ref input_pen_button -* @sa @ref glfwSetPenButtonCallback -* -* ---- @since Added in version 1.0. -* @glfw3 Added window handle and modifier mask parameters.------ +* @sa @ref glfwSetPenPressureCallback * * @ingroup input */ -typedef void(*GLFWpenpressurefun)(GLFWwindow*, int); +typedef void(*GLFWpenpressurefun)(GLFWwindow*, int, int, int); /*! @brief The function signature for cursor position callbacks. * diff --git a/src/input.c b/src/input.c index 9e444aefd..b8bda64e2 100644 --- a/src/input.c +++ b/src/input.c @@ -233,12 +233,14 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods) } /*************************PEN**************************************************/ -void _glfwInputPenPressure(_GLFWwindow* window, int pressure) +void _glfwInputPenPressure(_GLFWwindow* window, int pressure, int x, int y) { window->penPressure = pressure; + window->penXposition = x; + window->penYposition = y; if (window->callbacks.penPressure) - window->callbacks.penPressure((GLFWwindow*)window, pressure); + window->callbacks.penPressure((GLFWwindow*)window, pressure, x, y); } /***********************************PEN*************************************/ diff --git a/src/internal.h b/src/internal.h index 665f07652..1c567ea81 100644 --- a/src/internal.h +++ b/src/internal.h @@ -418,6 +418,8 @@ struct _GLFWwindow GLFWbool stickyKeys; GLFWbool stickyMouseButtons; int penPressure; + int penXposition; + int penYposition; int cursorMode; char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1]; char keys[GLFW_KEY_LAST + 1]; @@ -825,7 +827,7 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods) * @param[in] mods The modifiers pressed when the event was generated. * @ingroup event */ -void _glfwInputPenPressure(_GLFWwindow* window, int pressure); +void _glfwInputPenPressure(_GLFWwindow* window, int pressure, int x, int y); /*! @brief Notifies shared code of a cursor motion event. * @param[in] window The window that received the event. diff --git a/src/win32_window.c b/src/win32_window.c index bb00efd87..360c96c65 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -597,11 +597,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, else { // success, process penInfo + //We change the pen pressure which is given normalized to a range between 0 and 1024 + //to a normalized value in [0..1] + double pressure = (double)penInfo.pressure /(double) 1024; int xPos = GET_X_LPARAM(lParam); int yPos = GET_Y_LPARAM(lParam); if (IS_POINTER_INCONTACT_WPARAM(wParam)) { - _glfwInputPenPressure(window, penInfo.pressure); + _glfwInputPenPressure(window, pressure, xPos, yPos); } // mark as handled to skip call to DefWindowProc fHandled = TRUE;