X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmsdos.c;h=4c84010f90e4eb59daf90befa3f556a4fefe466a;hb=7ff43d7ba40390c41b10888aad0a35dfe3cad82a;hp=c6c51db6b65912ce03a3aba80d29a877ea9bd4b7;hpb=dd192af0efbe08a2ec5dedc204cdfb9244c00468;p=rocksndiamonds.git diff --git a/src/libgame/msdos.c b/src/libgame/msdos.c index c6c51db6..4c84010f 100644 --- a/src/libgame/msdos.c +++ b/src/libgame/msdos.c @@ -17,7 +17,9 @@ #if defined(PLATFORM_MSDOS) #include "sound.h" +#include "joystick.h" #include "misc.h" +#include "setup.h" #include "pcx.h" #define AllegroDefaultScreen() (display->screens[display->default_screen]) @@ -301,9 +303,9 @@ Display *XOpenDisplay(char *display_name) Screen *screen; Display *display; BITMAP *mouse_bitmap = NULL; + char *mouse_filename =getCustomImageFilename(program.msdos_pointer_filename); - mouse_bitmap = Read_PCX_to_AllegroBitmap(program.msdos_pointer_filename); - if (mouse_bitmap == NULL) + if ((mouse_bitmap = Read_PCX_to_AllegroBitmap(mouse_filename)) == NULL) return NULL; screen = malloc(sizeof(Screen)); @@ -944,4 +946,57 @@ void NetworkServer(int port, int serveronly) Error(ERR_WARN, "networking not supported in DOS version"); } + +/* ========================================================================= */ +/* joystick functions */ +/* ========================================================================= */ + +void MSDOSInitJoysticks() +{ + int i; + + /* start from scratch */ + remove_joystick(); + + /* try to access two joysticks; if that fails, try to access just one */ + if (install_joystick(JOY_TYPE_2PADS) == 0 || + install_joystick(JOY_TYPE_AUTODETECT) == 0) + joystick.status = JOYSTICK_ACTIVATED; + + for (i=0; i= num_joysticks) + joystick_nr = -1; + + /* misuse joystick file descriptor variable to store joystick number */ + joystick.fd[i] = joystick_nr; + } +} + +boolean MSDOSReadJoystick(int nr, int *x, int *y, boolean *b1, boolean *b2) +{ + /* the allegro global variable 'num_joysticks' contains the number + of joysticks found at initialization under MS-DOS / Windows */ + + if (nr < 0 || nr >= num_joysticks) + return FALSE; + + poll_joystick(); + + if (x != NULL) + *x = joy[nr].stick[0].axis[0].pos; + if (y != NULL) + *y = joy[nr].stick[0].axis[1].pos; + + if (b1 != NULL) + *b1 = joy[nr].button[0].b; + if (b2 != NULL) + *b2 = joy[nr].button[1].b; + + return TRUE; +} + #endif /* PLATFORM_MSDOS */