📄 winlink.cpp
字号:
if FAILED(JoystickInput[CurrentJoy]->SetProperty(DIPROP_RANGE, &diprg.diph)) { Y1Disable[CurrentJoy]=1; Y2Disable[CurrentJoy]=1; } diprg.diph.dwObj = DIJOFS_Z; if (FAILED(JoystickInput[CurrentJoy]->SetProperty(DIPROP_RANGE, &diprg.diph))) { Z1Disable[CurrentJoy]=1; Z2Disable[CurrentJoy]=1; } diprg.diph.dwObj = DIJOFS_RX; if (FAILED(JoystickInput[CurrentJoy]->SetProperty(DIPROP_RANGE, &diprg.diph))) { RX1Disable[CurrentJoy]=1; RX2Disable[CurrentJoy]=1; } diprg.diph.dwObj = DIJOFS_RY; if (FAILED(JoystickInput[CurrentJoy]->SetProperty(DIPROP_RANGE, &diprg.diph))) { RY1Disable[CurrentJoy]=1; RY2Disable[CurrentJoy]=1; } diprg.diph.dwObj = DIJOFS_RZ; if (FAILED(JoystickInput[CurrentJoy]->SetProperty(DIPROP_RANGE, &diprg.diph))) { RZ1Disable[CurrentJoy]=1; RZ2Disable[CurrentJoy]=1; } diprg.diph.dwObj = DIJOFS_SLIDER(0); if (FAILED(JoystickInput[CurrentJoy]->SetProperty(DIPROP_RANGE, &diprg.diph))) { S01Disable[CurrentJoy]=1; S02Disable[CurrentJoy]=1; } diprg.diph.dwObj = DIJOFS_SLIDER(1); if (FAILED(JoystickInput[CurrentJoy]->SetProperty(DIPROP_RANGE, &diprg.diph))) { S11Disable[CurrentJoy]=1; S12Disable[CurrentJoy]=1; } DIDEVCAPS didc; didc.dwSize = sizeof(DIDEVCAPS); if (JoystickInput[CurrentJoy]->GetCapabilities(&didc) != DI_OK) { JoystickInput[CurrentJoy]->Release(); return DIENUM_CONTINUE; } if (didc.dwButtons <= 16) NumBTN[CurrentJoy] = didc.dwButtons; else NumBTN[CurrentJoy] = 16; if (didc.dwPOVs) NumPOV[CurrentJoy] = didc.dwPOVs; else POVDisable[CurrentJoy] = 1; DIPROPDWORD dipdw; dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(dipdw.diph); dipdw.diph.dwHow = DIPH_BYOFFSET; dipdw.dwData = 2500; dipdw.diph.dwObj = DIJOFS_X; JoystickInput[CurrentJoy]->SetProperty(DIPROP_DEADZONE, &dipdw.diph); dipdw.diph.dwObj = DIJOFS_Y; JoystickInput[CurrentJoy]->SetProperty(DIPROP_DEADZONE, &dipdw.diph); dipdw.diph.dwObj = DIJOFS_Z; JoystickInput[CurrentJoy]->SetProperty(DIPROP_DEADZONE, &dipdw.diph); dipdw.diph.dwObj = DIJOFS_RX; JoystickInput[CurrentJoy]->SetProperty(DIPROP_DEADZONE, &dipdw.diph); dipdw.diph.dwObj = DIJOFS_RY; JoystickInput[CurrentJoy]->SetProperty(DIPROP_DEADZONE, &dipdw.diph); dipdw.diph.dwObj = DIJOFS_RZ; JoystickInput[CurrentJoy]->SetProperty(DIPROP_DEADZONE, &dipdw.diph); dipdw.diph.dwObj = DIJOFS_SLIDER(0); JoystickInput[CurrentJoy]->SetProperty(DIPROP_DEADZONE, &dipdw.diph); dipdw.diph.dwObj = DIJOFS_SLIDER(1); JoystickInput[CurrentJoy]->SetProperty(DIPROP_DEADZONE, &dipdw.diph); dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(dipdw.diph); dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = DIPROPAXISMODE_ABS; dipdw.diph.dwObj = 0; JoystickInput[CurrentJoy]->SetProperty(DIPROP_AXISMODE, &dipdw.diph); CurrentJoy+=1; return DIENUM_CONTINUE;}void ReleaseDirectInput(){ if (MouseInput) { MouseInput->Release(); MouseInput = NULL; } if (KeyboardInput) { KeyboardInput->Release(); KeyboardInput = NULL; } for (int i=0; i<5; i++) if (JoystickInput[i]) { JoystickInput[i]->Release(); JoystickInput[i] = NULL; } if (DInput) { DInput->Release(); DInput = NULL; }}void ReleaseDirectSound(){ if (lpSoundBuffer) { lpSoundBuffer->Release(); lpSoundBuffer = NULL; } if (lpPrimaryBuffer) { lpPrimaryBuffer->Release(); lpPrimaryBuffer = NULL; } if (lpDirectSound) { lpDirectSound->Release(); lpDirectSound = NULL; }}void ReleaseDirectDraw(){ if (DD_CFB) { DD_CFB->Release(); DD_CFB = NULL; } if (DD_CFB16) { DD_CFB16->Release(); DD_CFB16 = NULL; } if (lpDDClipper) { lpDDClipper->Release(); lpDDClipper = NULL; } if (DD_Primary) { DD_Primary->Release(); DD_Primary = NULL; } if (lpDD) { lpDD->Release(); lpDD = NULL; }}void DInputError(){ char message1[256]; sprintf(message1,"Error initializing DirectInput\nYou may need to install DirectX 8.0a or higher located at www.microsoft.com/directx%c", 0); MessageBox (NULL, message1, "DirectInput Error" , MB_ICONERROR );}bool InitInput(){ char message1[256]; HRESULT hr; if (FAILED(hr=pDirectInput8Create(hInst,DIRECTINPUT_VERSION,IID_IDirectInput8A,(void **) &DInput,NULL))) { sprintf(message1,"Error initializing DirectInput\nYou may need to install DirectX 8.0a or higher located at www.microsoft.com/directx%c", 0); MessageBox (NULL, message1, "DirectInput Error" , MB_ICONERROR ); switch (hr) { case DIERR_BETADIRECTINPUTVERSION: sprintf(message1,"Beta %X\n",(unsigned int)hr); MessageBox (NULL, message1, "Init", MB_ICONERROR ); break; case DIERR_INVALIDPARAM: sprintf(message1,"Invalid %X\n",(unsigned int)hr); MessageBox (NULL, message1, "Init", MB_ICONERROR ); break; case DIERR_OLDDIRECTINPUTVERSION: sprintf(message1,"OLDDIRECTINPUTVERSION %X\n",(unsigned int)hr); MessageBox (NULL, message1, "Init", MB_ICONERROR ); break; case DIERR_OUTOFMEMORY: sprintf(message1,"OUTOFMEMORY %X\n",(unsigned int)hr); MessageBox (NULL, message1, "Init", MB_ICONERROR ); break; default: sprintf(message1,"UNKNOWN %X\n",(unsigned int)hr); MessageBox (NULL, message1, "Init", MB_ICONERROR ); break; } return FALSE; } hr=DInput->CreateDevice(GUID_SysKeyboard, &KeyboardInput,NULL); if (FAILED(hr)) {DInputError();return FALSE;} hr=KeyboardInput->SetDataFormat(&c_dfDIKeyboard); if (FAILED(hr)) {DInputError();return FALSE;} hr=KeyboardInput->SetCooperativeLevel(hMainWindow,DISCL_NONEXCLUSIVE | DISCL_FOREGROUND ); hr=DInput->CreateDevice(GUID_SysMouse, &MouseInput,NULL); if (FAILED(hr)) {DInputError();return FALSE;} hr=MouseInput->SetDataFormat(&c_dfDIMouse); if (FAILED(hr)) {DInputError();return FALSE;} hr=MouseInput->SetCooperativeLevel(hMainWindow,DISCL_EXCLUSIVE|DISCL_FOREGROUND); if (FAILED(hr)) {DInputError();return FALSE;} JoystickInput[0]=NULL;JoystickInput[1]=NULL;JoystickInput[2]=NULL;JoystickInput[3]=NULL;JoystickInput[4]=NULL; hr=DInput->EnumDevices(DI8DEVCLASS_GAMECTRL, InitJoystickInput, DInput, DIEDFL_ATTACHEDONLY); if (FAILED(hr)) {DInputError(); return FALSE;} InputAcquire(); return TRUE;}void TestJoy(){ int i; for(i=0;i<5;i++) { if (JoystickInput[i]) { JoystickInput[i]->Poll(); if (JoystickInput[i]->GetDeviceState(sizeof(DIJOYSTATE), &js[i])==DIERR_INPUTLOST) { if (JoystickInput[i]) JoystickInput[i]->Acquire(); if (FAILED(JoystickInput[i]->GetDeviceState(sizeof(DIJOYSTATE), &js[i]))) return; } if (!X1Disable[i]) { if (js[i].lX>0) X1Disable[i]=1; } if (!X2Disable[i]) { if (js[i].lX<0) X2Disable[i]=1; } if (!Y1Disable[i]) { if (js[i].lY>0) Y1Disable[i]=1; } if (!Y2Disable[i]) { if (js[i].lY<0) Y2Disable[i]=1; } if (!Z1Disable[i]) { if (js[i].lZ>0) Z1Disable[i]=1; } if (!Z2Disable[i]) { if (js[i].lZ<0) Z2Disable[i]=1; } if (!RY1Disable[i]) { if (js[i].lRy>0) RY1Disable[i]=1; } if (!RY2Disable[i]) { if (js[i].lRy<0) RY2Disable[i]=1; } if (!RZ1Disable[i]) { if (js[i].lRz>0) RZ1Disable[i]=1; } if (!RZ2Disable[i]) { if (js[i].lRz<0) RZ2Disable[i]=1; } if (!S01Disable[i]) { if (js[i].rglSlider[0]>0) S01Disable[i]=1; } if (!S02Disable[i]) { if (js[i].rglSlider[0]<0) S02Disable[i]=1; } if (!S11Disable[i]) { if (js[i].rglSlider[1]>0) S11Disable[i]=1; } if (!S12Disable[i]) { if (js[i].rglSlider[1]<0) S12Disable[i]=1; } } }}extern "C" {BYTE changeRes=1;extern DWORD converta;extern unsigned int BitConv32Ptr;extern unsigned int RGBtoYUVPtr;extern unsigned short resolutn;extern BYTE GUIWFVID[];extern BYTE GUIDSIZE[];extern BYTE GUISMODE[];extern BYTE GUIDSMODE[];extern BYTE GUIHQ2X[];extern BYTE GUIHQ3X[];extern BYTE GUIHQ4X[];extern BYTE GUINTVID[];extern BYTE hqFilterlevel;}DWORD FirstVid=1;DWORD FirstFull=1;DWORD DMode=0;DWORD SMode=0;DWORD DSMode=0;DWORD NTSCMode=0;DWORD prevHQMode=~0;DWORD prevNTSCMode=0;DWORD prevScanlines=~0;WORD Refresh = 0;int InitDirectDraw(){ DDSURFACEDESC2 ddsd2; DDPIXELFORMAT format; //MK: unused 2003/08/31 //HRESULT hr; //char message1[256]; unsigned int color32,ScreenPtr2; int i, j, k, r, g, b, Y, u, v; ScreenPtr2=BitConv32Ptr; for(i=0;i<65536;i++) { color32=((i&0xF800)<<8)+ ((i&0x07E0)<<5)+ ((i&0x001F)<<3)+0xFF000000; (*(unsigned int *)(ScreenPtr2))=color32; ScreenPtr2+=4; } for (i=0; i<32; i++) for (j=0; j<64; j++) for (k=0; k<32; k++) { r = i << 3; g = j << 2; b = k << 3; Y = (r + g + b) >> 2; u = 128 + ((r - b) >> 2); v = 128 + ((-r + 2*g -b)>>3); *(((unsigned int *)RGBtoYUVPtr) + (i << 11) + (j << 5) + k) = (Y<<16) + (u<<8) + v; } if (!hMainWindow) { exit(1); } ReleaseDirectDraw(); GetClientRect(hMainWindow, &rcWindow); ClientToScreen(hMainWindow, ( LPPOINT )&rcWindow); ClientToScreen(hMainWindow, ( LPPOINT )&rcWindow + 1); FullScreen=GUIWFVID[cvidmode]; DSMode=GUIDSMODE[cvidmode]; DWORD HQMode=0; if ( hqFilter != 0 ) { if ((GUIHQ2X[cvidmode] != 0) && (hqFilterlevel == 2)) HQMode=2; if ((GUIHQ3X[cvidmode] != 0) && (hqFilterlevel == 3)) HQMode=3; if ((GUIHQ4X[cvidmode] != 0) && (hqFilterlevel == 4)) HQMode=4; } if (FullScreen == 1) { if (HQMode && !DSMode) { int marginx = (rcWindow.right - rcWindow.left - BlitArea.right + BlitArea.left)/2; int marginy = (rcWindow.bottom - rcWindow.top - BlitArea.bottom + BlitArea.top)/2; if (marginx>0) { rcWindow.left += marginx; rcWindow.right -= marginx; } if (marginy>0) { rcWindow.top += marginy; rcWindow.bottom -= marginy; } } if ((DSMode == 1) && (scanlines != 0)) { int OldHeight = rcWindow.bottom - rcWindow.top; if ((OldHeight % 240) == 0) { int NewHeight = (OldHeight/240)*resolutn; rcWindow.top += (OldHeight - NewHeight)/2; rcWindow.bottom = rcWindow.top + NewHeight; } } } if (pDirectDrawCreateEx(NULL, (void **)&lpDD, IID_IDirectDraw7, NULL) != DD_OK) { MessageBox(NULL, "DirectDrawCreateEx failed.", "DirectDraw Error", MB_ICONERROR); return FALSE; } if (FullScreen == 1) { if (lpDD->SetCooperativeLevel(hMainWindow, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT) != DD_OK) { MessageBox(NULL, "IDirectDraw7::SetCooperativeLevel failed.", "DirectDraw Error", MB_ICONERROR); return FALSE; } if (lpDD->SetDisplayMode(WindowWidth, WindowHeight, 16, Refresh, 0) != DD_OK) { if (lpDD->SetDisplayMode(WindowWidth, WindowHeight, 16, 0, 0) != DD_OK) { MessageBox(NULL, "IDirectDraw7::SetDisplayMode failed.\nMake sure your video card supports this mode.", "DirectDraw Error", MB_ICONERROR); return FALSE; } else { KitchenSync = 0; KitchenSyncPAL = 0; Refresh = 0; } } } else { if (lpDD->SetCooperativeLevel(hMainWindow, DDSCL_NORMAL) != DD_OK) { MessageBox(NULL, "IDirectDraw7::SetCooperativeLevel failed.", "DirectDraw Error", MB_ICONERROR); return FALSE; } CheckAlwaysOnTop(); } ZeroMemory(&ddsd2, sizeof(DDSURFACEDESC2)); ddsd2.dwSize = sizeof(DDSURFACEDESC2); ddsd2.dwFlags = DDSD_CAPS; ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; if (FullScreen == 1) { ddsd2.dwFlags |= DDSD_BACKBUFFERCOUNT; ddsd2.dwBackBufferCount = 2;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -