mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 21:56:36 +00:00
Add x any pen position
pen pressure normalization in [0..1]
This commit is contained in:
parent
07053602a5
commit
59721ebfef
@ -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)
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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*************************************/
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user