Compiling List of Joystick Name Adresses

Started by cmunoz, October 03, 2014, 10:51:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cmunoz


Let's compile a list of joystick name addresses!


I'm particularly interested in getting as many third party controllers for the xboxes and playstations. The purpose is to have a list of known controller names in my game to check the user's controller against in order to recognize what kind of controller it is. If there's any way to detect automatically if a controller is xbox or playstation, that would be much easier. Meanwhile I'd like to compile a list of controller names to compare the user's controller against, in order to sort out the user's button config.


I hope to post a demo of this in the next few days to show why I'm collecting the names, but for now, a brief explanation...


This would allow reassigning or allocation of buttons, such as reserving the start button (which is a different button number on ps3 controllers than it is on Xbox 360) for a pause system. It would also allow the game to display icons of the ps3 or xbox buttons, instead of simply saying "button 1" which would be confusing if all you see is an X, Y, Square, or Triangle on the button.


The following bennuGD program will recognize your joystick's string name joy_name(0) and save it in a text file called myjoystickname.txt
It's important to double check this because the same controller may have different names on different operating systems, and even on different computers, depending on which drivers are installed.


import "mod_joy"
import "mod_file"


global
int handle;
end


process Main()
begin
    if(joy_numjoysticks()>0)
       handle=fopen("./myjoystickname.txt",o_write);
       fputs(handle,joy_name(0));
       fclose(handle);
    end
end





Here's an updated list. The verified portion includes controllers that I have tested myself. The UNTESTED section includes controller names that I have found online but have not been able to test as of yet.
Please copy the entire list from whoever posted last, and add your joysticks to the appropriate categories, or move the names from untested to verified, if you can indeed verify them!
THANKS FOR HELPING CONTRIBUTE!


///////////////////THE LIST:////////////////////


///////////////////VERIFIED:////////////////////
LINUX:
   CAANOO:
      pollux-analog
   X-BOX 360:
      Microsoft X-Box 360 pad
      Generic X-Box pad
   PS3:
      BDA PS3 Airflo wired controller
   Other:
      HuiJia  USB GamePad
WINDOWS:
   X-BOX 360:
      XBOX 360 For Windows (Controller)
      Controller (XBOX 360 For Windows)
      Controller (XB360 Mortal Kombat FightStick)
      Controller (MK Klassic Fight Stick Xbox 360)
   PS3:
      PS3 Airflo wired controller
   OTHER:
      USB GamePad


///////////////////UNTESTED:////////////////////
LINUX:
   X-BOX 360:
      Xbox Gamepad (userspace driver)
WINDOWS:
   X-BOX 360:
      My XBox 360 Controller
      XBOX 360 For Windows
      XBox 360 For Windows (Controller)
      Controller (Xbox 360 Wireless Receiver for Windows)
      Xbox 360 Wireless Receiver for Windows
      Xbox 360 Wireless Receiver
   Other:
      XInput Controller
OSX:
   X-BOX 360:
      Wireless 360 Controller
   Other:
      Controller

cmunoz

Here's a quick test to give an example of what I'm trying to do. If you use it with an xbox or ps3 controller that are included in the code, you will see that the buttons are remapped, so that even though the button numbers are in different places, the controls work the same as far as behaviour. I didn't bother to map the axes or lb/rb buttons, hopefully this will be enough to get my basic idea across.


Of course, I only have the one ps3 controller, so if you have a different one, it will not be recognized by the program unless you add it to the list of controller names to check for. This is why I need to collect the names.import "mod_wm"
import "mod_video"
import "mod_text"
import "mod_key"
import "mod_joy"
import "mod_draw"
import "mod_proc"
import "mod_map"
import "mod_string"
import "mod_debug"


Global
quit;
string p1joytype;
p1startbutton;
p1selectbutton;
p1mainbutton1;
p1mainbutton2;
p1mainbutton3;
p1mainbutton4;
p1lb;
p1rb;
p1lt;
p1rt;
string p2joytype;
p2startbutton;
p2selectbutton;
p2mainbutton1;
p2mainbutton2;
p2mainbutton3;
p2mainbutton4;
p2lb;
p2rb;
p2lt;
p2rt;
end


process Main()
begin
    /////////////////SETUP MODE/////////////////
    set_mode(640,240,16);
    set_fps(60,0);
    //set title and icon
    set_title("xbox_testor");
////////////////////MAIN////////////////////
    //RECOGNIZE JOYSTICKS AND ASSIGN JOYTYPES
    //P1
    if((joy_numjoysticks()>0)&&(
    (joy_name(0)=="Microsoft X-Box 360 pad")||
    (joy_name(0)=="Generic X-Box pad")||
    (joy_name(0)=="XBOX 360 For Windows (Controller)")||
    (joy_name(0)=="Controller (XBOX 360 For Windows)")||
    (joy_name(0)=="Controller (XB360 Mortal Kombat FightStick)")||
    (joy_name(0)=="Controller (MK Klassic Fight Stick Xbox 360)")
    ))
    p1joytype="xbox360";
    p1startbutton=7;
    p1selectbutton=6;
    p1mainbutton1=0;
    p1mainbutton2=2;
    p1mainbutton3=1;
    p1mainbutton4=3;
    p1lb=4;
p1rb=5;
p1lt=6;
p1rt=7;
    elseif((joy_numjoysticks()>0)&&(
    (joy_name(0)=="BDA PS3 Airflo wired controller")||
    (joy_name(0)=="PS3 Airflo wired controller")
    ))
    p1joytype="playstation3";
    p1startbutton=9;
    p1selectbutton=8;
    p1mainbutton1=1;
    p1mainbutton2=0;
    p1mainbutton3=2;
    p1mainbutton4=3;
    p1lb=4;
p1rb=5;
p1lt=6;
p1rt=7;
    end
    if((joy_numjoysticks()>1)&&(
    (joy_name(1)=="Microsoft X-Box 360 pad")||
    (joy_name(1)=="Generic X-Box pad")||
    (joy_name(1)=="XBOX 360 For Windows (Controller)")||
    (joy_name(1)=="Controller (XBOX 360 For Windows)")||
    (joy_name(1)=="Controller (XB360 Mortal Kombat FightStick)")||
    (joy_name(1)=="Controller (MK Klassic Fight Stick Xbox 360)")
    ))
    p2joytype="xbox360";
    p2startbutton=7;
    p2selectbutton=6;
    p2mainbutton1=0;
    p2mainbutton2=2;
    p2mainbutton3=1;
    p2mainbutton4=3;
    elseif((joy_numjoysticks()>1)&&(
    (joy_name(1)=="BDA PS3 Airflo wired controller")||
    (joy_name(1)=="PS3 Airflo wired controller")
    ))
    p2joytype="playstation3";
    p2startbutton=9;
    p2selectbutton=8;
    p2mainbutton1=1;
    p2mainbutton2=0;
    p2mainbutton3=2;
    p2mainbutton4=3;
    p2lb=4;
p2rb=5;
p2lt=6;
p2rt=7;
    end
    if(joy_numjoysticks()>0)
    controller(0,0,0,255,180,0,&p1startbutton,&p1selectbutton,&p1mainbutton1,&p1mainbutton2,&p1mainbutton3,&p1mainbutton4);
    end
    if(joy_numjoysticks()>1)
    controller(1,321,0,0,153,255,&p2startbutton,&p2selectbutton,&p2mainbutton1,&p2mainbutton2,&p2mainbutton3,&p2mainbutton4);
    end
    repeat
    set_text_color(rgb(0,0,0));
    //DISPLAY JOYSTICK NAMES
    if(joy_numjoysticks()==0)
    set_text_color(rgb(255,255,255));
    write(0,320,50,1,"No joysticks found");
    elseif(joy_numjoysticks()==1)
    write(0,160,10,1,"Player 1 joystick found: "+(p1joytype));
    write(0,160,20,1,joy_name(0));
    elseif(joy_numjoysticks()>1)
    write(0,160,10,1,"Player 1 joystick found: "+(p1joytype));
    write(0,160,20,1,joy_name(0));
    write(0,480,10,1,"Player 2 joystick found: "+(p2joytype));
    write(0,480,20,1,(joy_name(1)));
    end
    frame;
    until (key(_esc)||exit_status)
    let_me_alone();
end


process controller(player,x,y,rr,gg,bb,*start,*select,*a,*b,*c,*d/*lstickx,lsticky,lb,rb,lt,rt,rstickx,rsticky*/)
begin
loop
if(player==1)
    delete_draw(0);
    delete_text(0);
end
drawing_z(10);
drawing_color(rgb(0,0,0));
set_text_color(rgb(rr,gg,bb));
//select button
draw_box(x+130,135,x+150,145);
write(0,x+140,140,4,(*select));
if(joy_getbutton(player,*select))
drawing_color(rgb(0,255,0));
draw_box(x+128,133,x+152,147);
end
//start button
drawing_color(rgb(0,0,0));
draw_box(x+170,135,x+190,145);
write(0,x+180,140,4,(*start));
if(joy_getbutton(player,*start))
drawing_color(rgb(0,255,0));
draw_box(x+168,133,x+192,147);
end
//main button a
drawing_color(rgb(0,0,0));
draw_fcircle(x+240,160,10);
write(0,x+240,160,4,(*a));
if(joy_getbutton(player,*a))
drawing_color(rgb(0,255,0));
draw_fcircle(x+240,160,12);
end
//main button b
drawing_color(rgb(0,0,0));
draw_fcircle(x+220,140,10);
write(0,x+220,140,4,(*b));
if(joy_getbutton(player,*b))
drawing_color(rgb(0,255,0));
draw_fcircle(x+220,140,12);
end
//main button c
drawing_color(rgb(0,0,0));
draw_fcircle(x+260,140,10);
write(0,x+260,140,4,(*c));
if(joy_getbutton(player,*c))
drawing_color(rgb(0,255,0));
draw_fcircle(x+260,140,12);
end
//main button d
drawing_color(rgb(0,0,0));
draw_fcircle(x+240,120,10);
write(0,x+240,120,4,(*d));
if(joy_getbutton(player,*d))
drawing_color(rgb(0,255,0));
draw_fcircle(x+240,120,12);
end
//d_pad
drawing_color(rgb(0,0,0));
draw_box(x+80,160,x+94,200);
draw_box(x+67,173,x+107,187);
write(0,x+87,180,4,(joy_gethat((player),0)));
if(joy_gethat((player),0)==1||joy_gethat((player),0)==3||joy_gethat((player),0)==9)
drawing_color(rgb(0,255,0));
draw_box(x+78,158,x+96,172);
end
if(joy_gethat((player),0)==2||joy_gethat((player),0)==3||joy_gethat((player),0)==6)
drawing_color(rgb(0,255,0));
draw_box(x+90,171,x+109,189);
end
if(joy_gethat((player),0)==4||joy_gethat((player),0)==6||joy_gethat((player),0)==12)
drawing_color(rgb(0,255,0));
draw_box(x+78,186,x+96,202);
end
if(joy_gethat((player),0)==8||joy_gethat((player),0)==12||joy_gethat((player),0)==9)
drawing_color(rgb(0,255,0));
draw_box(x+64,171,x+79,189);
end
//left_stick

//draw_bg
drawing_z(12);
drawing_color(rgb(rr,gg,bb));
draw_box(x,0,x+320,240);
frame;
end
end

JaViS

Working on Anarkade. A couch multiplayer 2D shooter.

panreyes

Hi cmunoz :)


Maybe I'm wrong, but the next Bennu, the one built on SDL2, will have something like that integrated, thanks to the improvements in the gamepad handling in SDL2.


But still, I like your idea. I did something like that too, you may see it here:
https://code.google.com/p/pixjuegos/source/browse/trunk/common-src/controles.pr-?spec=svn719&r=719

cmunoz

#4
Thank you PiX, this is brilliant!

if(find(joy_profiles[i].name,"xbox")=>0)


So with "find" you can search the string of the joystick name for certain buzzwords like "xbox," "playstation," "ps3" "dreamcast," "guitar hero," etc. without having to attempt the creation of some exhaustive list that would inevitably be incomplete.

Thanks a million! I may end up using a combination of the two methods, but this sure is a lifesaver!

panreyes

I'm glad that helped you :)


In fact you could also use something like that:

find(lcase(joy_name(),"xbox"))=>0)


With the lcase, it won't matter wether if it's Xbox or xbox.


Cheers!


cmunoz

#6
Thanks again, I did notice that it was case sensitive, so this will be much more efficient than listing all permutations of caps and lowercase!


Meanwhile, I'm adding the RedOctane Guitar Hero X-plorer to the list, since it's an xbox controller that doesn't include the words xbox in its name.
It has names under xbox categories in windows and linux.