News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Input handling with WM_INPUT and other win32/win64 questions

Started by ccdcmc421, March 25, 2025, 10:02:26 AM

Previous topic - Next topic

sinsi

This line shouldn't compile?
mov     DWORD PTR [RawInputDevices.hwndTarget], RAXhwndTarget is a QWORD

What does RegisterRawInputDevices return?

You're using fastcall, are you setting up shadow space correctly?

zedd151

Quote from: sinsi on March 25, 2025, 02:20:09 PMWhat does RegisterRawInputDevices return?

Quote from: ccdcmc421 on March 25, 2025, 12:32:50 PMRAX = 00000000000003E6

Edit:
Whoops, That was what GetLastError returned.  :undecided:  sorry 'bout that. I will leave now.   :eusa_boohoo:
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

NoCforMe

Let's hope we can just leave all this "raw input" crap behind us ...
Assembly language programming should be fun. That's why I do it.

TimoVJL

Using Raw Input
RAWINPUTDEVICE structure
So RAWINPUTDEVICE structs could have static values in it, except if hwndTarget is needed.

Small test:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

TCHAR *szAppName = TEXT("WinFrame");
TCHAR *szFrameClass = TEXT("cWinFrame");
HWND hFrame;
HANDLE hInst;

RAWINPUTDEVICE rid[2] = {1,0x06,RIDEV_NOLEGACY,0};

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX wcx;
    MSG msg;

    wcx.cbSize = sizeof(WNDCLASSEX);
    wcx.style = CS_HREDRAW | CS_VREDRAW;
    wcx.lpfnWndProc = WndProc;
    wcx.cbClsExtra = 0;
    wcx.cbWndExtra = 0;
    wcx.hInstance = hInstance;
    wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcx.hbrBackground= (HBRUSH)COLOR_APPWORKSPACE+1;
    wcx.lpszMenuName = NULL;
    wcx.lpszClassName= szFrameClass;
    wcx.hIconSm = 0;

    if (!RegisterClassEx(&wcx))
        return 0;
    hInst = hInstance;

    hFrame = CreateWindowEx(0, szFrameClass, szAppName,
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT,
        CW_USEDEFAULT, CW_USEDEFAULT,
        NULL, NULL, hInst, NULL);
    if(!hFrame) return 0;
    ShowWindow(hFrame, nCmdShow);
    //UpdateWindow(hFrame);
    rid[0].hwndTarget = hFrame;    // test target window
    if (RegisterRawInputDevices(rid, 1, sizeof(rid[0])) == FALSE) {
        MessageBox(hFrame, TEXT("failled"), TEXT("error"), MB_OK);
    }

    while(GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch(uMsg) {
        case WM_INPUT:
            OutputDebugString(TEXT("WM_INPUT"));
            return (0);
        case WM_DESTROY:
            PostQuitMessage(0);
            return(0);
    }
    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}

And that earlier error:
Error name:
    ERROR_NOACCESS

Error value:
    0x000003E6 (998)

Description:
    Invalid access to memory location.
May the source be with you

NoCforMe

Assembly language programming should be fun. That's why I do it.

NoCforMe

So OP: how goes your experiment with the old-school keyboard messages?
Despite the recent disruption we're still interested in that.
Assembly language programming should be fun. That's why I do it.

ccdcmc421

Hi all,

I'm so sorry!

So, I actually came to the conclusion that I might be a bit slow. Should have used WM_TIMER messages. WM_CHAR Didn't really work out so well as it had the same effect as WM_KEYDOWN. However, WM_TIMER worked perfectly for my use case in handling crisp, clean and responsive inputs.

I appreciate the assistance and the minds of everyone who tried to help :)

sucks that rawinput messages don't work, but for the use, case this is working perfectly. Maybe one day I'll have to revisit the Rawinputdevices thing. But that wont be till the future and when I'm more experienced.

zedd151

Well that's not a very satisfying conclusion.  :sad:  Your post above mine sounds like you are finished with this part of the code.

No code to share with us, or even just the executable?
It really would have been nice to see your current progress.  :smiley:
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—