need help with an api call for my wiimote lib

Blitz3D Forums/Blitz3D Userlibs/need help with an api call for my wiimote lib

Charrua(Posted 2009) [#1]
Hi, i'been paying arround with a wiimote last year and wrote some code to handle it (http://blitzbasic.com/Community/posts.php?topic=78384), it seems to work correctly under XP but, i'm testing the code under Vista Home Basic and found a trouble.

the call to wiiSetupDiGetClassDevs returnsme a -1, I call getLastError and give me error code #13 (i couldn't find what means 13 help here too!).

the line of code is
DeviceInfoSet = wiiSetupDiGetClassDevs(GUID,"",0,Flags)


(inside the Function: ObtenerHID() )

The fact is that if in the same machine i do that call from a small app in VisualBasic 6, and it works good. So I think that is not merely a vista problem.


any idea?

thank's in advance

Juan

(sorry for my bad english!)


_PJ_(Posted 2009) [#2]
Traditionally, an Error 13 (With regards to Device Drivers) in Windows is:

[quote]
Code 13
This device is either not present, not working properly, or does not have all the drivers installed. (Code 13)

To have Windows detect whether this device is present or not, click Detect Hardware.
Solution button: Detect Hardware

This code indicates that the device driver did not find the hardware.
[/code]


Charrua(Posted 2009) [#3]
thank's malice

but I'm confused, becouse that error arrives when I do the call from blitz but when I do the same call from visual basic the routine doesn'r report any error and work properly. Why the same call does two diferent thing's?

the machine, operating system and drivers are the same. The source of the call is diferent, from Visual Basic 6.0 and from blitz. Under XP I have no problems.

any idea?


_PJ_(Posted 2009) [#4]
I have no idea, I don;t like Vista ftrom what limited experience I have with it, but I can hazard a guess it might be related to Vista's insitence on admin rights and signed drivers?
i.e. Run blitz as an administrator and check the drivers are signed.... sorry can't help much :S


Charrua(Posted 2009) [#5]
thank's again

i tried to run in administrator mode, try to run blitz in xp compatibility and the like, but without succees! I'm new too in vista and at this time I' m testing if my other software works properly with it, and obviously the wiimote code fail the tests!

based on the sample dll that is in the userlibs.txt on the userlibs folder i did a simple dll to handle some matrix calulations just for test if I could done some thing like that, but my skills are so limited with c and i'm not shure that could write part of the lib or the whole lib in c. But being a technician in electronics I think that I travel so far in porgramming so, probably do the work (try at least) if no one has a simpler solution. I think that if it works from within visual basic it will work from c.

I'm using BlueSolei and probably try to use other bloototh stack if my hardware work with it. But I relize that the problem is not in vista, should be the calling method from within blitz?

best regards

Juan


AJ00200(Posted 2009) [#6]
You can try what I'm doing.

You need the Internet Channel for your Wii, and a free web hosting account at t35.com.

Build a webpage to access the opera.wii JavaScript object, and use AJAX to upload the info to a PHP script on the server, and use BB3D to connect to the server and get the info.

Google opera.wii, and Wii Opera SDK


Warner(Posted 2009) [#7]
Actually, I think it should work from Blitz3D, there might just be something small that is causing this. I wish I could help, but I have no Wiimote.
If you're considering writing a DLL, maybe you could create one in VB?


_PJ_(Posted 2009) [#8]

Actually, I think it should work from Blitz3D


I agree. Doesn't Blitz effectively go 'via' windows to do stuff like that?

I do admit this is all quite beyond me, and I neither have Wii remote, nor know much about DLLs etc.

I am a little confused as to what's happening, can you clarify:

1) You call the 'function' from a VB app on XP - No problem ?
2) You call the 'function' from Blitz3D on XP - No problem ?
3) You call the 'function' from a VB app on Vista - No Problem ?
4) You call the 'function' from Blitz3D on Vista - Error Report ?

Are you SURE the .decls fiile is written properly and in the right place with the dll? Maybe just try a quick test on Vista with B3D using a different .dll and .decls t(that does something different)


Charrua(Posted 2009) [#9]
thank's people!

that's my "wii_setupapi.decls" (the same i use on xp)



that's are the declarations in a .bas of VB required to get access to an api from Visual Basic:



of particular interest the declaration of the routine that is problematic at this time (is the first error I found and probably if i fix it oher arrives...!)




malice, yes to all 1,2,3, 4. I think that the code should work from blitz.

that call isn't related wiht the wiimote. Acordingly with the few thing's I know that call is to get access to a list of all the devices that match certain type. The wiimote is seen as a HID (human interfase device) as a mouse or a keyboard. Some lines of code after, the code loops through that list (until reach the end) and get aditional information looking for a particular device number () with the intention of found specifically a wiimote.

the code i translated is from a book about USB devices (HID) and is related to a general pourpose code to find some kind of devices, the comments of the autor about that call says:

'******************************************************************************
'SetupDiGetClassDevs
'Returns: a handle to a device information set for all installed devices.
'Requires: the HidGuid returned in GetHidGuid.
'******************************************************************************

so is a call that should get no error

without bluesolei installed and with a mouse and a keypad connected on two usb ports, i get a list of 2 devices (always function properly from VB!), obviously no one matches the one I'm looking for (the not installed wiimote).
What i'm saying is that the trouble is in a function that report an error when it should report a least 2 devices!
by the way in xp blitz report the list of devices (mouse, keypad etc and the wiimote!)
thank's again

probably this weekend i have time to capture that BUG

Juan


Charrua(Posted 2009) [#10]
Hi again

i wrote a simple small app that use the call to the api that isn't working (in my machine) under vista.
It needs 3 .decls that are in the zip.

http://odriozola.juanignacio.googlepages.com/hidtest.zip

if is it posible for you to test what happens in your machine i will be pleased.

it will give a list of HID devices as: mouse, keyboard, joystick etc that are connected via usb (in theory)
or, it will be giving an error code 13, that's what happend in my machine under windows vista. Aparently under xp works properly

any test you could do under xp or vista will appreciated.

thank's in advance.

sincerely

Juan


_PJ_(Posted 2009) [#11]
Okay, here's my results:

I have no idea what it all means but I can tell you I do not possess a Wii or any hardware for it. :D

At least,it ran perfectly every time, I got no errors. I have a few HID devices attached, as my keyboard possesses its own USB ports too, plus I have joystick etc.

This was run on Blitz3D on Windows XP (service Pack 3)


wiiHidD_GetHidGuid: 1754207236
4D1E55B2
F16F
11CF
88
CB
00
11
11
00
00
30
wiiSetupDiGetClassDevs success!
Handle ID: 1260
\\?\hid#vid_046d&pid_c215#7&15e4f500&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
VendorID : 0000046D Product: 0000C215
No es el que yo busco
Handle ID: -1
\\?\hid#vid_046d&pid_c221&mi_00#8&25f687a2&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
VendorID : 0000046D Product: 0000C215
No es el que yo busco
Handle ID: 1260
\\?\hid#vid_046d&pid_c221&mi_01&col01#8&361dc87&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
VendorID : 0000046D Product: 0000C221
No es el que yo busco
Handle ID: 1260
\\?\hid#vid_046d&pid_c221&mi_01&col02#8&361dc87&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
VendorID : 0000046D Product: 0000C221
No es el que yo busco
Handle ID: -1
\\?\hid#vid_046d&pid_c225&col01#7&24b1a1&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
VendorID : 0000046D Product: 0000C221
No es el que yo busco
Handle ID: 1260
\\?\hid#vid_046d&pid_c225&col02#7&24b1a1&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
VendorID : 0000046D Product: 0000C225
No es el que yo busco
Handle ID: -1
\\?\hid#vid_1532&pid_0001#6&bea07d6&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
VendorID : 0000046D Product: 0000C225
No es el que yo busco
Ultimo dispositivo




Charrua(Posted 2009) [#12]
thnk's
it's just a list of HID's (Human Device Interfase) connected or listed (not necesary present) on your system. VendorID and ProductID are specific for a manufacturer and product so, when I search that list, I look for:
(VendorID = $057E) And (ProductID = $0306)the ones the wiimote has.
I don't know what specifically means VendorID $046D and the product $C225, but what I know with this loop is if one or more wiimotes are installed on a system.
Under xp i get a result similar to your depending on the amount of USB devices installed (i.e. keyboard, mouse, scanner, printer, joystick and the like, really not shure about scanner and printer but a pendrive should be no detectes as a HID).
The thing still is that the api call succeed in xp and not in vista when is made from blitz. When is made from VB is always ok.

If some one could test this code in vista i will be pleased.

at this moment I know that in my machine have this problem and i don't know if it is my machine or a general rule.

(when i say "not necesary present" is for example, if we connect the wiimote and blue solei detects it, then the call list the device even in the case that we were turned it off)

thanks

Juan


Warner(Posted 2009) [#13]
I'm on Windows Vista, this is the result:



_PJ_(Posted 2009) [#14]
Thanks for that explanation, Charrua, I understand it now :D

Looking at the
"nro de error: 13
Ultimo dispositivo"

of Warner's results, seems like it is a general issue with Blitz3D on vista, and since, it works on XP, I guess there's something about Vista that VB knows where to look, but Blitz for some reason doesn't or isn't allowed to.


Charrua(Posted 2009) [#15]
i feel the same!
thank's a lot for your help.
as always something new to investigate.

see you

Juan


Warner(Posted 2009) [#16]
When looking into this, I found mentions of SetupDiGetClassDevsW, SetupDiGetClassDevsExA and SetupDiGetClassDevsExW? Not sure what they are, what their difference is, and if they exist, but I thought it could be worth mentioning them.


Charrua(Posted 2009) [#17]
i'll try to google on this to see what they are

malice, warner thanks's sincerely

juan


Charrua(Posted 2009) [#18]
surprise, surprise

my functions call doesen't work from vista, but if i make a VirtualMachine with VirtualBox, and install an XP on it, the code above works!

so, in a virtual machine the call to the apis work and not direct from vista!

the big problem i have now is that, blitz only works in text mode, because the CountGfxModes3D reports 0 from blitz running on a VM!

any idea?



Juan


nanahuatzin(Posted 2010) [#19]
Hi.. this thread is a bit old... but i have just tested in an XP64 machine... and got the same error:


wiiHidD_GetHidGuid: 1749750832
4D1E55B2
F16F
11CF
88
CB
00
11
11
00
00
30
nro de error: 13
Ultimo dispositivo

So.. interesting...


Charrua(Posted 2010) [#20]
mmm, i thinked that the problem where on vista. I use 32 bits vista home basic and this detection code stop working from my 32 bits XP.

I rewrite the lib wiht another detection code, that work's in 32 bits XP and my 32 vista home basic, if you can test the new one, i'll be pleased
see this thread
http://www.blitzbasic.com/Community/posts.php?topic=89809
or download from my signature

nice to hear about you, has you enjoyed with the wiimote?

regards

Juan


nanahuatzin(Posted 2010) [#21]
well the new version works beatifully in XP 64

And yes, i have been having a los of fun... maybe i will do a video of it :)


Charrua(Posted 2010) [#22]
i'm glad to know that!

thank's for your feedback about xp64

keep in touch

Juan


_PJ_(Posted 2010) [#23]
That's good to know...
Any ideas on whether this works with Windows 7 too?

I don't own a Wii or Windowes 7, just curious! :D


Charrua(Posted 2010) [#24]
at this moment it work's on the few machines/os tested:
xp32, xp64 and vista home basic

when some one else do that test, hope it will post here or the wiimote 2010 thread

the problem where not about the file trasnfers to comunicate with the bluettooth device, in the transition to the new code, i made a VB code to obtaint the "Device file name" and using (pasting that string) it from blitz3d (in the same machine) there where no problems, so i found another way to ask the OS the device file name.

Obviously didnt fount that solution lookin for it, sudenly, working with keypads rawinput and the like, i found the way to ask for a device list!. And works in vista for wiimotes!

Juan


Blitzplotter(Posted 2010) [#25]
Hi Charrua,

this still has my interest, I've just been a little busy with work, exams & life stuff. I've got a Wii & A W7 machine - just gotta source the interfacing hardware.


Charrua(Posted 2010) [#26]
i'll wait for your results with W7. Hope you enjoy with it.
i just instaled W7 for test it on my laptop and this weekend i'll test the wiimote related software on it. Probably soon i'll install w7 64 on my home pc and then will do a test on it too.

Juan