mirror of
https://github.com/glfw/glfw.git
synced 2025-10-05 06:06:36 +00:00
Merge
This commit is contained in:
commit
2e514c6b19
1
.gitignore
vendored
1
.gitignore
vendored
@ -82,3 +82,4 @@ tests/title
|
|||||||
tests/vulkan
|
tests/vulkan
|
||||||
tests/windows
|
tests/windows
|
||||||
|
|
||||||
|
/build
|
||||||
|
@ -38,13 +38,14 @@ add_executable(particles WIN32 MACOSX_BUNDLE particles.c ${ICON} ${TINYCTHREAD}
|
|||||||
add_executable(simple WIN32 MACOSX_BUNDLE simple.c ${ICON} ${GLAD})
|
add_executable(simple WIN32 MACOSX_BUNDLE simple.c ${ICON} ${GLAD})
|
||||||
add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD})
|
add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD})
|
||||||
add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD})
|
add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD})
|
||||||
|
add_executable(pen WIN32 MACOSX_BUNDLE pen.c ${ICON} ${GLAD})
|
||||||
|
|
||||||
target_link_libraries(particles "${CMAKE_THREAD_LIBS_INIT}")
|
target_link_libraries(particles "${CMAKE_THREAD_LIBS_INIT}")
|
||||||
if (RT_LIBRARY)
|
if (RT_LIBRARY)
|
||||||
target_link_libraries(particles "${RT_LIBRARY}")
|
target_link_libraries(particles "${RT_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(WINDOWS_BINARIES boing gears heightmap particles simple splitview wave)
|
set(WINDOWS_BINARIES boing gears heightmap particles simple splitview wave pen)
|
||||||
set(CONSOLE_BINARIES offscreen)
|
set(CONSOLE_BINARIES offscreen)
|
||||||
|
|
||||||
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
||||||
@ -64,6 +65,7 @@ if (APPLE)
|
|||||||
set_target_properties(simple PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simple")
|
set_target_properties(simple PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simple")
|
||||||
set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView")
|
set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView")
|
||||||
set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
|
set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
|
||||||
|
set_target_properties(pen PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Pen")
|
||||||
|
|
||||||
set_target_properties(${WINDOWS_BINARIES} PROPERTIES
|
set_target_properties(${WINDOWS_BINARIES} PROPERTIES
|
||||||
RESOURCE glfw.icns
|
RESOURCE glfw.icns
|
||||||
|
173
examples/pen.c
Normal file
173
examples/pen.c
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
//========================================================================
|
||||||
|
// Simple GLFW example
|
||||||
|
// Copyright (c) Camilla Löwy <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would
|
||||||
|
// be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
// be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
//! [code]
|
||||||
|
|
||||||
|
#include <glad/glad.h>
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
#include "linmath.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
float x, y;
|
||||||
|
float r, g, b;
|
||||||
|
} vertices[3] =
|
||||||
|
{
|
||||||
|
{ -0.6f, -0.4f, 1.f, 0.f, 0.f },
|
||||||
|
{ 0.6f, -0.4f, 0.f, 1.f, 0.f },
|
||||||
|
{ 0.f, 0.6f, 0.f, 0.f, 1.f }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char* vertex_shader_text =
|
||||||
|
"#version 110\n"
|
||||||
|
"uniform mat4 MVP;\n"
|
||||||
|
"attribute vec3 vCol;\n"
|
||||||
|
"attribute vec2 vPos;\n"
|
||||||
|
"varying vec3 color;\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n"
|
||||||
|
" color = vCol;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const char* fragment_shader_text =
|
||||||
|
"#version 110\n"
|
||||||
|
"varying vec3 color;\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" gl_FragColor = vec4(color, 1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static void error_callback(int error, const char* description)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||||
|
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pen_callback(GLFWwindow* window, double pressure, int x, int y)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "pressure -- %f --\n", pressure);
|
||||||
|
fprintf (stderr, "xPosition -- %d --\n", x);
|
||||||
|
fprintf(stderr, "yPosition -- %d --\n", y);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
GLFWwindow* window;
|
||||||
|
GLuint vertex_buffer, vertex_shader, fragment_shader, program;
|
||||||
|
GLint mvp_location, vpos_location, vcol_location;
|
||||||
|
|
||||||
|
glfwSetErrorCallback(error_callback);
|
||||||
|
|
||||||
|
if (!glfwInit())
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
|
|
||||||
|
window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL);
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
glfwSetPenPressureCallback(window, pen_callback);
|
||||||
|
|
||||||
|
glfwMakeContextCurrent(window);
|
||||||
|
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||||
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
|
// NOTE: OpenGL error checks have been omitted for brevity
|
||||||
|
|
||||||
|
glGenBuffers(1, &vertex_buffer);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
vertex_shader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
glShaderSource(vertex_shader, 1, &vertex_shader_text, NULL);
|
||||||
|
glCompileShader(vertex_shader);
|
||||||
|
|
||||||
|
fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
glShaderSource(fragment_shader, 1, &fragment_shader_text, NULL);
|
||||||
|
glCompileShader(fragment_shader);
|
||||||
|
|
||||||
|
program = glCreateProgram();
|
||||||
|
glAttachShader(program, vertex_shader);
|
||||||
|
glAttachShader(program, fragment_shader);
|
||||||
|
glLinkProgram(program);
|
||||||
|
|
||||||
|
mvp_location = glGetUniformLocation(program, "MVP");
|
||||||
|
vpos_location = glGetAttribLocation(program, "vPos");
|
||||||
|
vcol_location = glGetAttribLocation(program, "vCol");
|
||||||
|
|
||||||
|
glEnableVertexAttribArray(vpos_location);
|
||||||
|
glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE,
|
||||||
|
sizeof(vertices[0]), (void*) 0);
|
||||||
|
glEnableVertexAttribArray(vcol_location);
|
||||||
|
glVertexAttribPointer(vcol_location, 3, GL_FLOAT, GL_FALSE,
|
||||||
|
sizeof(vertices[0]), (void*) (sizeof(float) * 2));
|
||||||
|
|
||||||
|
while (!glfwWindowShouldClose(window))
|
||||||
|
{
|
||||||
|
float ratio;
|
||||||
|
int width, height;
|
||||||
|
mat4x4 m, p, mvp;
|
||||||
|
|
||||||
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
|
ratio = width / (float) height;
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
mat4x4_identity(m);
|
||||||
|
mat4x4_rotate_Z(m, m, (float) glfwGetTime());
|
||||||
|
mat4x4_ortho(p, -ratio, ratio, -1.f, 1.f, 1.f, -1.f);
|
||||||
|
mat4x4_mul(mvp, p, m);
|
||||||
|
|
||||||
|
glUseProgram(program);
|
||||||
|
glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) mvp);
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||||
|
|
||||||
|
glfwSwapBuffers(window);
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwDestroyWindow(window);
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [code]
|
@ -507,6 +507,8 @@ extern "C" {
|
|||||||
|
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
|
/*! @} */
|
||||||
|
|
||||||
/*! @defgroup buttons Mouse buttons
|
/*! @defgroup buttons Mouse buttons
|
||||||
* @brief Mouse button IDs.
|
* @brief Mouse button IDs.
|
||||||
*
|
*
|
||||||
@ -1277,6 +1279,24 @@ typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
|
|||||||
*/
|
*/
|
||||||
typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
|
typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
|
||||||
|
|
||||||
|
/*! @brief The function signature for pen callbacks.
|
||||||
|
*
|
||||||
|
* This is the function signature for pen callback functions.
|
||||||
|
*
|
||||||
|
* @param[in] window The window that received the event.
|
||||||
|
* @param[in] pressure The [pen pressure](@ref pressure) that was pressed or
|
||||||
|
* released.
|
||||||
|
* @param[in] the x (horizontal point) coordinate of the point location of the pen.
|
||||||
|
* @param[in] the y (vertical point) coordinate of the point location of the pen.
|
||||||
|
* *
|
||||||
|
* @sa @ref input_pen_pressure
|
||||||
|
* @sa @ref glfwSetPenPressureCallback
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef void(*GLFWpenpressurefun)(GLFWwindow*, double, int, int);
|
||||||
|
|
||||||
/*! @brief The function signature for cursor position callbacks.
|
/*! @brief The function signature for cursor position callbacks.
|
||||||
*
|
*
|
||||||
* This is the function signature for cursor position callback functions.
|
* This is the function signature for cursor position callback functions.
|
||||||
@ -1349,6 +1369,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
|
|||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
|
typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
|
||||||
|
|
||||||
/*! @brief The function signature for Unicode character callbacks.
|
/*! @brief The function signature for Unicode character callbacks.
|
||||||
@ -3821,7 +3842,32 @@ GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
|
|||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
|
GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button);
|
||||||
|
|
||||||
|
/*! @brief Returns the last reported state of a pen button for the specified
|
||||||
|
* window.
|
||||||
|
*
|
||||||
|
* This function returns the last state reported for the specified pen button
|
||||||
|
* to the specified window. The returned state is one of `GLFW_PRESS` or
|
||||||
|
* `GLFW_RELEASE`.
|
||||||
|
*
|
||||||
|
* @param[in] window The desired window.
|
||||||
|
* @param[in] button The desired [pen button](@ref pen buttons).
|
||||||
|
* @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||||
|
* GLFW_INVALID_ENUM.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref input_pen_button
|
||||||
|
*
|
||||||
|
* @since Added in version 1.0.
|
||||||
|
* @glfw3 Added window handle parameter.
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
GLFWAPI int glfwGetPenPressure(GLFWwindow* handle);
|
||||||
|
|
||||||
/*! @brief Retrieves the position of the cursor relative to the client area of
|
/*! @brief Retrieves the position of the cursor relative to the client area of
|
||||||
* the window.
|
* the window.
|
||||||
@ -4159,6 +4205,27 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods
|
|||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
|
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
|
||||||
|
/*! @brief Sets the pen callback.
|
||||||
|
*
|
||||||
|
* This function sets the pen callback of the specified window, which
|
||||||
|
* is called when a pen is pressed or released.
|
||||||
|
**
|
||||||
|
* @param[in] window The window whose callback to set.
|
||||||
|
* @param[in] cbfun The new callback, or `NULL` to remove the currently set
|
||||||
|
* callback.
|
||||||
|
* @return The previously set callback, or `NULL` if no callback was set or the
|
||||||
|
* library had not been [initialized](@ref intro_init).
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref input_pen_pressure
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
GLFWAPI GLFWpenpressurefun glfwSetPenPressureCallback(GLFWwindow* window, GLFWpenpressurefun cbfun);
|
||||||
|
|
||||||
/*! @brief Sets the cursor position callback.
|
/*! @brief Sets the cursor position callback.
|
||||||
*
|
*
|
||||||
|
34
src/input.c
34
src/input.c
@ -232,6 +232,16 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
|||||||
window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
|
window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwInputPenPressure(_GLFWwindow* window, double pressure, int x, int y)
|
||||||
|
{
|
||||||
|
window->penPressure = pressure;
|
||||||
|
window->penXposition = x;
|
||||||
|
window->penYposition = y;
|
||||||
|
|
||||||
|
if (window->callbacks.penPressure)
|
||||||
|
window->callbacks.penPressure((GLFWwindow*)window, pressure, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
||||||
{
|
{
|
||||||
if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos)
|
if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos)
|
||||||
@ -513,6 +523,19 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
|
|||||||
return (int) window->mouseButtons[button];
|
return (int) window->mouseButtons[button];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************PEN**************************************************/
|
||||||
|
GLFWAPI int glfwGetPenPressure(GLFWwindow* handle)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*)handle;
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
||||||
|
|
||||||
|
return window->penPressure;
|
||||||
|
}
|
||||||
|
/**************************PEN***************************************************/
|
||||||
|
|
||||||
GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
|
GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
@ -708,6 +731,17 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
|
|||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI GLFWpenpressurefun glfwSetPenPressureCallback(GLFWwindow* handle,
|
||||||
|
GLFWpenpressurefun cbfun)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*)handle;
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.penPressure, cbfun);
|
||||||
|
return cbfun;
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
||||||
GLFWcursorposfun cbfun)
|
GLFWcursorposfun cbfun)
|
||||||
{
|
{
|
||||||
|
@ -417,6 +417,9 @@ struct _GLFWwindow
|
|||||||
|
|
||||||
GLFWbool stickyKeys;
|
GLFWbool stickyKeys;
|
||||||
GLFWbool stickyMouseButtons;
|
GLFWbool stickyMouseButtons;
|
||||||
|
double penPressure;
|
||||||
|
int penXposition;
|
||||||
|
int penYposition;
|
||||||
int cursorMode;
|
int cursorMode;
|
||||||
char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
|
char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
|
||||||
char keys[GLFW_KEY_LAST + 1];
|
char keys[GLFW_KEY_LAST + 1];
|
||||||
@ -435,6 +438,7 @@ struct _GLFWwindow
|
|||||||
GLFWwindowmaximizefun maximize;
|
GLFWwindowmaximizefun maximize;
|
||||||
GLFWframebuffersizefun fbsize;
|
GLFWframebuffersizefun fbsize;
|
||||||
GLFWmousebuttonfun mouseButton;
|
GLFWmousebuttonfun mouseButton;
|
||||||
|
GLFWpenpressurefun penPressure;
|
||||||
GLFWcursorposfun cursorPos;
|
GLFWcursorposfun cursorPos;
|
||||||
GLFWcursorenterfun cursorEnter;
|
GLFWcursorenterfun cursorEnter;
|
||||||
GLFWscrollfun scroll;
|
GLFWscrollfun scroll;
|
||||||
@ -818,6 +822,15 @@ void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
|
|||||||
*/
|
*/
|
||||||
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
|
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
|
||||||
|
|
||||||
|
/*! @brief Notifies shared code of a pen click event.
|
||||||
|
* @param[in] window The window that received the event.
|
||||||
|
* @param[in] pressure when the pen was pressed.
|
||||||
|
* @param[in] x (horizontal point) coordinate of the point location of the pen.
|
||||||
|
* @param[in] y (vertical point) coordinate of the point location of the pen.
|
||||||
|
* @ingroup event
|
||||||
|
*/
|
||||||
|
void _glfwInputPenPressure(_GLFWwindow* window, double pressure, int x, int y);
|
||||||
|
|
||||||
/*! @brief Notifies shared code of a cursor motion event.
|
/*! @brief Notifies shared code of a cursor motion event.
|
||||||
* @param[in] window The window that received the event.
|
* @param[in] window The window that received the event.
|
||||||
* @param[in] xpos The new x-coordinate of the cursor, relative to the left
|
* @param[in] xpos The new x-coordinate of the cursor, relative to the left
|
||||||
|
@ -49,13 +49,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// GLFW requires Windows XP or later
|
// GLFW requires Windows XP or later
|
||||||
#if WINVER < 0x0501
|
#if WINVER < 0x0604
|
||||||
#undef WINVER
|
#undef WINVER
|
||||||
#define WINVER 0x0501
|
#define WINVER 0x0604
|
||||||
#endif
|
#endif
|
||||||
#if _WIN32_WINNT < 0x0501
|
#if _WIN32_WINNT < 0x0604
|
||||||
#undef _WIN32_WINNT
|
#undef _WIN32_WINNT
|
||||||
#define _WIN32_WINNT 0x0501
|
#define _WIN32_WINNT 0x0604
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// GLFW uses DirectInput8 interfaces
|
// GLFW uses DirectInput8 interfaces
|
||||||
@ -104,7 +104,7 @@
|
|||||||
#define _WIN32_WINNT_WINBLUE 0x0602
|
#define _WIN32_WINNT_WINBLUE 0x0602
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if WINVER < 0x0601
|
#if WINVER < 0x0400
|
||||||
typedef struct tagCHANGEFILTERSTRUCT
|
typedef struct tagCHANGEFILTERSTRUCT
|
||||||
{
|
{
|
||||||
DWORD cbSize;
|
DWORD cbSize;
|
||||||
@ -116,7 +116,7 @@ typedef struct tagCHANGEFILTERSTRUCT
|
|||||||
#endif
|
#endif
|
||||||
#endif /*Windows 7*/
|
#endif /*Windows 7*/
|
||||||
|
|
||||||
#if WINVER < 0x0600
|
#if WINVER > 0x0400 //Changed from 0x0600 to 0x0400
|
||||||
#define DWM_BB_ENABLE 0x00000001
|
#define DWM_BB_ENABLE 0x00000001
|
||||||
#define DWM_BB_BLURREGION 0x00000002
|
#define DWM_BB_BLURREGION 0x00000002
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -31,8 +31,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <WinUser.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#define _GLFW_KEY_INVALID -2
|
#define _GLFW_KEY_INVALID -2
|
||||||
|
|
||||||
@ -561,6 +563,68 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_POINTERDOWN:
|
||||||
|
case WM_POINTERUPDATE:
|
||||||
|
case WM_POINTERUP:
|
||||||
|
{
|
||||||
|
POINTER_TOUCH_INFO touchInfo;
|
||||||
|
POINTER_PEN_INFO penInfo;
|
||||||
|
POINTER_INFO pointerInfo;
|
||||||
|
UINT32 pointerId = GET_POINTERID_WPARAM(wParam);
|
||||||
|
POINTER_INPUT_TYPE pointerType = PT_POINTER;
|
||||||
|
|
||||||
|
// default to unhandled to enable call to DefWindowProc
|
||||||
|
BOOL fHandled = FALSE;
|
||||||
|
|
||||||
|
// Retrieve common pointer information
|
||||||
|
if (!GetPointerType(pointerId, &pointerType))
|
||||||
|
{
|
||||||
|
// failure, call
|
||||||
|
GetLastError();
|
||||||
|
// set PT_POINTER to fall to default case below
|
||||||
|
pointerType = PT_POINTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (pointerType)
|
||||||
|
{
|
||||||
|
case (PT_PEN):
|
||||||
|
//Retrieve pen information
|
||||||
|
if (!GetPointerPenInfo(pointerId, &penInfo))
|
||||||
|
{
|
||||||
|
// failure, call
|
||||||
|
GetLastError();
|
||||||
|
}
|
||||||
|
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, pressure, xPos, yPos);
|
||||||
|
}
|
||||||
|
// mark as handled to skip call to DefWindowProc
|
||||||
|
fHandled = TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if (!GetPointerInfo(pointerId, &pointerInfo))
|
||||||
|
{
|
||||||
|
// failure.
|
||||||
|
GetLastError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// success, proceed with pointerInfo.
|
||||||
|
// fHandled = HandleGenericPointerMessage(&pointerInfo);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_CAPTURECHANGED:
|
case WM_CAPTURECHANGED:
|
||||||
{
|
{
|
||||||
// HACK: Disable the cursor once the caption button action has been
|
// HACK: Disable the cursor once the caption button action has been
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
#include <WinUser.h>
|
||||||
|
#include <windowsx.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user