diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 3039fd04..e1a82e04 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -1,5 +1,5 @@ ;sfall configuration settings -;v3.8.6 +;v3.8.7 [Main] ;Change to 1 if you want to use command line args to tell sfall to use another ini file. @@ -72,7 +72,7 @@ Use32BitHeadGraphics=0 ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX [Input] -;Set to 1 to enable the mouse scroll wheel to scroll through your inventory +;Set to 1 to enable the mouse scroll wheel to scroll through inventory, barter, and loot screens UseScrollWheel=1 ;The mouse Z position is divided by this modifier to calculate the number of inventory diff --git a/sfall/Inventory.cpp b/sfall/Inventory.cpp index 70c1f92e..d552d0c1 100644 --- a/sfall/Inventory.cpp +++ b/sfall/Inventory.cpp @@ -23,6 +23,7 @@ #include "Define.h" #include "FalloutEngine.h" #include "HookScripts.h" +#include "input.h" #include "Inventory.h" #include "LoadGameHook.h" @@ -633,6 +634,126 @@ end: } } +static void __declspec(naked) loot_container_hack2() { + __asm { + cmp esi, 0x150 // source_down + je scroll + cmp esi, 0x148 // source_up + jne end +scroll: + push edx + push ecx + push ebx + mov eax, ds:[_i_wid] + call GNW_find_ + mov ebx, [eax+0x8+0x0] // ebx = _i_wid.rect.x + mov ecx, [eax+0x8+0x4] // ecx = _i_wid.rect.y + mov eax, 297 + add eax, ebx // x_start + add ebx, 297+64 // x_end + mov edx, 37 + add edx, ecx // y_start + add ecx, 37+6*48 // y_end + call mouse_click_in_ + pop ebx + pop ecx + pop edx + test eax, eax + jz end + cmp esi, 0x150 // source_down + je targetDown + mov esi, 0x18D // target_up + jmp end +targetDown: + mov esi, 0x191 // target_down +end: + mov eax, ds:[_curr_stack] + retn + } +} + +static void __declspec(naked) barter_inventory_hack2() { + __asm { + push edx + push ecx + push ebx + xchg esi, eax + cmp esi, 0x150 // source_down + je scroll + cmp esi, 0x148 // source_up + jne end +scroll: + mov eax, ds:[_i_wid] + call GNW_find_ + mov ebx, [eax+0x8+0x0] // ebx = _i_wid.rect.x + mov ecx, [eax+0x8+0x4] // ecx = _i_wid.rect.y + push ebx + push ecx + mov eax, 395 + add eax, ebx // x_start + add ebx, 395+64 // x_end + mov edx, 35 + add edx, ecx // y_start + add ecx, 35+3*48 // y_end + call mouse_click_in_ + pop ecx + pop ebx + test eax, eax + jz notTargetScroll + cmp esi, 0x150 // source_down + je targetDown + mov esi, 0x18D // target_up + jmp end +targetDown: + mov esi, 0x191 // target_down + jmp end +notTargetScroll: + push ebx + push ecx + mov eax, 250 + add eax, ebx // x_start + add ebx, 250+64 // x_end + mov edx, 20 + add edx, ecx // y_start + add ecx, 20+3*48 // y_end + call mouse_click_in_ + pop ecx + pop ebx + test eax, eax + jz notTargetBarter + cmp esi, 0x150 // source_down + je barterTargetDown + mov esi, 0x184 // target_barter_up + jmp end +barterTargetDown: + mov esi, 0x176 // target_barter_down + jmp end +notTargetBarter: + mov eax, 165 + add eax, ebx // x_start + add ebx, 165+64 // x_end + mov edx, 20 + add edx, ecx // y_start + add ecx, 20+3*48 // y_end + call mouse_click_in_ + test eax, eax + jz end + cmp esi, 0x150 // source_down + je barterSourceDown + mov esi, 0x149 // source_barter_up + jmp end +barterSourceDown: + mov esi, 0x151 // source_barter_down +end: + pop ebx + pop ecx + pop edx + mov eax, esi + cmp eax, 0x11 + retn + } +} + void InventoryInit() { mode=GetPrivateProfileInt("Misc", "CritterInvSizeLimitMode", 0, ini); @@ -701,6 +822,13 @@ void InventoryInit() { // Move items to player's main inventory instead of the opened bag/backpack when confirming a trade SafeWrite32(0x475CF2, _stack); + + // Enable mouse scroll control in barter and loot screens when the cursor is hovering over other lists + if (UseScrollWheel) { + MakeCall(0x473E66, loot_container_hack2); + MakeCall(0x4759F1, barter_inventory_hack2); + *((DWORD*)_max) = 100; + }; } void InventoryReset() { invenapcost=GetPrivateProfileInt("Misc", "InventoryApCost", 4, ini); diff --git a/sfall/dinput.cpp b/sfall/dinput.cpp index 40582aeb..1e31a0c6 100644 --- a/sfall/dinput.cpp +++ b/sfall/dinput.cpp @@ -23,15 +23,17 @@ #include "main.h" +#include "FalloutEngine.h" #include "graphics.h" #include "ScriptExtender.h" #include "HookScripts.h" +#include "input.h" #include "DebugEditor.h" #include "Logging.h" typedef HRESULT (_stdcall *DInputCreateProc)(HINSTANCE a,DWORD b,IDirectInputA** c,IUnknown* d); -static bool UseScrollWheel; +bool UseScrollWheel = true; static DWORD WheelMod; static bool ReverseMouse; @@ -53,15 +55,20 @@ static DWORD KeysDown[MAX_KEYS]; static int mouseX; static int mouseY; -static DWORD ForcingGraphicsRefresh=0; +static DWORD ForcingGraphicsRefresh = 0; -static DWORD DebugEditorKey=0; +static DWORD DebugEditorKey = 0; -void _stdcall ForceGraphicsRefresh(DWORD d) { ForcingGraphicsRefresh=(d==0)?0:1; } -void GetMouse(int* x, int* y) { *x=mouseX; *y=mouseY; mouseX=0; mouseY=0; } +void _stdcall ForceGraphicsRefresh(DWORD d) { + ForcingGraphicsRefresh = (d == 0) ? 0 : 1; +} -static BYTE LMouse=0; -static BYTE RMouse=0; +void GetMouse(int* x, int* y) { + *x = mouseX; *y = mouseY; mouseX = 0; mouseY = 0; +} + +static BYTE LMouse = 0; +static BYTE RMouse = 0; static int MPMouseX; static int MPMouseY; @@ -73,12 +80,13 @@ static std::queue bufferedPresses; static HKL keyboardLayout; void SetMDown(bool down, bool right) { - if(right) RMouse=down?0x80:0; - else LMouse=down?0x80:0; + if (right) RMouse = down ? 0x80 : 0; + else LMouse = down ? 0x80 : 0; } + void SetMPos(int x, int y) { - MPMouseX=x; - MPMouseY=y; + MPMouseX = x; + MPMouseY = y; } DWORD _stdcall KeyDown(DWORD key) { @@ -87,11 +95,11 @@ DWORD _stdcall KeyDown(DWORD key) { } key = key & 0xFFFF; // combined use of DINPUT states + confirmation from GetAsyncKeyState() - if (key>MAX_KEYS) { + if (key > MAX_KEYS) { return 0; } else { DWORD keyVK = 0; - if (KeysDown[key]) { // confirm pressed state + if (KeysDown[key]) { // confirm pressed state keyVK = MapVirtualKeyEx(key, MAPVK_VSC_TO_VK, keyboardLayout); if (keyVK) KeysDown[key] = (GetAsyncKeyState(keyVK) & 0x8000); } @@ -101,232 +109,317 @@ DWORD _stdcall KeyDown(DWORD key) { void _stdcall TapKey(DWORD key) { DIDEVICEOBJECTDATA data; - data.dwTimeStamp=0; - data.dwSequence=0; - data.dwOfs=key; - data.dwData=0x80; + data.dwTimeStamp = 0; + data.dwSequence = 0; + data.dwOfs = key; + data.dwData = 0x80; bufferedPresses.push(data); - data.dwData=0x00; + data.dwData = 0x00; bufferedPresses.push(data); } class FakeDirectInputDevice : public IDirectInputDeviceA { private: - IDirectInputDeviceA* RealDevice; - DWORD DeviceType; + IDirectInputDeviceA* RealDevice; + DWORD DeviceType; ULONG Refs; bool formatLock; DIDATAFORMAT oldFormat; public: - /*** Constructor and misc functions ***/ - FakeDirectInputDevice(IDirectInputDevice* device,DWORD type) { - RealDevice=device; - DeviceType=type; - Refs=1; + /*** Constructor and misc functions ***/ + FakeDirectInputDevice(IDirectInputDevice* device,DWORD type) { + RealDevice = device; + DeviceType = type; + Refs = 1; formatLock = false; - oldFormat.dwDataSize=0; - } - /*** IUnknown methods ***/ - HRESULT _stdcall QueryInterface (REFIID riid, LPVOID * ppvObj) { return RealDevice->QueryInterface(riid,ppvObj); } - ULONG _stdcall AddRef(void) { return ++Refs; } - ULONG _stdcall Release(void) { - if(--Refs==0) { + oldFormat.dwDataSize = 0; + } + + /*** IUnknown methods ***/ + HRESULT _stdcall QueryInterface(REFIID riid, LPVOID * ppvObj) { + return RealDevice->QueryInterface(riid, ppvObj); + } + + ULONG _stdcall AddRef(void) { + return ++Refs; + } + + ULONG _stdcall Release(void) { + if (--Refs == 0) { RealDevice->Release(); delete this; return 0; - } else { return Refs; } + } else { + return Refs; + } + } + + /*** IDirectInputDevice8A methods ***/ + HRESULT _stdcall GetCapabilities(LPDIDEVCAPS a) { + return RealDevice->GetCapabilities(a); + } + + HRESULT _stdcall EnumObjects(LPDIENUMDEVICEOBJECTSCALLBACKA a, LPVOID b, DWORD c) { + return RealDevice->EnumObjects(a, b, c); + } + + HRESULT _stdcall GetProperty(REFGUID a, DIPROPHEADER* b) { + return RealDevice->GetProperty(a, b); + } + + HRESULT _stdcall SetProperty(REFGUID a, const DIPROPHEADER* b) { + return RealDevice->SetProperty(a, b); + } + + HRESULT _stdcall Acquire(void) { + return RealDevice->Acquire(); + } + + HRESULT _stdcall Unacquire(void) { + return RealDevice->Unacquire(); } - /*** IDirectInputDevice8A methods ***/ - HRESULT _stdcall GetCapabilities(LPDIDEVCAPS a) { return RealDevice->GetCapabilities(a); } - HRESULT _stdcall EnumObjects(LPDIENUMDEVICEOBJECTSCALLBACKA a,LPVOID b,DWORD c) { return RealDevice->EnumObjects(a,b,c); } - HRESULT _stdcall GetProperty(REFGUID a,DIPROPHEADER* b) { return RealDevice->GetProperty(a,b); } - HRESULT _stdcall SetProperty(REFGUID a,const DIPROPHEADER* b) { return RealDevice->SetProperty(a,b); } - HRESULT _stdcall Acquire(void) { return RealDevice->Acquire(); } - HRESULT _stdcall Unacquire(void) { return RealDevice->Unacquire(); } //Only called for the mouse - HRESULT _stdcall GetDeviceState(DWORD a,LPVOID b) { - if(ForcingGraphicsRefresh) RefreshGraphics(); - if(DeviceType!=kDeviceType_MOUSE) { - return RealDevice->GetDeviceState(a,b); + HRESULT _stdcall GetDeviceState(DWORD a, LPVOID b) { + if (ForcingGraphicsRefresh) RefreshGraphics(); + if (DeviceType != kDeviceType_MOUSE) { + return RealDevice->GetDeviceState(a, b); } DIMOUSESTATE2 MouseState; HRESULT hr; int numButtons; - if(formatLock) hr=RealDevice->GetDeviceState(sizeof(DIMOUSESTATE2), &MouseState); - else hr=RealDevice->GetDeviceState(sizeof(DIMOUSESTATE), &MouseState); - if(FAILED(hr)) return hr; - if(ReverseMouse) { - BYTE tmp=MouseState.rgbButtons[0]; - MouseState.rgbButtons[0]=MouseState.rgbButtons[1]; - MouseState.rgbButtons[1]=tmp; + if (formatLock) hr = RealDevice->GetDeviceState(sizeof(DIMOUSESTATE2), &MouseState); + else hr = RealDevice->GetDeviceState(sizeof(DIMOUSESTATE), &MouseState); + if (FAILED(hr)) return hr; + if (ReverseMouse) { + BYTE tmp = MouseState.rgbButtons[0]; + MouseState.rgbButtons[0] = MouseState.rgbButtons[1]; + MouseState.rgbButtons[1] = tmp; } - if(AdjustMouseSpeed) { - double d=((double)MouseState.lX)*MouseSpeedMod + MousePartX; + if (AdjustMouseSpeed) { + double d = ((double)MouseState.lX)*MouseSpeedMod + MousePartX; MousePartX = modf(d, &d); - MouseState.lX=(LONG)d; - d=((double)MouseState.lY)*MouseSpeedMod + MousePartY; + MouseState.lX = (LONG)d; + d = ((double)MouseState.lY)*MouseSpeedMod + MousePartY; MousePartY = modf(d, &d); - MouseState.lY=(LONG)d; + MouseState.lY = (LONG)d; } if (UseScrollWheel) { int count = 1; if (MouseState.lZ > 0) { - if (WheelMod) count = MouseState.lZ / WheelMod; - if (count < 1) count = 1; - while (count--) TapKey(DIK_UP); + if (*(DWORD*)_gmouse_current_cursor == 2 || *(DWORD*)_gmouse_current_cursor == 3) { + __asm { + call display_scroll_up_; + } + } else { + if (WheelMod) count = MouseState.lZ / WheelMod; + if (count < 1) count = 1; + while (count--) TapKey(DIK_UP); + } } else if (MouseState.lZ < 0) { - if (WheelMod) count = (-MouseState.lZ) / WheelMod; - if (count < 1) count = 1; - while (count--) TapKey(DIK_DOWN); + if (*(DWORD*)_gmouse_current_cursor == 2 || *(DWORD*)_gmouse_current_cursor == 3) { + __asm { + call display_scroll_down_; + } + } else { + if (WheelMod) count = (-MouseState.lZ) / WheelMod; + if (count < 1) count = 1; + while (count--) TapKey(DIK_DOWN); + } } } - if(MiddleMouseKey&&MouseState.rgbButtons[2]) { - if(!MiddleMouseDown) { + if (MiddleMouseKey&&MouseState.rgbButtons[2]) { + if (!MiddleMouseDown) { TapKey(MiddleMouseKey); - MiddleMouseDown=true; + MiddleMouseDown = true; } - } else MiddleMouseDown=false; - mouseX=MouseState.lX; - mouseY=MouseState.lY; + } else MiddleMouseDown = false; + mouseX = MouseState.lX; + mouseY = MouseState.lY; numButtons = formatLock ? 8 : 4; - for(int i=0;i 0); } - KeysDown[256+i]=MouseState.rgbButtons[i]; + KeysDown[256 + i] = MouseState.rgbButtons[i]; } memcpy(b, &MouseState, sizeof(DIMOUSESTATE)); - return 0; - } + return 0; + } + //Only called for the keyboard - HRESULT _stdcall GetDeviceData(DWORD a,DIDEVICEOBJECTDATA* b,DWORD* c,DWORD d) { - if(DeviceType!=kDeviceType_KEYBOARD) { - return RealDevice->GetDeviceData(a,b,c,d); + HRESULT _stdcall GetDeviceData(DWORD a, DIDEVICEOBJECTDATA* b, DWORD* c, DWORD d) { + if (DeviceType != kDeviceType_KEYBOARD) { + return RealDevice->GetDeviceData(a, b, c, d); } RunGlobalScripts2(); - if(!b||bufferedPresses.empty()||(d&DIGDD_PEEK)) { - HRESULT hr=RealDevice->GetDeviceData(a,b,c,d); - if(FAILED(hr)||!b||!(*c)) return hr; - for(DWORD i=0;i<*c;i++) { - KeysDown[b[i].dwOfs]=b[i].dwData&0x80; + if (!b || bufferedPresses.empty() || (d&DIGDD_PEEK)) { + HRESULT hr = RealDevice->GetDeviceData(a, b, c, d); + if (FAILED(hr) || !b || !(*c)) return hr; + for (DWORD i = 0; i < *c; i++) { + KeysDown[b[i].dwOfs] = b[i].dwData & 0x80; KeyPressHook(b[i].dwOfs, (b[i].dwData & 0x80) > 0, MapVirtualKeyEx(b[i].dwOfs, MAPVK_VSC_TO_VK, keyboardLayout)); } - if(KeysDown[DebugEditorKey]) RunDebugEditor(); + if (KeysDown[DebugEditorKey]) RunDebugEditor(); return hr; } //Despite passing an array of 32 data objects, fallout cant seem to cope with a key being pressed and released in the same frame... //TODO: Fallouts behaviour when passing multiple keypresses makes it appear like it's expecting the DIDEVICEOBJECTDATA struct to be // something other than 16 bytes. afaik, fallout uses DX3 for input, which is before the appData field was added, but it could // be worth checking anyway. - *b=bufferedPresses.front(); + *b = bufferedPresses.front(); bufferedPresses.pop(); - *c=1; + *c = 1; return DI_OK; } - HRESULT _stdcall SetDataFormat(const DIDATAFORMAT* a) { - if(formatLock&&oldFormat.dwSize) return RealDevice->SetDataFormat(&oldFormat); + + HRESULT _stdcall SetDataFormat(const DIDATAFORMAT* a) { + if (formatLock&&oldFormat.dwSize) return RealDevice->SetDataFormat(&oldFormat); memcpy(&oldFormat, a, sizeof(DIDATAFORMAT)); return RealDevice->SetDataFormat(a); } - HRESULT _stdcall SetEventNotification(HANDLE a) { return RealDevice->SetEventNotification(a); } - HRESULT _stdcall SetCooperativeLevel(HWND a,DWORD b) { - if(DeviceType==kDeviceType_KEYBOARD&&BackgroundKeyboard) b=DISCL_BACKGROUND|DISCL_NONEXCLUSIVE; - if(DeviceType==kDeviceType_MOUSE&&BackgroundMouse) b=DISCL_BACKGROUND|DISCL_NONEXCLUSIVE; - return RealDevice->SetCooperativeLevel(a,b); + + HRESULT _stdcall SetEventNotification(HANDLE a) { + return RealDevice->SetEventNotification(a); + } + + HRESULT _stdcall SetCooperativeLevel(HWND a, DWORD b) { + if (DeviceType == kDeviceType_KEYBOARD&&BackgroundKeyboard) b = DISCL_BACKGROUND | DISCL_NONEXCLUSIVE; + if (DeviceType == kDeviceType_MOUSE&&BackgroundMouse) b = DISCL_BACKGROUND | DISCL_NONEXCLUSIVE; + return RealDevice->SetCooperativeLevel(a, b); + } + + HRESULT _stdcall GetObjectInfo(LPDIDEVICEOBJECTINSTANCEA a, DWORD b, DWORD c) { + return RealDevice->GetObjectInfo(a, b, c); + } + + HRESULT _stdcall GetDeviceInfo(LPDIDEVICEINSTANCEA a) { + return RealDevice->GetDeviceInfo(a); + } + + HRESULT _stdcall RunControlPanel(HWND a, DWORD b) { + return RealDevice->RunControlPanel(a, b); + } + + HRESULT _stdcall Initialize(HINSTANCE a, DWORD b, REFGUID c) { + return RealDevice->Initialize(a, b, c); + } + + void LockDataFormat(bool lock) { + formatLock = lock; } - HRESULT _stdcall GetObjectInfo(LPDIDEVICEOBJECTINSTANCEA a,DWORD b,DWORD c) { return RealDevice->GetObjectInfo(a,b,c); } - HRESULT _stdcall GetDeviceInfo(LPDIDEVICEINSTANCEA a) { return RealDevice->GetDeviceInfo(a); } - HRESULT _stdcall RunControlPanel(HWND a,DWORD b) { return RealDevice->RunControlPanel(a,b); } - HRESULT _stdcall Initialize(HINSTANCE a,DWORD b,REFGUID c) { return RealDevice->Initialize(a,b,c); } - void LockDataFormat(bool lock) {formatLock = lock; } }; + class FakeDirectInput : public IDirectInputA { private: - IDirectInputA* RealInput; + IDirectInputA* RealInput; ULONG Refs; public: - /*** Constructor ***/ - FakeDirectInput(IDirectInput* Real) { RealInput=Real; Refs=1; } - /*** IUnknown methods ***/ - HRESULT _stdcall QueryInterface (REFIID riid, LPVOID* ppvObj) { return RealInput->QueryInterface(riid,ppvObj); } - ULONG _stdcall AddRef(void) { return ++Refs; } - ULONG _stdcall Release(void) { - if(--Refs==0) { + /*** Constructor ***/ + FakeDirectInput(IDirectInput* Real) { + RealInput = Real; Refs = 1; + } + + /*** IUnknown methods ***/ + HRESULT _stdcall QueryInterface(REFIID riid, LPVOID* ppvObj) { + return RealInput->QueryInterface(riid, ppvObj); + } + + ULONG _stdcall AddRef(void) { + return ++Refs; + } + + ULONG _stdcall Release(void) { + if (--Refs == 0) { RealInput->Release(); delete this; return 0; - } else { return Refs; } - } - /*** IDirectInput8A methods ***/ - HRESULT _stdcall CreateDevice(REFGUID r,IDirectInputDeviceA** device,IUnknown* unused) { + } else { + return Refs; + } + } + + /*** IDirectInput8A methods ***/ + HRESULT _stdcall CreateDevice(REFGUID r, IDirectInputDeviceA** device, IUnknown* unused) { GUID GUID_SysMouse = { 0x6F1D2B60, 0xD5A0, 0x11CF, { 0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00} }; GUID GUID_SysKeyboard = { 0x6F1D2B61, 0xD5A0, 0x11CF, { 0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00} }; - if(r!=GUID_SysKeyboard&&r!=GUID_SysMouse) { - return RealInput->CreateDevice(r,device,unused); + if (r != GUID_SysKeyboard && r != GUID_SysMouse) { + return RealInput->CreateDevice(r, device, unused); } else { - DWORD d; + DWORD d; IDirectInputDeviceA* RealDevice; HRESULT hr; - if(r==GUID_SysKeyboard) d=kDeviceType_KEYBOARD; - else d=kDeviceType_MOUSE; - hr=RealInput->CreateDevice(r,&RealDevice,unused); - if(hr!=DI_OK) return hr; + if (r == GUID_SysKeyboard) d = kDeviceType_KEYBOARD; + else d = kDeviceType_MOUSE; + hr = RealInput->CreateDevice(r, &RealDevice, unused); + if (hr != DI_OK) return hr; - FakeDirectInputDevice* fd=new FakeDirectInputDevice(RealDevice,d); - *device = fd; - if(d==kDeviceType_MOUSE) { - if(FAILED(fd->SetDataFormat(&c_dfDIMouse2))) { + FakeDirectInputDevice* fd = new FakeDirectInputDevice(RealDevice, d); + *device = fd; + if (d == kDeviceType_MOUSE) { + if (FAILED(fd->SetDataFormat(&c_dfDIMouse2))) { dlogr("ERROR: Could not set mouse format to DIMOUSESTATE2. Only 4 buttons will be available!", DL_MAIN); } else fd->LockDataFormat(true); } - return DI_OK; - } - } - HRESULT _stdcall EnumDevices(DWORD a,LPDIENUMDEVICESCALLBACKA b,void* c,DWORD d) { return RealInput->EnumDevices(a,b,c,d); } - HRESULT _stdcall GetDeviceStatus(REFGUID r) { return RealInput->GetDeviceStatus(r); } - HRESULT _stdcall RunControlPanel(HWND a,DWORD b) { return RealInput->RunControlPanel(a,b); } - HRESULT _stdcall Initialize(HINSTANCE a,DWORD b) { return RealInput->Initialize(a,b); } + return DI_OK; + } + } + + HRESULT _stdcall EnumDevices(DWORD a, LPDIENUMDEVICESCALLBACKA b, void* c, DWORD d) { + return RealInput->EnumDevices(a, b, c, d); + } + + HRESULT _stdcall GetDeviceStatus(REFGUID r) { + return RealInput->GetDeviceStatus(r); + } + + HRESULT _stdcall RunControlPanel(HWND a, DWORD b) { + return RealInput->RunControlPanel(a, b); + } + + HRESULT _stdcall Initialize(HINSTANCE a, DWORD b) { + return RealInput->Initialize(a, b); + } }; -HRESULT _stdcall FakeDirectInputCreate(HINSTANCE a,DWORD b,IDirectInputA** c,IUnknown* d) { - ZeroMemory(KeysDown,sizeof(KeysDown)); +HRESULT _stdcall FakeDirectInputCreate(HINSTANCE a, DWORD b, IDirectInputA** c, IUnknown* d) { + ZeroMemory(KeysDown, sizeof(KeysDown)); - HMODULE dinput=LoadLibraryA("dinput.dll"); - if(!dinput||dinput==INVALID_HANDLE_VALUE) return -1; - DInputCreateProc proc=(DInputCreateProc)GetProcAddress(dinput, "DirectInputCreateA"); - if(!proc) return -1; - - HRESULT hr=proc(a,b,c,d); - if(FAILED(hr)) return hr; + HMODULE dinput = LoadLibraryA("dinput.dll"); + if (!dinput || dinput == INVALID_HANDLE_VALUE) return -1; + DInputCreateProc proc = (DInputCreateProc)GetProcAddress(dinput, "DirectInputCreateA"); + if (!proc) return -1; - ReverseMouse=GetPrivateProfileInt("Input", "ReverseMouseButtons", 0, ini)!=0; + HRESULT hr = proc(a, b, c, d); + if (FAILED(hr)) return hr; - UseScrollWheel=GetPrivateProfileInt("Input", "UseScrollWheel", 1, ini)!=0; - WheelMod=GetPrivateProfileInt("Input", "ScrollMod", 0, ini); - LONG MouseSpeed=GetPrivateProfileInt("Input", "MouseSensitivity", 100, ini); - if(MouseSpeed!=100) { - AdjustMouseSpeed=true; - MouseSpeedMod=((double)MouseSpeed)/100.0; - MousePartX=0; - MousePartY=0; - } else AdjustMouseSpeed=false; + ReverseMouse = GetPrivateProfileInt("Input", "ReverseMouseButtons", 0, ini) != 0; - MiddleMouseKey=GetPrivateProfileInt("Input", "MiddleMouse", 0x30, ini); - MiddleMouseDown=false; + UseScrollWheel = GetPrivateProfileInt("Input", "UseScrollWheel", 1, ini) != 0; + WheelMod = GetPrivateProfileInt("Input", "ScrollMod", 0, ini); + LONG MouseSpeed = GetPrivateProfileInt("Input", "MouseSensitivity", 100, ini); + if (MouseSpeed != 100) { + AdjustMouseSpeed = true; + MouseSpeedMod = ((double)MouseSpeed) / 100.0; + MousePartX = 0; + MousePartY = 0; + } else AdjustMouseSpeed = false; - BackgroundKeyboard=GetPrivateProfileInt("Input", "BackgroundKeyboard", 0, ini)!=0; - BackgroundMouse=GetPrivateProfileInt("Input", "BackgroundMouse", 0, ini)!=0; + MiddleMouseKey = GetPrivateProfileInt("Input", "MiddleMouse", 0x30, ini); + MiddleMouseDown = false; - DebugEditorKey=GetPrivateProfileInt("Input", "DebugEditorKey", 0, ini); + BackgroundKeyboard = GetPrivateProfileInt("Input", "BackgroundKeyboard", 0, ini) != 0; + BackgroundMouse = GetPrivateProfileInt("Input", "BackgroundMouse", 0, ini) != 0; - *c=(IDirectInputA*)new FakeDirectInput(*c); + DebugEditorKey = GetPrivateProfileInt("Input", "DebugEditorKey", 0, ini); + + *c = (IDirectInputA*)new FakeDirectInput(*c); keyboardLayout = GetKeyboardLayout(0); diff --git a/sfall/input.h b/sfall/input.h index c250b183..63344243 100644 --- a/sfall/input.h +++ b/sfall/input.h @@ -18,6 +18,8 @@ #pragma once +extern bool UseScrollWheel; + void SetMPMode(bool active); void SetMDown(bool down, bool right); void SetMPos(int x, int y); @@ -122,7 +124,7 @@ void GetMouse(int* x, int* y); #define DIK_NOCONVERT 0x7B /* (Japanese keyboard) */ #define DIK_YEN 0x7D /* (Japanese keyboard) */ #define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */ -#define DIK_CIRCUMFLEX 0x90 /* (Japanese keyboard) */ +#define DIK_PREVTRACK 0x90 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ #define DIK_AT 0x91 /* (NEC PC98) */ #define DIK_COLON 0x92 /* (NEC PC98) */ #define DIK_UNDERLINE 0x93 /* (NEC PC98) */ @@ -169,4 +171,9 @@ void GetMouse(int* x, int* y); #define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */ #define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */ +/* + * Alternate names for keys originally not used on US keyboards. + */ +#define DIK_CIRCUMFLEX DIK_PREVTRACK /* Japanese keyboard */ + void _stdcall ForceGraphicsRefresh(DWORD); diff --git a/sfall/version.h b/sfall/version.h index 904e176a..d7ad4e54 100644 --- a/sfall/version.h +++ b/sfall/version.h @@ -22,12 +22,12 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 6 +#define VERSION_BUILD 7 #define VERSION_REV 0 #ifdef WIN2K -#define VERSION_STRING "3.8.6 win2k" +#define VERSION_STRING "3.8.7 win2k" #else -#define VERSION_STRING "3.8.6" +#define VERSION_STRING "3.8.7" #endif #define CHECK_VAL (4)