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
ca4b8205
Commit
ca4b8205
authored
Mar 09, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed testgesture to work on the iPhone
parent
5f55b90c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
15 deletions
+26
-15
testgesture.c
test/testgesture.c
+26
-15
No files found.
test/testgesture.c
View file @
ca4b8205
...
@@ -5,10 +5,11 @@
...
@@ -5,10 +5,11 @@
*/
*/
#include <stdio.h>
#include <stdio.h>
#include <SDL.h>
#include <math.h>
#include <math.h>
#include <SDL_touch.h>
#include <SDL_gesture.h>
#include "SDL.h"
#include "SDL_touch.h"
#include "SDL_gesture.h"
/* Make sure we have good macros for printing 32 and 64 bit values */
/* Make sure we have good macros for printing 32 and 64 bit values */
...
@@ -44,9 +45,11 @@
...
@@ -44,9 +45,11 @@
#define VERBOSE SDL_FALSE
#define VERBOSE SDL_FALSE
SDL_Window
*
window
;
SDL_Event
events
[
EVENT_BUF_SIZE
];
SDL_Event
events
[
EVENT_BUF_SIZE
];
int
eventWrite
;
int
eventWrite
;
int
colors
[
7
]
=
{
0xFF
,
0xFF00
,
0xFF0000
,
0xFFFF00
,
0x00FFFF
,
0xFF00FF
,
0xFFFFFF
};
int
colors
[
7
]
=
{
0xFF
,
0xFF00
,
0xFF0000
,
0xFFFF00
,
0x00FFFF
,
0xFF00FF
,
0xFFFFFF
};
typedef
struct
{
typedef
struct
{
...
@@ -134,14 +137,15 @@ void drawKnob(SDL_Surface* screen,Knob k) {
...
@@ -134,14 +137,15 @@ void drawKnob(SDL_Surface* screen,Knob k) {
void
DrawScreen
(
SDL_Surface
*
screen
)
void
DrawScreen
(
SDL_Surface
*
screen
)
{
{
int
x
,
y
,
i
;
int
i
;
if
(
SDL_MUSTLOCK
(
screen
))
#if 1
{
SDL_FillRect
(
screen
,
NULL
,
0
);
if
(
SDL_LockSurface
(
screen
)
<
0
)
return
;
#else
}
int
x
,
y
;
for
(
y
=
0
;
y
<
screen
->
h
;
y
++
)
for
(
y
=
0
;
y
<
screen
->
h
;
y
++
)
for
(
x
=
0
;
x
<
screen
->
w
;
x
++
)
for
(
x
=
0
;
x
<
screen
->
w
;
x
++
)
setpix
(
screen
,(
float
)
x
,(
float
)
y
,((
x
%
255
)
<<
16
)
+
((
y
%
255
)
<<
8
)
+
(
x
+
y
)
%
255
);
setpix
(
screen
,(
float
)
x
,(
float
)
y
,((
x
%
255
)
<<
16
)
+
((
y
%
255
)
<<
8
)
+
(
x
+
y
)
%
255
);
#endif
//draw Touch History
//draw Touch History
for
(
i
=
SDL_max
(
0
,
eventWrite
-
EVENT_BUF_SIZE
);
i
<
eventWrite
;
i
++
)
{
for
(
i
=
SDL_max
(
0
,
eventWrite
-
EVENT_BUF_SIZE
);
i
<
eventWrite
;
i
++
)
{
...
@@ -175,14 +179,20 @@ void DrawScreen(SDL_Surface* screen)
...
@@ -175,14 +179,20 @@ void DrawScreen(SDL_Surface* screen)
if
(
knob
.
p
.
x
>
0
)
if
(
knob
.
p
.
x
>
0
)
drawKnob
(
screen
,
knob
);
drawKnob
(
screen
,
knob
);
if
(
SDL_MUSTLOCK
(
screen
))
SDL_UnlockSurface
(
screen
);
SDL_UpdateWindowSurface
(
window
);
SDL_Flip
(
screen
);
}
}
SDL_Surface
*
initScreen
(
int
width
,
int
height
)
SDL_Surface
*
initScreen
(
int
width
,
int
height
)
{
{
return
SDL_SetVideoMode
(
width
,
height
,
DEPTH
,
if
(
!
window
)
{
SDL_HWSURFACE
|
SDL_RESIZABLE
);
window
=
SDL_CreateWindow
(
"Gesture Test"
,
SDL_WINDOWPOS_CENTERED
,
SDL_WINDOWPOS_CENTERED
,
WIDTH
,
HEIGHT
,
SDL_WINDOW_RESIZABLE
);
}
if
(
!
window
)
{
return
NULL
;
}
return
SDL_GetWindowSurface
(
window
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
...
@@ -237,13 +247,14 @@ int main(int argc, char* argv[])
...
@@ -237,13 +247,14 @@ int main(int argc, char* argv[])
break
;
break
;
}
}
break
;
break
;
case
SDL_
VIDEORESIZE
:
case
SDL_
WINDOWEVENT
:
if
(
!
(
screen
=
initScreen
(
event
.
resize
.
w
,
if
(
event
.
window
.
event
==
SDL_WINDOWEVENT_RESIZED
)
{
event
.
resize
.
h
)))
if
(
!
(
screen
=
initScreen
(
0
,
0
)))
{
{
SDL_Quit
();
SDL_Quit
();
return
1
;
return
1
;
}
}
}
break
;
break
;
case
SDL_FINGERMOTION
:
case
SDL_FINGERMOTION
:
#if VERBOSE
#if VERBOSE
...
...
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