X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fjoystick.c;h=0966b94934ed68b664acdd71cbc8af2213d09d02;hb=2e99b0c26d334eb287486b8933b52b5048c6cc0c;hp=d5a78a290465dfa71730ab29d00de1fe7ef23e92;hpb=959794cfda1f83edc51512211ae5a9f6b1e0b179;p=rocksndiamonds.git diff --git a/src/libgame/joystick.c b/src/libgame/joystick.c index d5a78a29..0966b949 100644 --- a/src/libgame/joystick.c +++ b/src/libgame/joystick.c @@ -19,91 +19,6 @@ #include "misc.h" -/* ========================================================================= */ -/* platform dependent joystick functions */ -/* ========================================================================= */ - -#if defined(PLATFORM_UNIX) && !defined(TARGET_SDL) -void UnixInitJoysticks() -{ - static boolean unix_joystick_subsystem_initialized = FALSE; - boolean print_warning = !unix_joystick_subsystem_initialized; - int i; - - for (i = 0; i < MAX_PLAYERS; i++) - { - char *device_name = setup.input[i].joy.device_name; - - /* this allows subsequent calls to 'InitJoysticks' for re-initialization */ - if (joystick.fd[i] != -1) - { - close(joystick.fd[i]); - joystick.fd[i] = -1; - } - - if (!setup.input[i].use_joystick) - continue; - - if (access(device_name, R_OK) != 0) - { - if (print_warning) - Error(ERR_WARN, "cannot access joystick device '%s'", device_name); - - continue; - } - - if ((joystick.fd[i] = open(device_name, O_RDONLY)) < 0) - { - if (print_warning) - Error(ERR_WARN, "cannot open joystick device '%s'", device_name); - - continue; - } - - joystick.status = JOYSTICK_ACTIVATED; - } - - unix_joystick_subsystem_initialized = TRUE; -} - -boolean UnixReadJoystick(int fd, int *x, int *y, boolean *b1, boolean *b2) -{ -#if defined(PLATFORM_FREEBSD) - struct joystick joy_ctrl; -#else - struct joystick_control - { - int buttons; - int x; - int y; - } joy_ctrl; -#endif - - if (read(fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl)) - return FALSE; - - if (x != NULL) - *x = joy_ctrl.x; - if (y != NULL) - *y = joy_ctrl.y; - -#if defined(PLATFORM_FREEBSD) - if (b1 != NULL) - *b1 = joy_ctrl.b1; - if (b2 != NULL) - *b2 = joy_ctrl.b2; -#else - if (b1 != NULL) - *b1 = joy_ctrl.buttons & 1; - if (b2 != NULL) - *b2 = joy_ctrl.buttons & 2; -#endif - - return TRUE; -} -#endif /* PLATFORM_UNIX && !TARGET_SDL */ - - /* ========================================================================= */ /* platform independent joystick functions */ /* ========================================================================= */