| File was renamed from source/src/joystick/bsd/SDL_sysjoystick.c |
| | |
| | | #include <usb.h> |
| | | #endif |
| | | #ifdef __DragonFly__ |
| | | #include <bus/usb/usb.h> |
| | | #include <bus/usb/usbhid.h> |
| | | #include <bus/u4b/usb.h> |
| | | #include <bus/u4b/usbhid.h> |
| | | #else |
| | | #include <dev/usb/usb.h> |
| | | #include <dev/usb/usbhid.h> |
| | |
| | | #endif |
| | | |
| | | #if defined(__FREEBSD__) || defined(__FreeBSD_kernel__) |
| | | #ifndef __DragonFly__ |
| | | #include <osreldate.h> |
| | | #endif |
| | | #if __FreeBSD_kernel_version > 800063 |
| | | #include <dev/usb/usb_ioctl.h> |
| | | #endif |
| | | #include <sys/joystick.h> |
| | | #elif defined(__DragonFly__) |
| | | #include <bus/u4b/usb_ioctl.h> |
| | | #include <sys/joystick.h> |
| | | #endif |
| | | |
| | |
| | | |
| | | struct report |
| | | { |
| | | #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000) |
| | | #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000) || \ |
| | | defined(__DragonFly__) |
| | | void *buf; /* Buffer */ |
| | | #elif defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) |
| | | struct usb_gen_descriptor *buf; /* Buffer */ |
| | |
| | | |
| | | #if defined(USBHID_UCR_DATA) || (defined(__FreeBSD_kernel__) && __FreeBSD_kernel_version <= 800063) |
| | | #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) |
| | | #elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000)) |
| | | #elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000)) || \ |
| | | defined(__DragonFly__) |
| | | #define REP_BUF_DATA(rep) ((rep)->buf) |
| | | #elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) |
| | | #define REP_BUF_DATA(rep) ((rep)->buf->ugd_data) |
| | |
| | | goto usberr; |
| | | } |
| | | rep = &hw->inreport; |
| | | #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) || defined(__FreeBSD_kernel__) |
| | | #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) |
| | | rep->rid = hid_get_report_id(fd); |
| | | if (rep->rid < 0) { |
| | | #else |
| | |
| | | hw->path); |
| | | goto usberr; |
| | | } |
| | | #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) |
| | | #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) |
| | | hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid); |
| | | #else |
| | | hdata = hid_start_parse(hw->repdesc, 1 << hid_input); |
| | |
| | | Sint32 dpad[4] = {0, 0, 0, 0}; |
| | | #endif |
| | | |
| | | #if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H || defined(__FreeBSD_kernel__) |
| | | #if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H || defined(__FreeBSD_kernel__) || defined(__DragonFly_) |
| | | struct joystick gameport; |
| | | static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0; |
| | | |
| | |
| | | rep = &joy->hwdata->inreport; |
| | | |
| | | while (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) == rep->size) { |
| | | #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) |
| | | #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) |
| | | hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); |
| | | #else |
| | | hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); |
| | |
| | | int len; |
| | | |
| | | #ifdef __DragonFly__ |
| | | len = hid_report_size(rd, r->rid, repinfo[repind].kind); |
| | | len = hid_report_size(rd, repinfo[repind].kind, r->rid); |
| | | #elif __FREEBSD__ |
| | | # if (__FreeBSD_kernel_version >= 460000) || defined(__FreeBSD_kernel__) |
| | | # if (__FreeBSD_kernel_version <= 500111) |
| | |
| | | r->size = len; |
| | | |
| | | if (r->size > 0) { |
| | | #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000) |
| | | #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000) || defined(__DragonFly__) |
| | | r->buf = SDL_malloc(r->size); |
| | | #else |
| | | r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) + |
| | |
| | | return SDL_Unsupported(); |
| | | } |
| | | |
| | | static int |
| | | BSD_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) |
| | | { |
| | | return SDL_Unsupported(); |
| | | } |
| | | |
| | | static SDL_bool |
| | | BSD_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) |
| | | { |
| | | return SDL_FALSE; |
| | | } |
| | | |
| | | static SDL_bool |
| | | BSD_JoystickHasLED(SDL_Joystick *joystick) |
| | | { |
| | | return SDL_FALSE; |
| | | } |
| | | |
| | | static int |
| | | BSD_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) |
| | | { |
| | | return SDL_Unsupported(); |
| | | } |
| | | |
| | | static int |
| | | BSD_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) |
| | | { |
| | | return SDL_Unsupported(); |
| | | } |
| | | |
| | | SDL_JoystickDriver SDL_BSD_JoystickDriver = |
| | | { |
| | | BSD_JoystickInit, |
| | |
| | | BSD_JoystickGetDeviceInstanceID, |
| | | BSD_JoystickOpen, |
| | | BSD_JoystickRumble, |
| | | BSD_JoystickRumbleTriggers, |
| | | BSD_JoystickHasLED, |
| | | BSD_JoystickSetLED, |
| | | BSD_JoystickSetSensorsEnabled, |
| | | BSD_JoystickUpdate, |
| | | BSD_JoystickClose, |
| | | BSD_JoystickQuit, |
| | | BSD_JoystickGetGamepadMapping |
| | | }; |
| | | |
| | | #endif /* SDL_JOYSTICK_USBHID */ |