[Fenix] Can you explain the joystick to me?

Started by MisterN, August 23, 2011, 04:34:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MisterN

Can you explain the joystick to me?
like I know you can make custom buttons (then when pressed, actually press the real button its set to lol) like this
__A = _control;
__B = _alt;
__SELECT = _space;
__START = _enter;
__R = _tab;
__L = _backspace;


what can I do for joystick commands then?
Quoteget_joy_position(0)= returns the state of the X axis of the analog pad (from -128 to 128 ).

get_joy_position(1)= returns the state of the Y axis of the analog pad (from -128 to 128 ).

get_joy_button(1)= returns the state of the B button (0 if unpressed and 1 if it's pressed).

get_joy_button(2)= returns the state of the A button (0 if unpressed and 1 if it's pressed).

get_joy_button(3)= returns the state of the START button (0 if unpressed and 1 if it's pressed).

get_joy_button(5)= returns the state of the Y button.

get_joy_button(6)= returns the state of the X button.

so can you create for me an example? thankls
werg

handsource-dyko

Well, the first thing is a bit awkward to do, but I think what you want is "input abstraction". Or basically user defined keys/joystick buttons.

I have created my own input hander for malvado that abstracts user input events to a layer that deals with keyboard and joystick input. It's a bit similair to the jkeys lib. Joystick buttons have to be scanned in a loop. Maybe this joytest program clarifies the working of the joystick system: http://wiki.bennugd.org/index.php?title=Tutorial:Joystick_tester.


MisterN

#2
no? I just want for example

__X to be the x button on the joystick and so forth because that exact code is the controller commands for the dreamcast, and i just got the game to work at full 100% speed. lololol
werg

handsource-dyko

#3
Here's a 3 part example of malvado's input system, it's perhaps a little much, but it shows how to map up to 10 joysticks/gamepads, and keyboard inputs to more general events. So for instance, the joyaction() function (wich is called from a loop) scans for a particair action to be true, depending the value of the action, the function checks if a certain key or joystickbutton is pressed.

So, let's assume the user hits the up key on the keyboard, the value of action is 1, (1=up), joyaction detects that it is 1 during it's loop, then it executes CASE up, wich checks if it was a key on the keyboard or the joybutton. If no key or button is pressed, the action returns false (action=0). The other routines are more related to selecting and configuring the joystick system, the joyaction function is th core part of the whole thing. But, it is very important that joyaction is constantly called from loop in the calling process. The CONST part contains symbolic names for the action numbers. I've also taken the WIZ and Cannoo buttons into account, of course it can be easily extended to support dreamcast controls. The values for the WIZ and Cannoo buttons where looked upon from splinters jkeys.lib.


Part 1 of joystick routines.prg:


/* Source file: JOYSTICK ROUTINES
*
*/

//---------------------------------------------------------------------------------
// STRUCT joy: Stores the properties of the detected joystick devices, and use the
//             data for joystick input scanning.
//          
//---------------------------------------------------------------------------------

CONST

// empty key
LAST=0;

// general keys
UP=1; DOWN=2; LEFT=3; RIGHT=4; ESC=5; ENTER=6; SPACE=7; ALT=8; CTRL=9; btn_FIRE=10;

// gpe-wiz specific keys
btn_UPLEFT=11; btn_DOWNLEFT=12; btn_DOWNRIGHT=13; btn_UPRIGHT=14; btn_MENU=15; btn_SELECT=16; btn_L=17; btn_R=18;
btn_A=19; btn_B=20; btn_X=21; btn_Y=22; btn_VOLUP=23; btn_VOLDOWN=24; btn_CLICK=25;



GLOBAL

// Note: These joystick variables are not used for GPE-WIZ input, that is handled by it's own, because it's
// standard and pc joysticks are not (more flexible, lot's of different capabilities).
byte joy_attached=FALSE;
byte button_pressed=FALSE;
int number; // wich joystick device, in the joystick selection routine.

int selected_joystick;
int number_of_joysticks; joy_count; first_firebutton; last_firebutton; user_firebutton;

int j_left; j_right; j_up; j_down;

STRUCT joy[9];

  string name;  
  int number_of_axes;
  int number_of_buttons;    
 
  int first_firebutton; // button 0
  int last_firebutton;  // last detected button, this is variable
  int user_firebutton;  // user selected button
END



//-----------------------------------------------------------------------------
// Function for joystick scanning. (routine must be placed in loop)
// Entries: -
//          
//-----------------------------------------------------------------------------
FUNCTION scan_joy_axis();

BEGIN

  // scan the joystick axis, when a joystick is attached.
  IF (joy_attached==TRUE)
 
     // x-axis
     j_left=joy_getaxis(0);
     j_right=joy_getaxis(0);
 
 // y-axis
     j_up=joy_getaxis(1);
     j_down=joy_getaxis(1);
  END
END



handsource-dyko

part2 of joystickroutines.prg


//-----------------------------------------------------------------------------
// Function for scanning keyboard or joystick input.
// Entries: - action
// Returns: 0 when no button was pressed, or number of the button pressed.
//          
// Note: the joystick device on the GPW-WIZ is always 0.
//-----------------------------------------------------------------------------
FUNCTION joy_action(byte action);

BEGIN

  SWITCH (action)
     CASE UP:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF ((key(_up) OR j_up<-1))
              RETURN UP;
  ELSE
  RETURN LAST;
           END
END

// GPE-WIZ
        IF (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO)
       IF (joy_getbutton(0,0))
              RETURN UP;
  ELSE
  RETURN LAST;
           END
END
 END
 
 CASE DOWN:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF ((key(_down) OR j_down>0))
          RETURN DOWN;
  ELSE
  RETURN LAST;
           END
END

// GPE-WIZ
        IF (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO)
       IF (joy_getbutton(0,4))
              RETURN DOWN;
  ELSE
  RETURN LAST;
           END
END
 END
 
 CASE LEFT:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF ((key(_left) OR j_left<-1))
      RETURN LEFT;
  ELSE
  RETURN LAST;
   END
END

// GPE-WIZ
        IF (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO)
       IF (joy_getbutton(0,2))
              RETURN LEFT;
  ELSE
  RETURN LAST;
           END
END
 END
 
 CASE RIGHT:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF ((key(_right) OR j_right>0))
      RETURN RIGHT;
  ELSE
  RETURN LAST;
   END
END

// GPE-WIZ
        IF (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO)
       IF (joy_getbutton(0,6))
              RETURN RIGHT;
  ELSE
  RETURN LAST;
           END
END
 END
 
 CASE btn_L:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (key(_l))
      RETURN btn_L;
  ELSE
  RETURN LAST;
   END
END
 
    // GPE-WIZ
        IF (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO)
       IF (joy_getbutton(0,10))
      RETURN btn_L;
  ELSE
  RETURN LAST;
   END
END
 END
 
 CASE btn_R:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (key(_r))
      RETURN btn_R;
  ELSE
  RETURN LAST;
   END
END
 
        // GPE-WIZ
        IF (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO)  
       IF (joy_getbutton(0,11))
      RETURN btn_R;
  ELSE
  RETURN LAST;
   END
    END
 END
 
 CASE btn_A:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (key(_a))
      RETURN btn_A;
  ELSE
  RETURN LAST;
   END
END
 
    // GPE-WIZ
        IF (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO)
       IF (joy_getbutton(0,12))
      RETURN btn_A;
  ELSE
  RETURN LAST;
   END
    END
 END
 
 CASE btn_B:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (key(_b))
      RETURN btn_B;
  ELSE
  RETURN LAST;
   END
END
 
    // GPE-WIZ
        IF (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO)
       IF (joy_getbutton(0,13))
      RETURN btn_B;
  ELSE
  RETURN LAST;
   END
    END
 END
 
 CASE btn_X:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (key(_x))
      RETURN btn_X;
  ELSE
  RETURN LAST;
   END
END
 
    // GPE-WIZ
        IF (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO)
       IF (joy_getbutton(0,14))
      RETURN btn_X;
  ELSE
  RETURN LAST;
   END
    END
 END
 
 CASE btn_Y:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (key(_y))
      RETURN btn_Y;
  ELSE
  RETURN LAST;
   END
END
 
    // GPE-WIZ
        IF ((OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (joy_getbutton(0,15))
      RETURN btn_Y;
  ELSE
  RETURN LAST;
   END
    END
 END
 
 CASE btn_MENU:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (key(_esc))
      RETURN btn_MENU;
  ELSE
  RETURN LAST;
   END
END
 
    // GPE-WIZ
        IF ((OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (joy_getbutton(0,8))
      RETURN btn_MENU;
  ELSE
  RETURN LAST;
   END
    END
 END
 
 CASE btn_SELECT:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (key(_enter))
      RETURN btn_SELECT;
  ELSE
  RETURN LAST;
   END
END
 
    // GPE-WIZ
        IF ((OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (joy_getbutton(0,9))
      RETURN btn_SELECT;
  ELSE
  RETURN LAST;
   END
    END
 END
 
 CASE btn_VOLDOWN:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (key(_c_minus))
      RETURN btn_VOLDOWN;
  ELSE
  RETURN LAST;
   END
END
 
    // GPE-WIZ
        IF ((OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (joy_getbutton(0,17))
      RETURN btn_VOLDOWN;
  ELSE
  RETURN LAST;
   END
    END
 END
 
 CASE btn_VOLUP:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (key(_c_plus))
      RETURN btn_VOLUP;
  ELSE
  RETURN LAST;
   END
END
 
    // GPE-WIZ
        IF ((OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (joy_getbutton(0,16))
      RETURN btn_VOLUP;
  ELSE
  RETURN LAST;
   END
    END
 END
 
 CASE btn_CLICK:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (key(_c_home))
      RETURN btn_CLICK;
  ELSE
  RETURN LAST;
   END
END
 
    // GPE-WIZ
        IF ((OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (joy_getbutton(0,18))
      RETURN btn_CLICK;
  ELSE
  RETURN LAST;
   END
    END
 END
 
 
 
 CASE ESC:
    IF (key(_esc))
   RETURN ESC;
ELSE
RETURN LAST;
END
 END
 
 CASE SPACE:
    IF (key(_space))
   RETURN SPACE;
ELSE
RETURN LAST;
END
 END
 
 CASE ENTER:
    IF (key(_enter))
   RETURN ENTER;
ELSE
RETURN LAST;
END
 END
 
 CASE ALT:
    IF (key(_alt))
   RETURN ALT;
ELSE
RETURN LAST;
END
 END
 
 CASE CTRL:
    IF (key(_control))
   RETURN CTRL;
ELSE
RETURN LAST;
END
 END
 
 
 
 // general "fire button" (=space, control, enter, first, last and user firebutton)
 CASE btn_FIRE:
    // PC keyboard or joystick
    IF (NOT (OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
       IF (key(_space) OR key(_control) OR key(_enter) OR (joy_getbutton(first_firebutton)==TRUE) OR (joy_getbutton(last_firebutton)==TRUE) OR (joy_getbutton(user_firebutton)==TRUE))
      RETURN btn_FIRE;
              ELSE
              RETURN LAST;
       END
END
// GPE-WIZ (buttons A,B,X,Y)
        IF ((OS_ID==OS_GP2X_WIZ OR OS_ID==OS_CAANOO))
   IF (joy_getbutton(0,12) OR joy_getbutton(0,13) OR joy_getbutton(0,14) OR joy_getbutton(0,15))
      RETURN btn_FIRE;
  ELSE
  RETURN LAST;
   END
END
 END
 
 
  END      
END

//-----------------------------------------------------------------------------
// Function for detecting the number of joysticks and their capabilities.
// Entries: -
//         
//-----------------------------------------------------------------------------
FUNCTION joy_system_init();

BEGIN

   // Get number of joysticks attached
   number_of_joysticks=joy_numjoysticks();
   
   
   say("");
   say("number of joysticks attached: "+number_of_joysticks);
   
   // print some error messages
   IF (number_of_joysticks>9)
      say("you have more then 10 joysticks attached!, will only use the first 10!");
   END
   
   IF (number_of_joysticks<1)
      say("you have no joystick attached.");
  joy_attached=FALSE;
   END
   
   say("");
   
   // list all detected joystick devices in the console, also list the amount of buttons and axis per detected
   // joystick device.
   IF (number_of_joysticks<=9)
     FOR (joy_count=0; joy_count<number_of_joysticks; joy_count+=1)
         say("joystick "+joy_count+" name: "+joy_name(joy_count)+" number of buttons: "+joy_numbuttons(joy_count));           
           
         joy[joy_count].name=joy_name(joy_count);
         joy[joy_count].number_of_axes=joy_numaxes(joy_count);
         joy[joy_count].number_of_buttons=joy_numbuttons(joy_count);   
         joy[joy_count].first_firebutton=0;
         joy[joy_count].last_firebutton=(joy_numbuttons(joy_count))-1; 
joy[joy_count].user_firebutton=0; //(0=default)
      END
   END

   // we've detected one or more joysticks.
   joy_attached=TRUE;
   
   // default, we select the first detected joystick.
   selected_joystick=0;
   joy_select(selected_joystick);
   
   // do some standard mapping of the fire buttons (does not apply for gpe-wiz).
   IF (joy_attached==TRUE)
      first_firebutton=joy[0].first_firebutton;
      last_firebutton=joy[0].last_firebutton;
  user_firebutton=joy[0].user_firebutton;
   END  
   
END

handsource-dyko

part 3 of joystickroutines.prg


//-----------------------------------------------------------------------------
// Function for selecting a different joystick and defining the buttons.
// Entries: -
//         
//-----------------------------------------------------------------------------
FUNCTION joy_mapping();

PRIVATE
byte c; // counter

BEGIN

  delete_text(all_text);

   // there's only one device attached
  IF (number_of_joysticks<1)
say("");
say("The joystick button option can only be used when there's a joystick device attached.");
write(0,10,10,3,"The joystick button option can only");
write(0,10,20,3,"be used when there's a joysitck device");
write(0,10,30,3,"attached.");
  ELSE
 
 
// we have more then one device attached     
IF (number_of_joysticks>1)
say("");
say("Which connected joystick device do you want to use?");
write(0,10,10,3,"Which connected joystick device do");
write(0,10,20,3,"you want to use? (0-9)");



// scan the numerical keys from 0-9 and check if the selected number
// doesn't exceed the number of attached devices, and keep doing this
// until a number key has been pressed.
REPEAT
   IF (key(_0))
  IF (number_of_joysticks =>1)
selected_joystick=0;
joy_select(selected_joystick);
say("");
say("You have selected joystick device number: "+selected_joystick+"; "+joy_name(selected_joystick));
                 write(0,10,40,3,"You have selected joystick device number: "+selected_joystick);
                 write(0,10,50,3,joy_name(selected_joystick));
  ELSE
say("you don't have that many joysticks attached!");
write(0,10,40,3,"you don't have that many joysticks attached!");
  END
  button_pressed=TRUE;
   END
   IF (key(_1))
  IF (number_of_joysticks =>2)
selected_joystick=1;
joy_select(selected_joystick);
say("");
say("You have selected joystick device number: "+selected_joystick+"; "+joy_name(selected_joystick));
                 write(0,10,40,3,"You have selected joystick device number: "+selected_joystick);
                 write(0,10,50,3,joy_name(selected_joystick));      
  ELSE
say("you don't have that many joysticks attached!");
write(0,10,40,3,"you don't have that many joysticks attached!");
  END
  button_pressed=TRUE;  
   END
   IF (key(_2))
  IF (number_of_joysticks =>3)
selected_joystick=2;
joy_select(selected_joystick);
say("");
say("You have selected joystick device number: "+selected_joystick+"; "+joy_name(selected_joystick));
                 write(0,10,40,3,"You have selected joystick device number: "+selected_joystick);
                 write(0,10,50,3,joy_name(selected_joystick));      
  ELSE
say("you don't have that many joysticks attached!");
write(0,10,40,3,"you don't have that many joysticks attached!");
  END
  button_pressed=TRUE;
   END
   IF (key(_3))
  IF (number_of_joysticks =>4)
selected_joystick=3;
joy_select(selected_joystick);
say("");
say("You have selected joystick device number: "+selected_joystick+"; "+joy_name(selected_joystick));
                 write(0,10,40,3,"You have selected joystick device number: "+selected_joystick);
                 write(0,10,50,3,joy_name(selected_joystick));
  ELSE
say("you don't have that many joysticks attached!");
write(0,10,40,3,"you don't have that many joysticks attached!");
  END
  button_pressed=TRUE;
   END
   IF (key(_4))
  IF (number_of_joysticks =>5)
selected_joystick=4;
joy_select(selected_joystick);
say("");
say("You have selected joystick device number: "+selected_joystick+"; "+joy_name(selected_joystick));
                 write(0,10,40,3,"You have selected joystick device number: "+selected_joystick);
                 write(0,10,50,3,joy_name(selected_joystick));      
  ELSE
say("you don't have that many joysticks attached!");
write(0,10,40,3,"you don't have that many joysticks attached!");
  END
  button_pressed=TRUE;
   END
   IF (key(_5))
  IF (number_of_joysticks =>6)
selected_joystick=5;
joy_select(selected_joystick);
say("");
say("You have selected joystick device number: "+selected_joystick+"; "+joy_name(selected_joystick));
                 write(0,10,40,3,"You have selected joystick device number: "+selected_joystick);
                 write(0,10,50,3,joy_name(selected_joystick));      
  ELSE
say("you don't have that many joysticks attached!");
write(0,10,40,3,"you don't have that many joysticks attached!");
  END
  button_pressed=TRUE;
   END
   IF (key(_6))
  IF (number_of_joysticks =>7)
selected_joystick=6;
joy_select(selected_joystick);
say("");
say("You have selected joystick device number: "+selected_joystick+"; "+joy_name(selected_joystick));
                 write(0,10,40,3,"You have selected joystick device number: "+selected_joystick);
                 write(0,10,50,3,joy_name(selected_joystick));      
  ELSE
say("you don't have that many joysticks attached!");
write(0,10,40,3,"you don't have that many joysticks attached!");
  END
  button_pressed=TRUE;
   END
   IF (key(_7))
  IF (number_of_joysticks =>8)
selected_joystick=7;
joy_select(selected_joystick);
say("");
say("You have selected joystick device number: "+selected_joystick+"; "+joy_name(selected_joystick));
                 write(0,10,40,3,"You have selected joystick device number: "+selected_joystick);
                 write(0,10,50,3,joy_name(selected_joystick));      
  ELSE
say("you don't have that many joysticks attached!");
write(0,10,40,3,"you don't have that many joysticks attached!");
  END
  button_pressed=TRUE;
   END
   IF (key(_8))
  IF (number_of_joysticks =>9)
selected_joystick=8;
joy_select(selected_joystick);
say("");
say("You have selected joystick device number: "+selected_joystick+"; "+joy_name(selected_joystick));
                 write(0,10,40,3,"You have selected joystick device number: "+selected_joystick);
                 write(0,10,50,3,joy_name(selected_joystick));      
  ELSE
say("you don't have that many joysticks attached!");
write(0,10,40,3,"you don't have that many joysticks attached!");
  END
  button_pressed=TRUE;
   END
   IF (key(_9))
  IF (number_of_joysticks =>10)
selected_joystick=9;
joy_select(selected_joystick);
say("");
say("You have selected joystick device number: "+selected_joystick+"; "+joy_name(selected_joystick));
                 write(0,10,40,3,"You have selected joystick device number: "+selected_joystick);
                 write(0,10,50,3,joy_name(selected_joystick));      
  ELSE
say("you don't have that many joysticks attached!");
write(0,10,40,3,"you don't have that many joysticks attached!");
  END
  button_pressed=TRUE;
   END
   FRAME;
UNTIL (button_pressed==TRUE)

button_pressed=FALSE; // reset the button pressed flag, so it can be used by the next bit of the routine
END

say("");
say("Press the joystick button you want to use as user defined firebutton.");
say("");
say("Current joystick in use: "+selected_joystick);
say("Current user button: "+user_firebutton);
 
     write(0,10,70,3,"Press the joystick button you want to ");
write(0,10,80,3,"use as user defined firebutton.");
write(0,10,100,3,"Current joystick in use: "+selected_joystick);
write(0,10,110,3,"Current user button: "+user_firebutton);


// let the user press any button, and this will become the user define firebutton.
REPEAT
FOR (c=0; c<joy[selected_joystick].number_of_buttons; c+=1)
   IF (joy_getbutton(c)==TRUE)
  joy[selected_joystick].user_firebutton=c;
  button_pressed=TRUE;
   END   
END
FRAME;
UNTIL (button_pressed==TRUE)
 
// set the user firebutton
user_firebutton=joy[selected_joystick].user_firebutton;
say("");
say("You selected button: "+user_firebutton+" on joystick device: "+selected_joystick);
write(0,10,130,3,"You selected button: "+user_firebutton+" on joystick device: "+selected_joystick);

FRAME(10000); // wait 10 seconds.
delete_text(all_text);
  END
END



//-----------------------------------------------------------------------------
// Function for selecting a different joystick during gameplay.
// Entries: -
//         
//-----------------------------------------------------------------------------
FUNCTION joy_switcher();

BEGIN
   
  // allows to select a different joystick.
  IF (key(_j) AND key(_0))
IF (number_of_joysticks =>1)
selected_joystick=0;
joy_select(selected_joystick);
say("");
say("you have selected joystick number: "+selected_joystick);
ELSE
say("you don't have that many joysticks attached!"); 
END   
  END

  IF (key(_j) AND key(_1))
IF (number_of_joysticks =>2)
selected_joystick=1;
joy_select(selected_joystick);
say("");
say("you have selected joystick number: "+selected_joystick);
ELSE
say("you don't have that many joysticks attached!");   
END   
  END

  IF (key(_j) AND key(_2))
IF (number_of_joysticks =>3)
selected_joystick=2;
joy_select(selected_joystick);
say("");
say("you have selected joystick number: "+selected_joystick);
ELSE
say("you don't have that many joysticks attached!");
END
  END   

  IF (key(_j) AND key(_3))
IF (number_of_joysticks =>4)
selected_joystick=3;
joy_select(selected_joystick);
say("");
say("you have selected joystick number: "+selected_joystick);
ELSE
say("you don't have that many joysticks attached!");
END
  END

  IF (key(_j) AND key(_4))
IF (number_of_joysticks =>5)
selected_joystick=4;
joy_select(selected_joystick);
say("");
say("you have selected joystick number: "+selected_joystick);
ELSE
say("you don't have that many joysticks attached!");
END
  END

  IF (key(_j) AND key(_5))
IF (number_of_joysticks =>6)
selected_joystick=5;
joy_select(selected_joystick);
say("");
say("you have selected joystick number: "+selected_joystick);
ELSE
say("you don't have that many joysticks attached!");
END
  END 

  IF (key(_j) AND key(_6))
IF (number_of_joysticks =>7)
selected_joystick=6;
joy_select(selected_joystick);
say("");
say("you have selected joystick number: "+selected_joystick);
ELSE
say("you don't have that many joysticks attached!");
END
  END
  IF (key(_j) AND key(_7))
IF (number_of_joysticks =>8)
selected_joystick=7;
joy_select(selected_joystick);
say("");
say("you have selected joystick number: "+selected_joystick);
ELSE
say("you don't have that many joysticks attached!");
END
  END

  IF (key(_j) AND key(_8))
IF (number_of_joysticks =>9)
selected_joystick=8;
joy_select(selected_joystick);
say("");
say("you have selected joystick number: "+selected_joystick);
ELSE
say("you don't have that many joysticks attached!");
END
  END               
  IF (key(_j) AND key(_9))
IF (number_of_joysticks =>10)
selected_joystick=9;
joy_select(selected_joystick);
say("");
say("you have selected joystick number: "+selected_joystick);
ELSE
say("you don't have that many joysticks attached!");
END
  END
END

MisterN

I like read it but i didnt understnad that at all lol.

If you map a control to a key, then every controller uses that command. if you map it to a joy stick with select_joy(); then only that controller uses that command
werg

SplinterGU

Quote from: DoctorN on August 23, 2011, 04:34:42 AM
Can you explain the joystick to me?
like I know you can make custom buttons (then when pressed, actually press the real button its set to lol) like this
__A = _control;
__B = _alt;
__SELECT = _space;
__START = _enter;
__R = _tab;
__L = _backspace;


what can I do for joystick commands then?
Quoteget_joy_position(0)= returns the state of the X axis of the analog pad (from -128 to 128 ).

get_joy_position(1)= returns the state of the Y axis of the analog pad (from -128 to 128 ).

get_joy_button(1)= returns the state of the B button (0 if unpressed and 1 if it's pressed).

get_joy_button(2)= returns the state of the A button (0 if unpressed and 1 if it's pressed).

get_joy_button(3)= returns the state of the START button (0 if unpressed and 1 if it's pressed).

get_joy_button(5)= returns the state of the Y button.

get_joy_button(6)= returns the state of the X button.

so can you create for me an example? thankls

BennuGD? or Fenix?
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

MisterN

fenix, and did you get that emulator to work right?
werg

SplinterGU

I recommend you to clarify your doubts are for Fenix, because they put the codes do not work for Fenix.

sorry, I have not had time to try the emulator, yet... I'm very complicated time and very tired.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

MisterN

Quote from: SplinterGU on August 27, 2011, 11:50:58 PM
I recommend you to clarify your doubts about Fenix, because alot of the codes do not work.

sorry, I have not had time to try the emulator, yet... My time is very complicated right now so not yet.

fixed
werg

SplinterGU

#11
I mean, the handsource-dyko's code don't works in Fenix, is for BennuGD.

Is very hard get help for Fenix, because Fenix is obsolete... and have lot of bugs and wrong behavior in some issues.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

MisterN

until bennu comes to dreamcast, thats what I have to code first. then once the dreamcast engine is done, then i will do it on bennu and linux.
werg

SplinterGU

sure, I understand you...

please, when you ask for Fenix support, add the word "Fenix" in the title post.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

MisterN

Ok, if you ever work on bennu, the #1 thing to work on is getting unload to work.
werg