Jump to content

Getting Raw Input


Oxin8
 Share

Recommended Posts

I've been trying to get the rawinput api's to work for awhile now and I'm still pretty stumped. I started off trying to do it in vb but failed so I moved right on to try in autoit.

What I'm trying to do is get raw input from a usb device (a PS2 Dvd Remote) and then act on it. The problem is getting the input. I can find the device and read it's info(just the basic string that's stored in the registry or whatever) and it tells me that it found the correct device. I don't know how to get the input though. I know this is kinda advanced but I wouldn't post it here if it wasn't.

http://msdn.microsoft.com/library/default....ut/rawinput.asp

Const $RIDI_DEVICENAME = 0x20000007
Const $RID_INPUT = 0x10000003
Const $RID_HEADER = 0x10000005
$ridl=DllStructCreate("dword;dword")
$numdevices=DllStructCreate("int")
$temp=DllCall("user32.dll","long","GetRawInputDeviceList","ptr",0,"ptr",DllStructGetPtr($numdevices),"long",DllStructGetSize($ridl))
;MsgBox(0,"Call Return:",$temp)
$devnum = DllStructGetData($numdevices,1)
MsgBox(0,"Number of Devices:",$devnum)
;Dim $rid[4]
$temp = ""
For $i = 1 to ($devnum-1)
    $temp=$temp & "dword;dword;"
Next
$temp = $temp & "dword;dword"
;MsgBox(0,"Structure:",$temp)
$rid=DllStructCreate($temp)
$dwsize = $numdevices * DllStructGetSize($ridl)
$temp=DllCall("user32.dll","long","GetRawInputDeviceList","ptr",DllStructGetPtr($rid),"ptr",DllStructGetPtr($numdevices),"long",DllStructGetSize($ridl))
;MsgBox(0,"Call Return:",$temp)
For $i = 0 to ($devnum-1)
    $devname=DllStructCreate("char[256]")
    $size=DllStructCreate("dword")
    DllStructSetData($size,1,256)
    DllCall("user32.dll","long","GetRawInputDeviceInfo","long",DllStructGetData($rid,($i*2)+1),"int",$RIDI_DEVICENAME,"ptr",DllStructGetPtr($devname),"ptr",DllStructGetPtr($size))
    MsgBox(0,"Device: " & $i, "Handle: " & DllStructGetData($rid,($i*2)+1) & " Type: " & DllStructGetData($rid,($i*2)+2) & " Name: " & DllStructGetData($devname,1))
    If StringInStr(DllStructGetData($devname,1),"Vid_0925") <> 0 Then;works up to here
        MsgBox(0,"Score!","Playstation 2 Dvd Remote Found!")
        $remotehwnd = DllStructGetData($rid,($i*2)+1)
        $i = 99
    EndIf
Next
$size=0;DllStructCreate("dword")
$RawInputHeader=DllStructCreate("dword;dword;dword;dword")
$RawInput=DllStructCreate("dword;dword;dword;dword;dword;dword;byte[256]")
MsgBox(0,"Size:",DllStructGetData($size,1))
;here's the call that i can't get working
$temp = DllCall("user32.dll","int","GetRawInputData", _
    "long",$remotehwnd,"int",$RID_HEADER, _
    "ptr",0,"long",$size, _
    "long",DllStructGetSize($RawInputHeader) )
$ourError = DLLCall("kernel32.dll","int","GetLastError")
MsgBox(0,"Error:",$ourError)
MsgBox(0,"Call Return:",$temp)
MsgBox(0,"Size:",DllStructGetData($size,1))
For $i = 1 to 7
MsgBox(0,"Data Lister:",DllStructGetData($RawInput,$i))
Next
Link to comment
Share on other sites

You may wish to check out some usb sniffers with available source, such as snoopy (a sourceforge project) -- this would let you see the syntax being used in those development languages, perhaps easing a port to au3 or (gasp) vb. I like the following link as a jumping off point for things USB. http://www.lvr.com/usb.htm

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...