Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Just updated
Browse files Browse the repository at this point in the history
  • Loading branch information
jimtla committed Jun 14, 2010
2 parents 3612e66 + 69dab91 commit 68a1db9
Show file tree
Hide file tree
Showing 17 changed files with 480 additions and 133 deletions.
4 changes: 2 additions & 2 deletions VisualC/SDL.sln
@@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL", "SDL\SDL.vcproj", "{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLmain", "SDLmain\SDLmain.vcproj", "{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}"
Expand Down
30 changes: 20 additions & 10 deletions VisualC/SDL/SDL.vcproj
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Version="9.00"
Name="SDL"
ProjectGUID="{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}"
RootNamespace="SDL"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Expand Down Expand Up @@ -76,16 +77,21 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalOptions="/MACHINE:I386&#x0D;&#x0A;msvcrt.lib"
AdditionalDependencies="msimg32.lib winmm.lib"
OutputFile=".\Debug/SDL.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
IgnoreAllDefaultLibraries="true"
IgnoreAllDefaultLibraries="false"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/SDL.pdb"
SubSystem="2"
SubSystem="0"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary=".\Debug/SDL.lib"
Profile="true"
CLRThreadAttribute="0"
CLRUnmanagedCodeCheck="false"
/>
<Tool
Expand All @@ -106,9 +112,6 @@
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
Expand Down Expand Up @@ -185,6 +188,8 @@
IgnoreAllDefaultLibraries="true"
ProgramDatabaseFile=".\Release/SDL.pdb"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary=".\Release/SDL.lib"
/>
<Tool
Expand All @@ -205,9 +210,6 @@
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
Expand Down Expand Up @@ -928,6 +930,14 @@
RelativePath="..\..\src\timer\SDL_timer_c.h"
>
</File>
<File
RelativePath="..\..\src\events\SDL_touch.c"
>
</File>
<File
RelativePath="..\..\src\events\SDL_touch_c.h"
>
</File>
<File
RelativePath="..\..\src\video\SDL_video.c"
>
Expand Down
9 changes: 5 additions & 4 deletions VisualC/SDLmain/SDLmain.vcproj
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Version="9.00"
Name="SDLmain"
ProjectGUID="{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Expand All @@ -25,7 +26,7 @@
<Tool
Name="VCPreBuildEventTool"
Description="Making sure basic SDL headers are in place..."
CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY"
CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
/>
<Tool
Name="VCCustomBuildTool"
Expand Down Expand Up @@ -98,7 +99,7 @@
<Tool
Name="VCPreBuildEventTool"
Description="Making sure basic SDL headers are in place..."
CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY"
CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
/>
<Tool
Name="VCCustomBuildTool"
Expand Down Expand Up @@ -171,7 +172,7 @@
<Tool
Name="VCPreBuildEventTool"
Description="Making sure basic SDL headers are in place..."
CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY"
CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_win32.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_win32.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
/>
<Tool
Name="VCCustomBuildTool"
Expand Down
9 changes: 5 additions & 4 deletions include/SDL_touch.h
Expand Up @@ -41,8 +41,6 @@ extern "C" {
/* *INDENT-ON* */
#endif

typedef struct SDL_Touch SDL_Touch;
typedef struct SDL_Finger SDL_Finger;

struct SDL_Finger {
int id;
Expand All @@ -55,9 +53,11 @@ struct SDL_Finger {
int pressure;
};

typedef struct SDL_Touch SDL_Touch;
typedef struct SDL_Finger SDL_Finger;


struct SDL_Touch
{
struct SDL_Touch {

/* Free the touch when it's time */
void (*FreeTouch) (SDL_Touch * touch);
Expand Down Expand Up @@ -87,6 +87,7 @@ struct SDL_Touch
};



/* Function prototypes */

/**
Expand Down
178 changes: 89 additions & 89 deletions src/events/SDL_touch.c
Expand Up @@ -27,6 +27,8 @@
#include "SDL_events_c.h"
#include "../video/SDL_sysvideo.h"

#include <stdio.h>


static int SDL_num_touch = 0;
static SDL_Touch **SDL_touchPads = NULL;
Expand Down Expand Up @@ -99,9 +101,7 @@ int
SDL_AddTouch(const SDL_Touch * touch, char *name)
{
SDL_Touch **touchPads;
int selected_touch;
int index;
size_t length;
int index,length;

if (SDL_GetTouchIndexId(touch->id) != -1) {
SDL_SetError("Touch ID already in use");
Expand Down Expand Up @@ -252,27 +252,25 @@ SDL_AddFinger(SDL_Touch* touch,SDL_Finger* finger)
{
int index;
SDL_Finger **fingers;
size_t length;
//printf("Adding Finger...\n");
if (SDL_GetFingerIndexId(touch,finger->id) != -1) {
SDL_SetError("Finger ID already in use");
}

/* Add the touch to the list of touch */
if(touch->num_fingers >= touch->max_fingers){
printf("Making room for it!\n");
fingers = (SDL_Finger **) SDL_realloc(touch->fingers,
(touch->num_fingers + 1) * sizeof(SDL_Finger *));
touch->max_fingers = touch->num_fingers+1;
if (!fingers) {
SDL_OutOfMemory();
return -1;
}
else {
touch->max_fingers = touch->num_fingers+1;
touch->fingers = fingers;
//printf("Making room for it!\n");
fingers = (SDL_Finger **) SDL_realloc(touch->fingers,
(touch->num_fingers + 1) * sizeof(SDL_Finger *));
touch->max_fingers = touch->num_fingers+1;
if (!fingers) {
SDL_OutOfMemory();
return -1;
} else {
touch->max_fingers = touch->num_fingers+1;
touch->fingers = fingers;
}
}
}

index = touch->num_fingers;
//printf("Max_Fingers: %i Index: %i\n",touch->max_fingers,index);
Expand All @@ -295,13 +293,14 @@ SDL_DelFinger(SDL_Touch* touch,int fingerid)
SDL_Finger* finger = SDL_GetFinger(touch,fingerid);

if (!finger) {
return;
return -1;
}


SDL_free(finger);
touch->num_fingers--;
touch->fingers[index] = touch->fingers[touch->num_fingers];
return 0;
}


Expand Down Expand Up @@ -370,79 +369,80 @@ SDL_SendTouchMotion(int id, int fingerid, int relative,
return 0;
}

if(finger == NULL)
SDL_SendFingerDown(id,fingerid,SDL_TRUE,x,y,pressure);
else {
/* the relative motion is calculated regarding the last position */
if (relative) {
xrel = x;
yrel = y;
x = (finger->last_x + x);
y = (finger->last_y + y);
if(finger == NULL) {
SDL_SendFingerDown(id,fingerid,SDL_TRUE,x,y,pressure);
return 0;
} else {
if(x < 0) x = finger->last_x; /*If movement is only in one axis,*/
if(y < 0) y = finger->last_y; /*The other is marked as -1*/
if(pressure < 0) pressure = finger->last_pressure;
xrel = x - finger->last_x;
yrel = y - finger->last_y;
}

/* Drop events that don't change state */
if (!xrel && !yrel) {
#if 0
printf("Touch event didn't change state - dropped!\n");
#endif
return 0;
}

/* Update internal touch coordinates */

finger->x = x;
finger->y = y;

/*Should scale to window? Normalize? Maintain Aspect?*/
//SDL_GetWindowSize(touch->focus, &x_max, &y_max);

/* make sure that the pointers find themselves inside the windows */
/* only check if touch->xmax is set ! */
/*
if (x_max && touch->x > x_max) {
touch->x = x_max;
} else if (touch->x < 0) {
touch->x = 0;
}
if (y_max && touch->y > y_max) {
touch->y = y_max;
} else if (touch->y < 0) {
touch->y = 0;
}
*/
finger->xdelta = xrel;
finger->ydelta = yrel;
finger->pressure = pressure;



/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
SDL_Event event;
event.tfinger.type = SDL_FINGERMOTION;
event.tfinger.touchId = (Uint8) id;
event.tfinger.fingerId = (Uint8) fingerid;
event.tfinger.x = x;
event.tfinger.y = y;
event.tfinger.pressure = pressure;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
/* the relative motion is calculated regarding the last position */
if (relative) {
xrel = x;
yrel = y;
x = (finger->last_x + x);
y = (finger->last_y + y);
} else {
if(x < 0) x = finger->last_x; /*If movement is only in one axis,*/
if(y < 0) y = finger->last_y; /*The other is marked as -1*/
if(pressure < 0) pressure = finger->last_pressure;
xrel = x - finger->last_x;
yrel = y - finger->last_y;
}

/* Drop events that don't change state */
if (!xrel && !yrel) {
#if 0
printf("Touch event didn't change state - dropped!\n");
#endif
return 0;
}

/* Update internal touch coordinates */

finger->x = x;
finger->y = y;

/*Should scale to window? Normalize? Maintain Aspect?*/
//SDL_GetWindowSize(touch->focus, &x_max, &y_max);

/* make sure that the pointers find themselves inside the windows */
/* only check if touch->xmax is set ! */
/*
if (x_max && touch->x > x_max) {
touch->x = x_max;
} else if (touch->x < 0) {
touch->x = 0;
}
if (y_max && touch->y > y_max) {
touch->y = y_max;
} else if (touch->y < 0) {
touch->y = 0;
}
*/
finger->xdelta = xrel;
finger->ydelta = yrel;
finger->pressure = pressure;



/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
SDL_Event event;
event.tfinger.type = SDL_FINGERMOTION;
event.tfinger.touchId = (Uint8) id;
event.tfinger.fingerId = (Uint8) fingerid;
event.tfinger.x = x;
event.tfinger.y = y;
event.tfinger.pressure = pressure;
event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
}
finger->last_x = finger->x;
finger->last_y = finger->y;
finger->last_pressure = finger->pressure;
return posted;
}
finger->last_x = finger->x;
finger->last_y = finger->y;
finger->last_pressure = finger->pressure;
return posted;
}
}
int
SDL_SendTouchButton(int id, Uint8 state, Uint8 button)
Expand Down Expand Up @@ -483,7 +483,7 @@ SDL_SendTouchButton(int id, Uint8 state, Uint8 button)
if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event;
event.type = type;
event.tbutton.touchId = (Uint8) index;
event.tbutton.touchId = (Uint8) touch->id;
event.tbutton.state = state;
event.tbutton.button = button;
event.tbutton.windowID = touch->focus ? touch->focus->id : 0;
Expand Down

0 comments on commit 68a1db9

Please sign in to comment.