Need help with usb joystick input!

Problems building or running the engine, queries about how to use features etc.
Post Reply
atomtm
Gnoblar
Posts: 4
Joined: Wed Feb 05, 2014 10:55 am

Need help with usb joystick input!

Post by atomtm »

Hello everyone!
I am trying to help a friend with a little racing game that was build with OGRE and it's inputs. It uses an APEM usb interface(http://uk.rs-online.com/web/p/joystick- ... s/0126903/) with a JoyWarrior chip as a controller which is now broken.
From Windows control panel i found out that it uses X axis for throttle , Y for break and Z for steering. I tried to plug in a generic usb gamepad with the same axes configuration but I can't get throttle or breake - only steering works.Then i pluged an Xbox controller which seems to work correctly.
We ordered a new APEM usb interface and connected it based on its manual (wiring was exactly the same as with the original-broken interface we had) but it came with the wrong Joywarrior chip , so now when I press for example throttle button it is steering left and nothing more (no breake/reverse no right steering with any combination of button presses).
So I am trying to figure out how the game was implemented , how OGRE receives input and how I could find a solution to this problem.
I also tried to create an Arduino HID Joystick with same results (steering but no throttle/breake).
Is there anyway I can find the input the Game is insecting or a general rule on how OGRE receives data from HID devices?
Please if anyone can help me with this , that would be much appreciated.
Thank you in advance and sorry for the long post.
User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
x 94
Contact:

Re: Need help with usb joystick input!

Post by tod »

Ogre uses OIS for input. I see this page has some info on Joystick support with OIS. I'm not sure it's up to date.
You can google yourself further for OIS docs.
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: Need help with usb joystick input!

Post by scrawl »

Ogre is a rendering library and does not provide input.
The Ogre sample browser uses OIS, but when making your own application you are free to choose whatever input library you prefer.
atomtm
Gnoblar
Posts: 4
Joined: Wed Feb 05, 2014 10:55 am

Re: Need help with usb joystick input!

Post by atomtm »

Thank you for your replies!
Any idea on how to monitor HID usb raw data?
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Need help with usb joystick input!

Post by Kojack »

atomtm wrote:Any idea on how to monitor HID usb raw data?
If you want to work down at the usb/hid level, and are using windows, have a look at Raw Input. http://msdn.microsoft.com/en-us/library ... 85%29.aspx
This lets you access raw data from usb devices. You can find devices by specifying the usage and usagepage codes from the usb spec.
I've used this for wiimotes and rudder pedals, but I mainly use it for accessing my Space Pilot Pro cad controller.

Looking at the game's source to see what it does would be easier though, it might just be accessing the wrong axes. For example, old gamepads used to do X and Y for the left stick and RX and RY for the right stick, but the 360 controller does Z and RZ for the right stick. I have old student games (no source code) that don't play anymore because I don't have any non 360 gamepads.
atomtm
Gnoblar
Posts: 4
Joined: Wed Feb 05, 2014 10:55 am

Re: Need help with usb joystick input!

Post by atomtm »

The problem is that I don't have the source code so I am trying to reverse engineer it (don't know if I am capable though...).
As I mentioned the game works with a Xbox controller although it uses different axes from the one that came with (Joywarrior which only uses x,y,z). The new controller that we bought (different JoyWarrior chip) also uses x,y,z as I can see from Windows gamecontroller settings but has completely different behaviour in game.
So what could be possible wrong with this? Can two controllers control the same axes but send different raw input data?
If you have any experience with this please let me know!
Thank you for your response
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Need help with usb joystick input!

Post by Kojack »

Maybe take a look at something like http://www.autohotkey.com/board/topic/8 ... sing-vjoy/
From the page:
Why would I want it?

Your joystick is not recognised by the game
Your joystick is recognised, but an axis is the wrong way around and you cannot fix it.
You have a pair of racing pedals that feature an axis for each pedal, and wish to use them as a single rudder axis.
You want to use two devices for a game (eg a pedals and a stick/throttle) for a game but it only supports one joystick at a time.
You want a specific feature, but lack the knowledge to write such a thing yourself. The code is pretty easy to understand and you just need a text editor.

Features

"Portable" application, no installation required - just run the EXE!
Control up to 16 virtual joysticks with 8 Axes and 32 Buttons each!
Controlled by up to 16 physical joysticks
Invert any axis
Per-axis deadzone and sensitivity settings
Axis Merging - Combine two racing pedals into a rudder!
Axis Splitting
Remap the 1st Hat (POV) switch to any buttons.
Settings saved between uses
Profile support
Run multiple copies - each copy can control a different virtual stick
(But each version can read any of the physical axes)
"QuickBind" mode to control the virtual joystick via the UJR GUI
Use this when the game detects the underlying physical stick instead of the virtual one - allows you to move the virtual stick without moving the physical stick
It's free too.
I've never tried it though, so no idea if it's any good. But it's partly made it AutoHotKey, which is awesome (and I have used).
atomtm
Gnoblar
Posts: 4
Joined: Wed Feb 05, 2014 10:55 am

Re: Need help with usb joystick input!

Post by atomtm »

Yeah autohotkey is awesome ! I will check and post back
Post Reply