It is possible to access RawInputdevices in C/C++ via the User32.dll , this is necessary it you want more than one mouse in your application for example.
Does anybody know how I can access these functions from within Purebasic.
GetRawInputData_ is the main function I require.
Hope you can help.
Thanks.
RawInput Devices
Re: RawInput Devices
Welcome to the forums.
Well, I don't know if I got your question right but I'll give it a shot anyway:
Basically, you can use any API function in PureBasic even if they are not defined,
ie API_Function_().
To do that, you could either access the appropriate DLL directly, like...
...or alternatively use PB's DLL-Importer. That's a matter of taste and handling.
The next issue you'll encounter is that none of the structures or constants you need
are pre-defined in PureBasic but that shouldn't be much of a problem.
With a basic understanding of C (or good imagination
) you'll be able to convert
the required headers to PB in next to no time.
I had a quick peek at MSDN and found the following which may be useful to
give you an idea:
I must admit, I never heard of these RawInput routines before and I should
already be sleeping for 2-3 hours now
- so please double-check the structures
as they may well contain errors!
BTW: As far as I could see you have to register the device beforehand but
you may already know that.
Hope that helps.
Well, I don't know if I got your question right but I'll give it a shot anyway:
Basically, you can use any API function in PureBasic even if they are not defined,
ie API_Function_().
To do that, you could either access the appropriate DLL directly, like...
Code: Select all
OpenLibrary(0, "user32.dll")
*f = IsFunction(0, "GetRawInputData")
If *f
If CallFunctionFast(*f, hRawInput.RAWINPUT, #RID_INPUT, #NULL, @pcbSize.l, SizeOf(RAWINPUTHEADER)) <> -1
;
; yadayadayada
;
EndIf
EndIf
CloseLibrary(0)
The next issue you'll encounter is that none of the structures or constants you need
are pre-defined in PureBasic but that shouldn't be much of a problem.
With a basic understanding of C (or good imagination
the required headers to PB in next to no time.
I had a quick peek at MSDN and found the following which may be useful to
give you an idea:
Code: Select all
; see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/rawinput.asp
#RID_INPUT = $10000003
Structure RAWINPUTHEADER
dwType.l
dwSize.l
hDevice.l
wParam.l
EndStructure
Structure usButtonHELP
usButtonFlags.w
usButtonData.w
EndStructure
Structure RAWMOUSE
usFlags.w
StructureUnion
ulButtons.l
usButton.usButtonHELP
EndStructureUnion
ulRawButtons.l
lLastX.l
lLastY.l
ulExtraInformation.l
EndStructure
Structure RAWKEYBOARD
MakeCod.w
Flags.w
Reserved.w
VKey.w
Message.l
ExtraInformation.l
EndStructure
Structure RAWHID
dwSizeHid.l
dwCount.l
bRawData.b
EndStructure
Structure RAWDATA
StructureUnion
mouse.RAWMOUSE
keyboard.RAWKEYBOARD
hid.RAWHID
EndStructureUnion
EndStructure
Structure RAWINPUT
header.RAWINPUTHEADER
Data.RAWDATA
EndStructure
already be sleeping for 2-3 hours now
as they may well contain errors!
BTW: As far as I could see you have to register the device beforehand but
you may already know that.
Hope that helps.
Good programmers don't comment their code. It was hard to write, should be hard to read.
-
IndiepathT
- New User

- Posts: 2
- Joined: Tue Feb 22, 2005 8:58 pm
Any got a working example of using the RawInput buffer with a mouse?
Been messing with it abit now, and so far without luck. Got to the point where I can recieve the WM_INPUT events in a windowcallback procedure and examine them with GetRawInputData. But I never get any success with the GetRawInputBuffer command.
a link to msdn about raw input:
http://msdn.microsoft.com/library/defau ... winput.asp
btw I think one of the structures in the above examples is abit wrong.
If needed I will post a example of my struggles laters, just abit tied up now.
Kind regards
Been messing with it abit now, and so far without luck. Got to the point where I can recieve the WM_INPUT events in a windowcallback procedure and examine them with GetRawInputData. But I never get any success with the GetRawInputBuffer command.
a link to msdn about raw input:
http://msdn.microsoft.com/library/defau ... winput.asp
btw I think one of the structures in the above examples is abit wrong.
Code: Select all
Structure RAWMOUSE
unitid.w ; <---- this needs added.
usFlags.w
StructureUnion
ulButtons.l
usButton.usButtonHELP
EndStructureUnion
ulRawButtons.l
lLastX.l
lLastY.l
ulExtraInformation.l
EndStructure
Kind regards

