website logo
Auteur
avatar
thellier

Forum » » Création-Développement » » L'Abbaye des morts (par Locomalito)


Posté : 06-03-2015 15:55 icone du post

OK ça marche


BSzili m'a recommandé la lowlevel.library et elle est hyper simple


Configurer Prefs/AmigaInput : lowlevel,pad,port1


Et juste rajouter l'ouverture/fermeture de lowlevel.brary à votre code et ajouter ça


Et Voilà un joystick Trustmaster4 qui marche sous OS4


/*==================================================================*/
static void printbuttons(ULONG joy)
{
    if (joy & JPF_BUTTON_PLAY)      printf("[PLAY/MMB]");
    if (joy & JPF_BUTTON_REVERSE)   printf("[REVERSE]");
    if (joy & JPF_BUTTON_FORWARD)   printf("[FORWARD]");
    if (joy & JPF_BUTTON_GREEN)     printf("[SHUFFLE]");
    if (joy & JPF_BUTTON_RED)       printf("[SELECT/LMB/FIRE]");
    if (joy & JPF_BUTTON_BLUE)      printf("[STOP/RMB]");
}
/*=============================================== ===================*/
static void printmousedirections(ULONG joy)
{
    printf("[%d,%d]", (joy & JP_MHORZ_MASK), (joy & JP_MVERT_MASK) >> 8);
}
/*================================================================= =*/
static void printjoydirections(ULONG joy)
{
    if (joy & JPF_JOY_UP)       printf("[UP]");
    if (joy & JPF_JOY_DOWN)     printf("[DOWN]");
    if (joy & JPF_JOY_LEFT)     printf("[LEFT]");
    if (joy & JPF_JOY_RIGHT)    printf("[RIGHT]");
}
/*================================================== ================*/
static void printjoyport(ULONG unit,ULONG joy)
{
    int i;
 
    printf("UNIT%d: ",unit);
    for(i = 31; i >= 0; i--)
    {
     printf("%d", (joy & (1 << i)) ? 1 : 0);
    }
 
    printf(" - ");
 
    if ((joy & JP_TYPE_MASK) == JP_TYPE_NOTAVAIL) printf("NOT AVAILABLE");
    if ((joy & JP_TYPE_MASK) == JP_TYPE_UNKNOWN)  printf("UNKNOWN");
 
    if ((joy & JP_TYPE_MASK) == JP_TYPE_JOYSTK)
    {
        printf("JOYSTICK - ");
        printjoydirections(joy);
        printbuttons(joy);
    }
 
    if ((joy & JP_TYPE_MASK) == JP_TYPE_GAMECTLR)
    {
        printf("GAME CONTROLLER - ");
        printjoydirections(joy);
        printbuttons(joy);
    }
 
    if ((joy & JP_TYPE_MASK) == JP_TYPE_MOUSE)
    {
        printf("MOUSE - ");
        printmousedirections(joy);
        printbuttons(joy);
    }


    printf("\n");
}
/*======================================================= ===========*/
void MyProcessJoystickNew(struct game *G)
{
ULONG joy,n;


 NLOOP(4)
 {
 joy = ReadJoyPort(n);
 if(joy)
    if(!((joy & JP_TYPE_MASK) == JP_TYPE_MOUSE) )
    if(!((joy & JP_TYPE_MASK) == JP_TYPE_NOTAVAIL)  )
  break;
 }
 


 G->joystick.right =(joy & JPF_JOY_RIGHT);
 G->joystick.left =(joy & JPF_JOY_LEFT);
 G->joystick.down =(joy & JPF_JOY_DOWN);
 G->joystick.up  =(joy & JPF_JOY_UP); 
 G->joystick.b0  =(joy & JPF_BUTTON_RED);
 G->joystick.b1  =(joy & JPF_BUTTON_PLAY);


 G->joystick.b0  =0;
 G->joystick.b1 &nb sp;=0;
    if (joy & JPF_BUTTON_RED)       G->joystick.b0  =TRUE;
    if (joy & JPF_BUTTON_PLAY)      G->joystick.b1  =TRUE;


 G->key=1;
 if(debug) printjoyport(n,joy);
}

Sam440 - Sam460 - X5000 - PowerBookG4 - WinUAE - MiniMig

Cet article provient de Le site des utilisateurs francophones actuels et futurs d'AmigaOS 4.x
https://amiga-ng.org/viewtopic.php?topic=2007&forum=14