mirror of
https://github.com/glfw/glfw.git
synced 2025-10-03 13:20:58 +00:00
Added dynamic loading of Win32 touch API.
This commit is contained in:
parent
fdb140d927
commit
7052c8dd39
16
src/win32_init.c
Normal file → Executable file
16
src/win32_init.c
Normal file → Executable file
@ -96,6 +96,22 @@ static GLboolean initLibraries(void)
|
|||||||
GetProcAddress(_glfw.win32.user32.instance, "SetProcessDPIAware");
|
GetProcAddress(_glfw.win32.user32.instance, "SetProcessDPIAware");
|
||||||
_glfw.win32.user32.ChangeWindowMessageFilterEx = (CHANGEWINDOWMESSAGEFILTEREX_T)
|
_glfw.win32.user32.ChangeWindowMessageFilterEx = (CHANGEWINDOWMESSAGEFILTEREX_T)
|
||||||
GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
|
GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
|
||||||
|
_glfw.win32.user32.GetTouchInputInfo = (GETTOUCHINPUTINFO_T)
|
||||||
|
GetProcAddress(_glfw.win32.user32.instance, "GetTouchInputInfo");
|
||||||
|
_glfw.win32.user32.CloseTouchInputHandle = (CLOSETOUCHINPUTHANDLE_T)
|
||||||
|
GetProcAddress(_glfw.win32.user32.instance, "CloseTouchInputHandle");
|
||||||
|
_glfw.win32.user32.RegisterTouchWindow = (REGISTERTOUCHWINDOW_T)
|
||||||
|
GetProcAddress(_glfw.win32.user32.instance, "RegisterTouchWindow");
|
||||||
|
_glfw.win32.user32.UnregisterTouchWindow = (UNREGISTERTOUCHWINDOW_T)
|
||||||
|
GetProcAddress(_glfw.win32.user32.instance, "UnregisterTouchWindow");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_glfw.win32.user32.GetTouchInputInfo &&
|
||||||
|
_glfw.win32.user32.CloseTouchInputHandle &&
|
||||||
|
_glfw.win32.user32.RegisterTouchWindow &&
|
||||||
|
_glfw.win32.user32.UnregisterTouchWindow)
|
||||||
|
{
|
||||||
|
_glfw.win32.touch.available = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.win32.dwmapi.instance = LoadLibraryW(L"dwmapi.dll");
|
_glfw.win32.dwmapi.instance = LoadLibraryW(L"dwmapi.dll");
|
||||||
|
44
src/win32_platform.h
Normal file → Executable file
44
src/win32_platform.h
Normal file → Executable file
@ -99,6 +99,34 @@ typedef struct tagCHANGEFILTERSTRUCT
|
|||||||
#endif
|
#endif
|
||||||
#endif /*Windows 7*/
|
#endif /*Windows 7*/
|
||||||
|
|
||||||
|
#if WINVER < 0x0601
|
||||||
|
|
||||||
|
#define WM_TOUCH 0x0240
|
||||||
|
|
||||||
|
DECLARE_HANDLE(HTOUCHINPUT);
|
||||||
|
|
||||||
|
typedef struct tagTOUCHINPUT
|
||||||
|
{
|
||||||
|
LONG x;
|
||||||
|
LONG y;
|
||||||
|
HANDLE hSource;
|
||||||
|
DWORD dwID;
|
||||||
|
DWORD dwFlags;
|
||||||
|
DWORD dwMask;
|
||||||
|
DWORD dwTime;
|
||||||
|
ULONG_PTR dwExtraInfo;
|
||||||
|
DWORD cxContact;
|
||||||
|
DWORD cyContext;
|
||||||
|
} TOUCHINPUT, *PTOUCHINPUT;
|
||||||
|
|
||||||
|
#define TOUCH_COORD_TO_PIXEL(x) ((x) / 100)
|
||||||
|
|
||||||
|
#define TOUCHEVENTF_MOVE 0x0001
|
||||||
|
#define TOUCHEVENTF_DOWN 0x0002
|
||||||
|
#define TOUCHEVENTF_UP 0x0004
|
||||||
|
|
||||||
|
#endif /*WINVER < 0x0601*/
|
||||||
|
|
||||||
// winmm.dll function pointer typedefs
|
// winmm.dll function pointer typedefs
|
||||||
typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T)(UINT,LPJOYCAPS,UINT);
|
typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T)(UINT,LPJOYCAPS,UINT);
|
||||||
typedef MMRESULT (WINAPI * JOYGETPOS_T)(UINT,LPJOYINFO);
|
typedef MMRESULT (WINAPI * JOYGETPOS_T)(UINT,LPJOYINFO);
|
||||||
@ -112,8 +140,16 @@ typedef DWORD (WINAPI * TIMEGETTIME_T)(void);
|
|||||||
// user32.dll function pointer typedefs
|
// user32.dll function pointer typedefs
|
||||||
typedef BOOL (WINAPI * SETPROCESSDPIAWARE_T)(void);
|
typedef BOOL (WINAPI * SETPROCESSDPIAWARE_T)(void);
|
||||||
typedef BOOL (WINAPI * CHANGEWINDOWMESSAGEFILTEREX_T)(HWND,UINT,DWORD,PCHANGEFILTERSTRUCT);
|
typedef BOOL (WINAPI * CHANGEWINDOWMESSAGEFILTEREX_T)(HWND,UINT,DWORD,PCHANGEFILTERSTRUCT);
|
||||||
|
typedef BOOL (WINAPI * GETTOUCHINPUTINFO_T)(HTOUCHINPUT,UINT,PTOUCHINPUT,int);
|
||||||
|
typedef BOOL (WINAPI * CLOSETOUCHINPUTHANDLE_T)(HTOUCHINPUT);
|
||||||
|
typedef BOOL (WINAPI * REGISTERTOUCHWINDOW_T)(HWND,LONG);
|
||||||
|
typedef BOOL (WINAPI * UNREGISTERTOUCHWINDOW_T)(HWND);
|
||||||
#define _glfw_SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware
|
#define _glfw_SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware
|
||||||
#define _glfw_ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx
|
#define _glfw_ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx
|
||||||
|
#define _glfw_GetTouchInputInfo _glfw.win32.user32.GetTouchInputInfo
|
||||||
|
#define _glfw_CloseTouchInputHandle _glfw.win32.user32.CloseTouchInputHandle
|
||||||
|
#define _glfw_RegisterTouchWindow _glfw.win32.user32.RegisterTouchWindow
|
||||||
|
#define _glfw_UnregisterTouchWindow _glfw.win32.user32.UnregisterTouchWindow
|
||||||
|
|
||||||
// dwmapi.dll function pointer typedefs
|
// dwmapi.dll function pointer typedefs
|
||||||
typedef HRESULT (WINAPI * DWMISCOMPOSITIONENABLED_T)(BOOL*);
|
typedef HRESULT (WINAPI * DWMISCOMPOSITIONENABLED_T)(BOOL*);
|
||||||
@ -184,8 +220,16 @@ typedef struct _GLFWlibraryWin32
|
|||||||
HINSTANCE instance;
|
HINSTANCE instance;
|
||||||
SETPROCESSDPIAWARE_T SetProcessDPIAware;
|
SETPROCESSDPIAWARE_T SetProcessDPIAware;
|
||||||
CHANGEWINDOWMESSAGEFILTEREX_T ChangeWindowMessageFilterEx;
|
CHANGEWINDOWMESSAGEFILTEREX_T ChangeWindowMessageFilterEx;
|
||||||
|
GETTOUCHINPUTINFO_T GetTouchInputInfo;
|
||||||
|
CLOSETOUCHINPUTHANDLE_T CloseTouchInputHandle;
|
||||||
|
REGISTERTOUCHWINDOW_T RegisterTouchWindow;
|
||||||
|
UNREGISTERTOUCHWINDOW_T UnregisterTouchWindow;
|
||||||
} user32;
|
} user32;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
GLboolean available;
|
||||||
|
} touch;
|
||||||
|
|
||||||
// dwmapi.dll
|
// dwmapi.dll
|
||||||
struct {
|
struct {
|
||||||
HINSTANCE instance;
|
HINSTANCE instance;
|
||||||
|
@ -527,10 +527,13 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
TOUCHINPUT* inputs;
|
TOUCHINPUT* inputs;
|
||||||
UINT count = LOWORD(wParam);
|
UINT count = LOWORD(wParam);
|
||||||
|
|
||||||
|
if (!_glfw.win32.touch.available)
|
||||||
|
return 0;
|
||||||
|
|
||||||
inputs = (TOUCHINPUT*) malloc(sizeof(TOUCHINPUT) * count);
|
inputs = (TOUCHINPUT*) malloc(sizeof(TOUCHINPUT) * count);
|
||||||
|
|
||||||
if (GetTouchInputInfo((HTOUCHINPUT) lParam,
|
if (_glfw_GetTouchInputInfo((HTOUCHINPUT) lParam,
|
||||||
count, inputs, sizeof(TOUCHINPUT)))
|
count, inputs, sizeof(TOUCHINPUT)))
|
||||||
{
|
{
|
||||||
int i, width, height;
|
int i, width, height;
|
||||||
|
|
||||||
@ -564,7 +567,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseTouchInputHandle((HTOUCHINPUT) lParam);
|
_glfw_CloseTouchInputHandle((HTOUCHINPUT) lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(inputs);
|
free(inputs);
|
||||||
@ -1095,10 +1098,13 @@ void _glfwPlatformPostEmptyEvent(void)
|
|||||||
|
|
||||||
void _glfwPlatformSetTouchInput(_GLFWwindow* window, int enabled)
|
void _glfwPlatformSetTouchInput(_GLFWwindow* window, int enabled)
|
||||||
{
|
{
|
||||||
|
if (!_glfw.win32.touch.available)
|
||||||
|
return;
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
RegisterTouchWindow(window->win32.handle, 0);
|
_glfw_RegisterTouchWindow(window->win32.handle, 0);
|
||||||
else
|
else
|
||||||
UnregisterTouchWindow(window->win32.handle);
|
_glfw_UnregisterTouchWindow(window->win32.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||||
|
Loading…
Reference in New Issue
Block a user