01-26-2025, 10:03 AM
For testing purposes only, give this a try with your favorite joystick and see how this maps out/behaves.
I've tested this on my Xbox-style joystick and... these mappings seem odd as BLEEP to me!
Left paddle is axis 1 and 2
Right paddle is axis 4 and 5
D-pad is axis 7 and 6
Axis 3 is the button left/right buttons on the front of the joystick
Note that the D-pad is REVERSED in order compared to the paddles.
Who the crap configures these things? Who thought this type of set up would be nice and normal and easy to configure for??
/sigh
Anywho... Test this out with your own joysticks and see if it responds as expected for you. So far, this just tests for the stick movement (it doesn't even try and tell you about those button-sticks!), but it *should* have x and y both mapped for all 3 axis.
Let me know if it works for you, or if it gives some odd readings, or whatnot. I have no idea how the heck this might work on various controllers. It's just... weird the mapping on this thing.
As for the angle, I've fixed it so it should map to the same coordinates as what we learned in school. 0 is to right, 90 is to the top, 180 is left and 270 is bottom. It should be the quickest way to tell if something is completely off with the left/right paddles.
Code: (Select All)
Type Axis_Type
Active As _Byte
Vert As Single
Hort As Single
Angle As Single
End Type
ReDim Shared As Axis_Type JoyStick(0)
Do
Cls
ReadJoyStick
For i = 1 To UBound(JoyStick)
If JoyStick(i).Active Then
Print Using "STICK # ACTIVE:"; i
Print JoyStick(i).Hort, JoyStick(i).Vert, JoyStick(i).Angle
End If
Next
_Limit 30
_Display
Loop
Sub ReadJoyStick
Static d, LA
If d = 0 Then d = _Devices
If d < 3 Then Exit Sub '3 is joystick. Without one, then there's no reason to waste effort doing anything else.
If LA = 0 Then LA = _LastAxis(3): ReDim JoyStick(1 To LA \ 2) As Axis_Type
If LA = 0 Then Exit Sub 'if there's no axis on your joystick, I don't know how to read it!
Dim axis(LA) As Single
Do
di = _DeviceInput
Select Case di
Case 3
For a = 1 To LA: axis(a) = _Axis(a): Next
For j = 1 To LA \ 2
If j = 1 Then
'left pad is axis 1 and 2
JoyStick(j).Hort = axis(j * 2 - 1): JoyStick(j).Vert = axis(j * 2)
Else
'axis 3 is the botton left/right buttons on the front of my joystick
'so the right pad is axis 4 and 5
'and the d-pad is axis 6 and 7
JoyStick(j).Hort = axis(j * 2 + 1): JoyStick(j).Vert = axis(j * 2)
'd-pad seems to be mapped backwards to the other axis??!!
If j = 3 Then Swap JoyStick(j).hort, JoyStick(j).vert
End If
Next
End Select
Loop Until di = 0
For j = 1 To LA \ 2
If Abs(JoyStick(j).Vert) <= .01 Then JoyStick(j).Vert = 0
If Abs(JoyStick(j).Hort) <= .01 Then JoyStick(j).Hort = 0
JoyStick(j).Angle = _Atan2(JoyStick(j).Hort, JoyStick(j).Vert)
JoyStick(j).Angle = (_R2D(JoyStick(j).Angle) + 270) Mod 360
If JoyStick(j).Vert = 0 And JoyStick(j).Hort = 0 Then JoyStick(j).Active = _FALSE Else JoyStick(j).Active = _TRUE
Next
End Sub
I've tested this on my Xbox-style joystick and... these mappings seem odd as BLEEP to me!
Left paddle is axis 1 and 2
Right paddle is axis 4 and 5
D-pad is axis 7 and 6
Axis 3 is the button left/right buttons on the front of the joystick
Note that the D-pad is REVERSED in order compared to the paddles.
Who the crap configures these things? Who thought this type of set up would be nice and normal and easy to configure for??
/sigh
Anywho... Test this out with your own joysticks and see if it responds as expected for you. So far, this just tests for the stick movement (it doesn't even try and tell you about those button-sticks!), but it *should* have x and y both mapped for all 3 axis.
Let me know if it works for you, or if it gives some odd readings, or whatnot. I have no idea how the heck this might work on various controllers. It's just... weird the mapping on this thing.
As for the angle, I've fixed it so it should map to the same coordinates as what we learned in school. 0 is to right, 90 is to the top, 180 is left and 270 is bottom. It should be the quickest way to tell if something is completely off with the left/right paddles.