Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
56c7ba92
Commit
56c7ba92
authored
Dec 01, 2010
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First pass at Windows multi-touch gesture support
parent
f7fc00e7
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
383 additions
and
309 deletions
+383
-309
SDL_gesture.c
src/events/SDL_gesture.c
+124
-124
SDL_touch.c
src/events/SDL_touch.c
+148
-148
SDL_win32events.c
src/video/win32/SDL_win32events.c
+64
-36
SDL_win32video.c
src/video/win32/SDL_win32video.c
+11
-0
SDL_win32video.h
src/video/win32/SDL_win32video.h
+33
-1
SDL_win32window.c
src/video/win32/SDL_win32window.c
+3
-0
No files found.
src/events/SDL_gesture.c
View file @
56c7ba92
src/events/SDL_touch.c
View file @
56c7ba92
src/video/win32/SDL_win32events.c
View file @
56c7ba92
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "SDL_syswm.h"
#include "SDL_syswm.h"
#include "SDL_vkeys.h"
#include "SDL_vkeys.h"
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_touch_c.h"
...
@@ -55,13 +56,11 @@
...
@@ -55,13 +56,11 @@
#ifndef WM_INPUT
#ifndef WM_INPUT
#define WM_INPUT 0x00ff
#define WM_INPUT 0x00ff
#endif
#endif
#ifndef WM_GESTURE
#define WM_GESTURE 0x0119
#endif
#ifndef WM_TOUCH
#ifndef WM_TOUCH
#define WM_TOUCH 0x0240
#define WM_TOUCH 0x0240
#endif
#endif
static
WPARAM
static
WPARAM
RemapVKEY
(
WPARAM
wParam
,
LPARAM
lParam
)
RemapVKEY
(
WPARAM
wParam
,
LPARAM
lParam
)
{
{
...
@@ -519,39 +518,68 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
...
@@ -519,39 +518,68 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
}
returnCode
=
0
;
returnCode
=
0
;
break
;
break
;
case
WM_TOUCH
:
case
WM_TOUCH
:
{
{
//printf("Got Touch Event!\n");
UINT
i
,
num_inputs
=
LOWORD
(
wParam
);
PTOUCHINPUT
inputs
=
SDL_stack_alloc
(
TOUCHINPUT
,
num_inputs
);
if
(
data
->
videodata
->
GetTouchInputInfo
((
HTOUCHINPUT
)
lParam
,
num_inputs
,
inputs
,
sizeof
(
TOUCHINPUT
)))
{
RECT
rect
;
float
x
,
y
;
#ifdef WMMSG_DEBUG
if
(
!
GetClientRect
(
hwnd
,
&
rect
)
||
FILE
*
log
=
fopen
(
"wmmsg.txt"
,
"a"
);
(
rect
.
right
==
rect
.
left
&&
rect
.
bottom
==
rect
.
top
))
{
fprintf
(
log
,
"Received Touch Message: %p "
,
hwnd
);
break
;
if
(
msg
>
MAX_WMMSG
)
{
fprintf
(
log
,
"%d"
,
msg
);
}
else
{
fprintf
(
log
,
"%s"
,
wmtab
[
msg
]);
}
}
fprintf
(
log
,
"WM_TOUCH = %d -- 0x%X, 0x%X
\n
"
,
msg
,
wParam
,
lParam
);
ClientToScreen
(
hwnd
,
(
LPPOINT
)
&
rect
);
fclose
(
log
);
ClientToScreen
(
hwnd
,
(
LPPOINT
)
&
rect
+
1
);
#endif
rect
.
top
*=
100
;
rect
.
left
*=
100
;
rect
.
bottom
*=
100
;
rect
.
right
*=
100
;
for
(
i
=
0
;
i
<
num_inputs
;
++
i
)
{
PTOUCHINPUT
input
=
&
inputs
[
i
];
SDL_TouchID
touchId
=
(
SDL_TouchID
)
input
->
hSource
;
if
(
!
SDL_GetTouch
(
touchId
))
{
SDL_Touch
touch
;
touch
.
id
=
touchId
;
touch
.
x_min
=
0
;
touch
.
x_max
=
1
;
touch
.
native_xres
=
touch
.
x_max
-
touch
.
x_min
;
touch
.
y_min
=
0
;
touch
.
y_max
=
1
;
touch
.
native_yres
=
touch
.
y_max
-
touch
.
y_min
;
touch
.
pressure_min
=
0
;
touch
.
pressure_max
=
1
;
touch
.
native_pressureres
=
touch
.
pressure_max
-
touch
.
pressure_min
;
if
(
SDL_AddTouch
(
&
touch
,
""
)
<
0
)
{
continue
;
}
}
}
break
;
case
WM_GESTURE
:
{
//printf("Got Touch Event!\n");
#ifdef WMMSG_DEBUG
// Get the normalized coordinates for the window
FILE
*
log
=
fopen
(
"wmmsg.txt"
,
"a"
);
x
=
(
float
)(
input
->
x
-
rect
.
left
)
/
(
rect
.
right
-
rect
.
left
);
fprintf
(
log
,
"Received Gesture Message: %p "
,
hwnd
);
y
=
(
float
)(
input
->
y
-
rect
.
top
)
/
(
rect
.
bottom
-
rect
.
top
);
if
(
msg
>
MAX_WMMSG
)
{
fprintf
(
log
,
"%d"
,
msg
);
if
(
input
->
dwFlags
&
TOUCHEVENTF_DOWN
)
{
}
else
{
SDL_SendFingerDown
(
touchId
,
input
->
dwID
,
SDL_TRUE
,
x
,
y
,
1
);
fprintf
(
log
,
"%s"
,
wmtab
[
msg
]);
}
}
fprintf
(
log
,
"WM_GESTURE = %d -- 0x%X, 0x%X
\n
"
,
msg
,
wParam
,
lParam
);
if
(
input
->
dwFlags
&
TOUCHEVENTF_MOVE
)
{
fclose
(
log
);
SDL_SendTouchMotion
(
touchId
,
input
->
dwID
,
SDL_FALSE
,
x
,
y
,
1
);
#endif
}
if
(
input
->
dwFlags
&
TOUCHEVENTF_UP
)
{
SDL_SendFingerDown
(
touchId
,
input
->
dwID
,
SDL_FALSE
,
x
,
y
,
1
);
}
}
}
SDL_stack_free
(
inputs
);
data
->
videodata
->
CloseTouchInputHandle
((
HTOUCHINPUT
)
lParam
);
return
0
;
}
}
break
;
break
;
}
}
...
...
src/video/win32/SDL_win32video.c
View file @
56c7ba92
...
@@ -82,6 +82,10 @@ WIN_DeleteDevice(SDL_VideoDevice * device)
...
@@ -82,6 +82,10 @@ WIN_DeleteDevice(SDL_VideoDevice * device)
FreeLibrary
(
data
->
hAygShell
);
FreeLibrary
(
data
->
hAygShell
);
}
}
#endif
#endif
if
(
data
->
userDLL
)
{
FreeLibrary
(
data
->
userDLL
);
}
SDL_free
(
device
->
driverdata
);
SDL_free
(
device
->
driverdata
);
SDL_free
(
device
);
SDL_free
(
device
);
}
}
...
@@ -155,6 +159,13 @@ WIN_CreateDevice(int devindex)
...
@@ -155,6 +159,13 @@ WIN_CreateDevice(int devindex)
data
->
CoordTransform
=
NULL
;
data
->
CoordTransform
=
NULL
;
#endif
#endif
data
->
userDLL
=
LoadLibrary
(
TEXT
(
"USER32.DLL"
));
if
(
data
->
userDLL
)
{
data
->
CloseTouchInputHandle
=
(
BOOL
(
WINAPI
*
)(
HTOUCHINPUT
))
GetProcAddress
(
data
->
userDLL
,
"CloseTouchInputHandle"
);
data
->
GetTouchInputInfo
=
(
BOOL
(
WINAPI
*
)(
HTOUCHINPUT
,
UINT
,
PTOUCHINPUT
,
int
))
GetProcAddress
(
data
->
userDLL
,
"GetTouchInputInfo"
);
data
->
RegisterTouchWindow
=
(
BOOL
(
WINAPI
*
)(
HWND
,
ULONG
))
GetProcAddress
(
data
->
userDLL
,
"RegisterTouchWindow"
);
}
/* Set the function pointers */
/* Set the function pointers */
device
->
VideoInit
=
WIN_VideoInit
;
device
->
VideoInit
=
WIN_VideoInit
;
device
->
VideoQuit
=
WIN_VideoQuit
;
device
->
VideoQuit
=
WIN_VideoQuit
;
...
...
src/video/win32/SDL_win32video.h
View file @
56c7ba92
...
@@ -80,6 +80,32 @@ extern void WIN_SetError(const char *prefix);
...
@@ -80,6 +80,32 @@ extern void WIN_SetError(const char *prefix);
enum
{
RENDER_NONE
,
RENDER_D3D
,
RENDER_DDRAW
,
RENDER_GDI
,
RENDER_GAPI
,
RENDER_RAW
};
enum
{
RENDER_NONE
,
RENDER_D3D
,
RENDER_DDRAW
,
RENDER_GDI
,
RENDER_GAPI
,
RENDER_RAW
};
#if WINVER < 0x0601
/* Touch input definitions */
#define TWF_FINETOUCH 1
#define TWF_WANTPALM 2
#define TOUCHEVENTF_MOVE 0x0001
#define TOUCHEVENTF_DOWN 0x0002
#define TOUCHEVENTF_UP 0x0004
DECLARE_HANDLE
(
HTOUCHINPUT
);
typedef
struct
_TOUCHINPUT
{
LONG
x
;
LONG
y
;
HANDLE
hSource
;
DWORD
dwID
;
DWORD
dwFlags
;
DWORD
dwMask
;
DWORD
dwTime
;
ULONG_PTR
dwExtraInfo
;
DWORD
cxContact
;
DWORD
cyContact
;
}
TOUCHINPUT
,
*
PTOUCHINPUT
;
#endif
/* WINVER < 0x0601 */
typedef
BOOL
(
*
PFNSHFullScreen
)(
HWND
,
DWORD
);
typedef
BOOL
(
*
PFNSHFullScreen
)(
HWND
,
DWORD
);
typedef
void
(
*
PFCoordTransform
)(
SDL_Window
*
,
POINT
*
);
typedef
void
(
*
PFCoordTransform
)(
SDL_Window
*
,
POINT
*
);
...
@@ -137,6 +163,12 @@ typedef struct SDL_VideoData
...
@@ -137,6 +163,12 @@ typedef struct SDL_VideoData
const
SDL_scancode
*
key_layout
;
const
SDL_scancode
*
key_layout
;
DWORD
clipboard_count
;
DWORD
clipboard_count
;
/* Touch input functions */
HANDLE
userDLL
;
BOOL
(
WINAPI
*
CloseTouchInputHandle
)(
HTOUCHINPUT
);
BOOL
(
WINAPI
*
GetTouchInputInfo
)(
HTOUCHINPUT
,
UINT
,
PTOUCHINPUT
,
int
);
BOOL
(
WINAPI
*
RegisterTouchWindow
)(
HWND
,
ULONG
);
SDL_bool
ime_com_initialized
;
SDL_bool
ime_com_initialized
;
struct
ITfThreadMgr
*
ime_threadmgr
;
struct
ITfThreadMgr
*
ime_threadmgr
;
SDL_bool
ime_initialized
;
SDL_bool
ime_initialized
;
...
...
src/video/win32/SDL_win32window.c
View file @
56c7ba92
...
@@ -144,6 +144,9 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
...
@@ -144,6 +144,9 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
}
}
}
}
/* Enable multi-touch */
videodata
->
RegisterTouchWindow
(
hwnd
,
(
TWF_FINETOUCH
|
TWF_WANTPALM
));
/* All done! */
/* All done! */
window
->
driverdata
=
data
;
window
->
driverdata
=
data
;
return
0
;
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment