Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411518 Posts in 69380 Topics- by 58436 Members - Latest Member: GlitchyPSI

May 01, 2024, 01:53:05 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)non standard gamepads and WM_INPUT
Pages: [1]
Print
Author Topic: non standard gamepads and WM_INPUT  (Read 5305 times)
mechacrash
Level 1
*


It's almost like I'm actually being productive!


View Profile
« on: September 26, 2010, 02:41:45 PM »

i say sorry in advance because this is a really specific question... one which even google cannot answer...

im currently trying to read gamepads / joysticks through the WM_INPUT message in windows. I had registered the two device types:

Code:
RAWINPUTDEVICE rid[2];
rid[0].usUsagePage = 0x01;
rid[0].usUsage = 0x05;
rid[0].dwFlags = RIDEV_INPUTSINK;
rid[0].hwndTarget = hWnd;

rid[1].usUsagePage = 0x01;
rid[1].usUsage = 0x04;
rid[1].dwFlags = RIDEV_INPUTSINK;
rid[1].hwndTarget = hWnd;
RegisterRawInputDevices(rid,2,sizeof(rid[0]));

and have started grabbing and translating the information as its received through the WNDPROC:

Code:
LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam){
    if(uMsg == WM_INPUT){
        RAWINPUT raw;
        UINT dwSize = sizeof(raw);
        GetRawInputData(hRawInput,RID_INPUT,&raw,&dwSize,sizeof(RAWINPUTHEADER));
        if(raw.header.dwType == RIM_TYPEHID){
            BYTE* test = new BYTE[raw.data.hid.dwCount * raw.data.hid.dwSizeHid];           
            test = &raw.data.hid.bRawData;
        }
    }
    return DefWindowProc(hWnd,uMsg,wParam,lParam);
}

and this works perfectly with 2 of my 3 available gamepads...

my cheap 8 button, 2 axis gamepad works, my psp (running FuSa) works... however my USB connected PS3 controller does not...

instead it sends itself as RIM_TYPEMOUSE (instead of RIM_TYPEHID) and gives garbled data regardless of what i read it as (mouse, keyboard or hid)

im assuming this is not only the case for PS3 controllers, but also for other controllers that i havnt got at hand.

If i use the standard windows mmsystem to read gamepad input, the PS3 controller works as expected... however i must use the RAW_INPUT model to comply with my current layout...

does anyone know what im doing wrong, or any fixes to this issue?
Logged

Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #1 on: September 27, 2010, 05:08:14 AM »

Could it be those goofy analog sticks?  I can see those begin picked up as a mouse.
Logged



What would John Carmack do?
mechacrash
Level 1
*


It's almost like I'm actually being productive!


View Profile
« Reply #2 on: September 27, 2010, 08:50:10 AM »

i doubt thats the case... as i said, its stored in the registry (both under media devices and DINPUT.DLL) as a joystick / gamepad... its registry values show that it has the standard gamepad layout (4 bytes are flags, second 4 determine the number of usable buttons on the gamepad) and it works perfectly if i use mmsystem (joyGetPosEx - same as SDL)

the issue is that i need it to only return data to a single function when a change occurs... rawinput does this perfectly (using it for keyboard and mouse atm)

mmsystem requires a call to a checker function every frame, same as dinput...

unless anyone can tell me how to read the driver and input even more directly than RAW_INPUT then i gotta try this :/
Logged

mechacrash
Level 1
*


It's almost like I'm actually being productive!


View Profile
« Reply #3 on: September 27, 2010, 09:53:15 AM »

OK... turns out i need to read documentation better...

i should have queried the size of the rawinputbuffer first before setting it, that way i can determine if the size is suitable for the input... and in turn get the correct data

Code:
UINT cbSize;
GetRawInputData(hRawInput,RID_INPUT,0,&cbSize,sizeof(RAWINPUTHEADER));
LPBYTE lpbBuffer = new BYTE[cbSize];
GetRawInputData(hRawInput,RID_INPUT,lpbBuffer,&cbSize,sizeof(RAWINPUTHEADER));
RAWINPUT *raw = (RAWINPUT*)lpbBuffer;

fixed :/
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic