Clean up dynamic loading of Win32 funcs, remove makepanda touchinput setting, remove checks for pre-WinXP

This commit is contained in:
rdb 2016-12-05 17:21:09 -05:00
parent c410d812ff
commit 6344c05b18
6 changed files with 132 additions and 200 deletions

View File

@ -94,7 +94,6 @@ PkgListSet(["PYTHON", "DIRECT", # Python support
"PANDAPARTICLESYSTEM", # Built in particle system
"CONTRIB", # Experimental
"SSE2", "NEON", # Compiler features
"TOUCHINPUT", # Touchinput interface (requires Windows 7)
])
CheckPandaSourceTree()
@ -170,7 +169,8 @@ def parseopts(args):
"version=","lzma","no-python","threads=","outputdir=","override=",
"static","host=","debversion=","rpmrelease=","p3dsuffix=","rtdist-version=",
"directx-sdk=", "windows-sdk=", "msvc-version=", "clean", "use-icl",
"universal", "target=", "arch=", "git-commit="]
"universal", "target=", "arch=", "git-commit=",
"use-touchinput", "no-touchinput"]
anything = 0
optimize = ""
target = None
@ -316,18 +316,6 @@ def parseopts(args):
print("No Windows SDK version specified. Defaulting to '7.1'.")
WINDOWS_SDK = '7.1'
is_win7 = False
if sys.platform == 'win32':
# Note: not available in cygwin.
winver = sys.getwindowsversion()
if winver[0] >= 6 and winver[1] >= 1:
is_win7 = True
if RUNTIME or not is_win7:
PkgDisable("TOUCHINPUT")
else:
PkgDisable("TOUCHINPUT")
if clean_build and os.path.isdir(GetOutputDir()):
print("Deleting %s" % (GetOutputDir()))
shutil.rmtree(GetOutputDir())
@ -1055,14 +1043,11 @@ def CompileCxx(obj,src,opts):
cmd += "/favor:blend "
cmd += "/wd4996 /wd4275 /wd4273 "
# Enable Windows 7 interfaces if we need Touchinput.
if PkgSkip("TOUCHINPUT") == 0:
cmd += "/DWINVER=0x601 "
else:
cmd += "/DWINVER=0x501 "
# Work around a WinXP/2003 bug when using VS 2015+.
if SDK.get("VISUALSTUDIO_VERSION") == '14.0':
cmd += "/Zc:threadSafeInit- "
# We still target Windows XP.
cmd += "/DWINVER=0x501 "
# Work around a WinXP/2003 bug when using VS 2015+.
if SDK.get("VISUALSTUDIO_VERSION") == '14.0':
cmd += "/Zc:threadSafeInit- "
cmd += "/Fo" + obj + " /nologo /c"
if GetTargetArch() != 'x64' and (not PkgSkip("SSE2") or 'SSE2' in opts):
@ -1113,12 +1098,7 @@ def CompileCxx(obj,src,opts):
if GetTargetArch() == 'x64':
cmd += "/favor:blend "
cmd += "/wd4996 /wd4275 /wd4267 /wd4101 /wd4273 "
# Enable Windows 7 interfaces if we need Touchinput.
if PkgSkip("TOUCHINPUT") == 0:
cmd += "/DWINVER=0x601 "
else:
cmd += "/DWINVER=0x501 "
cmd += "/DWINVER=0x501 "
cmd += "/Fo" + obj + " /c"
for x in ipath: cmd += " /I" + x
for (opt,dir) in INCDIRECTORIES:
@ -2129,7 +2109,6 @@ DTOOL_CONFIG=[
("REPORT_OPENSSL_ERRORS", '1', '1'),
("USE_PANDAFILESTREAM", '1', '1'),
("USE_DELETED_CHAIN", '1', '1'),
("HAVE_WIN_TOUCHINPUT", 'UNDEF', 'UNDEF'),
("HAVE_GLX", 'UNDEF', '1'),
("HAVE_WGL", '1', 'UNDEF'),
("HAVE_DX9", 'UNDEF', 'UNDEF'),
@ -2347,9 +2326,6 @@ def WriteConfigSettings():
if (PkgSkip("PYTHON") != 0):
dtool_config["HAVE_ROCKET_PYTHON"] = 'UNDEF'
if (PkgSkip("TOUCHINPUT") == 0 and GetTarget() == "windows"):
dtool_config["HAVE_WIN_TOUCHINPUT"] = '1'
if (GetOptimize() <= 3):
dtool_config["HAVE_ROCKET_DEBUGGER"] = '1'

View File

@ -19,6 +19,16 @@
TypeHandle wdxGraphicsPipe9::_type_handle;
static bool MyGetProcAddr(HINSTANCE hDLL, FARPROC *pFn, const char *szExportedFnName) {
*pFn = (FARPROC) GetProcAddress(hDLL, szExportedFnName);
if (*pFn == NULL) {
wdxdisplay9_cat.error()
<< "GetProcAddr failed for " << szExportedFnName << ", error=" << GetLastError() <<endl;
return false;
}
return true;
}
#define LOWVIDMEMTHRESHOLD 5700000 // 4MB cards should fall below this
#define CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD 1000000 // if # is > 1MB, card is lying and I cant tell what it is
#define UNKNOWN_VIDMEM_SIZE 0xFFFFFFFF
@ -154,7 +164,10 @@ make_output(const string &name,
*/
bool wdxGraphicsPipe9::
init() {
if (!MyLoadLib(_hDDrawDLL, "ddraw.dll")) {
_hDDrawDLL = LoadLibrary("ddraw.dll");
if (_hDDrawDLL == NULL) {
wdxdisplay9_cat.error()
<< "LoadLibrary failed for ddraw.dll, error=" << GetLastError() <<endl;
goto error;
}
@ -166,7 +179,10 @@ init() {
goto error;
}
if (!MyLoadLib(_hD3D9_DLL, "d3d9.dll")) {
_hD3D9_DLL = LoadLibrary("d3d9.dll");
if (_hD3D9_DLL == NULL) {
wdxdisplay9_cat.error()
<< "LoadLibrary failed for d3d9.dll, error=" << GetLastError() <<endl;
goto error;
}

View File

@ -47,15 +47,12 @@ typedef struct _PROCESSOR_POWER_INFORMATION {
} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
typedef BOOL (WINAPI *GetProcessMemoryInfoType) (HANDLE Process, PROCESS_MEMORY_COUNTERS *ppsmemCounters, DWORD cb);
typedef BOOL (WINAPI *GlobalMemoryStatusExType) (LPMEMORYSTATUSEX lpBuffer);
typedef long (__stdcall *CallNtPowerInformationType) (POWER_INFORMATION_LEVEL information_level, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength);
static int initialize = false;
static HMODULE psapi_dll = 0;
static HMODULE kernel32_dll = 0;
static HMODULE power_dll = 0;
static GetProcessMemoryInfoType GetProcessMemoryInfoFunction = 0;
static GlobalMemoryStatusExType GlobalMemoryStatusExFunction = 0;
static CallNtPowerInformationType CallNtPowerInformationFunction = 0;
void get_memory_information (DisplayInformation *display_information) {
@ -65,39 +62,19 @@ void get_memory_information (DisplayInformation *display_information) {
GetProcessMemoryInfoFunction = (GetProcessMemoryInfoType) GetProcAddress(psapi_dll, "GetProcessMemoryInfo");
}
kernel32_dll = LoadLibrary("kernel32.dll");
if (kernel32_dll) {
GlobalMemoryStatusExFunction = (GlobalMemoryStatusExType) GetProcAddress(kernel32_dll, "GlobalMemoryStatusEx");
}
initialize = true;
}
if (GlobalMemoryStatusExFunction) {
MEMORYSTATUSEX memory_status;
MEMORYSTATUSEX memory_status;
memory_status.dwLength = sizeof(MEMORYSTATUSEX);
if (GlobalMemoryStatusExFunction(&memory_status)) {
display_information->_physical_memory = memory_status.ullTotalPhys;
display_information->_available_physical_memory = memory_status.ullAvailPhys;
display_information->_page_file_size = memory_status.ullTotalPageFile;
display_information->_available_page_file_size = memory_status.ullAvailPageFile;
display_information->_process_virtual_memory = memory_status.ullTotalVirtual;
display_information->_available_process_virtual_memory = memory_status.ullAvailVirtual;
display_information->_memory_load = memory_status.dwMemoryLoad;
}
} else {
MEMORYSTATUS memory_status;
memory_status.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus (&memory_status);
display_information->_physical_memory = memory_status.dwTotalPhys;
display_information->_available_physical_memory = memory_status.dwAvailPhys;
display_information->_page_file_size = memory_status.dwTotalPageFile;
display_information->_available_page_file_size = memory_status.dwAvailPageFile;
display_information->_process_virtual_memory = memory_status.dwTotalVirtual;
display_information->_available_process_virtual_memory = memory_status.dwAvailVirtual;
memory_status.dwLength = sizeof(MEMORYSTATUSEX);
if (GlobalMemoryStatusEx(&memory_status)) {
display_information->_physical_memory = memory_status.ullTotalPhys;
display_information->_available_physical_memory = memory_status.ullAvailPhys;
display_information->_page_file_size = memory_status.ullTotalPageFile;
display_information->_available_page_file_size = memory_status.ullAvailPageFile;
display_information->_process_virtual_memory = memory_status.ullTotalVirtual;
display_information->_available_process_virtual_memory = memory_status.ullAvailVirtual;
display_information->_memory_load = memory_status.dwMemoryLoad;
}
@ -687,19 +664,12 @@ WinGraphicsPipe() {
_supported_types = OT_window | OT_fullscreen_window;
// these fns arent defined on win95, so get dynamic ptrs to them to avoid
// ugly DLL loader failures on w95
_pfnTrackMouseEvent = NULL;
_hUser32 = (HINSTANCE)LoadLibrary("user32.dll");
if (_hUser32 != NULL) {
_pfnTrackMouseEvent =
(PFN_TRACKMOUSEEVENT)GetProcAddress(_hUser32, "TrackMouseEvent");
HMODULE user32 = GetModuleHandleA("user32.dll");
if (user32 != NULL) {
if (dpi_aware) {
typedef HRESULT (WINAPI *PFN_SETPROCESSDPIAWARENESS)(Process_DPI_Awareness);
PFN_SETPROCESSDPIAWARENESS pfnSetProcessDpiAwareness =
(PFN_SETPROCESSDPIAWARENESS)GetProcAddress(_hUser32, "SetProcessDpiAwarenessInternal");
(PFN_SETPROCESSDPIAWARENESS)GetProcAddress(user32, "SetProcessDpiAwarenessInternal");
if (pfnSetProcessDpiAwareness == NULL) {
if (windisplay_cat.is_debug()) {
@ -908,26 +878,4 @@ lookup_cpu_data() {
*/
WinGraphicsPipe::
~WinGraphicsPipe() {
if (_hUser32 != NULL) {
FreeLibrary(_hUser32);
_hUser32 = NULL;
}
}
bool MyGetProcAddr(HINSTANCE hDLL, FARPROC *pFn, const char *szExportedFnName) {
*pFn = (FARPROC) GetProcAddress(hDLL, szExportedFnName);
if (*pFn == NULL) {
windisplay_cat.error() << "GetProcAddr failed for " << szExportedFnName << ", error=" << GetLastError() <<endl;
return false;
}
return true;
}
bool MyLoadLib(HINSTANCE &hDLL, const char *DLLname) {
hDLL = LoadLibrary(DLLname);
if(hDLL == NULL) {
windisplay_cat.error() << "LoadLibrary failed for " << DLLname << ", error=" << GetLastError() <<endl;
return false;
}
return true;
}

View File

@ -34,12 +34,6 @@ public:
virtual void lookup_cpu_data();
private:
HINSTANCE _hUser32;
typedef BOOL (WINAPI *PFN_TRACKMOUSEEVENT)(LPTRACKMOUSEEVENT);
PFN_TRACKMOUSEEVENT _pfnTrackMouseEvent;
public:
static TypeHandle get_class_type() {
return _type_handle;
@ -56,13 +50,8 @@ public:
private:
static TypeHandle _type_handle;
friend class WinGraphicsWindow;
};
extern EXPCL_PANDAWIN bool MyLoadLib(HINSTANCE &hDLL, const char *DLLname);
extern EXPCL_PANDAWIN bool MyGetProcAddr(HINSTANCE hDLL, FARPROC *pFn, const char *szExportedFnName);
#include "winGraphicsPipe.I"
#endif

View File

@ -29,6 +29,17 @@
#define WM_DPICHANGED 0x02E0
#endif
#ifndef WM_TOUCH
#define WM_TOUCH 0x0240
#endif
#if WINVER < 0x0601
// Not used on Windows XP, but we still need to define it.
#define TOUCH_COORD_TO_PIXEL(l) ((l) / 100)
DECLARE_HANDLE(HTOUCHINPUT);
#endif
TypeHandle WinGraphicsWindow::_type_handle;
TypeHandle WinGraphicsWindow::WinWindowHandle::_type_handle;
@ -56,22 +67,15 @@ int WinGraphicsWindow::_window_class_index = 0;
static const char * const errorbox_title = "Panda3D Error";
// These static variables contain pointers to the Raw Input functions, which
// These static variables contain pointers to the touch input functions, which
// are dynamically extracted from USER32.DLL
typedef WINUSERAPI BOOL (WINAPI *PFN_REGISTERTOUCHWINDOW)(IN HWND hWnd, IN ULONG ulFlags);
typedef WINUSERAPI BOOL (WINAPI *PFN_GETTOUCHINPUTINFO)(IN HTOUCHINPUT hTouchInput, IN UINT cInputs, OUT PTOUCHINPUT pInputs, IN int cbSize);
typedef WINUSERAPI BOOL (WINAPI *PFN_CLOSETOUCHINPUTHANDLE)(IN HTOUCHINPUT hTouchInput);
typedef WINUSERAPI UINT (WINAPI *tGetRawInputDeviceList)
(OUT PRAWINPUTDEVICELIST pRawInputDeviceList, IN OUT PUINT puiNumDevices, IN UINT cbSize);
typedef WINUSERAPI UINT(WINAPI *tGetRawInputData)
(IN HRAWINPUT hRawInput, IN UINT uiCommand, OUT LPVOID pData, IN OUT PUINT pcbSize, IN UINT cbSizeHeader);
typedef WINUSERAPI UINT(WINAPI *tGetRawInputDeviceInfoA)
(IN HANDLE hDevice, IN UINT uiCommand, OUT LPVOID pData, IN OUT PUINT pcbSize);
typedef WINUSERAPI BOOL (WINAPI *tRegisterRawInputDevices)
(IN PCRAWINPUTDEVICE pRawInputDevices, IN UINT uiNumDevices, IN UINT cbSize);
static tGetRawInputDeviceList pGetRawInputDeviceList;
static tGetRawInputData pGetRawInputData;
static tGetRawInputDeviceInfoA pGetRawInputDeviceInfoA;
static tRegisterRawInputDevices pRegisterRawInputDevices;
static PFN_REGISTERTOUCHWINDOW pRegisterTouchWindow = 0;
static PFN_GETTOUCHINPUTINFO pGetTouchInputInfo = 0;
static PFN_CLOSETOUCHINPUTHANDLE pCloseTouchInputHandle = 0;
/**
*
@ -100,9 +104,7 @@ WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
_lalt_down = false;
_ralt_down = false;
_hparent = NULL;
#ifdef HAVE_WIN_TOUCHINPUT
_numTouches = 0;
#endif
_num_touches = 0;
}
/**
@ -512,13 +514,13 @@ open_window() {
}
// Registers to receive the WM_INPUT messages
if ((pRegisterRawInputDevices)&&(_input_devices.size() > 1)) {
if (_input_devices.size() > 1) {
RAWINPUTDEVICE Rid;
Rid.usUsagePage = 0x01;
Rid.usUsage = 0x02;
Rid.dwFlags = 0;// RIDEV_NOLEGACY; // adds HID mouse and also ignores legacy mouse messages
Rid.hwndTarget = _hWnd;
pRegisterRawInputDevices(&Rid, 1, sizeof (Rid));
RegisterRawInputDevices(&Rid, 1, sizeof (Rid));
}
// Create a WindowHandle for ourselves
@ -535,10 +537,23 @@ open_window() {
// set us as the focus window for keyboard input
set_focus();
// Try initializing the touch function pointers.
static bool initialized = false;
if (!initialized) {
initialized = true;
HMODULE user32 = GetModuleHandleA("user32.dll");
if (user32) {
// Introduced in Windows 7.
pRegisterTouchWindow = (PFN_REGISTERTOUCHWINDOW)GetProcAddress(user32, "RegisterTouchWindow");
pGetTouchInputInfo = (PFN_GETTOUCHINPUTINFO)GetProcAddress(user32, "GetTouchInputInfo");
pCloseTouchInputHandle = (PFN_CLOSETOUCHINPUTHANDLE)GetProcAddress(user32, "CloseTouchInputHandle");
}
}
// Register for Win7 touch events.
#ifdef HAVE_WIN_TOUCHINPUT
RegisterTouchWindow(_hWnd, 0);
#endif
if (pRegisterTouchWindow != NULL) {
pRegisterTouchWindow(_hWnd, 0);
}
return true;
}
@ -563,45 +578,35 @@ initialize_input_devices() {
GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
add_input_device(device);
// Try initializing the Raw Input function pointers.
if (pRegisterRawInputDevices==0) {
HMODULE user32 = LoadLibrary("user32.dll");
if (user32) {
pRegisterRawInputDevices = (tRegisterRawInputDevices)GetProcAddress(user32,"RegisterRawInputDevices");
pGetRawInputDeviceList = (tGetRawInputDeviceList) GetProcAddress(user32,"GetRawInputDeviceList");
pGetRawInputDeviceInfoA = (tGetRawInputDeviceInfoA) GetProcAddress(user32,"GetRawInputDeviceInfoA");
pGetRawInputData = (tGetRawInputData) GetProcAddress(user32,"GetRawInputData");
}
}
if (pRegisterRawInputDevices==0) return;
if (pGetRawInputDeviceList==0) return;
if (pGetRawInputDeviceInfoA==0) return;
if (pGetRawInputData==0) return;
// Get the number of devices.
if (pGetRawInputDeviceList(NULL, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0)
if (GetRawInputDeviceList(NULL, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0) {
return;
}
// Allocate the array to hold the DeviceList
pRawInputDeviceList = (PRAWINPUTDEVICELIST)alloca(sizeof(RAWINPUTDEVICELIST) * nInputDevices);
if (pRawInputDeviceList==0) return;
if (pRawInputDeviceList==0) {
return;
}
// Fill the Array
if (pGetRawInputDeviceList(pRawInputDeviceList, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) == -1)
if (GetRawInputDeviceList(pRawInputDeviceList, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) == -1) {
return;
}
// Loop through all raw devices and find the raw mice
for (int i = 0; i < (int)nInputDevices; i++) {
if (pRawInputDeviceList[i].dwType == RIM_TYPEMOUSE) {
// Fetch information about specified mouse device.
UINT nSize;
if (pGetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)0, &nSize) != 0)
if (GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)0, &nSize) != 0) {
return;
}
char *psName = (char*)alloca(sizeof(TCHAR) * nSize);
if (psName == 0) return;
if (pGetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)psName, &nSize) < 0)
if (GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)psName, &nSize) < 0) {
return;
}
// If it's not an RDP mouse, add it to the list of raw mice.
if (strncmp(psName,"\\??\\Root#RDP_MOU#0000#",22)!=0) {
@ -1215,31 +1220,25 @@ adjust_z_order(WindowProperties::ZOrder last_z_order,
*/
void WinGraphicsWindow::
track_mouse_leaving(HWND hwnd) {
// Note: could use _TrackMouseEvent in comctrl32.dll (part of IE 3.0+) which
// emulates TrackMouseEvent on w95, but that requires another 500K of memory
// to hold that DLL, which is lame just to support w95, which probably has
// other issues anyway
WinGraphicsPipe *winpipe;
DCAST_INTO_V(winpipe, _pipe);
if (winpipe->_pfnTrackMouseEvent != NULL) {
TRACKMOUSEEVENT tme = {
sizeof(TRACKMOUSEEVENT),
TME_LEAVE,
hwnd,
0
};
TRACKMOUSEEVENT tme = {
sizeof(TRACKMOUSEEVENT),
TME_LEAVE,
hwnd,
0
};
// tell win32 to post WM_MOUSELEAVE msgs
BOOL bSucceeded = winpipe->_pfnTrackMouseEvent(&tme);
// tell win32 to post WM_MOUSELEAVE msgs
BOOL bSucceeded = TrackMouseEvent(&tme);
if ((!bSucceeded) && windisplay_cat.is_debug()) {
windisplay_cat.debug()
<< "TrackMouseEvent failed!, LastError=" << GetLastError() << endl;
}
_tracking_mouse_leaving = true;
if (!bSucceeded && windisplay_cat.is_debug()) {
windisplay_cat.debug()
<< "TrackMouseEvent failed!, LastError=" << GetLastError() << endl;
}
_tracking_mouse_leaving = true;
}
/**
@ -2067,15 +2066,16 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
}
break;
#ifdef HAVE_WIN_TOUCHINPUT
case WM_TOUCH:
_numTouches = LOWORD(wparam);
if(_numTouches > MAX_TOUCHES)
_numTouches = MAX_TOUCHES;
GetTouchInputInfo((HTOUCHINPUT)lparam, _numTouches, _touches, sizeof(TOUCHINPUT));
CloseTouchInputHandle((HTOUCHINPUT)lparam);
_num_touches = LOWORD(wparam);
if (_num_touches > MAX_TOUCHES) {
_num_touches = MAX_TOUCHES;
}
if (pGetTouchInputInfo != 0) {
pGetTouchInputInfo((HTOUCHINPUT)lparam, _num_touches, _touches, sizeof(TOUCHINPUT));
pCloseTouchInputHandle((HTOUCHINPUT)lparam);
}
break;
#endif
}
// do custom messages processing if any has been set
@ -2607,7 +2607,7 @@ handle_raw_input(HRAWINPUT hraw) {
if (hraw == 0) {
return;
}
if (pGetRawInputData(hraw, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)) == -1) {
if (GetRawInputData(hraw, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)) == -1) {
return;
}
@ -2616,7 +2616,7 @@ handle_raw_input(HRAWINPUT hraw) {
return;
}
if (pGetRawInputData(hraw, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) {
if (GetRawInputData(hraw, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) {
return;
}
@ -2973,12 +2973,8 @@ bool WinGraphicsWindow::supports_window_procs() const{
*
*/
bool WinGraphicsWindow::
is_touch_event(GraphicsWindowProcCallbackData* callbackData){
#ifdef HAVE_WIN_TOUCHINPUT
is_touch_event(GraphicsWindowProcCallbackData *callbackData) {
return callbackData->get_msg() == WM_TOUCH;
#else
return false;
#endif
}
/**
@ -2987,11 +2983,7 @@ is_touch_event(GraphicsWindowProcCallbackData* callbackData){
*/
int WinGraphicsWindow::
get_num_touches(){
#ifdef HAVE_WIN_TOUCHINPUT
return _numTouches;
#else
return 0;
#endif
return _num_touches;
}
/**
@ -2999,8 +2991,9 @@ get_num_touches(){
*
*/
TouchInfo WinGraphicsWindow::
get_touch_info(int index){
#ifdef HAVE_WIN_TOUCHINPUT
get_touch_info(int index) {
nassertr(index >= 0 && index < MAX_TOUCHES, TouchInfo());
TOUCHINPUT ti = _touches[index];
POINT point;
point.x = TOUCH_COORD_TO_PIXEL(ti.x);
@ -3013,7 +3006,4 @@ get_touch_info(int index){
ret.set_id(ti.dwID);
ret.set_flags(ti.dwFlags);
return ret;
#else
return TouchInfo();
#endif
}

View File

@ -34,8 +34,23 @@ typedef struct {
int y;
int width;
int height;
}
WINDOW_METRICS;
} WINDOW_METRICS;
#if WINVER < 0x0601
// Not used on Windows XP, but we still need to define it.
typedef struct tagTOUCHINPUT {
LONG x;
LONG y;
HANDLE hSource;
DWORD dwID;
DWORD dwFlags;
DWORD dwMask;
DWORD dwTime;
ULONG_PTR dwExtraInfo;
DWORD cxContact;
DWORD cyContact;
} TOUCHINPUT, *PTOUCHINPUT;
#endif
/**
* An abstract base class for glGraphicsWindow and dxGraphicsWindow (and, in
@ -177,10 +192,8 @@ private:
typedef pset<GraphicsWindowProc*> WinProcClasses;
WinProcClasses _window_proc_classes;
#ifdef HAVE_WIN_TOUCHINPUT
UINT _numTouches;
UINT _num_touches;
TOUCHINPUT _touches[MAX_TOUCHES];
#endif
private:
// We need this map to support per-window calls to window_proc().