-
June 11th, 2007, 01:12 AM
#1
is it possible to simulate a joystick?
I am building a game controller that will be connected to the PC through a com port, and maybe later usb. I want to be able to simulate a joystick as one of the options. Is there some way to do this with VB6?
-
June 11th, 2007, 02:38 AM
#2
Re: is it possible to simulate a joystick?
-
June 11th, 2007, 02:52 AM
#3
Re: is it possible to simulate a joystick?
Originally Posted by Shaikh.Riyaz.a
I think that api is to read a joystick. I will be reading my own device through the com port and I want to convert the readings and output them as joystick moves. So I need to simulate a joystick without actually having one plugged in.
-
June 11th, 2007, 05:33 AM
#4
Re: is it possible to simulate a joystick?
I'd have to guess that a program which expects a joystick will be ultimately relying on the API, be it directly or indirectly. There are apparently USB controllers though, but I don't know if the drivers are designed to simulate a joystick to the point of sending the signals in such a way as to appear as a standard game port controller.
Since the game port is so easy to use, I'm wondering why you'd want to use a COM port instead. Can you elaborate on what you are trying to do?
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
June 11th, 2007, 09:23 AM
#5
Re: is it possible to simulate a joystick?
My suggestion is to use the API. Write your own program to work with a joystick. Use the Spy++ tool to monitor the messages being sent to your window. Once you know what the messages the joysick send, use the SendMessage API to mimic the joystick.
-
June 11th, 2007, 04:29 PM
#6
Re: is it possible to simulate a joystick?
Originally Posted by WizBang
I'd have to guess that a program which expects a joystick will be ultimately relying on the API, be it directly or indirectly. There are apparently USB controllers though, but I don't know if the drivers are designed to simulate a joystick to the point of sending the signals in such a way as to appear as a standard game port controller.
Since the game port is so easy to use, I'm wondering why you'd want to use a COM port instead. Can you elaborate on what you are trying to do?
I have an MCU that is reading from a digital compass and an accelerometer. It will do some number crunching but mostly it will just send raw data to the PC through the com port. My VB program will then convert the data to optional outputs, either simulating keypresses, mouse movements or joystick movements. I can do the keypresses and mouse movements but I have no idea how to make the pc think it is a joystick.
Last night I found a virtual joystick called PPJoy and had a play with that and when you add a virtual joystick windows starts up the "found new hardware" wizard and adds it as a joystick. So I know it can be done, but I am not sure how. I have a feeling I need to write my own driver.
Originally Posted by sotoasty
My suggestion is to use the API. Write your own program to work with a joystick. Use the Spy++ tool to monitor the messages being sent to your window. Once you know what the messages the joysick send, use the SendMessage API to mimic the joystick.
Thanks, I'll have a look at your suggestions. Can someone give me a hint on where to get spy++ and how to use it? From what I can find it is a tool for Developer Studio 6 which I don't have. I only have VB6 and the Visual Studio Installer.
Last edited by Taipan; June 11th, 2007 at 05:08 PM.
-
June 11th, 2007, 07:13 PM
#7
Re: is it possible to simulate a joystick?
It comes with most versions of VB6, but if you don't have it on the cd (optional addon) then you can download a replacement. just google for it. someone else wrote one that is identical. I used that before I found it on the CD...
-
June 12th, 2007, 04:36 AM
#8
Re: is it possible to simulate a joystick?
You can get example code for detecting joystick signals here: http://allapi.mentalis.org/apilist/joyGetPos.shtml
I've never seen anything to suggest that the joystick port is bidirectional, but I know there are MIDI APIs for both sending and receiving.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
June 12th, 2007, 04:44 PM
#9
Re: is it possible to simulate a joystick?
Originally Posted by sotoasty
My suggestion is to use the API. Write your own program to work with a joystick. Use the Spy++ tool to monitor the messages being sent to your window. Once you know what the messages the joysick send, use the SendMessage API to mimic the joystick.
Slowly puzzling my way through this. I wrote a program that has a timer that reads joystick information and displays the X, Y, Z coords in a text box. But I can't figure out how to see the messages that is being sent to it from the joystick. I have spy++ and I select my program and view the messages but I can't see anything that would be coming from the joystick. I think I am only viewing messages being sent from my program. How would I view messages being sent to it?
-
June 13th, 2007, 08:03 AM
#10
Re: is it possible to simulate a joystick?
Originally Posted by Taipan
Slowly puzzling my way through this. I wrote a program that has a timer that reads joystick information and displays the X, Y, Z coords in a text box. But I can't figure out how to see the messages that is being sent to it from the joystick. I have spy++ and I select my program and view the messages but I can't see anything that would be coming from the joystick. I think I am only viewing messages being sent from my program. How would I view messages being sent to it?
Basically, the information isn't being sent to your app's window per se. The API function queries the joystick, and returns the data. Even if there's a way of simulating this for your app, it isn't the same as having the OS think a joystick is connected and being used.
Maybe these can help:
http://bcb-tools.com/TDx_Library/Tut...tm#DirectInput
http://www.koders.com/cpp/fidD436700...AFD8D80A9.aspx
http://www.autohotkey.com/docs/Hotkeys.htm
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|