@all
Ok it works
lowlevel.library is TOOOO simple
Just add Open/close lowlevel.library to your game
and this et Voilà
/*==================================================================*/
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 =0;
G->joystick.b1 =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);
}