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
06e66b92
Commit
06e66b92
authored
Jun 18, 2010
by
Jim Grandpre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bugs in input, cleaned up $1
parent
66e6be2a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
105 deletions
+106
-105
SDL_touch.h
include/SDL_touch.h
+1
-0
SDL_touch.c
src/events/SDL_touch.c
+92
-85
SDL_x11events.c
src/video/x11/SDL_x11events.c
+9
-7
gestureTest.c
touchTest/gestureTest.c
+4
-13
No files found.
include/SDL_touch.h
View file @
06e66b92
...
...
@@ -50,6 +50,7 @@ struct SDL_Finger {
int
xdelta
;
int
ydelta
;
int
last_x
,
last_y
,
last_pressure
;
/* the last reported coordinates */
SDL_bool
down
;
int
pressure
;
};
...
...
src/events/SDL_touch.c
View file @
06e66b92
...
...
@@ -311,6 +311,8 @@ SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressu
SDL_Touch
*
touch
=
SDL_GetTouch
(
id
);
if
(
down
)
{
SDL_Finger
*
finger
=
SDL_GetFinger
(
touch
,
fingerid
);
if
(
finger
==
NULL
)
{
SDL_Finger
nf
;
nf
.
id
=
fingerid
;
nf
.
x
=
x
;
...
...
@@ -321,8 +323,12 @@ SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressu
nf
.
last_x
=
x
;
nf
.
last_y
=
y
;
nf
.
last_pressure
=
pressure
;
nf
.
down
=
SDL_FALSE
;
SDL_AddFinger
(
touch
,
&
nf
);
//if(x < 0 || y < 0) return 0; //should defer if only a partial input
finger
=
&
nf
;
}
else
if
(
finger
->
down
)
return
0
;
if
(
x
<
0
||
y
<
0
)
return
0
;
//should defer if only a partial input
posted
=
0
;
if
(
SDL_GetEventState
(
SDL_FINGERDOWN
)
==
SDL_ENABLE
)
{
SDL_Event
event
;
...
...
@@ -335,10 +341,11 @@ SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressu
event
.
tfinger
.
fingerId
=
fingerid
;
posted
=
(
SDL_PushEvent
(
&
event
)
>
0
);
}
if
(
posted
)
finger
->
down
=
SDL_TRUE
;
return
posted
;
}
else
{
SDL_DelFinger
(
touch
,
fingerid
)
;
if
(
SDL_DelFinger
(
touch
,
fingerid
)
<
0
)
return
0
;
posted
=
0
;
if
(
SDL_GetEventState
(
SDL_FINGERUP
)
==
SDL_ENABLE
)
{
SDL_Event
event
;
...
...
@@ -369,7 +376,7 @@ SDL_SendTouchMotion(int id, int fingerid, int relative,
return
0
;
}
if
(
finger
==
NULL
)
{
if
(
finger
==
NULL
||
!
finger
->
down
)
{
return
SDL_SendFingerDown
(
id
,
fingerid
,
SDL_TRUE
,
x
,
y
,
pressure
);
}
else
{
/* the relative motion is calculated regarding the last position */
...
...
src/video/x11/SDL_x11events.c
View file @
06e66b92
...
...
@@ -463,14 +463,16 @@ X11_PumpEvents(_THIS)
break
;
case
EV_SYN
:
//printf("Id: %i\n",touch->id);
if
(
data
->
x
>=
0
||
data
->
y
>=
0
)
SDL_SendTouchMotion
(
touch
->
id
,
data
->
finger
,
if
(
data
->
up
)
{
SDL_SendFingerDown
(
touch
->
id
,
data
->
finger
,
SDL_FALSE
,
data
->
x
,
data
->
y
,
data
->
pressure
);
if
(
data
->
up
)
SDL_SendFingerDown
(
touch
->
id
,
data
->
finger
,
}
else
if
(
data
->
x
>=
0
||
data
->
y
>=
0
)
SDL_SendTouchMotion
(
touch
->
id
,
data
->
finger
,
SDL_FALSE
,
data
->
x
,
data
->
y
,
data
->
pressure
);
//printf("Synched: %i tx: %i, ty: %i\n",
// data->finger,data->x,data->y);
data
->
x
=
-
1
;
...
...
touchTest/gestureTest.c
View file @
06e66b92
...
...
@@ -214,11 +214,12 @@ float dollarRecognize(SDL_Surface* screen, DollarPath path,int *bestTempl) {
int
i
;
int
k
;
/*
for(k = 0;k<DOLLARNPOINTS;k++) {
printf("(%f,%f)\n",points[k].x,
points[k].y);
}
*/
drawDollarPath
(
screen
,
points
,
numPoints
,
-
15
,
0xFF6600
);
int
bestDiff
=
10000
;
...
...
@@ -367,23 +368,13 @@ void DrawScreen(SDL_Surface* screen, int h)
gestureLine
[
j
].
points
=
0
;
#endif
//ignore last point - probably invalid
dollarPath
[
j
].
numPoints
--
;
float
dx
=
dollarPath
[
j
].
p
[
dollarPath
[
j
].
numPoints
].
x
-
dollarPath
[
j
].
p
[
dollarPath
[
j
].
numPoints
-
1
].
x
;
float
dy
=
dollarPath
[
j
].
p
[
dollarPath
[
j
].
numPoints
].
y
-
dollarPath
[
j
].
p
[
dollarPath
[
j
].
numPoints
-
1
].
y
;
dollarPath
[
j
].
length
-=
sqrt
(
dx
*
dx
+
dy
*
dy
);
if
(
!
keystat
[
32
]){
//spacebar
int
bestTempl
;
float
error
=
dollarRecognize
(
screen
,
dollarPath
[
j
],
&
bestTempl
);
printf
(
"%i
\n
"
,
bestTempl
);
if
(
bestTempl
>=
0
){
drawDollarPath
(
screen
,
dollarTemplate
[
bestTempl
]
,
DOLLARNPOINTS
,
-
15
,
0x0066FF
);
\
,
DOLLARNPOINTS
,
-
15
,
0x0066FF
);
printf
(
"ERROR: %f
\n
"
,
error
);
}
...
...
@@ -475,8 +466,8 @@ void DrawScreen(SDL_Surface* screen, int h)
if
(
gestureLast
[
j
].
id
<
0
)
continue
;
//Finger up. Or some error...
int
k
;
for
(
k
=
0
;
k
<
MAXFINGERS
;
k
++
)
{
if
(
gestureLast
[
k
].
id
<
0
)
continue
;
//printf("k = %i, id: %i\n",k,gestureLast[k].id);
//colors have no alpha, so shouldn't overflow
unsigned
int
c
=
(
colors
[
gestureLast
[
j
].
id
%
7
]
+
colors
[
gestureLast
[
k
].
id
%
7
])
/
2
;
...
...
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