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
67ddc464
Commit
67ddc464
authored
Jul 17, 2010
by
Jim Grandpre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fixes, now using RWops instead of File pointers.
parent
987edb15
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
26 deletions
+46
-26
SDL_gesture.h
include/SDL_gesture.h
+3
-3
SDL_gesture.c
src/events/SDL_gesture.c
+30
-15
gestureSDLTest.c
touchTest/gestureSDLTest.c
+13
-8
No files found.
include/SDL_gesture.h
View file @
67ddc464
...
@@ -57,7 +57,7 @@ extern "C" {
...
@@ -57,7 +57,7 @@ extern "C" {
*
*
*
*
*/
*/
extern
DECLSPEC
int
SDLCALL
SDL_SaveAllDollarTemplates
(
FILE
*
fp
);
extern
DECLSPEC
int
SDLCALL
SDL_SaveAllDollarTemplates
(
SDL_RWops
*
src
);
/**
/**
* \brief Save a currently loaded Dollar Gesture template
* \brief Save a currently loaded Dollar Gesture template
...
@@ -65,7 +65,7 @@ extern "C" {
...
@@ -65,7 +65,7 @@ extern "C" {
*
*
*/
*/
extern
DECLSPEC
int
extern
DECLSPEC
int
SDLCALL
SDL_SaveDollarTemplate
(
unsigned
long
gestureId
,
FILE
*
fp
);
SDLCALL
SDL_SaveDollarTemplate
(
unsigned
long
gestureId
,
SDL_RWops
*
src
);
/**
/**
...
@@ -73,7 +73,7 @@ extern "C" {
...
@@ -73,7 +73,7 @@ extern "C" {
*
*
*
*
*/
*/
extern
DECLSPEC
int
SDLCALL
SDL_LoadDollarTemplates
(
int
touchId
,
FILE
*
fp
);
extern
DECLSPEC
int
SDLCALL
SDL_LoadDollarTemplates
(
int
touchId
,
SDL_RWops
*
src
);
...
...
src/events/SDL_gesture.c
View file @
67ddc464
...
@@ -110,40 +110,50 @@ unsigned long SDL_HashDollar(Point* points) {
...
@@ -110,40 +110,50 @@ unsigned long SDL_HashDollar(Point* points) {
return
hash
;
return
hash
;
}
}
int
SaveTemplate
(
DollarTemplate
*
templ
,
FILE
*
fp
)
{
int
SaveTemplate
(
DollarTemplate
*
templ
,
SDL_RWops
*
src
)
{
if
(
src
==
NULL
)
return
0
;
int
i
;
int
i
;
fprintf
(
fp
,
"%lu "
,
templ
->
hash
);
//No Longer storing the Hash, rehash on load
//fprintf(fp,"%lu ",templ->hash);
//if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0;
/*
for(i = 0;i < DOLLARNPOINTS;i++) {
for(i = 0;i < DOLLARNPOINTS;i++) {
fprintf(fp,"%i %i ",(int)templ->path[i].x,(int)templ->path[i].y);
fprintf(fp,"%i %i ",(int)templ->path[i].x,(int)templ->path[i].y);
}
}
fprintf(fp,"\n");
fprintf(fp,"\n");
*/
if
(
SDL_RWwrite
(
src
,
templ
->
path
,
sizeof
(
templ
->
path
[
0
]),
DOLLARNPOINTS
)
!=
DOLLARNPOINTS
)
return
0
;
return
1
;
}
}
int
SDL_SaveAllDollarTemplates
(
FILE
*
fp
)
{
int
SDL_SaveAllDollarTemplates
(
SDL_RWops
*
src
)
{
int
i
,
j
,
rtrn
=
0
;
int
i
,
j
,
rtrn
=
0
;
for
(
i
=
0
;
i
<
numGestureTouches
;
i
++
)
{
for
(
i
=
0
;
i
<
numGestureTouches
;
i
++
)
{
GestureTouch
*
touch
=
&
gestureTouch
[
i
];
GestureTouch
*
touch
=
&
gestureTouch
[
i
];
for
(
j
=
0
;
j
<
touch
->
numDollarTemplates
;
j
++
)
{
for
(
j
=
0
;
j
<
touch
->
numDollarTemplates
;
j
++
)
{
rtrn
+=
SaveTemplate
(
&
touch
->
dollarTemplate
[
i
],
fp
);
rtrn
+=
SaveTemplate
(
&
touch
->
dollarTemplate
[
i
],
src
);
}
}
}
}
return
rtrn
;
return
rtrn
;
}
}
int
SDL_SaveDollarTemplate
(
unsigned
long
gestureId
,
FILE
*
fp
)
{
int
SDL_SaveDollarTemplate
(
unsigned
long
gestureId
,
SDL_RWops
*
src
)
{
int
i
,
j
;
int
i
,
j
;
for
(
i
=
0
;
i
<
numGestureTouches
;
i
++
)
{
for
(
i
=
0
;
i
<
numGestureTouches
;
i
++
)
{
GestureTouch
*
touch
=
&
gestureTouch
[
i
];
GestureTouch
*
touch
=
&
gestureTouch
[
i
];
for
(
j
=
0
;
j
<
touch
->
numDollarTemplates
;
j
++
)
{
for
(
j
=
0
;
j
<
touch
->
numDollarTemplates
;
j
++
)
{
if
(
touch
->
dollarTemplate
[
i
].
hash
==
gestureId
)
{
if
(
touch
->
dollarTemplate
[
i
].
hash
==
gestureId
)
{
return
SaveTemplate
(
&
touch
->
dollarTemplate
[
i
],
fp
);
return
SaveTemplate
(
&
touch
->
dollarTemplate
[
i
],
src
);
}
}
}
}
}
}
}
}
int
SDL_LoadDollarTemplates
(
int
touchId
,
FILE
*
fp
)
{
int
SDL_LoadDollarTemplates
(
int
touchId
,
SDL_RWops
*
src
)
{
if
(
src
==
NULL
)
return
0
;
int
i
,
loaded
=
0
;
int
i
,
loaded
=
0
;
GestureTouch
*
touch
=
NULL
;
GestureTouch
*
touch
=
NULL
;
if
(
touchId
>=
0
)
{
if
(
touchId
>=
0
)
{
...
@@ -153,9 +163,10 @@ int SDL_LoadDollarTemplates(int touchId, FILE *fp) {
...
@@ -153,9 +163,10 @@ int SDL_LoadDollarTemplates(int touchId, FILE *fp) {
if
(
touch
==
NULL
)
return
-
1
;
if
(
touch
==
NULL
)
return
-
1
;
}
}
while
(
!
feof
(
fp
)
)
{
while
(
1
)
{
DollarTemplate
templ
;
DollarTemplate
templ
;
fscanf
(
fp
,
"%lu "
,
&
templ
.
hash
);
//fscanf(fp,"%lu ",&templ.hash);
/*
for(i = 0;i < DOLLARNPOINTS; i++) {
for(i = 0;i < DOLLARNPOINTS; i++) {
int x,y;
int x,y;
if(fscanf(fp,"%i %i ",&x,&y) != 2) break;
if(fscanf(fp,"%i %i ",&x,&y) != 2) break;
...
@@ -163,22 +174,26 @@ int SDL_LoadDollarTemplates(int touchId, FILE *fp) {
...
@@ -163,22 +174,26 @@ int SDL_LoadDollarTemplates(int touchId, FILE *fp) {
templ.path[i].y = y;
templ.path[i].y = y;
}
}
fscanf(fp,"\n");
fscanf(fp,"\n");
*/
if
(
SDL_RWread
(
src
,
templ
.
path
,
sizeof
(
templ
.
path
[
0
]),
DOLLARNPOINTS
)
<
DOLLARNPOINTS
)
break
;
if
(
touchId
>=
0
)
{
if
(
touchId
>=
0
)
{
if
(
SDL_AddDollarGesture
(
touch
,
templ
))
loaded
++
;
printf
(
"Adding loaded gesture to 1 touch
\n
"
);
if
(
SDL_AddDollarGesture
(
touch
,
templ
.
path
))
loaded
++
;
}
}
else
{
else
{
printf
(
"Adding to: %i touches
\n
"
,
numGestureTouches
);
for
(
i
=
0
;
i
<
numGestureTouches
;
i
++
)
{
for
(
i
=
0
;
i
<
numGestureTouches
;
i
++
)
{
if
(
gestureTouch
[
i
].
id
==
touchId
)
{
touch
=
&
gestureTouch
[
i
];
touch
=
&
gestureTouch
[
i
]
;
printf
(
"Adding loaded gesture to + touches
\n
"
)
;
SDL_AddDollarGesture
(
touch
,
templ
);
//TODO: What if this fails?
}
SDL_AddDollarGesture
(
touch
,
templ
.
path
);
}
}
loaded
++
;
loaded
++
;
}
}
}
}
return
1
;
return
loaded
;
}
}
...
...
touchTest/gestureSDLTest.c
View file @
67ddc464
...
@@ -305,16 +305,21 @@ int main(int argc, char* argv[])
...
@@ -305,16 +305,21 @@ int main(int argc, char* argv[])
SDL_RecordGesture
(
-
1
);
SDL_RecordGesture
(
-
1
);
}
}
else
if
(
event
.
key
.
keysym
.
sym
==
115
)
{
else
if
(
event
.
key
.
keysym
.
sym
==
115
)
{
FILE
*
fp
;
SDL_RWops
*
src
;
fp
=
fopen
(
"gestureSave"
,
"w"
);
//fp = fopen("gestureSave","w");
SDL_SaveAllDollarTemplates
(
fp
);
src
=
SDL_RWFromFile
(
"gestureSave"
,
"w"
);
fclose
(
fp
);
printf
(
"Wrote %i templates
\n
"
,
SDL_SaveAllDollarTemplates
(
src
));
//fclose(fp);
SDL_RWclose
(
src
);
}
}
else
if
(
event
.
key
.
keysym
.
sym
==
108
)
{
else
if
(
event
.
key
.
keysym
.
sym
==
108
)
{
FILE
*
fp
;
SDL_RWops
*
src
;
fp
=
fopen
(
"gestureSave"
,
"r"
);
//fp = fopen("gestureSave","r");
printf
(
"Loaded: %i
\n
"
,
SDL_LoadDollarTemplates
(
-
1
,
fp
));
src
=
SDL_RWFromFile
(
"gestureSave"
,
"r"
);
fclose
(
fp
);
printf
(
"Loaded: %i
\n
"
,
SDL_LoadDollarTemplates
(
-
1
,
src
));
//fclose(fp);
SDL_RWclose
(
src
);
}
}
//keypress = 1;
//keypress = 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