Add a pen callback to the events test

Add relevant data structures to handle SDK platfom on older environments
This commit is contained in:
Raja 2017-11-27 21:36:57 -05:00
parent f0797653c5
commit 8ff07fbb22
2 changed files with 113 additions and 6 deletions

View File

@ -49,13 +49,13 @@
#endif
// GLFW requires Windows XP or later
#if WINVER < 0x0604
#if WINVER < 0x0501
#undef WINVER
#define WINVER 0x0604
#define WINVER 0x0501
#endif
#if _WIN32_WINNT < 0x0604
#if _WIN32_WINNT < 0x0501
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0604
#define _WIN32_WINNT 0x0501
#endif
// GLFW uses DirectInput8 interfaces
@ -104,7 +104,102 @@
#define _WIN32_WINNT_WINBLUE 0x0602
#endif
#if WINVER < 0x0400
#if WINVER < 0x0604
#define WM_POINTERUPDATE 0x0245
#define WM_POINTERDOWN 0x0246
#define WM_POINTERUP 0x0247
#define POINTER_MESSAGE_FLAG_INCONTACT 0x00000004 // Pointer is in contact
#define GET_POINTERID_WPARAM(wParam) (LOWORD(wParam))
#define IS_POINTER_INCONTACT_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_INCONTACT)
#define IS_POINTER_FLAG_SET_WPARAM(wParam, flag) (((DWORD)HIWORD(wParam) & (flag)) == (flag))
typedef DWORD POINTER_INPUT_TYPE;
typedef UINT32 POINTER_FLAGS;
typedef UINT32 PEN_FLAGS;
typedef UINT32 PEN_MASK;
typedef UINT32 TOUCH_FLAGS;
typedef UINT32 TOUCH_MASK;
typedef enum tagPOINTER_BUTTON_CHANGE_TYPE {
POINTER_CHANGE_NONE,
POINTER_CHANGE_FIRSTBUTTON_DOWN,
POINTER_CHANGE_FIRSTBUTTON_UP,
POINTER_CHANGE_SECONDBUTTON_DOWN,
POINTER_CHANGE_SECONDBUTTON_UP,
POINTER_CHANGE_THIRDBUTTON_DOWN,
POINTER_CHANGE_THIRDBUTTON_UP,
POINTER_CHANGE_FOURTHBUTTON_DOWN,
POINTER_CHANGE_FOURTHBUTTON_UP,
POINTER_CHANGE_FIFTHBUTTON_DOWN,
POINTER_CHANGE_FIFTHBUTTON_UP,
} POINTER_BUTTON_CHANGE_TYPE;
typedef struct tagPOINTER_INFO {
POINTER_INPUT_TYPE pointerType;
UINT32 pointerId;
UINT32 frameId;
POINTER_FLAGS pointerFlags;
HANDLE sourceDevice;
HWND hwndTarget;
POINT ptPixelLocation;
POINT ptHimetricLocation;
POINT ptPixelLocationRaw;
POINT ptHimetricLocationRaw;
DWORD dwTime;
UINT32 historyCount;
INT32 InputData;
DWORD dwKeyStates;
UINT64 PerformanceCount;
POINTER_BUTTON_CHANGE_TYPE ButtonChangeType;
} POINTER_INFO;
typedef struct tagPOINTER_PEN_INFO {
POINTER_INFO pointerInfo;
PEN_FLAGS penFlags;
PEN_MASK penMask;
UINT32 pressure;
UINT32 rotation;
INT32 tiltX;
INT32 tiltY;
} POINTER_PEN_INFO;
typedef struct tagPOINTER_TOUCH_INFO {
POINTER_INFO pointerInfo;
TOUCH_FLAGS touchFlags;
TOUCH_MASK touchMask;
RECT rcContact;
RECT rcContactRaw;
UINT32 orientation;
UINT32 pressure;
} POINTER_TOUCH_INFO;
enum tagPOINTER_INPUT_TYPE {
PT_POINTER = 0x00000001, // Generic pointer
PT_TOUCH = 0x00000002, // Touch
PT_PEN = 0x00000003, // Pen
PT_MOUSE = 0x00000004, // Mouse
#if(WINVER >= 0x0603)
PT_TOUCHPAD = 0x00000005, // Touchpad
#endif /* WINVER >= 0x0603 */
};
typedef struct tagPOINTER_TYPE_INFO {
POINTER_INPUT_TYPE type;
union {
POINTER_TOUCH_INFO touchInfo;
POINTER_PEN_INFO penInfo;
} DUMMYUNIONNAME;
} POINTER_TYPE_INFO, *PPOINTER_TYPE_INFO;
WINUSERAPI BOOL WINAPI GetPointerType(_In_ UINT32 pointerId, _Out_ POINTER_INPUT_TYPE *pointerType);
WINUSERAPI BOOL WINAPI GetPointerPenInfo(_In_ UINT32 pointerId, _Out_writes_(1) POINTER_PEN_INFO *penInfo);
WINUSERAPI BOOL WINAPI GetPointerInfo(_In_ UINT32 pointerId, _Out_writes_(1) POINTER_INFO *pointerInfo);
#endif /*Windows 8 and above*/
#if WINVER < 0x0601
typedef struct tagCHANGEFILTERSTRUCT
{
DWORD cbSize;
@ -116,7 +211,7 @@ typedef struct tagCHANGEFILTERSTRUCT
#endif
#endif /*Windows 7*/
#if WINVER > 0x0400 //Changed from 0x0600 to 0x0400
#if WINVER < 0x0600
#define DWM_BB_ENABLE 0x00000001
#define DWM_BB_BLURREGION 0x00000002
typedef struct

View File

@ -343,6 +343,17 @@ static void mouse_button_callback(GLFWwindow* window, int button, int action, in
get_action_name(action));
}
static void pen_callback(GLFWwindow* window, double pressure, int x, int y)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Pen position: %i %i Pressure: %f\n",
counter++, slot->number, glfwGetTime(), x, y, pressure);
/*
fprintf(stderr, "pressure -- %f --\n", pressure);
fprintf(stderr, "xPosition -- %d --\n", x);
fprintf(stderr, "yPosition -- %d --\n", y);*/
}
static void cursor_position_callback(GLFWwindow* window, double x, double y)
{
Slot* slot = glfwGetWindowUserPointer(window);
@ -592,6 +603,7 @@ int main(int argc, char** argv)
glfwSetWindowIconifyCallback(slots[i].window, window_iconify_callback);
glfwSetWindowMaximizeCallback(slots[i].window, window_maximize_callback);
glfwSetMouseButtonCallback(slots[i].window, mouse_button_callback);
glfwSetPenPressureCallback(slots[i].window, pen_callback);
glfwSetCursorPosCallback(slots[i].window, cursor_position_callback);
glfwSetCursorEnterCallback(slots[i].window, cursor_enter_callback);
glfwSetScrollCallback(slots[i].window, scroll_callback);