# HG changeset patch # User Jim Grandpre # Date 1276494368 14400 # Node ID 78f6e0b80d1e06cab61becd17923904a5eccc720 # Parent 86c171888eee59d18599ca944f2386a59f648db0# Parent 7ad7a473b086ec060b6f771e137be8b73ac4a06c Just updated diff -r 86c171888eee -r 78f6e0b80d1e VisualC/SDL.sln --- a/VisualC/SDL.sln Mon Jun 14 01:44:04 2010 -0400 +++ b/VisualC/SDL.sln Mon Jun 14 01:46:08 2010 -0400 @@ -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}" diff -r 86c171888eee -r 78f6e0b80d1e VisualC/SDL/SDL.vcproj --- a/VisualC/SDL/SDL.vcproj Mon Jun 14 01:44:04 2010 -0400 +++ b/VisualC/SDL/SDL.vcproj Mon Jun 14 01:46:08 2010 -0400 @@ -1,10 +1,11 @@ - @@ -185,6 +188,8 @@ IgnoreAllDefaultLibraries="true" ProgramDatabaseFile=".\Release/SDL.pdb" SubSystem="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" ImportLibrary=".\Release/SDL.lib" /> - @@ -929,6 +931,14 @@ > + + + + diff -r 86c171888eee -r 78f6e0b80d1e VisualC/SDLmain/SDLmain.vcproj --- a/VisualC/SDLmain/SDLmain.vcproj Mon Jun 14 01:44:04 2010 -0400 +++ b/VisualC/SDLmain/SDLmain.vcproj Mon Jun 14 01:46:08 2010 -0400 @@ -1,9 +1,10 @@ + static int SDL_num_touch = 0; static SDL_Touch **SDL_touchPads = NULL; @@ -99,9 +101,7 @@ 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"); @@ -252,7 +252,6 @@ { 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"); @@ -260,19 +259,18 @@ /* 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); @@ -295,13 +293,14 @@ 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; } @@ -370,79 +369,80 @@ 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; + /* 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; } - - /* 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; - } } int SDL_SendTouchButton(int id, Uint8 state, Uint8 button) @@ -483,7 +483,7 @@ 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; diff -r 86c171888eee -r 78f6e0b80d1e src/events/SDL_touch_c.h --- a/src/events/SDL_touch_c.h Mon Jun 14 01:44:04 2010 -0400 +++ b/src/events/SDL_touch_c.h Mon Jun 14 01:46:08 2010 -0400 @@ -64,8 +64,11 @@ /* Shutdown the touch subsystem */ extern void SDL_TouchQuit(void); -/* FIXME: Where do these functions go in this header? */ -extern void SDL_ChangeEnd(int id, int end); +/* Get the index of a touch device */ +extern int SDL_GetTouchIndexId(int id); + + + #endif /* _SDL_touch_c_h */ diff -r 86c171888eee -r 78f6e0b80d1e src/video/win32/SDL_win32events.c --- a/src/video/win32/SDL_win32events.c Mon Jun 14 01:44:04 2010 -0400 +++ b/src/video/win32/SDL_win32events.c Mon Jun 14 01:46:08 2010 -0400 @@ -20,9 +20,9 @@ slouken@libsdl.org */ -#if (_WIN32_WINNT < 0x0501) +#if (_WIN32_WINNT < 0x601) #undef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 +#define _WIN32_WINNT 0x601 #endif #include "SDL_config.h" @@ -32,11 +32,14 @@ #include "SDL_vkeys.h" #include "../../events/SDL_events_c.h" -/*#define WMMSG_DEBUG*/ + + +#define WMMSG_DEBUG #ifdef WMMSG_DEBUG -#include +#include #include "wmmsg.h" #endif +//#include /* Masks for processing the windows KEYDOWN and KEYUP messages */ #define REPEATED_KEYMASK (1<<30) @@ -125,9 +128,10 @@ if (!data) { return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); } + #ifdef WMMSG_DEBUG - { - FILE *log = fopen("wmmsg.txt", "a"); + { + FILE *log = fopen("wmmsg.txt", "a"); fprintf(log, "Received windows message: %p ", hwnd); if (msg > MAX_WMMSG) { fprintf(log, "%d", msg); @@ -643,7 +647,39 @@ } returnCode = 0; break; - } + case WM_TOUCH: + { + //printf("Got Touch Event!\n"); + + FILE *log = fopen("wmmsg.txt", "a"); + fprintf(log, "Received Touch Message: %p ", hwnd); + if (msg > MAX_WMMSG) { + fprintf(log, "%d", msg); + } else { + fprintf(log, "%s", wmtab[msg]); + } + fprintf(log, "WM_TOUCH = %d -- 0x%X, 0x%X\n",msg, wParam, lParam); + fclose(log); + + } + break; + case WM_GESTURE: + { + //printf("Got Touch Event!\n"); + + FILE *log = fopen("wmmsg.txt", "a"); + fprintf(log, "Received Gesture Message: %p ", hwnd); + if (msg > MAX_WMMSG) { + fprintf(log, "%d", msg); + } else { + fprintf(log, "%s", wmtab[msg]); + } + fprintf(log, "WM_GESTURE = %d -- 0x%X, 0x%X\n",msg, wParam, lParam); + fclose(log); + + } + break; + } /* If there's a window proc, assume it's going to handle messages */ if (data->wndproc) { diff -r 86c171888eee -r 78f6e0b80d1e src/video/win32/SDL_win32video.h --- a/src/video/win32/SDL_win32video.h Mon Jun 14 01:44:04 2010 -0400 +++ b/src/video/win32/SDL_win32video.h Mon Jun 14 01:46:08 2010 -0400 @@ -30,7 +30,14 @@ #define STRICT #define UNICODE #undef WINVER -#define WINVER 0x500 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */ +//#define WINVER 0x500 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */ +#define WINVER 0x601 /* Need 0x600 (_WIN32_WINNT_WIN7) for WM_Touch */ +#if (_WIN32_WINNT < 0x601) +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x601 +#endif + + #include #if SDL_VIDEO_RENDER_D3D diff -r 86c171888eee -r 78f6e0b80d1e src/video/win32/SDL_win32window.c --- a/src/video/win32/SDL_win32window.c Mon Jun 14 01:44:04 2010 -0400 +++ b/src/video/win32/SDL_win32window.c Mon Jun 14 01:46:08 2010 -0400 @@ -256,7 +256,8 @@ WIN_SetError("Couldn't create window"); return -1; } - + /*Disable Tablet support, replace with multi-touch.*/ +#if 0 /* we're configuring the tablet data. See Wintab reference for more info */ if (videodata->wintabDLL && videodata->WTInfoA(WTI_DEFSYSCTX, 0, &lc) != 0) { @@ -290,6 +291,9 @@ } g_hCtx[window->id] = videodata->WTOpenA(hwnd, &lc, TRUE); } +#else + //RegisterTouchWindow(hwnd, 0); +#endif #ifndef _WIN32_WCE /* has no RawInput */ /* we're telling the window, we want it to report raw input events from mice */ Rid.usUsagePage = 0x01; diff -r 86c171888eee -r 78f6e0b80d1e src/video/win32/wmmsg.h --- a/src/video/win32/wmmsg.h Mon Jun 14 01:44:04 2010 -0400 +++ b/src/video/win32/wmmsg.h Mon Jun 14 01:46:08 2010 -0400 @@ -283,7 +283,7 @@ "WM_INITMENU", "WM_INITMENUPOPUP", "UNKNOWN (280)", - "UNKNOWN (281)", + "WM_GESTURE", "UNKNOWN (282)", "UNKNOWN (283)", "UNKNOWN (284)", @@ -578,7 +578,7 @@ "UNKNOWN (573)", "UNKNOWN (574)", "UNKNOWN (575)", - "UNKNOWN (576)", + "WM_TOUCH", "UNKNOWN (577)", "UNKNOWN (578)", "UNKNOWN (579)", diff -r 86c171888eee -r 78f6e0b80d1e touchTest/touchTest.c --- a/touchTest/touchTest.c Mon Jun 14 01:44:04 2010 -0400 +++ b/touchTest/touchTest.c Mon Jun 14 01:46:08 2010 -0400 @@ -3,6 +3,8 @@ #include #include + + #define PI 3.1415926535897 #define WIDTH 640 #define HEIGHT 480 @@ -32,7 +34,7 @@ void handler (int sig) { - printf ("\exiting...(%d)\n", sig); + printf ("exiting...(%d)\n", sig); exit (0); } @@ -53,7 +55,7 @@ colour = SDL_MapRGB( screen->format, (col>>16)&0xFF, (col>>8)&0xFF, col&0xFF); - pixmem32 = (Uint32*) screen->pixels + y*screen->pitch/BPP + x; + pixmem32 = (Uint32*) screen->pixels + y*screen->pitch/screen->format->BytesPerPixel + x; //TODO : Check this. May cause crash. *pixmem32 = colour; } @@ -81,7 +83,7 @@ void DrawScreen(SDL_Surface* screen, int h) { - int x, y, xm,ym,c; + int x, y, xm,ym,c,i; if(SDL_MUSTLOCK(screen)) { if(SDL_LockSurface(screen) < 0) return; @@ -98,9 +100,10 @@ setpix(screen,x,y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255); } } + drawCircle(screen,mousx,mousy,-30,0xFFFFFF); - int i; + for(i=0;i= 0 && finger[i].p.y >= 0) if(finger[i].pressure > 0) @@ -131,8 +134,8 @@ memset(keystat,0,512*sizeof(keystat[0])); if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1; - - if (!(screen = initScreen(WIDTH,HEIGHT))) + screen = initScreen(WIDTH,HEIGHT); + if (!screen) { SDL_Quit(); return 1; @@ -179,21 +182,22 @@ ; //printf("Finger: %i,x: %i, y: %i\n",event.tfinger.fingerId, // event.tfinger.x,event.tfinger.y); - SDL_Touch* inTouch = SDL_GetTouch(event.tfinger.touchId); - SDL_Finger* inFinger = SDL_GetFinger(inTouch,event.tfinger.fingerId); - + //SDL_Touch *inTouch = SDL_GetTouch(event.tfinger.touchId); + //SDL_Finger *inFinger = SDL_GetFinger(inTouch,event.tfinger.fingerId); + /* finger[event.tfinger.fingerId].p.x = ((float)event.tfinger.x)/ inTouch->xres; finger[event.tfinger.fingerId].p.y = ((float)event.tfinger.y)/ inTouch->yres; finger[event.tfinger.fingerId].pressure = - ((float)event.tfinger.pressure)/inTouch->pressureres; - + ((float)event.tfinger.pressure)/inTouch->pressureres;*/ + /* printf("Finger: %i, Pressure: %f Pressureres: %i\n", event.tfinger.fingerId, finger[event.tfinger.fingerId].pressure, inTouch->pressureres); + */ //printf("Finger: %i, pressure: %f\n",event.tfinger.fingerId, // finger[event.tfinger.fingerId].pressure); @@ -215,6 +219,7 @@ } //And draw DrawScreen(screen,h); + printf("Things\n"); /* for(i=0;i<512;i++) if(keystat[i]) printf("%i\n",i); diff -r 86c171888eee -r 78f6e0b80d1e touchTest/touchTest2/touchTest2.ncb Binary file touchTest/touchTest2/touchTest2.ncb has changed diff -r 86c171888eee -r 78f6e0b80d1e touchTest/touchTest2/touchTest2.sln --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/touchTest/touchTest2/touchTest2.sln Mon Jun 14 01:46:08 2010 -0400 @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "touchTest2", "touchTest2\touchTest2.vcproj", "{42BC83F1-CF20-4CEC-AC81-12EA804639E2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {42BC83F1-CF20-4CEC-AC81-12EA804639E2}.Debug|Win32.ActiveCfg = Debug|Win32 + {42BC83F1-CF20-4CEC-AC81-12EA804639E2}.Debug|Win32.Build.0 = Debug|Win32 + {42BC83F1-CF20-4CEC-AC81-12EA804639E2}.Release|Win32.ActiveCfg = Release|Win32 + {42BC83F1-CF20-4CEC-AC81-12EA804639E2}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff -r 86c171888eee -r 78f6e0b80d1e touchTest/touchTest2/touchTest2.suo Binary file touchTest/touchTest2/touchTest2.suo has changed diff -r 86c171888eee -r 78f6e0b80d1e touchTest/touchTest2/touchTest2/SDL.dll Binary file touchTest/touchTest2/touchTest2/SDL.dll has changed diff -r 86c171888eee -r 78f6e0b80d1e touchTest/touchTest2/touchTest2/touchTest2.vcproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/touchTest/touchTest2/touchTest2/touchTest2.vcproj Mon Jun 14 01:46:08 2010 -0400 @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 86c171888eee -r 78f6e0b80d1e touchTest/touchTest2/touchTest2/touchTest2.vcproj.jgran-virtualPC.jgran.user --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/touchTest/touchTest2/touchTest2/touchTest2.vcproj.jgran-virtualPC.jgran.user Mon Jun 14 01:46:08 2010 -0400 @@ -0,0 +1,65 @@ + + + + + + + + + + +