19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Lesser General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2.1 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Lesser General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Lesser General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free Software 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@libsdl.org 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h" 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef SDL_JOYSTICK_BEOS 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* This is the system specific header for the SDL joystick API */ 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <be/support/String.h> 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <be/device/Joystick.h> 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern "C" { 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_joystick.h" 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_sysjoystick.h" 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_joystick_c.h" 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* The maximum number of joysticks we'll detect */ 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define MAX_JOYSTICKS 16 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* A list of available joysticks */ 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic char *SDL_joyport[MAX_JOYSTICKS]; 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic char *SDL_joyname[MAX_JOYSTICKS]; 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* The private structure used to keep track of a joystick */ 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstruct joystick_hwdata { 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall BJoystick *stick; 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall uint8 *new_hats; 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int16 *new_axes; 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}; 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function to scan the system for joysticks. 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * This function should set SDL_numjoysticks to the number of available 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * joysticks. Joystick 0 should be the system default joystick. 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * It should return 0, or -1 on an unrecoverable fatal error. 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint SDL_SYS_JoystickInit(void) 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall BJoystick joystick; 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int numjoysticks; 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int32 nports; 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall char name[B_OS_NAME_LENGTH]; 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Search for attached joysticks */ 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall nports = joystick.CountDevices(); 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall numjoysticks = 0; 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(SDL_joyport, 0, (sizeof SDL_joyport)); 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(SDL_joyname, 0, (sizeof SDL_joyname)); 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; (SDL_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i ) { 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( joystick.GetDeviceName(i, name) == B_OK ) { 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( joystick.Open(name) != B_ERROR ) { 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall BString stick_name; 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall joystick.GetControllerName(&stick_name); 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_joyport[numjoysticks] = strdup(name); 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_joyname[numjoysticks] = 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall strdup(stick_name.String()); 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall numjoysticks++; 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall joystick.Close(); 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(numjoysticks); 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function to get the device-dependent name of a joystick */ 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallconst char *SDL_SYS_JoystickName(int index) 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return SDL_joyname[index]; 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function to open a joystick for use. 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall The joystick to open is specified by the index field of the joystick. 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This should fill the nbuttons and naxes fields of the joystick structure. 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall It returns 0, or -1 if there is an error. 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint SDL_SYS_JoystickOpen(SDL_Joystick *joystick) 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall BJoystick *stick; 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Create the joystick data structure */ 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall joystick->hwdata = (struct joystick_hwdata *) 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_malloc(sizeof(*joystick->hwdata)); 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( joystick->hwdata == NULL ) { 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory(); 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(-1); 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall stick = new BJoystick; 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall joystick->hwdata->stick = stick; 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Open the requested joystick for use */ 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( stick->Open(SDL_joyport[joystick->index]) == B_ERROR ) { 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("Unable to open joystick"); 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SYS_JoystickClose(joystick); 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(-1); 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set the joystick to calibrated mode */ 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall stick->EnableCalibration(); 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Get the number of buttons, hats, and axes on the joystick */ 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall joystick->nbuttons = stick->CountButtons(); 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall joystick->naxes = stick->CountAxes(); 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall joystick->nhats = stick->CountHats(); 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall joystick->hwdata->new_axes = (int16 *) 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_malloc(joystick->naxes*sizeof(int16)); 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall joystick->hwdata->new_hats = (uint8 *) 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_malloc(joystick->nhats*sizeof(uint8)); 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! joystick->hwdata->new_hats || ! joystick->hwdata->new_axes ) { 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_OutOfMemory(); 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SYS_JoystickClose(joystick); 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(-1); 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* We're done! */ 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function to update the state of a joystick - called as a device poll. 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * This function shouldn't update the joystick structure directly, 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * but instead should call SDL_PrivateJoystick*() to deliver events 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * and update joystick device state. 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static const Uint8 hat_map[9] = { 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_HAT_CENTERED, 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_HAT_UP, 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_HAT_RIGHTUP, 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_HAT_RIGHT, 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_HAT_RIGHTDOWN, 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_HAT_DOWN, 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_HAT_LEFTDOWN, 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_HAT_LEFT, 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_HAT_LEFTUP 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }; 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const int JITTER = (32768/10); /* 10% jitter threshold (ok?) */ 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall BJoystick *stick; 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i, change; 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int16 *axes; 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall uint8 *hats; 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall uint32 buttons; 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set up data pointers */ 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall stick = joystick->hwdata->stick; 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall axes = joystick->hwdata->new_axes; 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall hats = joystick->hwdata->new_hats; 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Get the new joystick state */ 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall stick->Update(); 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall stick->GetAxisValues(axes); 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall stick->GetHatValues(hats); 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall buttons = stick->ButtonValues(); 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Generate axis motion events */ 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; i<joystick->naxes; ++i ) { 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall change = ((int32)axes[i] - joystick->axes[i]); 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (change > JITTER) || (change < -JITTER) ) { 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_PrivateJoystickAxis(joystick, i, axes[i]); 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Generate hat change events */ 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; i<joystick->nhats; ++i ) { 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( hats[i] != joystick->hats[i] ) { 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_PrivateJoystickHat(joystick, i, hat_map[hats[i]]); 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Generate button events */ 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; i<joystick->nbuttons; ++i ) { 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (buttons&0x01) != joystick->buttons[i] ) { 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_PrivateJoystickButton(joystick, i, (buttons&0x01)); 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall buttons >>= 1; 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function to close a joystick after use */ 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_SYS_JoystickClose(SDL_Joystick *joystick) 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( joystick->hwdata ) { 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall joystick->hwdata->stick->Close(); 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delete joystick->hwdata->stick; 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( joystick->hwdata->new_hats ) { 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(joystick->hwdata->new_hats); 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( joystick->hwdata->new_axes ) { 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(joystick->hwdata->new_axes); 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(joystick->hwdata); 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall joystick->hwdata = NULL; 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function to perform any system-specific joystick related cleanup */ 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_SYS_JoystickQuit(void) 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; SDL_joyport[i]; ++i ) { 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(SDL_joyport[i]); 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_joyport[0] = NULL; 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; SDL_joyname[i]; ++i ) { 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(SDL_joyname[i]); 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_joyname[0] = NULL; 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}; // extern "C" 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* SDL_JOYSTICK_BEOS */ 238