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#if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* This is the system specific header for the SDL joystick API */ 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_joystick.h" 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_sysjoystick.h" 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_joystick_c.h" 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function to scan the system for joysticks. 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * This function should set SDL_numjoysticks to the number of available 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * joysticks. Joystick 0 should be the system default joystick. 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * It should return 0, or -1 on an unrecoverable fatal error. 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint SDL_SYS_JoystickInit(void) 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_numjoysticks = 0; 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function to get the device-dependent name of a joystick */ 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallconst char *SDL_SYS_JoystickName(int index) 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("Logic error: No joysticks available"); 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(NULL); 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function to open a joystick for use. 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall The joystick to open is specified by the index field of the joystick. 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This should fill the nbuttons and naxes fields of the joystick structure. 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall It returns 0, or -1 if there is an error. 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint SDL_SYS_JoystickOpen(SDL_Joystick *joystick) 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("Logic error: No joysticks available"); 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(-1); 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function to update the state of a joystick - called as a device poll. 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * This function shouldn't update the joystick structure directly, 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * but instead should call SDL_PrivateJoystick*() to deliver events 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall * and update joystick device state. 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function to close a joystick after use */ 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_SYS_JoystickClose(SDL_Joystick *joystick) 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Function to perform any system-specific joystick related cleanup */ 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_SYS_JoystickQuit(void) 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */ 84