Windows 7 touch screen and SDL 1.2.14 |
lan.chih.hung
|
Hi Zeemvel,
Last week I got the same problem like you. But I have wrok around it. There are two way. way 1. change to SDL 1.3 way 2. copy some code from SDL 1.3. make patch at SDL 1.2 and rebuild SDL 1.2. 1. add touch function, struct declare in SDL_syswm_c.h #if WINVER < 0x0601 #ifndef WM_TOCUH #define WM_TOUCH 0x0240 #endif /* Touch input definitions */ #define TWF_FINETOUCH 1 #define TWF_WANTPALM 2 #define TOUCHEVENTF_MOVE 0x0001 #define TOUCHEVENTF_DOWN 0x0002 #define TOUCHEVENTF_UP 0x0004 DECLARE_HANDLE(HTOUCHINPUT); typedef struct _TOUCHINPUT { LONG x; LONG y; HANDLE hSource; DWORD dwID; DWORD dwFlags; DWORD dwMask; DWORD dwTime; ULONG_PTR dwExtraInfo; DWORD cxContact; DWORD cyContact; } TOUCHINPUT, *PTOUCHINPUT; extern BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT ); extern BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int ); extern BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG ); #endif /* WINVER < 0x0601 */ 2. in SDL_systemevents.c add function pointers #include "SDL_loadso.h" #if WINVER < 0x0601 BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT ); BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int ); BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG ); #endif /* WINVER < 0x0601 */ 3. in SDL_systemevents.c add code to int SDL_RegisterApp(char *name, Uint32 style, void *hInst) #ifdef WM_MOUSELEAVE /* Get the version of TrackMouseEvent() we use */ _TrackMouseEvent = NULL; handle = GetModuleHandle("USER32.DLL"); if ( handle ) { _TrackMouseEvent = (BOOL (WINAPI *)(TRACKMOUSEEVENT *))GetProcAddress(handle, "TrackMouseEvent"); } if ( _TrackMouseEvent == NULL ) { _TrackMouseEvent = WIN_TrackMouseEvent; } #endif /* WM_MOUSELEAVE */ #ifdef WM_TOUCH GetTouchInputInfo = NULL; CloseTouchInputHandle = NULL; RegisterTouchWindow = NULL; handle = GetModuleHandle("USER32.DLL"); if ( handle ) { GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) GetProcAddress(handle, "GetTouchInputInfo" ); CloseTouchInputHandle =(BOOL (WINAPI *)( HTOUCHINPUT )) GetProcAddress(handle, "CloseTouchInputHandle" ); RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) GetProcAddress(handle, "RegisterTouchWindow" ); } #endif #ifndef NO_GETKEYBOARDSTATE /* Initialise variables for SDL_ToUnicode() */ codepage = GetCodePage(); SDL_ToUnicode = Is9xME() ? ToUnicode9xME : ToUnicode; #endif 4.in SDL_systemevents.c add code to LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) #ifdef WM_TOUCH case WM_TOUCH: { UINT i, num_inputs = LOWORD(wParam); //you can copy codes from SDL 1.3. but it is not necessary if you just use mouse event return 0; } break; #endif 5. in SDL_dx5events.c & SDL_dibvideo.c add code #include "../wincommon/SDL_syswm_c.h" 6. the most important step, let Win7 OS know your ap accept touch message in SDL_dx5events.c & SDL_dibevents.c add code to int DX5_CreateWindow(_THIS) & int DIB_CreateWindow(_THIS) WIN_FlushMessageQueue(); #ifdef WM_TOUCH /* Enable multi-touch */ if (RegisterTouchWindow) { RegisterTouchWindow(SDL_Window, (TWF_FINETOUCH|TWF_WANTPALM)); } #endif That is all I done. |
|||||||||||
|