Game Development Community

Joystick detection not working?

by Ricky Hopper · in iTorque 2D · 11/27/2009 (6:41 pm) · 9 replies

Hey,

I'm compiling a test build of an early version of my game and getting this in the console:

game/gameScripts/game.cs (21): Unable to find function enableJoystick

I do not know why this is happening. In my game.cs, there is this:

activateDirectInput();
enableJoystick();

...which should be doing the trick. Any thoughts?

#1
11/27/2009 (10:49 pm)
Also, I added an "echoInputState()". Here's the relevant part from the console:

game/gameScripts/game.cs (21): Unable to find function enableJoystick
Low-level input system is enabled.
- Keyboard is disabled and inactive.
- Mouse is disabled and inactive.
Loading compiled script [...]

Nothing about joystick input at all. Weird.
#2
11/27/2009 (11:05 pm)
sure you are on the device?
there is no joystick support on osx as osx lacks directinput.

on the desktop you would need to use keyboard / mouse
#3
11/27/2009 (11:06 pm)
sure you are on the device?
there is no joystick support on osx

on the desktop you would need to use keyboard / mouse


also there is a thread on this board on how to get rid of the error
#4
11/27/2009 (11:09 pm)
Yes, I am on the device. Could you point me to this thread? I've looked around and haven't seen anything pertaining to this.
#5
12/01/2009 (9:46 pm)
...Any more advice for this? It could be a simple setting or something, I had to do a lot of messing around in xCode to get anything to compile on the device so could've done something by accident.
#6
12/01/2009 (9:50 pm)
If you use the search for enableJoystick on the itgb boards you will find the corresponding thread for sure :)

Unlikely that you messed something in the xcode project, chances are that you are more likely porting some desktop project to the iphone and have not yet corrected it for this usage.
#7
12/01/2009 (11:06 pm)
All I am finding in search is that enableJoystick is not a function on Mac, but it is on the device itself. However, I am running it on the device, and it still says that the function cannot be found. The rest of the project is working aside from accelerometer input... how would I go about "correcting the project for iphone usage"?
#8
12/02/2009 (7:34 pm)
Well, I got some new insight on this. I looked through iPhoneInput.mm to see that joystick input is purposefully disabled/commented out in places. getJoystickAxes is hard-coded to output an empty string ("") in all situations, though that may not correlate to that exact function in Torquescript. The only thing I see correlating to the accelerometer is at the very end, in createAccelMoveEvent.

How this helps, I am not entirely sure. I thought it was worth saying.
#9
12/04/2009 (8:14 am)
Joystick input works and is on by default on the iPhone - I suggest putting some text on the screen called debugText and outputting the tilt info to this text to check it's all working.

Call this in your game.cs

moveMap.bind(joystick, "xaxis", tiltX);

and then use this:

function tiltX(%val){
	debugText.text = %val;
	$tiltX = %val;
}

#10
12/06/2009 (12:44 am)
Problem solved. I had read somewhere that to do the function described, it was like this:

moveMap.bind(joystick0, xaxis, "tiltX");

Works like a charm now. Thanks for the help!