USB Port Scanner
Bill Chennault
Posts: 1,198
All--
I am looking for something that will tell me which USB COMM port my Logitech Dual Action Gamepad grabs. Is there such a thing as USB port scanner software?
IDEALLY, I would be able to use it to not only tell me which USB COMM port is grabbed, but what codes are sent per control activation.
I plan to use the Gamepad with Ugly Buster, at first, and eventually with my lawnmower. While on Ugly Buster, I will devote a BS2p24 to the eb501 that receives commands from the Gamepad via D-Link hub/laptop/Zoom Class I Bluetooth dongle.
First, I have to figure out which port the Gamepad uses and XP SP2 doesn't seem to want to tell me. (Although the calibration software works fine.)
Thanks!
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
I am looking for something that will tell me which USB COMM port my Logitech Dual Action Gamepad grabs. Is there such a thing as USB port scanner software?
IDEALLY, I would be able to use it to not only tell me which USB COMM port is grabbed, but what codes are sent per control activation.
I plan to use the Gamepad with Ugly Buster, at first, and eventually with my lawnmower. While on Ugly Buster, I will devote a BS2p24 to the eb501 that receives commands from the Gamepad via D-Link hub/laptop/Zoom Class I Bluetooth dongle.
First, I have to figure out which port the Gamepad uses and XP SP2 doesn't seem to want to tell me. (Although the calibration software works fine.)
Thanks!
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
Comments
Thanks! However, I have done that, of course. It does not tell me which COMM port the Logitech Dual Action Gamepad uses. However, I agree with you; IT SHOULD.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
The I don't believe the gamepad actually maps on a comm port. If you are using Windows with Visual Basic, download and install the latest DirectX development kit. The gamepad will be accessable and readable as a DirectX object.
You can see if the gamepad is being accessed as a direct X object by running DXDiag.exe. You should see the device listed on the input tab.
Post Edited (MSDTech) : 9/10/2008 12:43:26 AM GMT
Do you mean the DirectX drivers that I have on the CD that came with the Zoom dongle, or possibly something else? I did not install the CD DirectX 8.1 software . . . yet.
Thanks!
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
Wow!
I installed DirectX 9.0 and ran DXDIAG.EXE. I got more information than a non-super Windows expert like me can decipher. Give me the next hint concerning how I might use the Dual Action Gamepad with VB6.0. It seems there must be some channel of communication between the Gamepad and VB . . . somehow, somewhere.
Thanks!
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
You will first need to download and install the DirextX software development kit from the Microsoft website. It is almost 500MB, so plan on a long download. This provides the references that you will need to add to your VB6 project. The latest version is 9, but I'm using an older version 8.
In your VB app, select Project then Reference on the menu bar to list and select the DirectX Type Libraries (see attached picture).
In your code, you will first need to define the objects and properties that you deal with to communicate with the joystick:
'Variables for the DirectX interface to the Joystick
Dim dx As New DirectX8
Dim di As DirectInput8
Dim diDev As DirectInputDevice8
Dim diDevEnum As DirectInputEnumDevices8
Dim joyCaps As DIDEVCAPS
Dim JoyStick As DIJOYSTATE
Dim DiProp_Dead As DIPROPLONG
Dim DiPRop_Range As DIPROPRANGE
Dim DiProp_Saturation As DIPROPLONG
Then you will need to create the objects, make the connection to the joystick and set some of its properties in your program initialization:
'Initialize the Joystick Object
Set di = dx.DirectInputCreate
Set diDevEnum = di.GetDIDevices(DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY)
Set diDev = di.CreateDevice(diDevEnum.GetItem(1).GetGuidInstance)
diDev.SetCommonDataFormat DIFORMAT_JOYSTICK
diDev.GetCapabilities joyCaps
With DiProp_Dead
.lData = 1000
.lHow = DIPH_BYOFFSET
.lObj = DIJOFS_X
diDev.SetProperty "DIPROP_DEADZONE", DiProp_Dead
.lObj = DIJOFS_Y
diDev.SetProperty "DIPROP_DEADZONE", DiProp_Dead
.lObj = DIJOFS_Y
diDev.SetProperty "DIPROP_DEADZONE", DiProp_Dead
.lObj = DIJOFS_RZ
diDev.SetProperty "DIPROP_DEADZONE", DiProp_Dead
End With
With DiProp_Saturation
.lData = 9500
.lHow = DIPH_BYOFFSET
.lObj = DIJOFS_X
diDev.SetProperty "DIPROP_SATURATION", DiProp_Saturation
.lObj = DIJOFS_Y
diDev.SetProperty "DIPROP_SATURATION", DiProp_Saturation
End With
With DiPRop_Range
.lHow = DIPH_DEVICE
.lMin = 0
.lMax = 10000
End With
diDev.SetProperty "DIPROP_RANGE", DiPRop_Range
diDev.Acquire
Note: this code assumes that only one joystick is attached to the computer.
You should now be able to read the various controls on the joystick with the command:
diDev.GetDeviceStateJoystick JoyStick
You will find the position of the analog controls in
JoyStick.x JoyStick.y JoyStick.z JoyStick.rz
The various buttons are in the array JoyStick.Buttons(x)
I found the value for x was one less than the number printed on the gamepad since the array is 0 based.
I would suggest you create a simple application that just displays the various JoyStick values in a set of text boxes to get a better feel for the types of output you can expect while its running.
Well, I used to call myself a real VB programmer. (!) As I lay in bed last night, I was hoping the software would make the gamepad appear as a control to VB and all I would have to·do is include the control and use it, along with its convenient properties box, as I wished.
Ha, ha, ha! [noparse]:)[/noparse]
Thank you very much and I will get to work learning some stuff I should have learned long ago instead of acting like a big-shot running my part of the college! (I bet I had guys that worked for me that could do this out of the box! Now, they don't know my name, but then I don't have to run cover-up operations for them anymore, either! Or, create the tons of paperwork we invent in higher education so we can raise taxes.)
I really appreciate your help. If you discover something of use--and I will look, as well--I would love to know about it.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
Post Edited (Bill Chennault) : 9/10/2008 2:34:37 PM GMT
I'm still doing a lot of searching in msdn.microsoft.com to determine all the properties and methods exposed by the DirectX interface. It seems like another case where Microsoft took a simple idea and made it overly complex. On of the articles that I found helpful in decoding the various properties and constants in the code was:
http://msdn.microsoft.com/en-us/library/bb205973(VS.85).aspx
Keep in mind, the properties you set for the behavior of the joystick can only be changed before you actually acquire the device (note its the last method called on my sample above). I've also found a large bottle of asprin really helps when trying to sort through these Object Oriented Programs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Using this gamepad is doubtless beyond me. However, I am going to spend some time on it. I bet a FULL implementation of the gamepad would consume FAR more code space than my entire application!
There SHOULD be a device with software that allows one to load it as a tool component with properties right into VB. (Maybe I was out the day Microsoft called for my ideas?)
I certainly appreciate all your help and the fact that this topic has been moved to a place that assures no one else will contribute. After all, getting VB to communicate with a Stamp has never been a popular subject, especially when it comes to devices the PC will handle to make the Stamp more viable in both the hobby and commercial worlds. (We ought to develop this thing and sell it.)
If I can get anything up and running--such as your software--maybe I can expand by example to include other controls on the gamepad.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
1. Reads the joystick state.
2. Determines the robots actions based on the joystick and button states.
3. Sends the one-character commands to the robot through the bluetooth connection.
Snipping out the common code and the piece for motor control:
Motion = " "
diDev.GetDeviceStateJoystick JoyStick 'This is the only call required to the joystick object·the state of all the buttons and controls on the joystick is·now in the Joystick object
Select Case JoyStick.z 'right joystick on my gamepad for and aft motion
······· Case 0 To 1500
··········· Motion = "F"
······· Case 1501 To 3500
··········· Motion = "f"
······· Case 3501 To 6500
··········· Motion = "S"
······· Case 6501 To 8500
··········· Motion = "b"
······· Case 8501 To 10000
··········· Motion = "B"
··· End Select
Select Case JoyStick.rz ' left and right position - turning motions take precedence for my robot
······· Case 0 To 1500
··········· Motion = "L"
······· Case 8501 To 10000
··········· Motion = "R"
End Select
'Gather up all the controls being read on the joystick into a public string for the sendcommand sub
CommandString = Motion & Pan & Tilt & Lights & Gripper & SpecialMove
SendCommand 'This subroutine sends the control string to the robot
I had a chance to use this entire system at the opening assembly for school this year and sat in the audience with my laptop and gamepad and was able to drive the robot on stage and interact with the Superintendant while she was speaking.
It is only complex due to the transition to object oriented programming, which does take a little while to get used to. The older vb controls were also object based, but they at least provided a convenient window that would let you see the properties as a unit. This is also the type of transition you will need to make moving to the newer versions of VB, as they are now fully object oriented.
Ha! You are a genius! Thanks!
Let me get this up and running. After that, if I have problems implenting the remaining controls, I will float a question to you here in the SANDBOX under this subject.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
I dropped ALL of your VB code into Form_Load() and added these two statements right before End Sub just to see if I could get something to work . . .
Text1 = "X: " & JoyStick.X & vbCrLf & "Y: " & JoyStick.Y
Text2 = "X: " & JoyStick.rx & vbCrLf & "Y: " & JoyStick.ry
When I start the app the display is as you would expect, except that the left joystick X (JoyStick.X) equals 5000, as does the left joystick Y (JoyStick.Y). Both·ordinates of the right joystick (JoyStick.rx and JoyStick.ry) equal 0.
Since this is a pretty static application, I stopped it and held the joysticks in some other position than their default center position, but there was no change in readings.
What am I doing wrong? And, where should I REALLY put your most-excellent VB code? Finally, what event is good to drop the following into?
diDev.GetDeviceStateJoystick JoyStick
Text1 = "X: " & JoyStick.X & vbCrLf & "Y: " & JoyStick.Y
Text2 = "X: " & JoyStick.rx & vbCrLf & "Y: " & JoyStick.ry
Although my questions display my ignorance of modern VB, I got a lot further than I figured!
Thanks, as always!
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
I've attached the modified code I downloaded from·a reference on the·MSDN forums. This is what I started with to figure out how to get the joystick to work I wish I still had the original to give the author his due.
You might want to review this and run it to make sure your joystick responds the same way the phillips joystick I've got does.
Thank you so much!
I'll let you know how it goes.
It is raining, raining, raining here in The Land Of Oz. I think it is from the left-overs of two hurricanes ago.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
It worked!
I expanded it, of course, to include all the buttons. Now, I need to figure out the two "buttons" on top of each joystick and the D-pad.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
I set a watch on the js object and put a break after the diDev.GetDeviceStateJoystick call. The watch window will show the the enumerated objects that represent your joystick. For the life of me, I haven't been able to figure out which contol on my joystick corresponds to the "slider" control that shows up in my watch window, but VB says its there.
Rick
Well, if you can't figure it out, then I have little hope of doing so . . . but, I am going to give it a dumb-shot and see what happens. In any event, the two joysticks, plus the 10 buttons that I have up and running are more than enough to control Ugly Buster and next year's lawnmower!
From what little I checked it out, mult-channel R/C equipment is EXPENSIVE. I ALREADY have (what I think is) over $2500.00 of R/C-equivalent running via Bluetooth and the gamepad. Of course, I am sure R/C would have more range. But, Class I Bluetooth has plenty of range for Ugly Buster and so what if I can only cut the grass of the neighbor on either side of me? [noparse]:)[/noparse]
I can't thank you enough.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
Have you seen this bit about DirectInput? My wife found it for me. It is not too long and I understand some of it. (That may mean it is worthless.) It appears to directly address the situation with which we are involved. However, I only made an "A" in my C++ class to maintain my perfect GPA. It is not like I actually understood it, or anything.
Maybe you will. It looks like you wrote it.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
I hadn't seen that article. I tend to use the MSDN library, as I've finally gotten used to the writing style of Microsoft. My C coding is so rusty that it squeeks. I had a 5 day crash course in C about 15 years ago and haven't worked with it much since.
Rick
I changed the code a bit so the right joystick X ordinate operates as it should instead of "A, B, C, D, E". All that amounted to was commenting out the CASE statement and uncommenting one line, as I am sure you know.
The comment line "'THIS CODE IS FOR THE D-PAD (OR STICK) IT MOVES THE FORM!!!" kinda indicates to me that the author deleted or didn't finish the code with which we are experimenting. I kind find nothing--not that I am any kind of expert!--in the code that might display D-pad activation. Of course, it might be extremely simple due to the fact that perhaps a single statement obtained the state of the entire device after it was set up.
If you ever run across the person's name, I would sure like to see if one of us can locate him!
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
Rick
I don't know what I would do with the extra functionality. What you sent me is more than enough for my needs; even the mower.
Basically, I'm just thinking out loud.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.