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
9f6e4ab9
Commit
9f6e4ab9
authored
Oct 27, 2011
by
Kees Bakker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor SDL_AddDollarGesture
parent
3c27fa1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
35 deletions
+30
-35
SDL_gesture.c
src/events/SDL_gesture.c
+30
-35
No files found.
src/events/SDL_gesture.c
View file @
9f6e4ab9
...
@@ -162,52 +162,47 @@ int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src)
...
@@ -162,52 +162,47 @@ int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src)
//path is an already sampled set of points
//path is an already sampled set of points
//Returns the index of the gesture on success, or -1
//Returns the index of the gesture on success, or -1
static
int
SDL_AddDollarGesture
(
SDL_GestureTouch
*
inTouch
,
SDL_FloatPoint
*
path
)
static
int
SDL_AddDollarGesture
_one
(
SDL_GestureTouch
*
inTouch
,
SDL_FloatPoint
*
path
)
{
{
SDL_DollarTemplate
*
dollarTemplate
;
SDL_DollarTemplate
*
dollarTemplate
;
SDL_DollarTemplate
*
templ
;
SDL_DollarTemplate
*
templ
;
int
index
;
index
=
inTouch
->
numDollarTemplates
;
dollarTemplate
=
(
SDL_DollarTemplate
*
)
SDL_realloc
(
inTouch
->
dollarTemplate
,
(
index
+
1
)
*
sizeof
(
SDL_DollarTemplate
));
if
(
!
dollarTemplate
)
{
SDL_OutOfMemory
();
return
-
1
;
}
inTouch
->
dollarTemplate
=
dollarTemplate
;
templ
=
&
inTouch
->
dollarTemplate
[
index
];
SDL_memcpy
(
templ
->
path
,
path
,
DOLLARNPOINTS
*
sizeof
(
SDL_FloatPoint
));
templ
->
hash
=
SDL_HashDollar
(
templ
->
path
);
inTouch
->
numDollarTemplates
++
;
return
index
;
}
static
int
SDL_AddDollarGesture
(
SDL_GestureTouch
*
inTouch
,
SDL_FloatPoint
*
path
)
{
int
index
;
int
i
=
0
;
int
i
=
0
;
if
(
inTouch
==
NULL
)
{
if
(
inTouch
==
NULL
)
{
if
(
SDL_numGestureTouches
==
0
)
return
-
1
;
if
(
SDL_numGestureTouches
==
0
)
return
-
1
;
for
(
i
=
0
;
i
<
SDL_numGestureTouches
;
i
++
)
{
for
(
i
=
0
;
i
<
SDL_numGestureTouches
;
i
++
)
{
inTouch
=
&
SDL_gestureTouch
[
i
];
inTouch
=
&
SDL_gestureTouch
[
i
];
index
=
SDL_AddDollarGesture_one
(
inTouch
,
path
);
dollarTemplate
=
if
(
index
<
0
)
(
SDL_DollarTemplate
*
)
SDL_realloc
(
inTouch
->
dollarTemplate
,
(
inTouch
->
numDollarTemplates
+
1
)
*
sizeof
(
SDL_DollarTemplate
));
if
(
!
dollarTemplate
)
{
SDL_OutOfMemory
();
return
-
1
;
return
-
1
;
}
inTouch
->
dollarTemplate
=
dollarTemplate
;
templ
=
&
inTouch
->
dollarTemplate
[
inTouch
->
numDollarTemplates
];
SDL_memcpy
(
templ
->
path
,
path
,
DOLLARNPOINTS
*
sizeof
(
SDL_FloatPoint
));
templ
->
hash
=
SDL_HashDollar
(
templ
->
path
);
inTouch
->
numDollarTemplates
++
;
}
}
return
inTouch
->
numDollarTemplates
-
1
;
// Use the index of the last one added.
return
index
;
}
else
{
}
else
{
SDL_DollarTemplate
*
dollarTemplate
=
return
SDL_AddDollarGesture_one
(
inTouch
,
path
);
(
SDL_DollarTemplate
*
)
SDL_realloc
(
inTouch
->
dollarTemplate
,
(
inTouch
->
numDollarTemplates
+
1
)
*
sizeof
(
SDL_DollarTemplate
));
if
(
!
dollarTemplate
)
{
SDL_OutOfMemory
();
return
-
1
;
}
inTouch
->
dollarTemplate
=
dollarTemplate
;
templ
=
&
inTouch
->
dollarTemplate
[
inTouch
->
numDollarTemplates
];
SDL_memcpy
(
templ
->
path
,
path
,
DOLLARNPOINTS
*
sizeof
(
SDL_FloatPoint
));
templ
->
hash
=
SDL_HashDollar
(
templ
->
path
);
inTouch
->
numDollarTemplates
++
;
return
inTouch
->
numDollarTemplates
-
1
;
}
}
return
-
1
;
return
-
1
;
}
}
...
...
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