analog pads

Blitz3D Forums/Blitz3D Programming/analog pads

Pete Carter(Posted 2007) [#1]
Hi ive never had to do anything with analog pads before and im having a little trouble with set things up.

Ok ive noticed between different pads you get different values from the analog sticks some joypads give you much higher numbers and some give you the normal -1 to 1 range. its there a way to make all joypads behave the same? plus whats the best was of flipping the left and right, at the moment im just take the minus value and times it by its self to make it a plus.

Also the dead zone on my pad seams to be quite good but ive heard that on some pads you still get joypads not centring quite right and give small values in random directions. is it worth puting in limits like, if steerright = < 0 then steerright = 0?


Gabriel(Posted 2007) [#2]
The best way would be to have a config screen where you ask people to circle their analog stick to all extents. Store the min and max values and then you can divide the current value to get the relative position. Then when they've circled it, ask them to leave it centered for a second or two and you can see if it varies at all. It's probably best to have a fairly generous "dead zone".

Much the same thing that the drivers which come with analog pads do. It's a pain, but on a PC, I don't think you can rely on anything but manual configuration.


Stevie G(Posted 2007) [#3]
Something like this is what you're after ...

http://www.blitzbasic.com/codearcs/codearcs.php?code=1592

I may be mistaken but I think you can also set the deadspot which is essential. I've adapted the theory for my own game and it works very well for all analogue joypads.

Stevie


Pete Carter(Posted 2007) [#4]
thanks guys!


Pete Carter(Posted 2007) [#5]
whats the maths for converting the value given from the joyx or joyy eg a -1 to a percentage of say a 40 degree angle.

or to explain it another way, if i have a car that the wheels turn 40 degrees at full steer and I want the left joystick to give me max steer when moved to extreme left or right, do i just devide the joy output by 40 because if been get some odd results?


Stevie G(Posted 2007) [#6]
If JoyX gives you a value between -1 and 1 then it's as simple as ...

MaxSteer = 40.0
SteerAngle# = Joyx() * MaxSteer#

You'd be far better interpolating steerangle between a high and low angle based on the vehicle speed. This means that it's not a nightmare to control at high speeds. This is the kinda thing I use ...

Turn# = joyx()
MinSteer# = 10.0
MaxSteer# = 40.0
SpeedFactor# = 1.0 - ( Speed / MaxSpeed )
SteerAngle# = Turn * ( MinSteer + ( MaxSteer - MinSteer ) * SpeedFactor )


This means that at full speed you can only turn a max of 10 degrees.

Stevie


Pete Carter(Posted 2007) [#7]
Thanks stevie that is just what i need to tone down the steering its far to easy to over steer at the moment


Pongo(Posted 2007) [#8]
I like that way of adjusting steering rates based on speed.

Also, I've been trying to re-do the joystick code a bit, and some of the new features include deadzone setup, and also non-linear curves for the sticks.

The non-linear stuff works great when you want small delicate movements of the sticks, but still are able to get the full range when you push to the extremes.


Stevie G(Posted 2007) [#9]
The MaxSpeed could be quite tough to calculate - well it is for me using verlet, based on acceleration, friction & drag etc... I had to set up some form of wind tunnel to check what speeds a vehicle can achieve and even then it's best to set this MaxSpeed to be a good bit lower. So even if the vehicle can achieve 9 units per second you should set the max to say 6 and limit the speed in the speedfactor calculation ..

SpeedFactor# = 1.0 - ( LIMIT( Speed , 0, MaxSpeed ) / MaxSpeed )

I was just thinking that I have to set deadzones at around .2 to stop my loose analogues moving on their own but that means the minimum turn is .2 x [whatever]. Really, I need to do something like ...

DeadZone# = .2
Turn# = joyx()
if abs( Turn ) <= DeadZone 
   Turn = 0.0
else
   Turn = ( Turn - sgn(Turn) * DeadZone ) / ( 1.0 - DeadZone )
Endif


So that my possible turn will be converted from .2 --- > 1.0 to 0.0 ----> 1.0.

I'll need to try and see if it makes much of a difference.

@ Pongo - We need to talk ;)


Pongo(Posted 2007) [#10]
@Stevie - I'll try to send you an email tonight.

Also, I think the non-linear steering would help quite a bit with the deadzone issue. It may work well enough that the deadzone will no longer be needed, or can at least be quite small. (From memory, I think I usually use .15 for my deadzones, but I think that can change now)