Torque3D Documentation / _generateds / sdlInputManager.cpp

sdlInputManager.cpp

Engine/source/platformSDL/sdlInputManager.cpp

More...

Public Typedefs

SDL_JoystickType
SDLJoystickType 
SDL_JoystickPowerLevel
SDLPowerEnum 

Public Variables

Public Functions

DefineEngineStaticMethod(SDLInputManager , closeDevice , void , (S32 sdlIndex) , (0) , "@brief Used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> close the N'th item in the SDL device <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">list.\n\n</a>" "This will close <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Joystick or Game <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Controller.\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" )
DefineEngineStaticMethod(SDLInputManager , ControllerGetAxes , String , (S32 sdlIndex) , (0) , "@brief Gets the current <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> all controller <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">axes.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return A tab separated string that can be parsed from script with getField()/getFields(). " "Game controllers always have 6 axes in the following order: 0- LX, 1- LY, 2- RX, 3- RY, 4- LT, 5-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">RT.\n\n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , ControllerGetButtons , String , (S32 sdlIndex) , (0) , "@brief Gets the current <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> all controller <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">buttons.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return A tab separated string that can be parsed from script with getField()/getFields(). " "Game controllers always have 15 buttons in the following order: 0- A, 1- B, 2- X, 3- Y, 4- Back, " "5- Guide, 6- Start, 7-Left Stick, 8-Right Stick, 9-Left Shoulder, 10-Right Shoulder, " "11-DPad Up, 12-DPad Down, 13-DPad Left, 14-DPad <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Right.\n\n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , ControllerNameForIndex , const char * , (S32 sdlIndex) , (0) , "@brief Exposes SDL_GameControllerNameForIndex() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the implementation dependent name <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the game controller, " "or <a href="/coding/file/typesx86unix_8h/#typesx86unix_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> there is no name or the index is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">invalid.\n</a>" " @see https://wiki.libsdl.org/SDL_GameControllerNameForIndex \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , GameControllerAddMapping , S32 , (const char *mappingString) , "@brief Exposes SDL_GameControllerAddMapping() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "Use this function <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> add support <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> controllers that SDL is unaware of or " "<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> cause an existing controller <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> have <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> different <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">binding.\n</a>" "@param mappingString The <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> mapping string <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> apply. Full details on the format of this " "string are available at the linked SDL wiki <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">page.\n</a>" "@return Returns 1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> mapping is added, 0 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> an existing mapping is updated, -1 on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">error.\n</a>" " @see https://wiki.libsdl.org/SDL_GameControllerAddMapping \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , GameControllerAddMappingsFromFile , S32 , (const char *fileName) , "@brief Exposes SDL_GameControllerAddMappingsFromFile() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "Use this function <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> load <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> set of Game Controller mappings from <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> file, filtered by the " "current SDL_GetPlatform(). A community sourced database of controllers is available at " "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @param fileName The <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> load mappings <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">from.\n</a>" " @return Returns the number of mappings added or -1 on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">error.\n</a>" " @see https://wiki.libsdl.org/SDL_GameControllerAddMappingsFromFile \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , GameControllerMapping , String , (S32 sdlIndex) , (0) , "@brief Exposes SDL_GameControllerMapping() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> string that has the controller's mapping or <a href="/coding/file/typesx86unix_8h/#typesx86unix_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> no mapping " "is available or it does not <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">exist.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickNameForIndex \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , GameControllerMappingForGUID , String , (const char *guidStr) , "@brief Exposes SDL_GameControllerMappingForGUID() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param guidStr The GUID <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> which <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> mapping is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">desired.\n</a>" "@return Returns <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> mapping string or <a href="/coding/file/typesx86unix_8h/#typesx86unix_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">error.\n</a>" "@see https://wiki.libsdl.org/SDL_GameControllerMappingForGUID \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , GameControllerMappingForIndex , String , (S32 mappingIndex) , "Get the mapping at <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n\n</a>" "@param mappingIndex The index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> which <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> mapping is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">desired.\n</a>" "@return Returns <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> mapping string or <a href="/coding/file/typesx86unix_8h/#typesx86unix_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the index is out of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">range.\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , GameControllerNumMappings , S32 , () , "Get the number of mappings installed. Used with GameControllerMappingForIndex " "<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> iterate through all installed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">mappings.\n\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , getDeviceOpenState , S32 , (S32 sdlIndex) , (0) , "@brief Used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> determine the current state of the N'th item in the SDL device <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">list.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">values:\n</a>" "-1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the device does not exist (invalid sdlIndex passed)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "0 The device is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">closed\n</a>" "1 The device is open as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Joystick\n</a>" "2 The device is open as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Game <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Controller\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , GetDeviceType , SDLJoystickType , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickGetDeviceType() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return The type of device connected. Possible return strings are: \"Unknown\" , " "\"Game Controller\" , \"Wheel\" , \"Arcade Stick\" , \"Flight Stick\" , \"Dance Pad\" , " "\"Guitar\" , \"Drum Kit\" , \"Arcade Pad\" and \"Throttle\"\n" "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceType \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , GetProduct , S32 , (S32 sdlIndex) , (0) , "Gets the USB product ID of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> joystick device, <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">available.\n\n</a>" " @param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" " @return The USB product ID. If the product ID isn '<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1aded116371789db1fd63c90ef00c95a3d">t</a> available this function returns 0.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_JoystickGetDeviceProduct \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_JoystickGetProduct \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_GameControllerGetProduct \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , GetProductVersion , S32 , (S32 sdlIndex) , (0) , "Gets the product version of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> joystick device, <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">available.\n\n</a>" " @param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" " @return The product version. If the product version isn '<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1aded116371789db1fd63c90ef00c95a3d">t</a> available this function returns 0.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_JoystickGetDeviceProductVersion \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_JoystickGetProductVersion \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_GameControllerGetProductVersion \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , getTorqueInstFromDevice , const char * , (S32 sdlIndex) , (0) , "@brief Gets the T3D instance identifier <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> an open SDL <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">joystick.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the T3D instance ID used <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> mapping this device or Null <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it does not <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">exist.\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , GetVendor , S32 , (S32 sdlIndex) , (0) , "Gets the USB vendor ID of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> joystick device, <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">available.\n\n</a>" " @param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" " @return The USB vendor ID. If the vendor ID isn '<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1aded116371789db1fd63c90ef00c95a3d">t</a> available this function returns 0.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_JoystickGetDeviceVendor \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_JoystickGetVendor \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_GameControllerGetVendor \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , IsGameController , bool , (S32 sdlIndex) , (0) , "@brief Exposes SDL_IsGameController() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns true <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the given joystick is supported by the game controller " " interface, false <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it isn '<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1aded116371789db1fd63c90ef00c95a3d">t</a> or it 's an invalid <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n</a>" " @see https://wiki.libsdl.org/SDL_IsGameController \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , JoystickGetAxes , String , (S32 sdlIndex) , (0) , "@brief Gets the current <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> all joystick <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">axes.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return A tab separated string that can be parsed from script with getField()/getFields(). " "Each axis is one field, so <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> 4 axis device will have 4 <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">fields.\n\n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , JoystickGetButtons , String , (S32 sdlIndex) , (0) , "@brief Gets the current <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> all joystick <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">buttons.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return A tab separated string that can be parsed from script with getField()/getFields(). " "Each button is one field. 0 - SDL_JoystickNumButtons() <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">fields.\n\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , JoystickGetGUID , const char * , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickGetDeviceGUID() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return GUID <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the indexed device or Null <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it does not <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">exist.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceGUID \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , JoystickGetHats , String , (S32 sdlIndex) , (0) , "@brief Gets the current <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> all POV <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">hats.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return A tab separated string that can be parsed from script with getField()/getFields(). " "Each hat is one field. 0 - SDL_JoystickNumHats() fields. The <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> 4 bit bitmask. " "If no bits are set, the hat is centered. Bit 0 is up, 1 is right, 2 is down and 3 is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">left.\n\n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , JoystickGetSpecs , String , (S32 sdlIndex) , (0) , "@brief A convenience function <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> reurn all of the data <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Joystick/Game Controller " " packed as fields in <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> tab separated <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">string.\n\n</a>" "There is overhead involved in querying joystick data, especially <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the device is not open. " "If more than one field is required, it is more efficient <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> call JoystickGetSpecs() and " "parse the data out of the return string than <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> call the console method <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">each.\n</a>" " @param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" " @return A tab separated string that can be parsed from script with getField()/getFields().\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "Field 0:Number of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Axes\n</a>" " 1:Number of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Buttons\n</a>" " 2:Number of POV <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Hats\n</a>" " 3:Number of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Trackballs\n</a>" " 4:SDL_IsGameController()(Boolean)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " 5:SDL_JoystickIsHaptic()(Boolean)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " 6:Power Level(<a href="/coding/class/classstring/">String</a>)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " 7:Device <a href="/coding/file/rapidjson_8h/#rapidjson_8h_1a1d1cfd8ffb84e947f82999c682b666a7">Type</a>(<a href="/coding/class/classstring/">String</a>)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , JoystickIsHaptic , bool , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickIsHaptic() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns true <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the joystick is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">haptic.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickIsHaptic \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , JoystickNameForIndex , const char * , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickNameForIndex() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the name of the selected joystick or Null <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it does not <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">exist.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickNameForIndex \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , JoystickNumAxes , S32 , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickNumAxes() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the number of axis controls/number of axes on <a href="/coding/file/codeinterpreter_8h/#codeinterpreter_8h_1a6b4b0e49305f04dba3d0b888008d675fab8916948582bbb4902d6ad269064f7ef">success</a> or zero on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">failure.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickNumAxes \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , JoystickNumBalls , S32 , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickNumBalls() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the number of trackballs on <a href="/coding/file/codeinterpreter_8h/#codeinterpreter_8h_1a6b4b0e49305f04dba3d0b888008d675fab8916948582bbb4902d6ad269064f7ef">success</a> or zero on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">failure.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickNumBalls \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , JoystickNumButtons , S32 , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickNumButtons() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the number of buttons on <a href="/coding/file/codeinterpreter_8h/#codeinterpreter_8h_1a6b4b0e49305f04dba3d0b888008d675fab8916948582bbb4902d6ad269064f7ef">success</a> or zero on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">failure.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickNumButtons \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , JoystickNumHats , S32 , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickNumHats() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the number of POV hats on <a href="/coding/file/codeinterpreter_8h/#codeinterpreter_8h_1a6b4b0e49305f04dba3d0b888008d675fab8916948582bbb4902d6ad269064f7ef">success</a> or zero on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">failure.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickNumHats \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , JoystickPowerLevel , SDLPowerEnum , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickCurrentPowerLevel() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the current battery level or \"Wired\" if it's <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> connected <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickCurrentPowerLevel \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , numJoysticks , S32 , () , "@brief Returns the number of currently connected joystick <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">devices.\n\n</a>" "Game Controllers are <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> sub-set of joysticks and are included in the joystick count. " "See https://wiki.libsdl.org/SDL_NumJoysticks <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> more <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">details.\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
DefineEngineStaticMethod(SDLInputManager , openAsController , S32 , (S32 sdlIndex, S32 torqueInstId) , (0, 0) , "@brief Used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> open the device as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Game <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Controller.\n\n</a>" "If the device is currently open as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Joystick, it will be closed and opened as " "<a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Game Controller. If it is currently opened as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Game Controller with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> different " "T3D instance ID, it will be changed <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the requested ID <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> that ID is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">available.\n</a>" " @param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" " @param torqueInstId Is the requested T3D device instance ID. If there is already an " "open Game Controller with the requested ID, The first available ID will be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">assigned.\n</a>" " @return The T3D device instance ID assigned, or -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the device could not be opened." )
DefineEngineStaticMethod(SDLInputManager , openAsJoystick , S32 , (S32 sdlIndex, S32 torqueInstId) , (0, 0) , "@brief Used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> open the device as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Joystick.\n\n</a>" "If the device is currently open as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Game Controller, it will be closed and opened as " "<a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Joystick. If it is currently opened as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Joystick with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> different T3D instance ID, " "it will be changed <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the requested ID <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> that ID is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">available.\n</a>" " @param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" " @param torqueInstId Is the requested T3D device instance ID. If there is already an open Joystick with " "the requested ID, The first available ID will be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">assigned.\n</a>" " @return The T3D device instance ID assigned, or -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the device could not be opened." )
IMPLEMENT_GLOBAL_CALLBACK(onSDLDeviceConnected , void , (S32 sdlIndex, const char *deviceName, const char *deviceType) , (sdlIndex, deviceName, deviceType) , "Callback that occurs when an input device is connected <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">system.\n\n</a>" "@param sdlIndex The index that will be used by sdl <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> refer <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@param deviceName The name that the device reports. This will be the return " "<a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of SDL_JoystickNameForIndex or SDL_GameControllerNameForIndex depending on the device <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">type.\n</a>" "@param deviceType The type of device connected. See SDLInputManager::getDeviceType() " "<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> possible string <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">values.\n\n</a>" )
IMPLEMENT_GLOBAL_CALLBACK(onSDLDeviceDisconnected , void , (S32 sdlIndex) , (sdlIndex) , "Callback that occurs when an input device is disconnected from the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">system.\n\n</a>" "@param sdlIndex The index of the device that was <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">removed.\n</a>" )
IMPLEMENT_STATIC_CLASS(SDLInputManager , "@brief Static class exposing the SDL_Joystick and SDL_GameController APIs <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> Torque <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Script.\n</a>" "<a href="/coding/class/classsdlinputmanager/">SDLInputManager</a> provides access <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the functions of these APIs through static class " "functions.These functions are not <a href="/coding/file/tsshapeconstruct_8cpp/#tsshapeconstruct_8cpp_1a21625ca11566389388a748ad1acc0990">required</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> bind or process events.By setting " "pref::Input::JoystickEnabled or pref::Input::sdlControllerEnabled <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> true)
ImplementEnumType(SDLJoystickType , "The type of device <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">connected.\n\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )
ImplementEnumType(SDLPowerEnum , "An enumeration of battery levels of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">joystick.\n\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

Detailed Description

Public Typedefs

typedef SDL_JoystickType SDLJoystickType 
typedef SDL_JoystickPowerLevel SDLPowerEnum 

Public Variables

 EndImplementEnumType 

Public Functions

DefineEngineStaticMethod(SDLInputManager , closeDevice , void , (S32 sdlIndex) , (0) , "@brief Used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> close the N'th item in the SDL device <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">list.\n\n</a>" "This will close <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Joystick or Game <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Controller.\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" )

DefineEngineStaticMethod(SDLInputManager , ControllerGetAxes , String , (S32 sdlIndex) , (0) , "@brief Gets the current <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> all controller <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">axes.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return A tab separated string that can be parsed from script with getField()/getFields(). " "Game controllers always have 6 axes in the following order: 0- LX, 1- LY, 2- RX, 3- RY, 4- LT, 5-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">RT.\n\n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , ControllerGetButtons , String , (S32 sdlIndex) , (0) , "@brief Gets the current <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> all controller <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">buttons.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return A tab separated string that can be parsed from script with getField()/getFields(). " "Game controllers always have 15 buttons in the following order: 0- A, 1- B, 2- X, 3- Y, 4- Back, " "5- Guide, 6- Start, 7-Left Stick, 8-Right Stick, 9-Left Shoulder, 10-Right Shoulder, " "11-DPad Up, 12-DPad Down, 13-DPad Left, 14-DPad <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Right.\n\n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , ControllerNameForIndex , const char * , (S32 sdlIndex) , (0) , "@brief Exposes SDL_GameControllerNameForIndex() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the implementation dependent name <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the game controller, " "or <a href="/coding/file/typesx86unix_8h/#typesx86unix_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> there is no name or the index is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">invalid.\n</a>" " @see https://wiki.libsdl.org/SDL_GameControllerNameForIndex \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , GameControllerAddMapping , S32 , (const char *mappingString) , "@brief Exposes SDL_GameControllerAddMapping() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "Use this function <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> add support <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> controllers that SDL is unaware of or " "<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> cause an existing controller <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> have <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> different <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">binding.\n</a>" "@param mappingString The <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> mapping string <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> apply. Full details on the format of this " "string are available at the linked SDL wiki <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">page.\n</a>" "@return Returns 1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> mapping is added, 0 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> an existing mapping is updated, -1 on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">error.\n</a>" " @see https://wiki.libsdl.org/SDL_GameControllerAddMapping \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , GameControllerAddMappingsFromFile , S32 , (const char *fileName) , "@brief Exposes SDL_GameControllerAddMappingsFromFile() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "Use this function <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> load <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> set of Game Controller mappings from <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> file, filtered by the " "current SDL_GetPlatform(). A community sourced database of controllers is available at " "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @param fileName The <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> load mappings <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">from.\n</a>" " @return Returns the number of mappings added or -1 on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">error.\n</a>" " @see https://wiki.libsdl.org/SDL_GameControllerAddMappingsFromFile \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , GameControllerMapping , String , (S32 sdlIndex) , (0) , "@brief Exposes SDL_GameControllerMapping() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> string that has the controller's mapping or <a href="/coding/file/typesx86unix_8h/#typesx86unix_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> no mapping " "is available or it does not <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">exist.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickNameForIndex \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , GameControllerMappingForGUID , String , (const char *guidStr) , "@brief Exposes SDL_GameControllerMappingForGUID() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param guidStr The GUID <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> which <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> mapping is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">desired.\n</a>" "@return Returns <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> mapping string or <a href="/coding/file/typesx86unix_8h/#typesx86unix_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">error.\n</a>" "@see https://wiki.libsdl.org/SDL_GameControllerMappingForGUID \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , GameControllerMappingForIndex , String , (S32 mappingIndex) , "Get the mapping at <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n\n</a>" "@param mappingIndex The index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> which <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> mapping is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">desired.\n</a>" "@return Returns <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> mapping string or <a href="/coding/file/typesx86unix_8h/#typesx86unix_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the index is out of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">range.\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , GameControllerNumMappings , S32 , () , "Get the number of mappings installed. Used with GameControllerMappingForIndex " "<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> iterate through all installed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">mappings.\n\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , getDeviceOpenState , S32 , (S32 sdlIndex) , (0) , "@brief Used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> determine the current state of the N'th item in the SDL device <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">list.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">values:\n</a>" "-1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the device does not exist (invalid sdlIndex passed)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "0 The device is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">closed\n</a>" "1 The device is open as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Joystick\n</a>" "2 The device is open as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Game <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Controller\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , GetDeviceType , SDLJoystickType , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickGetDeviceType() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return The type of device connected. Possible return strings are: \"Unknown\" , " "\"Game Controller\" , \"Wheel\" , \"Arcade Stick\" , \"Flight Stick\" , \"Dance Pad\" , " "\"Guitar\" , \"Drum Kit\" , \"Arcade Pad\" and \"Throttle\"\n" "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceType \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , GetProduct , S32 , (S32 sdlIndex) , (0) , "Gets the USB product ID of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> joystick device, <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">available.\n\n</a>" " @param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" " @return The USB product ID. If the product ID isn '<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1aded116371789db1fd63c90ef00c95a3d">t</a> available this function returns 0.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_JoystickGetDeviceProduct \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_JoystickGetProduct \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_GameControllerGetProduct \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , GetProductVersion , S32 , (S32 sdlIndex) , (0) , "Gets the product version of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> joystick device, <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">available.\n\n</a>" " @param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" " @return The product version. If the product version isn '<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1aded116371789db1fd63c90ef00c95a3d">t</a> available this function returns 0.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_JoystickGetDeviceProductVersion \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_JoystickGetProductVersion \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_GameControllerGetProductVersion \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , getTorqueInstFromDevice , const char * , (S32 sdlIndex) , (0) , "@brief Gets the T3D instance identifier <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> an open SDL <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">joystick.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the T3D instance ID used <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> mapping this device or Null <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it does not <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">exist.\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , GetVendor , S32 , (S32 sdlIndex) , (0) , "Gets the USB vendor ID of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> joystick device, <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">available.\n\n</a>" " @param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" " @return The USB vendor ID. If the vendor ID isn '<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1aded116371789db1fd63c90ef00c95a3d">t</a> available this function returns 0.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_JoystickGetDeviceVendor \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_JoystickGetVendor \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see https://wiki.libsdl.org/SDL_GameControllerGetVendor \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , IsGameController , bool , (S32 sdlIndex) , (0) , "@brief Exposes SDL_IsGameController() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns true <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the given joystick is supported by the game controller " " interface, false <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it isn '<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1aded116371789db1fd63c90ef00c95a3d">t</a> or it 's an invalid <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n</a>" " @see https://wiki.libsdl.org/SDL_IsGameController \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , JoystickGetAxes , String , (S32 sdlIndex) , (0) , "@brief Gets the current <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> all joystick <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">axes.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return A tab separated string that can be parsed from script with getField()/getFields(). " "Each axis is one field, so <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> 4 axis device will have 4 <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">fields.\n\n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , JoystickGetButtons , String , (S32 sdlIndex) , (0) , "@brief Gets the current <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> all joystick <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">buttons.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return A tab separated string that can be parsed from script with getField()/getFields(). " "Each button is one field. 0 - SDL_JoystickNumButtons() <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">fields.\n\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , JoystickGetGUID , const char * , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickGetDeviceGUID() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return GUID <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the indexed device or Null <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it does not <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">exist.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceGUID \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , JoystickGetHats , String , (S32 sdlIndex) , (0) , "@brief Gets the current <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> all POV <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">hats.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return A tab separated string that can be parsed from script with getField()/getFields(). " "Each hat is one field. 0 - SDL_JoystickNumHats() fields. The <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> 4 bit bitmask. " "If no bits are set, the hat is centered. Bit 0 is up, 1 is right, 2 is down and 3 is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">left.\n\n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , JoystickGetSpecs , String , (S32 sdlIndex) , (0) , "@brief A convenience function <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> reurn all of the data <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Joystick/Game Controller " " packed as fields in <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> tab separated <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">string.\n\n</a>" "There is overhead involved in querying joystick data, especially <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the device is not open. " "If more than one field is required, it is more efficient <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> call JoystickGetSpecs() and " "parse the data out of the return string than <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> call the console method <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">each.\n</a>" " @param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" " @return A tab separated string that can be parsed from script with getField()/getFields().\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "Field 0:Number of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Axes\n</a>" " 1:Number of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Buttons\n</a>" " 2:Number of POV <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Hats\n</a>" " 3:Number of <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Trackballs\n</a>" " 4:SDL_IsGameController()(Boolean)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " 5:SDL_JoystickIsHaptic()(Boolean)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " 6:Power Level(<a href="/coding/class/classstring/">String</a>)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " 7:Device <a href="/coding/file/rapidjson_8h/#rapidjson_8h_1a1d1cfd8ffb84e947f82999c682b666a7">Type</a>(<a href="/coding/class/classstring/">String</a>)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , JoystickIsHaptic , bool , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickIsHaptic() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns true <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the joystick is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">haptic.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickIsHaptic \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , JoystickNameForIndex , const char * , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickNameForIndex() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the name of the selected joystick or Null <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it does not <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">exist.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickNameForIndex \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , JoystickNumAxes , S32 , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickNumAxes() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the number of axis controls/number of axes on <a href="/coding/file/codeinterpreter_8h/#codeinterpreter_8h_1a6b4b0e49305f04dba3d0b888008d675fab8916948582bbb4902d6ad269064f7ef">success</a> or zero on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">failure.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickNumAxes \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , JoystickNumBalls , S32 , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickNumBalls() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the number of trackballs on <a href="/coding/file/codeinterpreter_8h/#codeinterpreter_8h_1a6b4b0e49305f04dba3d0b888008d675fab8916948582bbb4902d6ad269064f7ef">success</a> or zero on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">failure.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickNumBalls \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , JoystickNumButtons , S32 , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickNumButtons() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the number of buttons on <a href="/coding/file/codeinterpreter_8h/#codeinterpreter_8h_1a6b4b0e49305f04dba3d0b888008d675fab8916948582bbb4902d6ad269064f7ef">success</a> or zero on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">failure.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickNumButtons \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , JoystickNumHats , S32 , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickNumHats() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the number of POV hats on <a href="/coding/file/codeinterpreter_8h/#codeinterpreter_8h_1a6b4b0e49305f04dba3d0b888008d675fab8916948582bbb4902d6ad269064f7ef">success</a> or zero on <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">failure.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickNumHats \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , JoystickPowerLevel , SDLPowerEnum , (S32 sdlIndex) , (0) , "@brief Exposes SDL_JoystickCurrentPowerLevel() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">script.\n\n</a>" "@param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@return Returns the current battery level or \"Wired\" if it's <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> connected <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@see https://wiki.libsdl.org/SDL_JoystickCurrentPowerLevel \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , numJoysticks , S32 , () , "@brief Returns the number of currently connected joystick <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">devices.\n\n</a>" "Game Controllers are <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> sub-set of joysticks and are included in the joystick count. " "See https://wiki.libsdl.org/SDL_NumJoysticks <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> more <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">details.\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

DefineEngineStaticMethod(SDLInputManager , openAsController , S32 , (S32 sdlIndex, S32 torqueInstId) , (0, 0) , "@brief Used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> open the device as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Game <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Controller.\n\n</a>" "If the device is currently open as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Joystick, it will be closed and opened as " "<a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Game Controller. If it is currently opened as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Game Controller with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> different " "T3D instance ID, it will be changed <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the requested ID <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> that ID is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">available.\n</a>" " @param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" " @param torqueInstId Is the requested T3D device instance ID. If there is already an " "open Game Controller with the requested ID, The first available ID will be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">assigned.\n</a>" " @return The T3D device instance ID assigned, or -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the device could not be opened." )

DefineEngineStaticMethod(SDLInputManager , openAsJoystick , S32 , (S32 sdlIndex, S32 torqueInstId) , (0, 0) , "@brief Used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> open the device as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Joystick.\n\n</a>" "If the device is currently open as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Game Controller, it will be closed and opened as " "<a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Joystick. If it is currently opened as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> Joystick with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> different T3D instance ID, " "it will be changed <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the requested ID <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> that ID is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">available.\n</a>" " @param sdlIndex The SDL index <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" " @param torqueInstId Is the requested T3D device instance ID. If there is already an open Joystick with " "the requested ID, The first available ID will be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">assigned.\n</a>" " @return The T3D device instance ID assigned, or -1 <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the device could not be opened." )

DefineEnumType(SDLJoystickType )

DefineEnumType(SDLPowerEnum )

IMPLEMENT_GLOBAL_CALLBACK(onSDLDeviceConnected , void , (S32 sdlIndex, const char *deviceName, const char *deviceType) , (sdlIndex, deviceName, deviceType) , "Callback that occurs when an input device is connected <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">system.\n\n</a>" "@param sdlIndex The index that will be used by sdl <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> refer <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n</a>" "@param deviceName The name that the device reports. This will be the return " "<a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of SDL_JoystickNameForIndex or SDL_GameControllerNameForIndex depending on the device <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">type.\n</a>" "@param deviceType The type of device connected. See SDLInputManager::getDeviceType() " "<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> possible string <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">values.\n\n</a>" )

IMPLEMENT_GLOBAL_CALLBACK(onSDLDeviceDisconnected , void , (S32 sdlIndex) , (sdlIndex) , "Callback that occurs when an input device is disconnected from the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">system.\n\n</a>" "@param sdlIndex The index of the device that was <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">removed.\n</a>" )

IMPLEMENT_STATIC_CLASS(SDLInputManager , "@brief Static class exposing the SDL_Joystick and SDL_GameController APIs <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> Torque <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Script.\n</a>" "<a href="/coding/class/classsdlinputmanager/">SDLInputManager</a> provides access <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the functions of these APIs through static class " "functions.These functions are not <a href="/coding/file/tsshapeconstruct_8cpp/#tsshapeconstruct_8cpp_1a21625ca11566389388a748ad1acc0990">required</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> bind or process events.By setting " "pref::Input::JoystickEnabled or pref::Input::sdlControllerEnabled <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> true)

ImplementEnumType(SDLJoystickType , "The type of device <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">connected.\n\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

ImplementEnumType(SDLPowerEnum , "An enumeration of battery levels of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">joystick.\n\n</a>" "@ingroup <a href="/coding/class/classinput/">Input</a>" )

   1
   2//-----------------------------------------------------------------------------
   3// Copyright (c) 2012 GarageGames, LLC
   4//
   5// Permission is hereby granted, free of charge, to any person obtaining a copy
   6// of this software and associated documentation files (the "Software"), to
   7// deal in the Software without restriction, including without limitation the
   8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   9// sell copies of the Software, and to permit persons to whom the Software is
  10// furnished to do so, subject to the following conditions:
  11//
  12// The above copyright notice and this permission notice shall be included in
  13// all copies or substantial portions of the Software.
  14//
  15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21// IN THE SOFTWARE.
  22//-----------------------------------------------------------------------------
  23
  24#include "console/console.h"
  25#include "console/consoleTypes.h"
  26#include "console/engineAPI.h"
  27#include "sim/actionMap.h"
  28
  29#include "sdlInputManager.h"
  30
  31typedef SDL_JoystickType SDLJoystickType;
  32DefineEnumType(SDLJoystickType);
  33ImplementEnumType(SDLJoystickType,
  34   "The type of device connected.\n\n"
  35   "@ingroup Input")
  36{ SDL_JOYSTICK_TYPE_UNKNOWN, "Unknown"},
  37{ SDL_JOYSTICK_TYPE_GAMECONTROLLER, "Game Controller" },
  38{ SDL_JOYSTICK_TYPE_WHEEL, "Wheel" },
  39{ SDL_JOYSTICK_TYPE_ARCADE_STICK, "Arcade Stick" },
  40{ SDL_JOYSTICK_TYPE_FLIGHT_STICK, "Flight Stick" },
  41{ SDL_JOYSTICK_TYPE_DANCE_PAD, "Dance Pad" },
  42{ SDL_JOYSTICK_TYPE_GUITAR, "Guitar" },
  43{ SDL_JOYSTICK_TYPE_DRUM_KIT, "Drum Kit" },
  44{ SDL_JOYSTICK_TYPE_ARCADE_PAD, "Arcade Pad" },
  45{ SDL_JOYSTICK_TYPE_THROTTLE, "Throttle" },
  46EndImplementEnumType;
  47
  48typedef SDL_JoystickPowerLevel SDLPowerEnum;
  49DefineEnumType(SDLPowerEnum);
  50ImplementEnumType(SDLPowerEnum,
  51   "An enumeration of battery levels of a joystick.\n\n"
  52   "@ingroup Input")
  53{ SDL_JOYSTICK_POWER_UNKNOWN, "Unknown" },
  54{ SDL_JOYSTICK_POWER_EMPTY, "Empty" },
  55{ SDL_JOYSTICK_POWER_LOW, "Low" },
  56{ SDL_JOYSTICK_POWER_MEDIUM, "Medium" },
  57{ SDL_JOYSTICK_POWER_FULL, "Full" },
  58{ SDL_JOYSTICK_POWER_WIRED, "Wired" },
  59{ SDL_JOYSTICK_POWER_MAX, "Max" },
  60EndImplementEnumType;
  61
  62IMPLEMENT_STATIC_CLASS(SDLInputManager, ,
  63   "@brief Static class exposing the SDL_Joystick and SDL_GameController APIs to Torque Script.\n"
  64   "SDLInputManager provides access to the functions of these APIs through static class "
  65   "functions.These functions are not required to bind or process events.By setting "
  66   "pref::Input::JoystickEnabled or pref::Input::sdlControllerEnabled to true, all connected "
  67   "devices will automatically be opened.All of the joystick and controller events defined "
  68   "in event.h can then be bound. For complete API documentation see the Joystick and Game "
  69   "Controller section of https ://wiki.libsdl.org/APIByCategory#Input_Events.\n\n"
  70
  71   "@tsexample\n"
  72   "// Get the name and device type for all connected devices\n"
  73   "%sdlDevices = SDLInputManager::numJoysticks();\n"
  74   "for (%i = 0; %i < %sdlDevices; %i++)\n"
  75   "{\n"
  76   "   %deviceName = SDLInputManager::JoystickNameForIndex(%i);\n"
  77   "   %deviceType = SDLInputManager::GetDeviceType(%i);\n"
  78   "}\n"
  79   "\n"
  80   "// List all installed controller mappings\n"
  81   "%numMappings = SDLInputManager::GameControllerNumMappings();\n"
  82   "for (%i = 0; %i < %numMappings; %i++)\n"
  83   "   echo(SDLInputManager::GameControllerMappingForIndex(%i));\n"
  84   "@endtsexample\n\n");
  85
  86IMPLEMENT_GLOBAL_CALLBACK(onSDLDeviceConnected, void, (S32 sdlIndex, const char* deviceName, const char* deviceType),
  87(sdlIndex, deviceName, deviceType),
  88"Callback that occurs when an input device is connected to the system.\n\n"
  89"@param sdlIndex The index that will be used by sdl to refer to the device.\n"
  90"@param deviceName The name that the device reports. This will be the return "
  91"value of SDL_JoystickNameForIndex or SDL_GameControllerNameForIndex depending on the device type.\n"
  92"@param deviceType The type of device connected. See SDLInputManager::getDeviceType() "
  93"for possible string values.\n\n");
  94
  95IMPLEMENT_GLOBAL_CALLBACK(onSDLDeviceDisconnected, void, (S32 sdlIndex), (sdlIndex),
  96"Callback that occurs when an input device is disconnected from the system.\n\n"
  97"@param sdlIndex The index of the device that was removed.\n");
  98
  99//------------------------------------------------------------------------------
 100// Static class variables:
 101bool SDLInputManager::smJoystickEnabled = true;
 102bool SDLInputManager::smJoystickSplitAxesLR = true;
 103bool SDLInputManager::smControllerEnabled = true;
 104bool SDLInputManager::smPOVButtonEvents = true;
 105bool SDLInputManager::smPOVMaskEvents = false;
 106
 107// Map SDL controller Axis to torque input event
 108// Commented text from map_StringForControllerAxis[] in SDL_gamecontroller.c
 109S32 SDLInputManager::map_EventForControllerAxis[] = {
 110   SI_XAXIS, //"leftx",
 111   SI_YAXIS, //"lefty",
 112   SI_RXAXIS, //"rightx",
 113   SI_RYAXIS, //"righty",
 114   SI_ZAXIS, //"lefttrigger",
 115   SI_RZAXIS, //"righttrigger",
 116   -1 // NULL
 117};
 118
 119// Map SDL controller button ID to torque input event
 120// Commented text from map_StringForControllerButton[] in SDL_gamecontroller.c
 121S32 SDLInputManager::map_EventForControllerButton[] = {
 122   XI_A, //"a",
 123   XI_B, //"b",
 124   XI_X, //"x",
 125   XI_Y, //"y",
 126   XI_BACK, //"back",
 127   XI_GUIDE, //"guide",
 128   XI_START, //"start",
 129   XI_LEFT_THUMB, //"leftstick",
 130   XI_RIGHT_THUMB, //"rightstick",
 131   XI_LEFT_SHOULDER, //"leftshoulder",
 132   XI_RIGHT_SHOULDER, //"rightshoulder",
 133   SI_UPOV, //"dpup",
 134   SI_DPOV, //"dpdown",
 135   SI_LPOV, //"dpleft",
 136   SI_RPOV, //"dpright",
 137   -1 // NULL
 138};
 139
 140//------------------------------------------------------------------------------
 141void SDLInputManager::joystickState::reset()
 142{
 143   sdlInstID = -1;
 144   inputDevice = NULL;
 145   numAxes = 0;
 146   lastHatState[0] = 0;
 147   lastHatState[1] = 0;
 148}
 149
 150//------------------------------------------------------------------------------
 151SDLInputManager::SDLInputManager()
 152{
 153   mEnabled = true;
 154   mJoystickActive = true;
 155
 156   for (S32 i = 0; i < MaxJoysticks; ++i)
 157   {
 158      mJoysticks[i].reset();
 159      mJoysticks[i].torqueInstID = i;
 160   }
 161
 162   for (S32 i = 0; i < MaxControllers; ++i)
 163   {
 164      mControllers[i].sdlInstID = -1;
 165      mControllers[i].torqueInstID = i;
 166      mControllers[i].inputDevice = NULL;
 167   }
 168}
 169
 170//------------------------------------------------------------------------------
 171void SDLInputManager::init()
 172{
 173   Con::addVariable( "pref::Input::JoystickEnabled",  TypeBool, &smJoystickEnabled, 
 174      "If true, Joystick devices will be automatically opened.\n\n"
 175      "@ingroup Input");
 176   Con::addVariable("pref::Input::JoystickSplitAxesLR", TypeBool, &smJoystickSplitAxesLR,
 177      "Split axis inputs on 4 axis joysticks. This has no effect on any other device.\n\n"
 178      "4 Axis joysticks use IDs 0-3 which get mapped to xaxis, yaxis, zaxis and rxaxis. "
 179      "When true, this will increment IDs 2 and 3 so the inputs map to xaxis, yaxis, rxaxis and ryaxis.\n"
 180      "@ingroup Input");
 181   Con::addVariable("pref::Input::sdlControllerEnabled", TypeBool, &smControllerEnabled,
 182      "If true, any Joystick device that SDL recognizes as a Game Controller will be automatically opened as a game controller.\n\n"
 183      "@ingroup Input");
 184   Con::addVariable("pref::Input::JoystickPOVButtons", TypeBool, &smPOVButtonEvents,
 185      "If true, the pov hat will be treated as 4 buttons and make/break events will be generated for "
 186      "upov, dpov, lpov and rpov.\n"
 187      "@ingroup Input");
 188   Con::addVariable("pref::Input::JoystickPOVMask", TypeBool, &smPOVMaskEvents,
 189      "If true, the pov hat will be treated as a single input with a 4 bit mask value. The povmask "
 190      "event will be generated with the current mask every time the mask value changes.\n"
 191      "@ingroup Input");
 192
 193   // POV Hat mask bits
 194   Con::setIntVariable("$SDLMask::HatUp", SDL_HAT_UP);
 195   Con::setIntVariable("$SDLMask::HatRight", SDL_HAT_RIGHT);
 196   Con::setIntVariable("$SDLMask::HatDown", SDL_HAT_DOWN);
 197   Con::setIntVariable("$SDLMask::HatLeft", SDL_HAT_LEFT);
 198}
 199
 200//------------------------------------------------------------------------------
 201bool SDLInputManager::enable()
 202{
 203   disable();
 204
 205   if (smControllerEnabled || smJoystickEnabled)
 206   {
 207      for (S32 i = 0; i < SDL_NumJoysticks(); ++i)
 208      {
 209         if (smControllerEnabled && SDL_IsGameController(i))
 210            openController(i, 0);
 211         else if (smJoystickEnabled)
 212            openJoystick(i, 0);
 213      }
 214   }
 215   mEnabled = true;
 216   return true;
 217}
 218
 219//------------------------------------------------------------------------------
 220void SDLInputManager::disable()
 221{
 222   // Close any open devices
 223   for (S32 i = 0; i < MaxControllers; ++i)
 224      closeControllerByIndex(i);
 225   for (S32 i = 0; i < MaxJoysticks; ++i)
 226      closeJoystickByIndex(i);
 227
 228   mEnabled = false;
 229}
 230
 231//------------------------------------------------------------------------------
 232void SDLInputManager::process()
 233{
 234}
 235
 236//------------------------------------------------------------------------------
 237void SDLInputManager::processEvent(SDL_Event &evt)
 238{
 239   switch (evt.type)
 240   {
 241   case SDL_JOYAXISMOTION:
 242   {
 243      joystickState* torqueMapping;
 244      if (mJoystickMap.isEmpty() || !mJoystickMap.find(evt.jaxis.which, torqueMapping))
 245         break;
 246      // SDL axis value inputs are in (range: -32768 to 32767)
 247      // Torque axis values are -1.0 to 1.0
 248      F32 value = ((F32)evt.jaxis.value) / (F32) (evt.jaxis.value > 0 ? SDL_JOYSTICK_AXIS_MAX : -SDL_JOYSTICK_AXIS_MIN);
 249      S32 mapAxis = SI_XAXIS + evt.jaxis.axis;
 250      if (evt.jaxis.axis > 1 && torqueMapping->numAxes == 4 && smJoystickSplitAxesLR)
 251         mapAxis += 1; // On a 4 axis, we'll shift the second two so we use LX LY RX RY instead of LX LY LZ RX
 252      buildInputEvent(JoystickDeviceType, torqueMapping->torqueInstID, SI_AXIS, mapAxis, SI_MOVE, value);
 253      break;
 254   }
 255
 256   case SDL_JOYBALLMOTION:
 257   {
 258      joystickState* torqueMapping;
 259      if (mJoystickMap.isEmpty() || !mJoystickMap.find(evt.jball.which, torqueMapping) || evt.jball.ball >= MaxBalls)
 260         break;
 261      if (evt.jball.xrel != 0)
 262         buildInputEvent(JoystickDeviceType, torqueMapping->torqueInstID, SI_INT, evt.jball.ball ? SI_XBALL2 : SI_XBALL, SI_MOVE, (S32) evt.jball.xrel);
 263      if (evt.jball.yrel != 0)
 264         buildInputEvent(JoystickDeviceType, torqueMapping->torqueInstID, SI_INT, evt.jball.ball ? SI_YBALL2 : SI_YBALL, SI_MOVE, (S32) evt.jball.yrel);
 265      break;
 266   }
 267
 268   case SDL_JOYHATMOTION:
 269   {
 270      joystickState* torqueMapping;
 271      if (mJoystickMap.isEmpty() || !mJoystickMap.find(evt.jball.which, torqueMapping) || evt.jhat.hat >= MaxHats)
 272         break;
 273      if (torqueMapping->lastHatState[evt.jhat.hat] != evt.jhat.value)
 274      {
 275         buildHatEvents(JoystickDeviceType, torqueMapping->torqueInstID, torqueMapping->lastHatState[evt.jhat.hat], evt.jhat.value, evt.jhat.hat);
 276         torqueMapping->lastHatState[evt.jhat.hat] = evt.jhat.value;
 277      }
 278      break;
 279   }
 280
 281   case SDL_JOYBUTTONDOWN:
 282   case SDL_JOYBUTTONUP:
 283   {
 284      joystickState* torqueMapping;
 285      if (mJoystickMap.isEmpty() || !mJoystickMap.find(evt.jbutton.which, torqueMapping))
 286         break;
 287      buildInputEvent(JoystickDeviceType, torqueMapping->torqueInstID, SI_BUTTON, KEY_BUTTON0 + evt.jbutton.button,
 288         evt.cbutton.state == SDL_PRESSED ? SI_MAKE : SI_BREAK, evt.cbutton.state == SDL_PRESSED ? 1.0f : 0.0f);
 289      break;
 290   }
 291
 292   case SDL_JOYDEVICEADDED:
 293   {
 294      deviceConnectedCallback(evt.jdevice.which);
 295      if (smControllerEnabled && SDL_IsGameController(evt.jdevice.which))
 296         break;   // This device will be added as a controller
 297
 298      if (smJoystickEnabled)
 299         openJoystick(evt.jdevice.which, 0);
 300      break;
 301   }
 302
 303   case SDL_JOYDEVICEREMOVED:
 304   {
 305      onSDLDeviceDisconnected_callback(evt.jdevice.which);
 306      closeJoystick(evt.jdevice.which);
 307   }
 308
 309   case SDL_CONTROLLERAXISMOTION:
 310   {
 311      controllerState* torqueMapping;
 312      if (mControllerMap.isEmpty() || !mControllerMap.find(evt.caxis.which, torqueMapping))
 313         break;
 314      // SDL axis value inputs are in (range: -32768 to 32767)
 315      // Torque axis values are -1.0 to 1.0
 316      F32 value = ((F32)evt.caxis.value) / (F32) (evt.caxis.value > 0 ? SDL_JOYSTICK_AXIS_MAX : -SDL_JOYSTICK_AXIS_MIN);
 317      buildInputEvent(GamepadDeviceType, torqueMapping->torqueInstID, SI_AXIS, map_EventForControllerAxis[evt.caxis.axis], SI_MOVE, value);
 318      break;
 319   }
 320
 321   case SDL_CONTROLLERBUTTONDOWN:
 322   case SDL_CONTROLLERBUTTONUP:
 323   {
 324      controllerState* torqueMapping;
 325      if (mControllerMap.isEmpty() || !mControllerMap.find(evt.cbutton.which, torqueMapping))
 326         break;
 327      buildInputEvent(GamepadDeviceType, torqueMapping->torqueInstID, SI_BUTTON, map_EventForControllerButton[evt.cbutton.button],
 328         evt.cbutton.state == SDL_PRESSED ? SI_MAKE : SI_BREAK, evt.cbutton.state == SDL_PRESSED ? 1.0f : 0.0f);
 329      break;
 330   }
 331
 332   case SDL_CONTROLLERDEVICEADDED:
 333   {
 334      if (smControllerEnabled)
 335         openController(evt.cdevice.which, 0);
 336      break;
 337   }
 338
 339   case SDL_CONTROLLERDEVICEREMOVED:
 340   {
 341      closeController(evt.cdevice.which);
 342      break;
 343   }
 344
 345   case SDL_CONTROLLERDEVICEREMAPPED:
 346      break;
 347
 348   default:
 349#ifdef TORQUE_DEBUG
 350      Con::warnf("Unhandled SDL input event: 0x%04x", evt.type);
 351#endif
 352      break;
 353   }
 354}
 355
 356//------------------------------------------------------------------------------
 357void SDLInputManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, S32 iValue)
 358{
 359   InputEventInfo newEvent;
 360
 361   newEvent.deviceType = deviceType;
 362   newEvent.deviceInst = deviceInst;
 363   newEvent.objType = objType;
 364   newEvent.objInst = objInst;
 365   newEvent.action = action;
 366   newEvent.iValue = iValue;
 367
 368   newEvent.postToSignal(Input::smInputEvent);
 369}
 370
 371//------------------------------------------------------------------------------
 372void SDLInputManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, F32 fValue)
 373{
 374   InputEventInfo newEvent;
 375
 376   newEvent.deviceType = deviceType;
 377   newEvent.deviceInst = deviceInst;
 378   newEvent.objType = objType;
 379   newEvent.objInst = objInst;
 380   newEvent.action = action;
 381   newEvent.fValue = fValue;
 382
 383   newEvent.postToSignal(Input::smInputEvent);
 384}
 385
 386//------------------------------------------------------------------------------
 387void SDLInputManager::buildHatEvents(U32 deviceType, U32 deviceInst, U8 lastState, U8 currentState, S32 hatIndex)
 388{
 389   if (smPOVButtonEvents)
 390   {
 391      if ((lastState & SDL_HAT_UP) != (currentState & SDL_HAT_UP))
 392      {
 393         buildInputEvent(deviceType, deviceInst, SI_POV, hatIndex ? SI_UPOV2 : SI_UPOV,
 394            (currentState & SDL_HAT_UP) ? SI_MAKE : SI_BREAK, (currentState & SDL_HAT_UP) ? 1.0f : 0.0f);
 395      }
 396
 397      if ((lastState & SDL_HAT_DOWN) != (currentState & SDL_HAT_DOWN))
 398      {
 399         buildInputEvent(deviceType, deviceInst, SI_POV, hatIndex ? SI_DPOV2 : SI_DPOV,
 400            (currentState & SDL_HAT_DOWN) ? SI_MAKE : SI_BREAK, (currentState & SDL_HAT_DOWN) ? 1.0f : 0.0f);
 401      }
 402
 403      if ((lastState & SDL_HAT_LEFT) != (currentState & SDL_HAT_LEFT))
 404      {
 405         buildInputEvent(deviceType, deviceInst, SI_POV, hatIndex ? SI_LPOV2 : SI_LPOV,
 406            (currentState & SDL_HAT_LEFT) ? SI_MAKE : SI_BREAK, (currentState & SDL_HAT_LEFT) ? 1.0f : 0.0f);
 407      }
 408
 409      if ((lastState & SDL_HAT_RIGHT) != (currentState & SDL_HAT_RIGHT))
 410      {
 411         buildInputEvent(deviceType, deviceInst, SI_POV, hatIndex ? SI_RPOV2 : SI_RPOV,
 412            (currentState & SDL_HAT_RIGHT) ? SI_MAKE : SI_BREAK, (currentState & SDL_HAT_RIGHT) ? 1.0f : 0.0f);
 413      }
 414   }
 415
 416   if (smPOVMaskEvents)
 417   {
 418      buildInputEvent(deviceType, deviceInst, SI_INT, hatIndex ? SI_POVMASK2 : SI_POVMASK, SI_VALUE, (S32) currentState);
 419   }
 420}
 421
 422//------------------------------------------------------------------------------
 423S32 SDLInputManager::openController(S32 sdlIndex, S32 requestedTID)
 424{
 425   if ((sdlIndex < 0) || (sdlIndex >= SDL_NumJoysticks()) || (requestedTID < 0) || (requestedTID >= MaxControllers))
 426      return -1;
 427
 428   if (SDL_IsGameController(sdlIndex))
 429   {
 430      SDL_GameController *inputDevice = SDL_GameControllerOpen(sdlIndex);
 431      if (inputDevice)
 432      {
 433         SDL_JoystickID sdlId = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(inputDevice));
 434
 435         // See if the device is already open as a joystick
 436         for (S32 i = 0; i < MaxJoysticks; ++i)
 437         {
 438            if (mJoysticks[i].sdlInstID == sdlId)
 439            {
 440               if (!closeJoystickByIndex(i))
 441               {
 442                  SDL_GameControllerClose(inputDevice);
 443                  return -1;
 444               }
 445            }
 446         }
 447
 448         controllerState* torqueMapping = NULL;
 449         if (mControllerMap.find(sdlId, torqueMapping))
 450         {
 451            if (torqueMapping->torqueInstID == (U32) requestedTID)
 452            {
 453               SDL_GameControllerClose(inputDevice);
 454               return requestedTID;  // Already open at the requested ID
 455            }
 456            closeControllerByIndex(torqueMapping->torqueInstID);
 457         }
 458
 459         S32 gamepadSlot = -1;
 460         if (!mControllers[requestedTID].inputDevice)
 461            gamepadSlot = requestedTID;
 462         else
 463         {
 464            // Find the first available gamepad device slot
 465            for (S32 i = 0; i < MaxControllers; ++i)
 466            {
 467               if (!mControllers[i].inputDevice)
 468               {
 469                  gamepadSlot = i;
 470                  break;
 471               }
 472            }
 473         }
 474
 475         if (gamepadSlot == -1)
 476         {
 477            Con::errorf("Unable to open Game Controller %s. Too many devices present.", SDL_GameControllerName(inputDevice));
 478            SDL_GameControllerClose(inputDevice);
 479            return -1;
 480         }
 481
 482         mControllers[gamepadSlot].inputDevice = inputDevice;
 483         mControllers[gamepadSlot].sdlInstID = sdlId;
 484         mControllerMap.insertUnique(sdlId, &mControllers[gamepadSlot]);
 485
 486         return gamepadSlot;
 487      }
 488   }
 489   return -1;
 490}
 491
 492//------------------------------------------------------------------------------
 493void SDLInputManager::closeController(SDL_JoystickID sdlId)
 494{
 495   controllerState* torqueMapping = NULL;
 496   if (mControllerMap.find(sdlId, torqueMapping))
 497      closeControllerByIndex(torqueMapping->torqueInstID);
 498}
 499
 500//------------------------------------------------------------------------------
 501bool SDLInputManager::closeControllerByIndex(S32 index)
 502{
 503   if (index < 0 || index >= MaxControllers)
 504      return false;
 505
 506   if (mControllers[index].inputDevice && mControllers[index].sdlInstID != -1)
 507   {
 508      SDL_GameControllerClose(mControllers[index].inputDevice);
 509      mControllerMap.erase(mControllers[index].sdlInstID);
 510      mControllers[index].sdlInstID = -1;
 511      mControllers[index].inputDevice = NULL;
 512      return true;
 513   }
 514
 515   return false;
 516}
 517
 518//------------------------------------------------------------------------------
 519S32 SDLInputManager::openJoystick(S32 sdlIndex, S32 requestedTID)
 520{
 521   if ((sdlIndex < 0) || (sdlIndex >= SDL_NumJoysticks()) || (requestedTID < 0) || (requestedTID >= MaxJoysticks))
 522      return -1;
 523
 524   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
 525   if (inputDevice)
 526   {
 527      SDL_JoystickID sdlId = SDL_JoystickInstanceID(inputDevice);
 528
 529      // See if the device is already open as a controller
 530      for (S32 i = 0; i < MaxControllers; ++i)
 531      {
 532         if (mControllers[i].sdlInstID == sdlId)
 533         {
 534            if (!closeControllerByIndex(i))
 535            {
 536               SDL_JoystickClose(inputDevice);
 537               return -1;
 538            }
 539         }
 540      }
 541
 542      joystickState* torqueMapping = NULL;
 543      if (mJoystickMap.find(sdlId, torqueMapping))
 544      {
 545         if (torqueMapping->torqueInstID == (U32) requestedTID)
 546         {
 547            SDL_JoystickClose(inputDevice);
 548            return requestedTID;  // Already open at the requested ID
 549         }
 550         closeJoystickByIndex(torqueMapping->torqueInstID);
 551      }
 552
 553      S32 joystickSlot = -1;
 554      if (!mJoysticks[requestedTID].inputDevice)
 555         joystickSlot = requestedTID;
 556      else
 557      {
 558         // Find the first available joystick device slot
 559         for (S32 i = 0; i < MaxJoysticks; ++i)
 560         {
 561            if (!mJoysticks[i].inputDevice)
 562            {
 563               joystickSlot = i;
 564               break;
 565            }
 566         }
 567      }
 568
 569      if (joystickSlot == -1)
 570      {
 571         Con::errorf("Unable to open Joystick %s. Too many devices present.", SDL_JoystickName(inputDevice));
 572         SDL_JoystickClose(inputDevice);
 573         return -1;
 574      }
 575
 576      mJoysticks[joystickSlot].inputDevice = inputDevice;
 577      mJoysticks[joystickSlot].sdlInstID = sdlId;
 578      mJoysticks[joystickSlot].numAxes = SDL_JoystickNumAxes(inputDevice);
 579      mJoystickMap.insertUnique(sdlId, &mJoysticks[joystickSlot]);
 580
 581      return joystickSlot;
 582   }
 583   return -1;
 584}
 585
 586//------------------------------------------------------------------------------
 587void SDLInputManager::closeJoystick(SDL_JoystickID sdlId)
 588{
 589   joystickState* torqueMapping = NULL;
 590   if (mJoystickMap.find(sdlId, torqueMapping))
 591      closeJoystickByIndex(torqueMapping->torqueInstID);
 592}
 593
 594//------------------------------------------------------------------------------
 595bool SDLInputManager::closeJoystickByIndex(S32 index)
 596{
 597   if (index < 0 || index >= MaxJoysticks)
 598      return false;
 599
 600   if (mJoysticks[index].inputDevice && mJoysticks[index].sdlInstID != -1)
 601   {
 602      SDL_JoystickClose(mJoysticks[index].inputDevice);
 603      mJoystickMap.erase(mJoysticks[index].sdlInstID);
 604      mJoysticks[index].reset();
 605      return true;
 606   }
 607
 608   return false;
 609}
 610
 611//------------------------------------------------------------------------------
 612void SDLInputManager::closeDevice(S32 sdlIndex)
 613{
 614   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
 615      return;
 616
 617   SDL_JoystickID sdlId = -1;
 618   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
 619   if (inputDevice)
 620   {
 621      sdlId = SDL_JoystickInstanceID(inputDevice);
 622      SDL_JoystickClose(inputDevice);
 623   }
 624
 625   if (sdlId < 0)
 626      return;
 627
 628   for (S32 i = 0; i < MaxControllers; ++i)
 629   {
 630      if (mControllers[i].sdlInstID == sdlId)
 631      {
 632         closeControllerByIndex(i);
 633         return;
 634      }
 635   }
 636
 637   for (S32 i = 0; i < MaxJoysticks; ++i)
 638   {
 639      if (mJoysticks[i].sdlInstID == sdlId)
 640      {
 641         closeJoystickByIndex(i);
 642         return;
 643      }
 644   }
 645}
 646
 647//------------------------------------------------------------------------------
 648void SDLInputManager::deviceConnectedCallback(S32 index)
 649{
 650   // This will generate the script callback:
 651   // onSDLDeviceConnected(%sdlIndex, %isController, %deviceName)
 652   bool isController = SDL_IsGameController(index);
 653   const char *deviceName = isController ? SDL_GameControllerNameForIndex(index) : SDL_JoystickNameForIndex(index);
 654   SDL_JoystickType deviceType = SDL_JoystickGetDeviceType(index);
 655   onSDLDeviceConnected_callback(index, deviceName, castConsoleTypeToString(deviceType));
 656}
 657
 658//------------------------------------------------------------------------------
 659// Console interface
 660
 661//------------------------------------------------------------------------------
 662// Get the N'th SDL device state -1=doesn't exist, 0=closed, 1=open joystick, 2=open controller
 663S32 SDLInputManager::getJoystickOpenState(S32 sdlIndex)
 664{
 665   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
 666      return -1;
 667
 668   S32 currentState = 0;
 669   // We need to open the joystick to get the sdl instanceID
 670   // This will increase the refcount on the joystick if it was already open.
 671   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
 672   if (inputDevice)
 673   {
 674      SDL_JoystickID sdlId = SDL_JoystickInstanceID(inputDevice);
 675      controllerState* controllerMapping = NULL;
 676      joystickState* joystickMapping = NULL;
 677      if (!mControllerMap.isEmpty() && mControllerMap.find(sdlId, controllerMapping))
 678         currentState = 2;
 679      else if (!mJoystickMap.isEmpty() && mJoystickMap.find(sdlId, joystickMapping))
 680         currentState = 1;
 681
 682      // Close the joystick to return the refcount to the previouse state
 683      SDL_JoystickClose(inputDevice);
 684   }
 685
 686   return currentState;
 687}
 688
 689//------------------------------------------------------------------------------
 690// Fills in the torque device instance string from an sdl joystick index number
 691void SDLInputManager::getJoystickTorqueInst(S32 sdlIndex, char* instBuffer)
 692{
 693   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
 694      return;
 695
 696   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
 697   if (inputDevice)
 698   {
 699      SDL_JoystickID sdlId = SDL_JoystickInstanceID(inputDevice);
 700      controllerState* controllerMapping = NULL;
 701      joystickState* joystickMapping = NULL;
 702      if (!mControllerMap.isEmpty() && mControllerMap.find(sdlId, controllerMapping))
 703         ActionMap::getDeviceName(GamepadDeviceType, controllerMapping->torqueInstID, instBuffer);
 704      else if (!mJoystickMap.isEmpty() && mJoystickMap.find(sdlId, joystickMapping))
 705         ActionMap::getDeviceName(JoystickDeviceType, joystickMapping->torqueInstID, instBuffer);
 706
 707      SDL_JoystickClose(inputDevice);
 708   }
 709}
 710
 711//------------------------------------------------------------------------------
 712DefineEngineStaticMethod(SDLInputManager, numJoysticks, S32, (), ,
 713   "@brief Returns the number of currently connected joystick devices.\n\n"
 714   "Game Controllers are a sub-set of joysticks and are included in the joystick count. "
 715   "See https://wiki.libsdl.org/SDL_NumJoysticks for more details.\n"
 716   "@ingroup Input")
 717{
 718   return SDL_NumJoysticks();
 719}
 720
 721//------------------------------------------------------------------------------
 722DefineEngineStaticMethod(SDLInputManager, getDeviceOpenState, S32, ( S32 sdlIndex ), ( 0 ),
 723   "@brief Used to determine the current state of the N'th item in the SDL device list.\n\n"
 724   "@param sdlIndex The SDL index for this device.\n"
 725   "@return values:\n"
 726   "-1 if the device does not exist (invalid sdlIndex passed)\n"
 727   "0 The device is closed\n"
 728   "1 The device is open as a Joystick\n"
 729   "2 The device is open as a Game Controller\n"
 730   "@ingroup Input")
 731{
 732   SDLInputManager* mgr = dynamic_cast<SDLInputManager*>(Input::getManager());
 733   if (mgr && mgr->isEnabled())
 734      return mgr->getJoystickOpenState(sdlIndex);
 735   return -1;
 736}
 737
 738//------------------------------------------------------------------------------
 739DefineEngineStaticMethod(SDLInputManager, openAsJoystick, S32, ( S32 sdlIndex, S32 torqueInstId ), ( 0, 0 ),
 740   "@brief Used to open the device as a Joystick.\n\n"
 741   "If the device is currently open as a Game Controller, it will be closed and opened as "
 742   "a Joystick. If it is currently opened as a Joystick with a different T3D instance ID, "
 743   "it will be changed to the requested ID if that ID is available.\n"
 744   "@param sdlIndex The SDL index for this device.\n"
 745   "@param  torqueInstId Is the requested T3D device instance ID. If there is already an open Joystick with "
 746   "the requested ID, The first available ID will be assigned.\n"
 747   "@return The T3D device instance ID assigned, or -1 if the device could not be opened.")
 748{
 749   SDLInputManager* mgr = dynamic_cast<SDLInputManager*>(Input::getManager());
 750   if (mgr && mgr->isEnabled())
 751      return mgr->openJoystick(sdlIndex, torqueInstId);
 752   return -1;
 753}
 754
 755//------------------------------------------------------------------------------
 756DefineEngineStaticMethod(SDLInputManager, openAsController, S32, (S32 sdlIndex, S32 torqueInstId), (0, 0),
 757   "@brief Used to open the device as a Game Controller.\n\n"
 758   "If the device is currently open as a Joystick, it will be closed and opened as "
 759   "a Game Controller. If it is currently opened as a Game Controller with a different "
 760   "T3D instance ID, it will be changed to the requested ID if that ID is available.\n"
 761   "@param sdlIndex The SDL index for this device.\n"
 762   "@param  torqueInstId Is the requested T3D device instance ID. If there is already an "
 763   "open Game Controller with the requested ID, The first available ID will be assigned.\n"
 764   "@return The T3D device instance ID assigned, or -1 if the device could not be opened.")
 765{
 766   SDLInputManager* mgr = dynamic_cast<SDLInputManager*>(Input::getManager());
 767   if (mgr && mgr->isEnabled())
 768      return mgr->openController(sdlIndex, torqueInstId);
 769   return -1;
 770}
 771
 772//------------------------------------------------------------------------------
 773DefineEngineStaticMethod(SDLInputManager, closeDevice, void, (S32 sdlIndex), (0),
 774   "@brief Used to close the N'th item in the SDL device list.\n\n"
 775   "This will close a Joystick or Game Controller.\n"
 776   "@param sdlIndex The SDL index for this device.\n")
 777{
 778   SDLInputManager* mgr = dynamic_cast<SDLInputManager*>(Input::getManager());
 779   if (mgr && mgr->isEnabled())
 780      mgr->closeDevice(sdlIndex);
 781   return;
 782}
 783
 784
 785//------------------------------------------------------------------------------
 786DefineEngineStaticMethod(SDLInputManager, getTorqueInstFromDevice, const char *, (S32 sdlIndex), (0),
 787   "@brief Gets the T3D instance identifier for an open SDL joystick.\n\n"
 788   "@param sdlIndex The SDL index for this device.\n"
 789   "@return Returns the T3D instance ID used for mapping this device or Null if it does not exist.\n"
 790   "@ingroup Input")
 791{
 792   SDLInputManager* mgr = dynamic_cast<SDLInputManager*>(Input::getManager());
 793   if (mgr && mgr->isEnabled())
 794   {
 795      char* deviceInst = Con::getReturnBuffer(32);
 796      deviceInst[0] = '\0';
 797      mgr->getJoystickTorqueInst(sdlIndex, deviceInst);
 798      return deviceInst;
 799   }
 800   return NULL;
 801}
 802
 803//------------------------------------------------------------------------------
 804DefineEngineStaticMethod(SDLInputManager, JoystickNameForIndex, const char *, (S32 sdlIndex), (0),
 805   "@brief Exposes SDL_JoystickNameForIndex() to script.\n\n"
 806   "@param sdlIndex The SDL index for this device.\n"
 807   "@return Returns the name of the selected joystick or Null if it does not exist.\n"
 808   "@see https://wiki.libsdl.org/SDL_JoystickNameForIndex \n"
 809   "@ingroup Input")
 810{
 811   if (sdlIndex >= 0 && sdlIndex < SDL_NumJoysticks())
 812      return SDL_JoystickNameForIndex(sdlIndex);
 813   return NULL;
 814}
 815
 816//------------------------------------------------------------------------------
 817DefineEngineStaticMethod(SDLInputManager, ControllerNameForIndex, const char *, (S32 sdlIndex), (0),
 818   "@brief Exposes SDL_GameControllerNameForIndex() to script.\n\n"
 819   "@param sdlIndex The SDL index for this device.\n"
 820   "@return Returns the implementation dependent name for the game controller, "
 821   "or NULL if there is no name or the index is invalid.\n"
 822   "@see https://wiki.libsdl.org/SDL_GameControllerNameForIndex \n"
 823   "@ingroup Input")
 824{
 825   if (sdlIndex >= 0 && sdlIndex < SDL_NumJoysticks() || !SDL_IsGameController(sdlIndex))
 826      return SDL_GameControllerNameForIndex(sdlIndex);
 827   return NULL;
 828}
 829
 830//------------------------------------------------------------------------------
 831DefineEngineStaticMethod(SDLInputManager, JoystickGetGUID, const char *, (S32 sdlIndex), (0),
 832   "@brief Exposes SDL_JoystickGetDeviceGUID() to script.\n\n"
 833   "@param sdlIndex The SDL index for this device.\n"
 834   "@return GUID for the indexed device or Null if it does not exist.\n"
 835   "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceGUID \n"
 836   "@ingroup Input")
 837{
 838   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
 839      return NULL;
 840      
 841   SDL_JoystickGUID guidVal = SDL_JoystickGetDeviceGUID(sdlIndex);
 842   char *guidStr = Con::getReturnBuffer(64);
 843   SDL_JoystickGetGUIDString(guidVal, guidStr, 64);
 844
 845   return guidStr;
 846}
 847
 848//------------------------------------------------------------------------------
 849DefineEngineStaticMethod(SDLInputManager, GetVendor, S32, (S32 sdlIndex), (0),
 850   "Gets the USB vendor ID of a joystick device, if available.\n\n"
 851   "@param sdlIndex The SDL index for this device.\n"
 852   "@return The USB vendor ID. If the vendor ID isn't available this function returns 0.\n"
 853   "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceVendor \n"
 854   "@see https://wiki.libsdl.org/SDL_JoystickGetVendor \n"
 855   "@see https://wiki.libsdl.org/SDL_GameControllerGetVendor \n"
 856   "@ingroup Input")
 857{
 858   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
 859      return 0;
 860
 861   return (S32) SDL_JoystickGetDeviceVendor(sdlIndex);
 862}
 863
 864//------------------------------------------------------------------------------
 865DefineEngineStaticMethod(SDLInputManager, GetProduct, S32, (S32 sdlIndex), (0),
 866   "Gets the USB product ID of a joystick device, if available.\n\n"
 867   "@param sdlIndex The SDL index for this device.\n"
 868   "@return The USB product ID. If the product ID isn't available this function returns 0.\n"
 869   "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceProduct \n"
 870   "@see https://wiki.libsdl.org/SDL_JoystickGetProduct \n"
 871   "@see https://wiki.libsdl.org/SDL_GameControllerGetProduct \n"
 872   "@ingroup Input")
 873{
 874   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
 875      return 0;
 876
 877   return (S32)SDL_JoystickGetDeviceProduct(sdlIndex);
 878}
 879
 880//------------------------------------------------------------------------------
 881DefineEngineStaticMethod(SDLInputManager, GetProductVersion, S32, (S32 sdlIndex), (0),
 882   "Gets the product version of a joystick device, if available.\n\n"
 883   "@param sdlIndex The SDL index for this device.\n"
 884   "@return The product version. If the product version isn't available this function returns 0.\n"
 885   "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceProductVersion \n"
 886   "@see https://wiki.libsdl.org/SDL_JoystickGetProductVersion \n"
 887   "@see https://wiki.libsdl.org/SDL_GameControllerGetProductVersion \n"
 888   "@ingroup Input")
 889{
 890   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
 891      return 0;
 892
 893   return (S32)SDL_JoystickGetDeviceProductVersion(sdlIndex);
 894}
 895
 896//------------------------------------------------------------------------------
 897DefineEngineStaticMethod(SDLInputManager, GetDeviceType, SDLJoystickType, (S32 sdlIndex), (0),
 898   "@brief Exposes SDL_JoystickGetDeviceType() to script.\n\n"
 899   "@param sdlIndex The SDL index for this device.\n"
 900   "@return The type of device connected. Possible return strings are: \"Unknown\", "
 901   "\"Game Controller\", \"Wheel\", \"Arcade Stick\", \"Flight Stick\", \"Dance Pad\", "
 902   "\"Guitar\", \"Drum Kit\", \"Arcade Pad\" and \"Throttle\"\n"
 903   "@see https://wiki.libsdl.org/SDL_JoystickGetDeviceType \n"
 904   "@ingroup Input")
 905{
 906   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
 907      return SDL_JOYSTICK_TYPE_UNKNOWN;
 908
 909   return SDL_JoystickGetDeviceType(sdlIndex);
 910}
 911
 912//------------------------------------------------------------------------------
 913DefineEngineStaticMethod(SDLInputManager, JoystickNumAxes, S32, (S32 sdlIndex), (0),
 914   "@brief Exposes SDL_JoystickNumAxes() to script.\n\n"
 915   "@param sdlIndex The SDL index for this device.\n"
 916   "@return Returns the number of axis controls/number of axes on success or zero on failure.\n"
 917   "@see https://wiki.libsdl.org/SDL_JoystickNumAxes \n"
 918   "@ingroup Input")
 919{
 920   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
 921      return 0;
 922
 923   S32 numAxes = 0;
 924   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
 925   if (inputDevice)
 926   {
 927      numAxes = SDL_JoystickNumAxes(inputDevice);
 928      if (numAxes < 0)
 929      {
 930         Con::errorf("SDL Joystick error: %s", SDL_GetError());
 931         numAxes = 0;
 932      }
 933
 934      SDL_JoystickClose(inputDevice);
 935   }
 936
 937   return numAxes;
 938}
 939
 940//------------------------------------------------------------------------------
 941DefineEngineStaticMethod(SDLInputManager, JoystickNumBalls, S32, (S32 sdlIndex), (0),
 942   "@brief Exposes SDL_JoystickNumBalls() to script.\n\n"
 943   "@param sdlIndex The SDL index for this device.\n"
 944   "@return Returns the number of trackballs on success or zero on failure.\n"
 945   "@see https://wiki.libsdl.org/SDL_JoystickNumBalls \n"
 946   "@ingroup Input")
 947{
 948   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
 949      return 0;
 950
 951   S32 numBalls = 0;
 952   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
 953   if (inputDevice)
 954   {
 955      numBalls = SDL_JoystickNumBalls(inputDevice);
 956      if (numBalls < 0)
 957      {
 958         Con::errorf("SDL Joystick error: %s", SDL_GetError());
 959         numBalls = 0;
 960      }
 961
 962      SDL_JoystickClose(inputDevice);
 963   }
 964
 965   return numBalls;
 966}
 967
 968//------------------------------------------------------------------------------
 969DefineEngineStaticMethod(SDLInputManager, JoystickNumButtons, S32, (S32 sdlIndex), (0),
 970   "@brief Exposes SDL_JoystickNumButtons() to script.\n\n"
 971   "@param sdlIndex The SDL index for this device.\n"
 972   "@return Returns the number of buttons on success or zero on failure.\n"
 973   "@see https://wiki.libsdl.org/SDL_JoystickNumButtons \n"
 974   "@ingroup Input")
 975{
 976   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
 977      return 0;
 978
 979   S32 numButtons = 0;
 980   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
 981   if (inputDevice)
 982   {
 983      numButtons = SDL_JoystickNumButtons(inputDevice);
 984      if (numButtons < 0)
 985      {
 986         Con::errorf("SDL Joystick error: %s", SDL_GetError());
 987         numButtons = 0;
 988      }
 989
 990      SDL_JoystickClose(inputDevice);
 991   }
 992
 993   return numButtons;
 994}
 995
 996//------------------------------------------------------------------------------
 997DefineEngineStaticMethod(SDLInputManager, JoystickNumHats, S32, (S32 sdlIndex), (0),
 998   "@brief Exposes SDL_JoystickNumHats() to script.\n\n"
 999   "@param sdlIndex The SDL index for this device.\n"
1000   "@return Returns the number of POV hats on success or zero on failure.\n"
1001   "@see https://wiki.libsdl.org/SDL_JoystickNumHats \n"
1002   "@ingroup Input")
1003{
1004   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
1005      return 0;
1006
1007   S32 numHats = 0;
1008   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
1009   if (inputDevice)
1010   {
1011      numHats = SDL_JoystickNumHats(inputDevice);
1012      if (numHats < 0)
1013      {
1014         Con::errorf("SDL Joystick error: %s", SDL_GetError());
1015         numHats = 0;
1016      }
1017
1018      SDL_JoystickClose(inputDevice);
1019   }
1020
1021   return numHats;
1022}
1023
1024//------------------------------------------------------------------------------
1025DefineEngineStaticMethod(SDLInputManager, IsGameController, bool, (S32 sdlIndex), (0),
1026   "@brief Exposes SDL_IsGameController() to script.\n\n"
1027   "@param sdlIndex The SDL index for this device.\n"
1028   "@return Returns true if the given joystick is supported by the game controller "
1029   "interface, false if it isn't or it's an invalid index.\n"
1030   "@see https://wiki.libsdl.org/SDL_IsGameController \n"
1031   "@ingroup Input")
1032{
1033   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks() || !SDL_IsGameController(sdlIndex))
1034      return false;
1035
1036   return true;
1037}
1038
1039//------------------------------------------------------------------------------
1040DefineEngineStaticMethod(SDLInputManager, JoystickIsHaptic, bool, (S32 sdlIndex), (0),
1041   "@brief Exposes SDL_JoystickIsHaptic() to script.\n\n"
1042   "@param sdlIndex The SDL index for this device.\n"
1043   "@return Returns true if the joystick is haptic.\n"
1044   "@see https://wiki.libsdl.org/SDL_JoystickIsHaptic \n"
1045   "@ingroup Input")
1046{
1047   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
1048      return false;
1049
1050   bool isHaptic = false;
1051   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
1052   if (inputDevice)
1053   {
1054      isHaptic = (SDL_JoystickIsHaptic(inputDevice) == SDL_TRUE);
1055      SDL_JoystickClose(inputDevice);
1056   }
1057
1058   return isHaptic;
1059}
1060
1061//------------------------------------------------------------------------------
1062DefineEngineStaticMethod(SDLInputManager, JoystickPowerLevel, SDLPowerEnum, (S32 sdlIndex), (0),
1063   "@brief Exposes SDL_JoystickCurrentPowerLevel() to script.\n\n"
1064   "@param sdlIndex The SDL index for this device.\n"
1065   "@return Returns the current battery level or \"Wired\" if it's a connected device.\n"
1066   "@see https://wiki.libsdl.org/SDL_JoystickCurrentPowerLevel \n"
1067   "@ingroup Input")
1068{
1069   SDL_JoystickPowerLevel powerLevel = SDL_JOYSTICK_POWER_UNKNOWN;
1070   if (sdlIndex >= 0 && sdlIndex < SDL_NumJoysticks())
1071   {
1072      SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
1073      if (inputDevice)
1074      {
1075         powerLevel = SDL_JoystickCurrentPowerLevel(inputDevice);
1076         SDL_JoystickClose(inputDevice);
1077      }
1078   }
1079   return powerLevel;
1080}
1081
1082//------------------------------------------------------------------------------
1083DefineEngineStaticMethod(SDLInputManager, JoystickGetSpecs, String, (S32 sdlIndex), (0),
1084   "@brief A convenience function to reurn all of the data for a Joystick/Game Controller "
1085   " packed as fields in a tab separated string.\n\n"
1086   "There is overhead involved in querying joystick data, especially if the device is not open. "
1087   "If more than one field is required, it is more efficient to call JoystickGetSpecs() and "
1088   "parse the data out of the return string than to call the console method for each.\n"
1089   "@param sdlIndex The SDL index for this device.\n"
1090   "@return A tab separated string that can be parsed from script with getField()/getFields().\n\n"
1091   "Field 0: Number of Axes\n"
1092   "      1: Number of Buttons\n"
1093   "      2: Number of POV Hats\n"
1094   "      3: Number of Trackballs\n"
1095   "      4: SDL_IsGameController() (Boolean)\n"
1096   "      5: SDL_JoystickIsHaptic() (Boolean)\n"
1097   "      6: Power Level (String)\n"
1098   "      7: Device Type (String)\n"
1099   "@ingroup Input")
1100{
1101   String specStr;
1102   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
1103      return specStr;
1104
1105   bool isController = SDL_IsGameController(sdlIndex);
1106   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
1107   if (inputDevice)
1108   {
1109      SDL_JoystickPowerLevel powerLevel = SDL_JoystickCurrentPowerLevel(inputDevice);
1110      SDL_JoystickType deviceType = SDL_JoystickGetDeviceType(sdlIndex);
1111
1112      specStr = String::ToString("%d\t%d\t%d\t%d\t%d\t%d\t%s\t%s\t",
1113         SDL_JoystickNumAxes(inputDevice), SDL_JoystickNumButtons(inputDevice),
1114         SDL_JoystickNumHats(inputDevice), SDL_JoystickNumBalls(inputDevice),
1115         isController ? 1 : 0, (SDL_JoystickIsHaptic(inputDevice) == SDL_TRUE) ? 1 : 0,
1116         castConsoleTypeToString(powerLevel), castConsoleTypeToString(deviceType));
1117      SDL_JoystickClose(inputDevice);
1118   }
1119
1120   return specStr;
1121}
1122
1123//------------------------------------------------------------------------------
1124DefineEngineStaticMethod(SDLInputManager, JoystickGetAxes, String, (S32 sdlIndex), (0),
1125   "@brief Gets the current value for all joystick axes.\n\n"
1126   "@param sdlIndex The SDL index for this device.\n"
1127   "@return A tab separated string that can be parsed from script with getField()/getFields(). "
1128   "Each axis is one field, so a 4 axis device will have 4 fields.\n\n"
1129   "@ingroup Input")
1130{
1131   String axesStr;
1132   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
1133      return axesStr;
1134
1135   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
1136   if (inputDevice)
1137   {
1138      S32 numAxes = SDL_JoystickNumAxes(inputDevice);
1139      for (S32 i = 0; i < numAxes; i++)
1140      {
1141         F32 axisVal = (F32) SDL_JoystickGetAxis(inputDevice, i);
1142         F32 value = axisVal / (F32)(axisVal > 0.0f ? SDL_JOYSTICK_AXIS_MAX : -SDL_JOYSTICK_AXIS_MIN);
1143         axesStr += String::ToString("%0.3f\t", value);
1144      }
1145      SDL_JoystickClose(inputDevice);
1146   }
1147
1148   return axesStr;
1149}
1150
1151//------------------------------------------------------------------------------
1152DefineEngineStaticMethod(SDLInputManager, JoystickGetButtons, String, (S32 sdlIndex), (0),
1153   "@brief Gets the current value for all joystick buttons.\n\n"
1154   "@param sdlIndex The SDL index for this device.\n"
1155   "@return A tab separated string that can be parsed from script with getField()/getFields(). "
1156   "Each button is one field. 0 - SDL_JoystickNumButtons() fields.\n\n"
1157   "@ingroup Input")
1158{
1159   String buttonStr;
1160   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
1161      return buttonStr;
1162
1163   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
1164   if (inputDevice)
1165   {
1166      S32 numbuttons = SDL_JoystickNumButtons(inputDevice);
1167      for (S32 i = 0; i < numbuttons; i++)
1168      {
1169         buttonStr += String::ToString("%d\t", (S32) SDL_JoystickGetButton(inputDevice, i));
1170      }
1171      SDL_JoystickClose(inputDevice);
1172   }
1173
1174   return buttonStr;
1175}
1176
1177//------------------------------------------------------------------------------
1178DefineEngineStaticMethod(SDLInputManager, JoystickGetHats, String, (S32 sdlIndex), (0),
1179   "@brief Gets the current value for all POV hats.\n\n"
1180   "@param sdlIndex The SDL index for this device.\n"
1181   "@return A tab separated string that can be parsed from script with getField()/getFields(). "
1182   "Each hat is one field. 0 - SDL_JoystickNumHats() fields. The value is a 4 bit bitmask. "
1183   "If no bits are set, the hat is centered. Bit 0 is up, 1 is right, 2 is down and 3 is left.\n\n"
1184   "@ingroup Input")
1185{
1186   String hatStr;
1187   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
1188      return hatStr;
1189
1190   SDL_Joystick *inputDevice = SDL_JoystickOpen(sdlIndex);
1191   if (inputDevice)
1192   {
1193      S32 numHats = SDL_JoystickNumHats(inputDevice);
1194      for (S32 i = 0; i < numHats; i++)
1195      {
1196         hatStr += String::ToString("%d\t", (S32)SDL_JoystickGetHat(inputDevice, i));
1197      }
1198      SDL_JoystickClose(inputDevice);
1199   }
1200
1201   return hatStr;
1202}
1203
1204//------------------------------------------------------------------------------
1205DefineEngineStaticMethod(SDLInputManager, ControllerGetAxes, String, (S32 sdlIndex), (0),
1206   "@brief Gets the current value for all controller axes.\n\n"
1207   "@param sdlIndex The SDL index for this device.\n"
1208   "@return A tab separated string that can be parsed from script with getField()/getFields(). "
1209   "Game controllers always have 6 axes in the following order: 0-LX, 1-LY, 2-RX, 3-RY, 4-LT, 5-RT.\n\n"
1210   "@ingroup Input")
1211{
1212   String axesStr;
1213   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
1214      return axesStr;
1215
1216   bool isController = SDL_IsGameController(sdlIndex);
1217   if (!isController)
1218      return axesStr;
1219
1220   SDL_GameController *inputDevice = SDL_GameControllerOpen(sdlIndex);
1221   if (inputDevice)
1222   {
1223      for (S32 i = SDL_CONTROLLER_AXIS_LEFTX; i < SDL_CONTROLLER_AXIS_MAX; i++)
1224      {
1225         F32 axisVal = (F32)SDL_GameControllerGetAxis(inputDevice, (SDL_GameControllerAxis) i);
1226         F32 value = axisVal / (F32)(axisVal > 0.0f ? SDL_JOYSTICK_AXIS_MAX : -SDL_JOYSTICK_AXIS_MIN);
1227         axesStr += String::ToString("%0.3f\t", value);
1228      }
1229      SDL_GameControllerClose(inputDevice);
1230   }
1231
1232   return axesStr;
1233}
1234
1235//------------------------------------------------------------------------------
1236DefineEngineStaticMethod(SDLInputManager, ControllerGetButtons, String, (S32 sdlIndex), (0),
1237   "@brief Gets the current value for all controller buttons.\n\n"
1238   "@param sdlIndex The SDL index for this device.\n"
1239   "@return A tab separated string that can be parsed from script with getField()/getFields(). "
1240   "Game controllers always have 15 buttons in the following order: 0-A, 1-B, 2-X, 3-Y, 4-Back, "
1241   "5-Guide, 6-Start, 7-Left Stick, 8-Right Stick, 9-Left Shoulder, 10-Right Shoulder, "
1242   "11-DPad Up, 12-DPad Down, 13-DPad Left, 14-DPad Right.\n\n"
1243   "@ingroup Input")
1244{
1245   String buttonStr;
1246   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
1247      return buttonStr;
1248
1249   bool isController = SDL_IsGameController(sdlIndex);
1250   if (!isController)
1251      return buttonStr;
1252
1253   SDL_GameController *inputDevice = SDL_GameControllerOpen(sdlIndex);
1254   if (inputDevice)
1255   {
1256      for (S32 i = SDL_CONTROLLER_BUTTON_A; i < SDL_CONTROLLER_BUTTON_MAX; i++)
1257      {
1258         buttonStr += String::ToString("%d\t", (S32)SDL_GameControllerGetButton(inputDevice, (SDL_GameControllerButton) i));
1259      }
1260      SDL_GameControllerClose(inputDevice);
1261   }
1262
1263   return buttonStr;
1264}
1265
1266//------------------------------------------------------------------------------
1267DefineEngineStaticMethod(SDLInputManager, GameControllerMapping, String, (S32 sdlIndex), (0),
1268   "@brief Exposes SDL_GameControllerMapping() to script.\n\n"
1269   "@param sdlIndex The SDL index for this device.\n"
1270   "@return Returns a string that has the controller's mapping or NULL if no mapping "
1271   "is available or it does not exist.\n"
1272   "@see https://wiki.libsdl.org/SDL_JoystickNameForIndex \n"
1273   "@ingroup Input")
1274{
1275   String mapping;
1276   if (sdlIndex < 0 || sdlIndex >= SDL_NumJoysticks())
1277      return mapping;
1278
1279   SDL_GameController *inputDevice = SDL_GameControllerOpen(sdlIndex);
1280   if (inputDevice)
1281   {
1282      char* sdlStr = SDL_GameControllerMapping(inputDevice);
1283      if (sdlStr)
1284      {
1285         mapping = sdlStr;
1286         SDL_free(sdlStr);
1287      }
1288      else
1289         Con::errorf("SDL Joystick error: %s", SDL_GetError());
1290
1291      SDL_GameControllerClose(inputDevice);
1292   }
1293
1294   return mapping;
1295}
1296
1297//------------------------------------------------------------------------------
1298DefineEngineStaticMethod(SDLInputManager, GameControllerMappingForGUID, String, (const char* guidStr), ,
1299   "@brief Exposes SDL_GameControllerMappingForGUID() to script.\n\n"
1300   "@param guidStr The GUID for which a mapping is desired.\n"
1301   "@return Returns a mapping string or NULL on error.\n"
1302   "@see https://wiki.libsdl.org/SDL_GameControllerMappingForGUID \n"
1303   "@ingroup Input")
1304{
1305   String mapping;
1306   SDL_JoystickGUID guid = SDL_JoystickGetGUIDFromString(guidStr);
1307
1308   char* sdlStr = SDL_GameControllerMappingForGUID(guid);
1309   if (sdlStr)
1310   {
1311      mapping = sdlStr;
1312      SDL_free(sdlStr);
1313   }
1314
1315   return mapping;
1316}
1317
1318//------------------------------------------------------------------------------
1319DefineEngineStaticMethod(SDLInputManager, GameControllerAddMapping, S32, (const char* mappingString), ,
1320   "@brief Exposes SDL_GameControllerAddMapping() to script.\n\n"
1321   "Use this function to add support for controllers that SDL is unaware of or "
1322   "to cause an existing controller to have a different binding.\n"
1323   "@param mappingString The new mapping string to apply. Full details on the format of this "
1324   "string are available at the linked SDL wiki page.\n"
1325   "@return Returns 1 if a new mapping is added, 0 if an existing mapping is updated, -1 on error.\n"
1326   "@see https://wiki.libsdl.org/SDL_GameControllerAddMapping \n"
1327   "@ingroup Input")
1328{
1329   S32 retVal = SDL_GameControllerAddMapping(mappingString);
1330   if (retVal == -1)
1331      Con::errorf("SDL Joystick error: %s", SDL_GetError());
1332
1333   return retVal;
1334}
1335
1336//------------------------------------------------------------------------------
1337DefineEngineStaticMethod(SDLInputManager, GameControllerAddMappingsFromFile, S32, (const char* fileName), ,
1338   "@brief Exposes SDL_GameControllerAddMappingsFromFile() to script.\n\n"
1339   "Use this function to load a set of Game Controller mappings from a file, filtered by the "
1340   "current SDL_GetPlatform(). A community sourced database of controllers is available at "
1341   "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt \n"
1342   "@param fileName The file to load mappings from.\n"
1343   "@return Returns the number of mappings added or -1 on error.\n"
1344   "@see https://wiki.libsdl.org/SDL_GameControllerAddMappingsFromFile \n"
1345   "@ingroup Input")
1346{
1347   char torquePath[1024];
1348   Con::expandScriptFilename(torquePath, sizeof(torquePath), fileName);
1349   S32 retVal = SDL_GameControllerAddMappingsFromFile(torquePath);
1350   if (retVal == -1)
1351      Con::errorf("SDL Joystick error: %s", SDL_GetError());
1352
1353   return retVal;
1354}
1355
1356//------------------------------------------------------------------------------
1357DefineEngineStaticMethod(SDLInputManager, GameControllerNumMappings, S32, (), ,
1358   "Get the number of mappings installed. Used with GameControllerMappingForIndex "
1359   "to iterate through all installed mappings.\n\n"
1360   "@ingroup Input")
1361{
1362   return SDL_GameControllerNumMappings();
1363}
1364
1365//------------------------------------------------------------------------------
1366DefineEngineStaticMethod(SDLInputManager, GameControllerMappingForIndex, String, (S32 mappingIndex), ,
1367   "Get the mapping at a particular index.\n\n"
1368   "@param mappingIndex The index for which a mapping is desired.\n"
1369   "@return Returns a mapping string or NULL if the index is out of range.\n"
1370   "@ingroup Input")
1371{
1372   String mapping;
1373   char* sdlStr = SDL_GameControllerMappingForIndex(mappingIndex);
1374
1375   if (sdlStr)
1376   {
1377      mapping = sdlStr;
1378      SDL_free(sdlStr);
1379   }
1380
1381   return mapping;
1382}
1383