Page 1 of 2

Change joystick layout to Logitech Dual Action (PS3)

Posted: Sun Oct 06, 2013 10:16 am
by Bananenfreak
Heyho,

I want to give my game a gamepadsupport. So, today I wanted to work with that. First: Thank you Team for working over the Joystick library. With supporting more gamepadaxis it is better for games ^^

Now my Problem:
First of all, i tried my Joystick with games, all of that got no Problem with my Joystick, so my Joystick isn´t broken.
My Problem is, that the right Gamepad isn´t working with PB... digital Gamepad and left analog Gamepad is working, but not the right one.

This is a edited JoystickExample.pb - file, please give it a try. Just Switch this one

Code: Select all

Debug JoystickAxisX(0, 1, #PB_Relative)
to 0 (left analog Gamepad) or 2 (digital Gamepad). With 1, it does nothing for me. Please try it, I wanna hear some other opinions.

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Joystick example file
;
;    (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;

NbJoysticks = InitJoystick() 

If NbJoysticks = 0
  MessageRequester("Error", "No joysticks are availables.", 0)
  End
EndIf

If OpenWindow(0, 100, 100, 300, 260, "PureBasic - Joystick Demo")

  MessageRequester("Information", "This will test the joystick in a window.", 0)

  x = WindowWidth(0)/2
  y = WindowHeight(0)/2-20

  Repeat
  
    Repeat
      Event = WindowEvent()
      If Event = #PB_Event_CloseWindow : Quit = 1 : EndIf
    Until Event = 0

    Delay(20) ; a little delay (20 milli seconds -> 50 fps)
  
    If ExamineJoystick(0)
      x+JoystickAxisX(0)
      y+JoystickAxisY(0)
     
      If JoystickButton(0, 1)
        MessageRequester("Info", "Button 1 has been pressed", 0)
      EndIf
      
      If JoystickButton(0, 2)
        MessageRequester("Info", "Button 2 has been pressed", 0)
      EndIf
      
      Debug JoystickAxisX(0, 1, #PB_Relative)
    
      If StartDrawing(WindowOutput(0)) ; Set the drawing output to our window
        FrontColor(RGB(255,0,0))      ; Use the RED colour
        Box(x, y, 10, 10)         ; Draw a little box
        StopDrawing()             ;
      EndIf
    EndIf

  Until Quit = 1

EndIf

End
EDIT: I found something unsettled...

Code: Select all

Debug JoystickAxisZ(0, 0, #PB_Relative)
This will display the X-Axis of the second analog Gamepad.

Code: Select all

Debug JoystickAxisZ(0, 1, #PB_Relative)
This will Display the Y-Axis of the second analog Gamepad.

This isn´t normal, or should it be this way?! :shock:
If this is normal, please move this Topic to related wishes. I want a second analog Gamepad with the number 1, not a unlogical Z-Axis :?

Re: PB 5.20 - Joystick 2. pad has no function

Posted: Sun Oct 13, 2013 6:27 am
by Regenduft
I don't know if this is a bug and haven't read your posting well, but thought the following (unfinished) code and my testing result might be useful.

I've got a MS Sidewinder Precision 2 Joystick (8 buttons, ruder, throttle and POV)

Image

The code might be buggy, since I didn't do much testing, yet.

Code: Select all

EnableExplicit

Global Dim Canvas_XY(2)
Global Dim Canvas_Z (2)
Global Dim Canvas_B (8)

If OpenWindow(0, #PB_Any, #PB_Any, 270, 180, "Joystick-Test", #PB_Window_SystemMenu) = 0
  MessageRequester("Fehler!", "OpenWindow() = 0") : End
EndIf
Canvas_XY(0) = CanvasGadget(#PB_Any,  10,  10, 90, 90)
Canvas_Z (0) = CanvasGadget(#PB_Any, 110,  10, 20, 90)
Canvas_XY(1) = CanvasGadget(#PB_Any, 140,  10, 90, 90)
Canvas_Z (1) = CanvasGadget(#PB_Any, 240,  10, 20, 90)
Canvas_B (1) = CanvasGadget(#PB_Any,  10, 130, 20, 20)
Canvas_B (2) = CanvasGadget(#PB_Any,  30, 130, 20, 20)
Canvas_B (3) = CanvasGadget(#PB_Any,  50, 130, 20, 20)
Canvas_B (4) = CanvasGadget(#PB_Any,  70, 130, 20, 20)
Canvas_B (5) = CanvasGadget(#PB_Any,  90, 130, 20, 20)
Canvas_B (6) = CanvasGadget(#PB_Any, 110, 130, 20, 20)
Canvas_B (7) = CanvasGadget(#PB_Any, 130, 130, 20, 20)
Canvas_B (8) = CanvasGadget(#PB_Any, 150, 130, 20, 20)
Canvas_XY(2) = CanvasGadget(#PB_Any, 180, 110, 60, 60)
Canvas_Z (2) = CanvasGadget(#PB_Any, 245, 110, 15, 60)

If InitJoystick() = 0 : MessageRequester("Fehler!", "InitJoystick() = 0") : End : EndIf

Procedure DrawButton(Button, State)
  State = Bool(State)<<8 - 1
  Define Gadget = Canvas_B(Button)
  Define w = GadgetWidth (Gadget)
  Define h = GadgetHeight(Gadget)
  Define t$ = Str(Button)
  If StartDrawing(CanvasOutput(Gadget))
    Define tx = ( w - TextWidth (t$) ) >> 1
    Define ty = ( h - TextHeight(t$) ) >> 1
    Box(0, 0, w, h, 0)
    Box(1, 1, w-2, h-2, State)
    DrawText(tx, ty, t$, 0, State)
    StopDrawing()
  EndIf
EndProcedure

Procedure DrawAxisXYZ(Pad, X, Y, Z)
  Define Gadget = Canvas_XY(Pad)
  Define w = GadgetWidth (Gadget)
  Define h = GadgetHeight(Gadget)
  Define mx = w>>1
  Define my = h>>1
  x = mx + (mx-4)*x/1000 - 3
  y = my + (my-4)*y/1000 - 3
  If StartDrawing(CanvasOutput(Gadget))
    Box(0, 0, w, h, 0)
    Box(1, 1, w-2, h-2, -1)
    Box(mx-3, my-3, 6, 6, $FF0000)
    Box(x, y, 6, 6, $FF)
    StopDrawing()
  EndIf
  Gadget = Canvas_Z(Pad)
  w = GadgetWidth (Gadget)
  h = GadgetHeight(Gadget)
  my = h>>1
  z = my + (my-3)*z/1000 - 2
  If StartDrawing(CanvasOutput(Gadget))
    Box(0, 0, w, h, 0)
    Box(1, 1, w-2, h-2, -1)
    Box(1, my-2, w-2, 4, $FF0000)
    Box(1, z, w-2, 4, $FF)
    StopDrawing()
  EndIf
EndProcedure

Define i
Repeat
  Repeat
    Select WindowEvent()
      Case #PB_Event_CloseWindow : End
      Case #PB_Event_None        : Break
    EndSelect
  ForEver
  If ExamineJoystick(0)
    For i = 1 To 8
      DrawButton(i, JoystickButton(0,i))
    Next
    For i = 0 To 2
      DrawAxisXYZ(i, JoystickAxisX(0,i,#PB_Relative),
                     JoystickAxisY(0,i,#PB_Relative),
                     JoystickAxisZ(0,i,#PB_Relative))
    Next
  EndIf
  Delay(100)
ForEver

Re: PB 5.20 - Joystick 2. pad has no function

Posted: Sun Oct 13, 2013 8:25 am
by Bananenfreak
I have a Logitech Dual Action Gamepad.

The Thing is, with WinAPI, my second analog stick (the right one) has its own X- and Y-axis. With PB, it works, too, but the axis for the 2. analog stick are for X the Z-Axis of the first analog stick (the left one) and for Y the Z-Axis of the 2. analog stick. I think this isn´t right and so in my opinion, this is a bug.

EDIT: In your example, the right analog stick (No. 1 for PB) interacts with the vertical canvasgadgets.

Re: PB 5.20 - Joystick 2. Stick (No. 1 for PB) has wrong axi

Posted: Sun Oct 13, 2013 1:55 pm
by heartbone
Bananenfreak, I have tested three different gamepads with the above program:
1) Logitech Dual Action
2) Snakebyte for PS3
3) X-KIM GPTL-01GM
Image
Image
Image
The X-KIM (only after I push its MODE button) is the sole controller where I could get both analogs to properly register using that joystick tester.
Different controller manufacturers have variances in the button and axis mapping positions.

I do consider the Logitech Dual Action
(and their newer very poor quality hardware F [for failure?] series controllers)
to be the PC standard controller if there ever was one.
PureBasic's gamepad controller function default mappings should work to read such a controller or be adaptable to work with it.
I would consider it a bug only if there was no way provided to read both controller analogs for a given dual analog stick configuration.

Looking at how your code performs Regenduft,
I think that PureBasic compiler gamepad support maps the right analog stick values into unexpected registers.
However the analog readings are returned to the program by the Joystick functions,
and are available to the programmer.

Just like I had to do in my Gamepad Button Trainer for the button mappings,
it looks like you will have to ask for some user input in order to correctly set and read the axis mappings for any given gamepad.

If Microsoft gets their way, then the XBOX controller (with the physically offset analogs) will be the new emerging standard.
Image
Perhaps the development team mapped the joystick readings XBOX style?
I don't have one of those annoyingly perverted form factor XBOX controllers to test,
but I am sure that someone reading this does,
and hopefully will let us know if both analogs are detected through the named axis functions.
If so, then it looks as if the PB gamepad command functionality will only support that subset of controllers without remapping.
If not, then I'd be interested in knowing the brand of controller that is natively supported.

An important message to the compiler development team.

Posted: Mon Oct 14, 2013 3:42 pm
by heartbone
If the updated joystick routines are indeed developed around the XBOX controller that Microsoft is attempting to borg the gaming community with,
please consider the following information.

The PC has never had a standard joystick/gamepad configuration.
Becuse the ancestor IBM PC platform discouraged game support as a non professional use,
things like color displays, decent audio, and joysticks were not considered essential parts of a computer system.
Believe it or not, joysticks connected to the "IBM compatible" systems through a serial port on the soundcard.
The later USB connectivity allowed for better options to be developed, and we can now see the myriad of solutions.

Around 2003 EA decided to consolidate things a bit by issuing a list of recommended controllers to be used with their sports titles.

Code: Select all

* Logitech Dual Action
* Logitech Rumble Pad 2
* Gravis Eliminator Aftershock
* Thrustmaster Firestorm Dual Analog Gamepad
* Thrustmaster Firestorm Dual Power 3
* Thrustmaster Firestorm Dual Analog 3
* Thrustmaster Firestorm Wireless controller
* Microsoft Xbox 360 Controller for Windows
Nothing official, but a reasonable attempt at standardization.
At the same time, the game consoles each had their own propriatory controller design.

Among the best of the lot, Sony's PlayStation took a cue from Nintendo's 64 controller,
and made the wise move to incorporate analog joysticks into the standard gamepad for better input for the PlayStation3.
Sony decided to adopt a design close to the leading PC gamepad controller, the Logitech Dual Action.
I think that a player can actually use the LDA with the PlayStation3.
Based on my research over the past year I've deteremined that the only difference
between a LDA and a generic (no rumble) PS3 controller is the name.
If within the Windows registry one changes the name of the generic PS3 controller to
"Logitech Dual Action", then the generic PS3 controller becomes a LDA as far as Windows sees.

The other flavor of the PlayStation3 controller is the dual shock controller,
which contains an adaptation of the Nintendo 64 controller's pioneering "rumble" feature.
Those dual shock controllers contain a different button and axis mapping than the no shock generic PS3 controllers.
Until I find out otherwise, I will assume that the new PS4 will be compatible with both PS3 controller types.

The (generic) PS3 (Logitech Dual Action compatible) controllers are available at a great price point.

$17.99 Gigaware® USB Wired Controller for PC available at Radio Shack.
Image
http://www.radioshack.com/product/index ... Id=3964949

The $8.99 TTX Tech PC Controller Wired might be a better choice, but not as widely available at brick'n'mortars.
Image
http://www.microcenter.com/product/3875 ... ller_Wired

If the PS3 controller has rumble/shock then it is not a generic (LDA compatible) controller, but a clone of Sony's Dual Shock product.
(generic and clone is my terminology used to distinguish the two flavors of non-Sony PS3 controllers)

Available for about a mere $12 at MalWarts nationwide, this Snakebyte PS3 dual shock (clone) controller is a really great deal!
Image
http://www.walmart.com/ip/Snakebyte-PS3 ... 3/21063198

These controllers are relatively inexpensive when compared to most available XBOX controllers,
and for that reason alone they would make a better choice for the default mapping gamepad device.

So if you want to make PureBasic compatible with the controller that is a better deal for the consumer,
one that has a configuration that promotes better muscle memory for the majority of gamers,
then I am asking the team to
please consider selecting the generic PlayStation3 controller (same as the Logitech Dual Action) configuration for the Joystick function's default axis and button mappings.

As a second choice, in my opinion the clone PS3 controller would be better than the XBOX,
because of muscle memory, price, the number of already purchased compatible controllers,
and support for the abandonment of Microsoft.

Re: PB 5.20 - Joystick 2. Stick (No. 1 for PB) has wrong axi

Posted: Mon Oct 14, 2013 4:38 pm
by Regenduft
(Meanwhile) I agree with heartbone: No Bug! I have been able to find all axes on two joysticks and one gamepad. It's just a standardization problem.

I'm now trying to write a reusable module which "adds a mapping layer" for the joystick input procedures and saves the configuration to a PB-Preferences file. Since I use JoystickName() to identify the controller:

Does anybody know if JoystickName() is giving reliable information? Is the name transferred through USB or is it depending on the driver? -> Is the name on different OS and OS versions the same? Do cheap controllers have a unique names?

I'll post my code here when finished, but it may take some time, since at the moment I do have to much small projects running in parallel.

Re: PB 5.20 - Joystick 2. Stick (No. 1 for PB) has wrong axi

Posted: Mon Oct 14, 2013 4:56 pm
by heartbone
As far as I know Regenduft, the name is transmitted to the computer from the controller,
but on different OSes the driver may indeed impact the name that shows up to the user.

In the button trainer I allowed only one saved button configuration,
but in future games I'll allow the user to name and save controller configurations,
with the last one used automatically selected at startup.

Your approach of building a database containing controller settings is sometimes used in emulators.
And automatically setting up the controller based on the detected name should work,
but you'll likely still need to allow for custom controller configurations,
or provide some way to edit the controller's configuration,
so allowing the user to select from previously saved user named configurations might prove to be a useful strategy.

Re: PB 5.20 - Joystick 2. Stick (No. 1 for PB) has wrong axi

Posted: Mon Oct 14, 2013 7:00 pm
by heartbone
If standards mean anything to anyone on the development team, then kindly consider this document where a diagram of a standard gamepad is shown.

https://dvcs.w3.org/hg/gamepad/raw-file ... mepad.html

It is not old, this standard was developed within the past year.
In August 2012 the document was still a working draft.

It would be nice if people (like the posters in this thread so far) could plugin their controller and not have to do any remapping.

It would be nice if somewhere in the documentation, compatible controllers were defined and the remapping problem described.

Re: PB 5.20 - Joystick 2. Stick (No. 1 for PB) has wrong axi

Posted: Tue Oct 15, 2013 5:04 am
by heartbone
Regenduft wrote:Do cheap controllers have a unique names?
If by cheap you mean low price, then the answer is both yes and no.
If by cheap you mean "knock-off" or imitation then the answer is usually yes.
Except in the case of the clone PS3 controllers, where they all generally post as "PLAYSTATION(R)3 Controller".
There the other information transmitted by the device such as the Vendor ID code must be used to discern the model if needed.
That is how the MotionInJoy (Windows PS3 driverset) utility works.

I know that the "Xbox Airflo wired controller" is how one "knock-off" XBOX controller posts in Windows, not the same as an actual XBOX controller,
so I'm guessing that the clone PS3 line may be the only one where different manufacturers use the same controller name.

I just examined the JoystickName() function return in UBUNTU Linux for my LDA, and it posted as "Logitech Logitech Dual Action".
So it looks as if different OS/driver combinations do indeed affect the device's name that is returned by the JoystickName() function,
because the last time that I looked in Windows the controller's name was identified as "Logitech Dual Action USB".
Still in Linux, I just checked the Snakebyte and it posted as "Sony PLAYSTATION(R)3 Controller",
and the X-KIM posts as "DragonRise Inc. Generic USB Joystick".
All three have a manufacturer's name prepended to the controller name that I am used to seeing in Windows.
But here is the puzzle, I have a generic PS3 controller purchased from GameStop,
Image
http://www.gamestop.com/ps3/accessories ... ller/77446
and in Linux it posts exactly the same as in Windows, "Afterglow controller for PS3".
(The Afterglow controller deserves the low user rating, it sucks.)

I do have another important point to post about the default Joystick functions, however it is time for me to go to Windows and see what is happening there, because I want to know is it the PureBasic JoystickName() function returning some form of manufacturer name concatenated with the controller name, or is it UBUNTU?

Re: PB 5.20 - Joystick 2. Stick (No. 1 for PB) has wrong axi

Posted: Tue Oct 15, 2013 5:51 am
by heartbone
Now to fully answer your question Regenduft, the controller names returned by PureBasic's JoystickName() function in Windows match the names that I am used to seeing as shown by the Game Controllers app in the Windows Control Panel.
And yes they are indeed different than the ones returned for the same device in Linux.
I must assume it's the Linux drivers which are building the controller name differently.

OK, now my final point to the compiler developers about the Joystick functions.

I hope that you will acknowledge the importance of selecting the optimal default joystick to be mapped to the Joystick commands.

If you decide to support either the XBOX controller or the clone (dual shock) PS3 controllers,
you then open up the compiler to the valid criticism of not fully supporting the device due to no rumble (a.k.a. force feedback) effects support.

If you decide to support the class of device that as shown above is accurately marketed under the concept of
"UNIVERSAL USB CONTROLLER FOR PS3 AND PC",
the same one that I think of and have described as a generic PS3 controller,
the same one that is functionally identical to the legendary PC defacto standard Logitech Dual Action,
then your support of the default device would be totally complete.

I believe that will make the best decision for all but the Microsoft fanboys.
Because their attempted XBOX stranglehold strategy was soundly rejected by the public,
I'm thinking that most will understand the danger of supporting anything Microsoft.

Supporting as the default controller any other device other than one the three configurations that I've suggested that you choose from,
that is having the compiler Joystick functions support an entirely different class of gamepad controller such as that generic X-KIM that I listed above, in my opinion is not a good idea at all.

Thanks for reading.

Re: PB 5.20 - Joystick 2. Stick (No. 1 for PB) has wrong axi

Posted: Tue Oct 15, 2013 3:23 pm
by Regenduft
Wow! Very detailed research! Thank you very much for the information! :D

Re: PB 5.20 - Joystick 2. Stick (No. 1 for PB) has wrong axi

Posted: Tue Oct 15, 2013 4:41 pm
by heartbone
Regenduft wrote:Wow! Very detailed research! Thank you very much for the information! :D
You are quite welcome, it was my pleasure.
I hope that it will be of some use.
Apparently the current situation has created the possibility of or has actually engendered some feelings of deception.
http://www.purebasic.fr/english/viewtop ... =3&t=56870

I think that we are also in agreement that this report is not a bug, and this thread belongs in the Feature Requests and Wishlists section.

Re: PB 5.20 - Joystick 2. Stick (No. 1 for PB) has wrong axi

Posted: Wed Oct 16, 2013 3:01 pm
by Bananenfreak
Thank you heartbone, you´re a Walking book Oo Amazing :D

Ok, I agree, it´s not a bug.
But I don´t agree with the diagram of a "standard" Gamepad. In my opinion, to handle with different sticks and not different axis (from 0 to 3) is much better.
One more, digipad as stick is still better than having 4 more Buttons. With digipad as stick, you can make 8 Buttons or other Things.

Re: PB 5.20 - Joystick 2. Stick (No. 1 for PB) has wrong axi

Posted: Wed Oct 16, 2013 3:20 pm
by heartbone
Bananenfreak wrote:Thank you heartbone, you´re a Walking book Oo Amazing :D
Not really, but thank you kind sir.
I just focus on a few areas.
Ok, I agree, it´s not a bug.
But I don´t agree with the diagram of a "standard" Gamepad. In my opinion, to handle with different sticks and not different axis (from 0 to 3) is much better.
One more, digipad as stick is still better than having 4 more Buttons. With digipad as stick, you can make 8 Buttons or other Things.
I am not quite sure what that means.
How can you disagree with someone's standard?
Or are you indicating that you prefer the GameCube controller form factor of offset analogs that M$ adopted?
Image

Re: PB 5.20 - Joystick 2. Stick (No. 1 for PB) has wrong axi

Posted: Wed Oct 16, 2013 5:42 pm
by Regenduft
Bananenfreak wrote:In my opinion, to handle with different sticks and not different axis (from 0 to 3) is much better.
True for Gamepads, but not true for joysticks. Here you have only one or two sticks, but 2 up to 6 axes -> stick up/down (x), stick left/right (y), throttle (z) and stick twisting (r*), pov up/down (x), pov left/right (y)

* sorry, but can't remember if it's mapped to x, y or z and can't test now.
heartbone wrote:
Bananenfreak wrote:But I don´t agree with the diagram of a "standard" Gamepad.(...)
(...)How can you disagree with someone's standard?
I guess he's referring to the stress between "de jure" and "de facto" standard. Defining a standard doesn't mean that people do care about.

(to bad there is no Denglisch to English translator :lol:)