From f9648c2b42e3684c50fdbaefc011c4bdf2851ced Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 26 Nov 2006 13:20:23 +0000 Subject: [PATCH] Windows updates --- videowin.h | 18 +++++++++--------- winmain.cc | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/videowin.h b/videowin.h index 2b0050c..7e85644 100644 --- a/videowin.h +++ b/videowin.h @@ -31,7 +31,7 @@ #include "defines.h" #include "video.h" -#define DS_DEBUG +//#define DS_DEBUG class DsSourceFilter; class DsAllocator; @@ -58,18 +58,18 @@ class VideoWin : public Video int setPosition(int x, int y); int sync(); int play(); - int dsplay(); - bool InIframemode() {return iframemode;}; + int dsplay(); + bool InIframemode() {return iframemode;}; int stop(); - int dsstop(); + int dsstop(); int pause(); - int dspause(); + int dspause(); int unPause(); - int dsunPause(); + int dsunPause(); int fastForward(); int unFastForward(); int reset(); - int dsreset(); + int dsreset(); int blank(); int signalOn(); int signalOff(); @@ -97,11 +97,11 @@ class VideoWin : public Video virtual void ResetTimeOffsets(); void SetAudioState(bool state){audioon=state;}; - void SetAudioVolume(long volume); + void SetAudioVolume(long volume); void turnVideoOn(){videoon=true;}; void turnVideoOff(){videoon=false;}; - + virtual void displayIFrame(const UCHAR* buffer, UINT length); unsigned int getPosx() {return videoposx;}; diff --git a/winmain.cc b/winmain.cc index 9fc88ca..0b4db46 100644 --- a/winmain.cc +++ b/winmain.cc @@ -61,7 +61,16 @@ Audio* audio; bool wnd_fullscreen=false; RECT wnd_fs_rect={20,20,768+20,576+20}; RECT wnd_fs_rect_client={0,0,768,576}; -OSVERSIONINFO windows_ver; //attempt to distigsh windows versions +//OSVERSIONINFO windows_ver; //attempt to distigsh windows versions +bool remotefnc=false; + + +HMODULE user32dll; +typedef UINT (*GETRAWINPUTDATAFNC) (HRAWINPUT,UINT,LPVOID,PUINT,UINT); +typedef UINT (*REGISTERRAWINPUTDEVICEFNC) (PCRAWINPUTDEVICE,UINT,UINT); + +GETRAWINPUTDATAFNC dynGetRawInputData=NULL; +REGISTERRAWINPUTDEVICEFNC dynRegisterRawInputDevices=NULL; void MILLISLEEP(ULONG a) @@ -77,6 +86,19 @@ DWORD WINAPI commandthreadStart(void *arg) return 0; } +void LoadRemoteFunctions() { + user32dll=LoadLibrary("user32.dll"); + if (user32dll!=NULL) { + dynGetRawInputData=(GETRAWINPUTDATAFNC)GetProcAddress(user32dll,"GetRawInputData"); + if (dynGetRawInputData!=NULL) { + dynRegisterRawInputDevices=(REGISTERRAWINPUTDEVICEFNC)GetProcAddress(user32dll,"RegisterRawInputDevices"); + if (dynRegisterRawInputDevices!=NULL) { + remotefnc=true; + } + } + } +} + bool InitApp(HINSTANCE hinst,int cmdshow); HWND win_main;//global window handle @@ -87,6 +109,7 @@ HACCEL acc; INT WINAPI WinMain( HINSTANCE hinst , HINSTANCE previnst, LPSTR cmdline, int cmdshow) { //On Windows we have to init a window, we use DXUT + LoadRemoteFunctions(); if (!InitApp(hinst,cmdshow)) return false; //Starting Network support WSADATA wsadat; @@ -95,6 +118,7 @@ INT WINAPI WinMain( HINSTANCE hinst , HINSTANCE previnst, LPSTR cmdline, int cmd ERROR_MSG("Initialising WinSocked: Error at WSAStartup()\n"); return 0; } + result= CoInitializeEx(NULL,COINIT_MULTITHREADED );//Initialize COM for DirectShow if (result!=S_OK) { ERROR_MSG("Initialising COM: Error at Coinitialize()\n"); @@ -311,6 +335,7 @@ INT WINAPI WinMain( HINSTANCE hinst , HINSTANCE previnst, LPSTR cmdline, int cmd WaitForSingleObject(commandthread,INFINITE); shutdown(0); WSACleanup(); + if (user32dll) FreeModule(user32dll); return 0; } @@ -489,14 +514,13 @@ LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam) break; case WM_INPUT: - if ((windows_ver.dwMajorVersion>5 || - (windows_ver.dwMajorVersion==5 && windows_ver.dwMinorVersion>=1)) ) { + if (remotefnc ) { //only on XP! LPRAWINPUT lpit; UINT risize; - GetRawInputData((HRAWINPUT)lparam,RID_INPUT,NULL,&risize,sizeof(RAWINPUTHEADER)); + dynGetRawInputData((HRAWINPUT)lparam,RID_INPUT,NULL,&risize,sizeof(RAWINPUTHEADER)); lpit=(LPRAWINPUT)malloc(risize); - GetRawInputData((HRAWINPUT)lparam,RID_INPUT,lpit,&risize,sizeof(RAWINPUTHEADER)); + dynGetRawInputData((HRAWINPUT)lparam,RID_INPUT,lpit,&risize,sizeof(RAWINPUTHEADER)); if (lpit->header.dwType==RIM_TYPEHID && lpit->data.hid.dwSizeHid>=2) { DWORD button=lpit->data.hid.bRawData[1] | (lpit->data.hid.bRawData[0]<< 8); @@ -548,8 +572,6 @@ LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam) bool InitApp(HINSTANCE hinst,int cmdshow) { /* main window */ - windows_ver.dwOSVersionInfoSize=sizeof(windows_ver); - GetVersionEx(&windows_ver); WNDCLASS wcs; DWORD flags; wcs.style = CS_HREDRAW | CS_VREDRAW; @@ -596,8 +618,7 @@ bool InitApp(HINSTANCE hinst,int cmdshow) { return FALSE; ShowWindow(win,SW_SHOWNORMAL); UpdateWindow(win); - if (windows_ver.dwMajorVersion>5 || - ( windows_ver.dwMajorVersion==5 && windows_ver.dwMinorVersion>=1)) {//at least windows XP + if (remotefnc) {//at least windows XP /* We want to support MCE Remote controls*/ RAWINPUTDEVICE remote_control_data[4]; ZeroMemory(remote_control_data,sizeof(remote_control_data)); @@ -613,7 +634,7 @@ bool InitApp(HINSTANCE hinst,int cmdshow) { remote_control_data[3].usUsagePage=0x01; remote_control_data[3].usUsage=0x80; remote_control_data[3].dwFlags=0; - if (RegisterRawInputDevices(remote_control_data,4,sizeof(remote_control_data[0]))!=TRUE) { + if (dynRegisterRawInputDevices(remote_control_data,4,sizeof(remote_control_data[0]))!=TRUE) { MessageBox(0,"Registering remote control failed!","Aborting!",0); return FALSE; } -- 2.39.5