Hand scroll smoothing to prevent physics punching.
@@ -16,6 +16,7 @@ HWND win32_window = nullptr;
tex2d_t win32_target = {};
IDXGISwapChain1 *win32_swapchain = {};
float win32_scroll = 0;
+float win32_scroll_dest = 0;
void win32_resize(int width, int height) {
if (width == d3d_screen_width && height == d3d_screen_height)
@@ -41,7 +42,7 @@ bool win32_init(const char *app_name) {
case WM_CLOSE: sk_run = false; PostQuitMessage(0); break;
case WM_SETFOCUS: sk_focused = true; break;
case WM_KILLFOCUS: sk_focused = false; break;
- case WM_MOUSEWHEEL:win32_scroll += (short)HIWORD(wParam); break;
+ case WM_MOUSEWHEEL:win32_scroll_dest += (short)HIWORD(wParam); break;
case WM_SIZE: if (wParam != SIZE_MINIMIZED) win32_resize((UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); break;
case WM_SYSCOMMAND: if ((wParam & 0xfff0) == SC_KEYMENU) return (LRESULT)0; // Disable alt menu
default: return DefWindowProc(hWnd, message, wParam, lParam);
@@ -97,6 +98,7 @@ void win32_step_begin() {
TranslateMessage(&msg);
DispatchMessage (&msg);
}
+ win32_scroll = win32_scroll + (win32_scroll_dest - win32_scroll) * sk_timev_elapsedf * 8;
win32_input_update();
}
void win32_step_end() {
