Implementation finished gsoc2008_manymouse
authorSzymon Wilczek
Thu, 31 Jul 2008 14:41:48 +0000
branchgsoc2008_manymouse
changeset 377081b649bad6d2
parent 3769 fe32943f86ec
child 3771 8cc36a399a12
Implementation finished
src/events/SDL_mouse.c
src/video/win32/SDL_win32events.c
src/video/win32/SDL_win32mouse.c
src/video/win32/SDL_win32video.c
src/video/win32/SDL_win32window.c
     1.1 --- a/src/events/SDL_mouse.c	Wed Jul 30 16:20:32 2008 +0000
     1.2 +++ b/src/events/SDL_mouse.c	Thu Jul 31 14:41:48 2008 +0000
     1.3 @@ -330,6 +330,8 @@
     1.4  {
     1.5      int index=SDL_GetIndexById(id);
     1.6      int posted=0;
     1.7 +	last_x=x;
     1.8 +	last_y=y;
     1.9      if(SDL_ProcessEvents[type]==SDL_ENABLE)
    1.10      {
    1.11          SDL_Event event;
     2.1 --- a/src/video/win32/SDL_win32events.c	Wed Jul 30 16:20:32 2008 +0000
     2.2 +++ b/src/video/win32/SDL_win32events.c	Thu Jul 31 14:41:48 2008 +0000
     2.3 @@ -62,6 +62,7 @@
     2.4  extern HCTX* g_hCtx;
     2.5  extern HANDLE* mice;
     2.6  extern int total_mice;
     2.7 +extern int tablet;
     2.8  
     2.9  int pressure=0;
    2.10  
    2.11 @@ -146,13 +147,16 @@
    2.12  	case WT_PROXIMITY:
    2.13  		{
    2.14  			int h_context=LOWORD(lParam);
    2.15 +			LPPOINT point;
    2.16 +			GetCursorPos(&point);
    2.17 +			ScreenToClient(hwnd, &point);
    2.18  			if(h_context==0)
    2.19  			{
    2.20 -				SDL_SendProximity(0, 0, 0, SDL_PROXIMITYOUT);
    2.21 +				SDL_SendProximity(tablet, (int)(&point->x),(int)(&point->y), SDL_PROXIMITYOUT);
    2.22  			}
    2.23  			else
    2.24  			{
    2.25 -				SDL_SendProximity(0, 0, 0, SDL_PROXIMITYIN);
    2.26 +				SDL_SendProximity(tablet, (int)(&point->x),(int)(&point->y), SDL_PROXIMITYIN);
    2.27  			}
    2.28  		}
    2.29  		break;
    2.30 @@ -202,74 +206,6 @@
    2.31              return (0);
    2.32          }
    2.33          break;
    2.34 -	case WT_CTXOPEN:
    2.35 -		{
    2.36 -			SDL_SendMouseMotion(0,1,1,0,0);
    2.37 -			SDL_SendMouseMotion(0,1,-1,0,0);
    2.38 -		}
    2.39 -    /*case WM_MOUSEMOVE:
    2.40 -        {
    2.41 -			LPBYTE lpb;
    2.42 -			const RAWINPUTHEADER *header;
    2.43 -            int index;
    2.44 -			int i;
    2.45 -			int size=0;
    2.46 -            SDL_Mouse *mouse;
    2.47 -            int x, y;
    2.48 -
    2.49 -            //index = data->videodata->mouse;
    2.50 -			GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size, sizeof (RAWINPUTHEADER));
    2.51 -			lpb = SDL_malloc(size*sizeof(LPBYTE));
    2.52 -			GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size, sizeof (RAWINPUTHEADER));
    2.53 -			raw = (RAWINPUT *) lpb;
    2.54 -			header = &raw->header;
    2.55 -			for(i=0;i<total_mice;++i)
    2.56 -			{
    2.57 -				if(mice[i]==header->hDevice)
    2.58 -				{
    2.59 -					index=i;
    2.60 -					break;
    2.61 -				}
    2.62 -			}
    2.63 -            mouse = SDL_GetMouse(index);
    2.64 -
    2.65 -            if (mouse->focus != data->windowID) {
    2.66 -                TRACKMOUSEEVENT tme;
    2.67 -
    2.68 -                tme.cbSize = sizeof(tme);
    2.69 -                tme.dwFlags = TME_LEAVE;
    2.70 -                tme.hwndTrack = hwnd;
    2.71 -                TrackMouseEvent(&tme);
    2.72 -
    2.73 -                SDL_SetMouseFocus(index, data->windowID);
    2.74 -            }
    2.75 -
    2.76 -            /* mouse has moved within the window */
    2.77 -            //x = LOWORD(lParam);
    2.78 -            //y = HIWORD(lParam);
    2.79 -			//printf("index: %d\n",index);
    2.80 -			/*if (WTPacketsPeek(g_hCtx[data->windowID],1,&packet))
    2.81 -				{
    2.82 -					pressure=(int)packet.pkNormalPressure;
    2.83 -				}*/
    2.84 -            /*if (mouse->relative_mode) {
    2.85 -                int w, h;
    2.86 -                POINT center;
    2.87 -                SDL_GetWindowSize(data->windowID, &w, &h);
    2.88 -                center.x = (w / 2);
    2.89 -                center.y = (h / 2);
    2.90 -                x -= center.x;
    2.91 -                y -= center.y;
    2.92 -                if (x || y) {
    2.93 -                    ClientToScreen(hwnd, &center);
    2.94 -                    SetCursorPos(center.x, center.y);
    2.95 -					SDL_SendMouseMotion(index, 1, x, y,pressure);
    2.96 -                }
    2.97 -            } else {
    2.98 -					SDL_SendMouseMotion(index, 0, x, y,pressure);
    2.99 -            }
   2.100 -        }
   2.101 -        return (0);*/
   2.102  	case WM_INPUT:
   2.103  		{
   2.104  			LPBYTE lpb;
   2.105 @@ -287,7 +223,6 @@
   2.106  			GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size, sizeof (RAWINPUTHEADER));
   2.107  			raw = (RAWINPUT *) lpb;
   2.108  			header = &raw->header;
   2.109 -			//raw_mouse=&raw->data.mouse;
   2.110  			flags=raw->data.mouse.usButtonFlags;
   2.111  			for(i=0;i<total_mice;++i)
   2.112  			{
   2.113 @@ -302,7 +237,14 @@
   2.114  			ScreenToClient(hwnd, &point);
   2.115  			SDL_GetWindowSize(data->windowID, &w, &h);
   2.116  			SDL_UpdateCoordinates(w,h);
   2.117 -			SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),pressure);
   2.118 +			if(i==tablet)
   2.119 +			{
   2.120 +				SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),pressure);
   2.121 +			}
   2.122 +			else
   2.123 +			{
   2.124 +				SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),0);
   2.125 +			}
   2.126  			if(flags & RI_MOUSE_BUTTON_1_DOWN)
   2.127  			{
   2.128  				SDL_SendMouseButton(index,SDL_PRESSED,SDL_BUTTON_LEFT);
   2.129 @@ -327,6 +269,13 @@
   2.130  			{
   2.131  				SDL_SendMouseButton(index,SDL_RELEASED,SDL_BUTTON_RIGHT);
   2.132  			}
   2.133 +			if(flags & RI_MOUSE_WHEEL)
   2.134 +			{
   2.135 +				if(raw->data.mouse.usButtonData!=0)
   2.136 +				{
   2.137 +					SDL_SendMouseWheel(index, 0, raw->data.mouse.usButtonData);
   2.138 +				}
   2.139 +			}
   2.140  		}
   2.141  		return(0);
   2.142      case WM_MOUSELEAVE:
   2.143 @@ -342,19 +291,6 @@
   2.144              }
   2.145          }
   2.146          return (0);
   2.147 -
   2.148 -    
   2.149 -
   2.150 - /*   case WM_MOUSEWHEEL:
   2.151 -        {
   2.152 -            int index;
   2.153 -            int motion = (short) HIWORD(wParam);
   2.154 -
   2.155 -            index = data->videodata->mouse;
   2.156 -            SDL_SendMouseWheel(index, 0, motion);
   2.157 -        }
   2.158 -        return (0);*/
   2.159 -
   2.160      case WM_SYSKEYDOWN:
   2.161      case WM_KEYDOWN:
   2.162          {
   2.163 @@ -743,3 +679,4 @@
   2.164  }
   2.165  
   2.166  /* vi: set ts=4 sw=4 expandtab: */
   2.167 +
     3.1 --- a/src/video/win32/SDL_win32mouse.c	Wed Jul 30 16:20:32 2008 +0000
     3.2 +++ b/src/video/win32/SDL_win32mouse.c	Thu Jul 31 14:41:48 2008 +0000
     3.3 @@ -31,13 +31,16 @@
     3.4  
     3.5  #include "../../events/SDL_mouse_c.h"
     3.6  
     3.7 -extern int total_mice;
     3.8 +#include <wintab.h>
     3.9 +#define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE)
    3.10 +#define PACKETMODE 0
    3.11 +#include <pktdef.h>
    3.12  
    3.13  extern HANDLE* mice;
    3.14  
    3.15  extern int total_mice;
    3.16  
    3.17 -RAWINPUTDEVICE *Rid=NULL;
    3.18 +extern int tablet;
    3.19  
    3.20  void
    3.21  WIN_InitMouse(_THIS)
    3.22 @@ -48,6 +51,7 @@
    3.23  	int i;
    3.24  	int tmp=0;
    3.25  	char* buffer=NULL;
    3.26 +	char* tab="wacom";
    3.27  
    3.28      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    3.29  
    3.30 @@ -67,6 +71,7 @@
    3.31  	for(i=0;i<devCount;++i)
    3.32  	{
    3.33  		int j;
    3.34 +		int k;
    3.35  		char *default_device_name="Pointing device xx";
    3.36  		const char *reg_key_root = "System\\CurrentControlSet\\Enum\\";
    3.37  		char *device_name=SDL_malloc(256*sizeof(char));
    3.38 @@ -77,6 +82,7 @@
    3.39  		DWORD regtype = REG_SZ;
    3.40  		DWORD out=256*sizeof(char);
    3.41  		SDL_Mouse mouse;
    3.42 +		int l;
    3.43  		if(deviceList[i].dwType!=RIM_TYPEMOUSE)
    3.44  		{
    3.45  			continue;
    3.46 @@ -117,35 +123,53 @@
    3.47  	rc = RegOpenKeyExA(HKEY_LOCAL_MACHINE, key_name, 0, KEY_READ, &hkey);
    3.48      
    3.49  	if (rc != ERROR_SUCCESS)
    3.50 -        return;
    3.51 +	{
    3.52 +		SDL_memcpy(device_name, default_device_name, SDL_strlen(default_device_name));
    3.53 +	}
    3.54  
    3.55      rc = RegQueryValueExA(hkey, "DeviceDesc", NULL, &regtype, device_name, &out);
    3.56      RegCloseKey(hkey);
    3.57      if (rc != ERROR_SUCCESS)
    3.58  	{
    3.59 -		return;
    3.60 -        //SDL_memcpy(device_name, default_device_name, SDL_strlen(default_device_name));
    3.61 +        SDL_memcpy(device_name, default_device_name, SDL_strlen(default_device_name));
    3.62      } 
    3.63 -    //device_name[254] = '\0';
    3.64 -
    3.65  		mice[index]=deviceList[i].hDevice;
    3.66  		SDL_zero(mouse);
    3.67  		SDL_SetIndexId(index,index);
    3.68 -		data->mouse = SDL_AddMouse(&mouse, index,device_name,0,0);
    3.69 -		//data->mouse = SDL_AddMouse(&mouse, index,key_name,0,0);
    3.70 +		l=SDL_strlen(device_name);
    3.71 +		if(tablet==-1)
    3.72 +		{
    3.73 +			for(j=0;j<l-5;++j)
    3.74 +			{
    3.75 +				for(k=0;k<5;++k)
    3.76 +				{
    3.77 +					if(tab[k]!=SDL_tolower((unsigned char)device_name[j+k]))
    3.78 +					{
    3.79 +						break;
    3.80 +					}
    3.81 +				}
    3.82 +				if(k==5)
    3.83 +				{
    3.84 +					tablet=index;
    3.85 +					break;
    3.86 +				}
    3.87 +			}
    3.88 +		}
    3.89 +		if(tablet==index)
    3.90 +		{
    3.91 +			AXIS pressure;
    3.92 +			WTInfo(WTI_DEVICES,DVC_NPRESSURE, &pressure);
    3.93 +			data->mouse = SDL_AddMouse(&mouse, index,device_name,pressure.axMax,pressure.axMin);
    3.94 +		}
    3.95 +		else
    3.96 +		{
    3.97 +			data->mouse = SDL_AddMouse(&mouse, index,device_name,0,0);
    3.98 +		}
    3.99  		++index;
   3.100  
   3.101  		SDL_free(buffer);
   3.102  		SDL_free(key_name);
   3.103  	}
   3.104 -	Rid = SDL_malloc(sizeof(RAWINPUTDEVICE));
   3.105 -	/*Rid[0].usUsagePage = 0x01; 
   3.106 -	Rid[0].usUsage = 0x02; 
   3.107 -	Rid[0].dwFlags = RIDEV_INPUTSINK;   // adds HID mouse and also ignores legacy mouse messages
   3.108 -	Rid[0].hwndTarget = NULL;
   3.109 -
   3.110 -	RegisterRawInputDevices(Rid, 1, sizeof(Rid[0]));*/
   3.111 -
   3.112  	total_mice=index;
   3.113  	SDL_free(deviceList);
   3.114  }
   3.115 @@ -159,7 +183,7 @@
   3.116  	{
   3.117  		SDL_DelMouse(i);
   3.118  	}
   3.119 -	SDL_free(Rid);
   3.120  }
   3.121  
   3.122  /* vi: set ts=4 sw=4 expandtab: */
   3.123 +
     4.1 --- a/src/video/win32/SDL_win32video.c	Wed Jul 30 16:20:32 2008 +0000
     4.2 +++ b/src/video/win32/SDL_win32video.c	Thu Jul 31 14:41:48 2008 +0000
     4.3 @@ -1,184 +1,185 @@
     4.4 -/*
     4.5 -    SDL - Simple DirectMedia Layer
     4.6 -    Copyright (C) 1997-2006 Sam Lantinga
     4.7 -
     4.8 -    This library is free software; you can redistribute it and/or
     4.9 -    modify it under the terms of the GNU Lesser General Public
    4.10 -    License as published by the Free Software Foundation; either
    4.11 -    version 2.1 of the License, or (at your option) any later version.
    4.12 -
    4.13 -    This library is distributed in the hope that it will be useful,
    4.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 -    Lesser General Public License for more details.
    4.17 -
    4.18 -    You should have received a copy of the GNU Lesser General Public
    4.19 -    License along with this library; if not, write to the Free Software
    4.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 -
    4.22 -    Sam Lantinga
    4.23 -    slouken@libsdl.org
    4.24 -*/
    4.25 -#include "SDL_config.h"
    4.26 -
    4.27 -#include "SDL_main.h"
    4.28 -#include "SDL_video.h"
    4.29 -#include "SDL_mouse.h"
    4.30 -#include "../SDL_sysvideo.h"
    4.31 -#include "../SDL_pixels_c.h"
    4.32 -
    4.33 -#include "SDL_win32video.h"
    4.34 -#include "SDL_d3drender.h"
    4.35 -#include "SDL_gdirender.h"
    4.36 -
    4.37 -#include <wintab.h>
    4.38 -
    4.39 -/* Initialization/Query functions */
    4.40 -static int WIN_VideoInit(_THIS);
    4.41 -static void WIN_VideoQuit(_THIS);
    4.42 -
    4.43 -int total_mice =0;
    4.44 -HANDLE* mice = NULL;
    4.45 -HCTX* g_hCtx = NULL;
    4.46 -//int highestId=0;
    4.47 -
    4.48 -/* WIN32 driver bootstrap functions */
    4.49 -
    4.50 -static int
    4.51 -WIN_Available(void)
    4.52 -{
    4.53 -    return (1);
    4.54 -}
    4.55 -
    4.56 -static void
    4.57 -WIN_DeleteDevice(SDL_VideoDevice * device)
    4.58 -{
    4.59 -    SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
    4.60 -
    4.61 -    SDL_UnregisterApp();
    4.62 -#if SDL_VIDEO_RENDER_D3D
    4.63 -    if (data->d3d) {
    4.64 -        IDirect3D9_Release(data->d3d);
    4.65 -        FreeLibrary(data->d3dDLL);
    4.66 -    }
    4.67 -#endif
    4.68 -    SDL_free(device->driverdata);
    4.69 -    SDL_free(device);
    4.70 -}
    4.71 -
    4.72 -static SDL_VideoDevice *
    4.73 -WIN_CreateDevice(int devindex)
    4.74 -{
    4.75 -    SDL_VideoDevice *device;
    4.76 -    SDL_VideoData *data;
    4.77 -
    4.78 -    SDL_RegisterApp(NULL, 0, NULL);
    4.79 -
    4.80 -    /* Initialize all variables that we clean on shutdown */
    4.81 -    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    4.82 -    if (device) {
    4.83 -        data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
    4.84 -    }
    4.85 -    if (!device || !data) {
    4.86 -        SDL_OutOfMemory();
    4.87 -        if (device) {
    4.88 -            SDL_free(device);
    4.89 -        }
    4.90 -        return NULL;
    4.91 -    }
    4.92 -    device->driverdata = data;
    4.93 -
    4.94 -#if SDL_VIDEO_RENDER_D3D
    4.95 -    data->d3dDLL = LoadLibrary(TEXT("D3D9.DLL"));
    4.96 -    if (data->d3dDLL) {
    4.97 -        IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion);
    4.98 -
    4.99 -        D3DCreate =
   4.100 -            (IDirect3D9 * (WINAPI *) (UINT)) GetProcAddress(data->d3dDLL,
   4.101 -                                                            "Direct3DCreate9");
   4.102 -        if (D3DCreate) {
   4.103 -            data->d3d = D3DCreate(D3D_SDK_VERSION);
   4.104 -        }
   4.105 -        if (!data->d3d) {
   4.106 -            FreeLibrary(data->d3dDLL);
   4.107 -            data->d3dDLL = NULL;
   4.108 -        }
   4.109 -    }
   4.110 -#endif /* SDL_VIDEO_RENDER_D3D */
   4.111 -
   4.112 -    /* Set the function pointers */
   4.113 -    device->VideoInit = WIN_VideoInit;
   4.114 -    device->VideoQuit = WIN_VideoQuit;
   4.115 -    device->GetDisplayModes = WIN_GetDisplayModes;
   4.116 -    device->SetDisplayMode = WIN_SetDisplayMode;
   4.117 -    device->SetDisplayGammaRamp = WIN_SetDisplayGammaRamp;
   4.118 -    device->GetDisplayGammaRamp = WIN_GetDisplayGammaRamp;
   4.119 -    device->PumpEvents = WIN_PumpEvents;
   4.120 -
   4.121 -#undef CreateWindow
   4.122 -    device->CreateWindow = WIN_CreateWindow;
   4.123 -    device->CreateWindowFrom = WIN_CreateWindowFrom;
   4.124 -    device->SetWindowTitle = WIN_SetWindowTitle;
   4.125 -    device->SetWindowPosition = WIN_SetWindowPosition;
   4.126 -    device->SetWindowSize = WIN_SetWindowSize;
   4.127 -    device->ShowWindow = WIN_ShowWindow;
   4.128 -    device->HideWindow = WIN_HideWindow;
   4.129 -    device->RaiseWindow = WIN_RaiseWindow;
   4.130 -    device->MaximizeWindow = WIN_MaximizeWindow;
   4.131 -    device->MinimizeWindow = WIN_MinimizeWindow;
   4.132 -    device->RestoreWindow = WIN_RestoreWindow;
   4.133 -    device->SetWindowGrab = WIN_SetWindowGrab;
   4.134 -    device->DestroyWindow = WIN_DestroyWindow;
   4.135 -    device->GetWindowWMInfo = WIN_GetWindowWMInfo;
   4.136 -#ifdef SDL_VIDEO_OPENGL_WGL
   4.137 -    device->GL_LoadLibrary = WIN_GL_LoadLibrary;
   4.138 -    device->GL_GetProcAddress = WIN_GL_GetProcAddress;
   4.139 -    device->GL_CreateContext = WIN_GL_CreateContext;
   4.140 -    device->GL_MakeCurrent = WIN_GL_MakeCurrent;
   4.141 -    device->GL_SetSwapInterval = WIN_GL_SetSwapInterval;
   4.142 -    device->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
   4.143 -    device->GL_SwapWindow = WIN_GL_SwapWindow;
   4.144 -    device->GL_DeleteContext = WIN_GL_DeleteContext;
   4.145 -#endif
   4.146 -
   4.147 -    device->free = WIN_DeleteDevice;
   4.148 -
   4.149 -    return device;
   4.150 -}
   4.151 -
   4.152 -VideoBootStrap WIN32_bootstrap = {
   4.153 -    "win32", "SDL Win32/64 video driver",
   4.154 -    WIN_Available, WIN_CreateDevice
   4.155 -};
   4.156 -
   4.157 -
   4.158 -int
   4.159 -WIN_VideoInit(_THIS)
   4.160 -{
   4.161 -    WIN_InitModes(_this);
   4.162 -
   4.163 -#if SDL_VIDEO_RENDER_D3D
   4.164 -    D3D_AddRenderDriver(_this);
   4.165 -#endif
   4.166 -#if SDL_VIDEO_RENDER_GDI
   4.167 -    GDI_AddRenderDriver(_this);
   4.168 -#endif
   4.169 -
   4.170 -	g_hCtx = SDL_malloc(sizeof(HCTX));
   4.171 -
   4.172 -    WIN_InitKeyboard(_this);
   4.173 -    WIN_InitMouse(_this);
   4.174 -
   4.175 -    return 0;
   4.176 -}
   4.177 -
   4.178 -void
   4.179 -WIN_VideoQuit(_THIS)
   4.180 -{
   4.181 -    WIN_QuitModes(_this);
   4.182 -    WIN_QuitKeyboard(_this);
   4.183 -    WIN_QuitMouse(_this);
   4.184 -	SDL_free(g_hCtx);
   4.185 -}
   4.186 -
   4.187 -/* vim: set ts=4 sw=4 expandtab: */
   4.188 +/*
   4.189 +    SDL - Simple DirectMedia Layer
   4.190 +    Copyright (C) 1997-2006 Sam Lantinga
   4.191 +
   4.192 +    This library is free software; you can redistribute it and/or
   4.193 +    modify it under the terms of the GNU Lesser General Public
   4.194 +    License as published by the Free Software Foundation; either
   4.195 +    version 2.1 of the License, or (at your option) any later version.
   4.196 +
   4.197 +    This library is distributed in the hope that it will be useful,
   4.198 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   4.199 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   4.200 +    Lesser General Public License for more details.
   4.201 +
   4.202 +    You should have received a copy of the GNU Lesser General Public
   4.203 +    License along with this library; if not, write to the Free Software
   4.204 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   4.205 +
   4.206 +    Sam Lantinga
   4.207 +    slouken@libsdl.org
   4.208 +*/
   4.209 +#include "SDL_config.h"
   4.210 +
   4.211 +#include "SDL_main.h"
   4.212 +#include "SDL_video.h"
   4.213 +#include "SDL_mouse.h"
   4.214 +#include "../SDL_sysvideo.h"
   4.215 +#include "../SDL_pixels_c.h"
   4.216 +
   4.217 +#include "SDL_win32video.h"
   4.218 +#include "SDL_d3drender.h"
   4.219 +#include "SDL_gdirender.h"
   4.220 +
   4.221 +#include <wintab.h>
   4.222 +
   4.223 +/* Initialization/Query functions */
   4.224 +static int WIN_VideoInit(_THIS);
   4.225 +static void WIN_VideoQuit(_THIS);
   4.226 +
   4.227 +int total_mice =0;
   4.228 +HANDLE* mice = NULL;
   4.229 +HCTX* g_hCtx = NULL;
   4.230 +int tablet=-1;
   4.231 +
   4.232 +/* WIN32 driver bootstrap functions */
   4.233 +
   4.234 +static int
   4.235 +WIN_Available(void)
   4.236 +{
   4.237 +    return (1);
   4.238 +}
   4.239 +
   4.240 +static void
   4.241 +WIN_DeleteDevice(SDL_VideoDevice * device)
   4.242 +{
   4.243 +    SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
   4.244 +
   4.245 +    SDL_UnregisterApp();
   4.246 +#if SDL_VIDEO_RENDER_D3D
   4.247 +    if (data->d3d) {
   4.248 +        IDirect3D9_Release(data->d3d);
   4.249 +        FreeLibrary(data->d3dDLL);
   4.250 +    }
   4.251 +#endif
   4.252 +    SDL_free(device->driverdata);
   4.253 +    SDL_free(device);
   4.254 +}
   4.255 +
   4.256 +static SDL_VideoDevice *
   4.257 +WIN_CreateDevice(int devindex)
   4.258 +{
   4.259 +    SDL_VideoDevice *device;
   4.260 +    SDL_VideoData *data;
   4.261 +
   4.262 +    SDL_RegisterApp(NULL, 0, NULL);
   4.263 +
   4.264 +    /* Initialize all variables that we clean on shutdown */
   4.265 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   4.266 +    if (device) {
   4.267 +        data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
   4.268 +    }
   4.269 +    if (!device || !data) {
   4.270 +        SDL_OutOfMemory();
   4.271 +        if (device) {
   4.272 +            SDL_free(device);
   4.273 +        }
   4.274 +        return NULL;
   4.275 +    }
   4.276 +    device->driverdata = data;
   4.277 +
   4.278 +#if SDL_VIDEO_RENDER_D3D
   4.279 +    data->d3dDLL = LoadLibrary(TEXT("D3D9.DLL"));
   4.280 +    if (data->d3dDLL) {
   4.281 +        IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion);
   4.282 +
   4.283 +        D3DCreate =
   4.284 +            (IDirect3D9 * (WINAPI *) (UINT)) GetProcAddress(data->d3dDLL,
   4.285 +                                                            "Direct3DCreate9");
   4.286 +        if (D3DCreate) {
   4.287 +            data->d3d = D3DCreate(D3D_SDK_VERSION);
   4.288 +        }
   4.289 +        if (!data->d3d) {
   4.290 +            FreeLibrary(data->d3dDLL);
   4.291 +            data->d3dDLL = NULL;
   4.292 +        }
   4.293 +    }
   4.294 +#endif /* SDL_VIDEO_RENDER_D3D */
   4.295 +
   4.296 +    /* Set the function pointers */
   4.297 +    device->VideoInit = WIN_VideoInit;
   4.298 +    device->VideoQuit = WIN_VideoQuit;
   4.299 +    device->GetDisplayModes = WIN_GetDisplayModes;
   4.300 +    device->SetDisplayMode = WIN_SetDisplayMode;
   4.301 +    device->SetDisplayGammaRamp = WIN_SetDisplayGammaRamp;
   4.302 +    device->GetDisplayGammaRamp = WIN_GetDisplayGammaRamp;
   4.303 +    device->PumpEvents = WIN_PumpEvents;
   4.304 +
   4.305 +#undef CreateWindow
   4.306 +    device->CreateWindow = WIN_CreateWindow;
   4.307 +    device->CreateWindowFrom = WIN_CreateWindowFrom;
   4.308 +    device->SetWindowTitle = WIN_SetWindowTitle;
   4.309 +    device->SetWindowPosition = WIN_SetWindowPosition;
   4.310 +    device->SetWindowSize = WIN_SetWindowSize;
   4.311 +    device->ShowWindow = WIN_ShowWindow;
   4.312 +    device->HideWindow = WIN_HideWindow;
   4.313 +    device->RaiseWindow = WIN_RaiseWindow;
   4.314 +    device->MaximizeWindow = WIN_MaximizeWindow;
   4.315 +    device->MinimizeWindow = WIN_MinimizeWindow;
   4.316 +    device->RestoreWindow = WIN_RestoreWindow;
   4.317 +    device->SetWindowGrab = WIN_SetWindowGrab;
   4.318 +    device->DestroyWindow = WIN_DestroyWindow;
   4.319 +    device->GetWindowWMInfo = WIN_GetWindowWMInfo;
   4.320 +#ifdef SDL_VIDEO_OPENGL_WGL
   4.321 +    device->GL_LoadLibrary = WIN_GL_LoadLibrary;
   4.322 +    device->GL_GetProcAddress = WIN_GL_GetProcAddress;
   4.323 +    device->GL_CreateContext = WIN_GL_CreateContext;
   4.324 +    device->GL_MakeCurrent = WIN_GL_MakeCurrent;
   4.325 +    device->GL_SetSwapInterval = WIN_GL_SetSwapInterval;
   4.326 +    device->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
   4.327 +    device->GL_SwapWindow = WIN_GL_SwapWindow;
   4.328 +    device->GL_DeleteContext = WIN_GL_DeleteContext;
   4.329 +#endif
   4.330 +
   4.331 +    device->free = WIN_DeleteDevice;
   4.332 +
   4.333 +    return device;
   4.334 +}
   4.335 +
   4.336 +VideoBootStrap WIN32_bootstrap = {
   4.337 +    "win32", "SDL Win32/64 video driver",
   4.338 +    WIN_Available, WIN_CreateDevice
   4.339 +};
   4.340 +
   4.341 +
   4.342 +int
   4.343 +WIN_VideoInit(_THIS)
   4.344 +{
   4.345 +    WIN_InitModes(_this);
   4.346 +
   4.347 +#if SDL_VIDEO_RENDER_D3D
   4.348 +    D3D_AddRenderDriver(_this);
   4.349 +#endif
   4.350 +#if SDL_VIDEO_RENDER_GDI
   4.351 +    GDI_AddRenderDriver(_this);
   4.352 +#endif
   4.353 +
   4.354 +	g_hCtx = SDL_malloc(sizeof(HCTX));
   4.355 +
   4.356 +    WIN_InitKeyboard(_this);
   4.357 +    WIN_InitMouse(_this);
   4.358 +
   4.359 +    return 0;
   4.360 +}
   4.361 +
   4.362 +void
   4.363 +WIN_VideoQuit(_THIS)
   4.364 +{
   4.365 +    WIN_QuitModes(_this);
   4.366 +    WIN_QuitKeyboard(_this);
   4.367 +    WIN_QuitMouse(_this);
   4.368 +	SDL_free(g_hCtx);
   4.369 +}
   4.370 +
   4.371 +/* vim: set ts=4 sw=4 expandtab: */
   4.372 +
     5.1 --- a/src/video/win32/SDL_win32window.c	Wed Jul 30 16:20:32 2008 +0000
     5.2 +++ b/src/video/win32/SDL_win32window.c	Thu Jul 31 14:41:48 2008 +0000
     5.3 @@ -475,3 +475,4 @@
     5.4  }
     5.5  
     5.6  /* vi: set ts=4 sw=4 expandtab: */
     5.7 +