2016-01-11 20:07:57 +01:00
// BlitzSteam - Steam wrapper for Blitz
2016-01-11 16:56:07 +01:00
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
2015-06-06 18:46:10 +02:00
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2016-02-06 00:17:29 +01:00
# include "BlitzSteam.h"
2015-06-06 14:33:52 +02:00
2016-03-04 03:47:32 +01:00
//-----------------------------------------------------------------------------
// Purpose: Native Steam controller support API
//-----------------------------------------------------------------------------
2016-03-19 14:22:11 +01:00
DLL ( ISteamController * ) BS_SteamController ( ) {
2016-02-06 00:17:29 +01:00
return SteamController ( ) ;
}
2016-02-23 13:25:34 +01:00
// Init and Shutdown must be called when starting/ending use of this interface
2016-03-19 14:22:11 +01:00
DLL ( int32_t ) BS_ISteamController_Init ( ISteamController * lpSteamController ) {
2016-01-11 16:56:07 +01:00
return lpSteamController - > Init ( ) ;
2015-06-06 21:15:41 +02:00
}
2016-02-23 13:25:34 +01:00
// Init and Shutdown must be called when starting/ending use of this interface
2016-03-19 14:22:11 +01:00
DLL ( int32_t ) BS_ISteamController_Shutdown ( ISteamController * lpSteamController ) {
2015-06-06 21:15:41 +02:00
return lpSteamController - > Shutdown ( ) ;
}
2016-02-23 13:25:34 +01:00
// Pump callback/callresult events
// Note: SteamAPI_RunCallbacks will do this for you, so you should never need to call this directly.
2016-03-19 14:22:11 +01:00
DLL ( void ) BS_ISteamController_RunFrame ( ISteamController * lpSteamController ) {
2015-06-06 21:15:41 +02:00
lpSteamController - > RunFrame ( ) ;
}
2016-02-23 13:25:34 +01:00
// Enumerate currently connected controllers
// handlesOut should point to a STEAM_CONTROLLER_MAX_COUNT sized array of ControllerHandle_t handles
// Returns the number of handles written to handlesOut
2016-03-19 14:22:11 +01:00
DLL ( int32_t ) BS_ISteamController_GetConnectedControllers ( ISteamController * lpSteamController , ControllerHandle_t * pHandlesOut ) {
2016-02-23 13:25:34 +01:00
return lpSteamController - > GetConnectedControllers ( pHandlesOut ) ;
2015-06-06 21:15:41 +02:00
}
2016-02-23 13:25:34 +01:00
ControllerHandle_t * pControllerHandles = new ControllerHandle_t [ STEAM_CONTROLLER_MAX_COUNT ] ;
2016-03-19 14:22:11 +01:00
DLL ( int32_t ) BS_ISteamController_GetConnectedControllersSimple ( ISteamController * lpSteamController ) {
2016-02-23 13:25:34 +01:00
return lpSteamController - > GetConnectedControllers ( pControllerHandles ) ;
}
2016-03-19 14:22:11 +01:00
DLL ( ControllerHandle_t * ) BS_ISteamController_GetConnectedControllersSimple_Index ( uint32_t index ) {
2016-02-23 13:25:34 +01:00
if ( index > = STEAM_CONTROLLER_MAX_COUNT )
index = STEAM_CONTROLLER_MAX_COUNT - 1 ;
return & ( pControllerHandles [ index ] ) ;
}
// Invokes the Steam overlay and brings up the binding screen
// Returns false is overlay is disabled / unavailable, or the user is not in Big Picture mode
2016-03-19 14:22:11 +01:00
DLL ( int32_t ) BS_ISteamController_ShowBindingPanel ( ISteamController * lpSteamController , ControllerHandle_t * pControllerHandle ) {
2016-02-23 13:25:34 +01:00
return lpSteamController - > ShowBindingPanel ( * pControllerHandle ) ;
}
// ACTION SETS
// Lookup the handle for an Action Set. Best to do this once on startup, and store the handles for all future API calls.
2016-03-19 14:22:11 +01:00
DLL ( ControllerActionSetHandle_t * ) BS_ISteamController_GetActionSetHandle ( ISteamController * lpSteamController , const char * pszActionSetName ) {
2016-02-23 13:25:34 +01:00
return new ControllerActionSetHandle_t ( lpSteamController - > GetActionSetHandle ( pszActionSetName ) ) ;
}
// Reconfigure the controller to use the specified action set (ie 'Menu', 'Walk' or 'Drive')
// This is cheap, and can be safely called repeatedly. It's often easier to repeatedly call it in
// your state loops, instead of trying to place it in all of your state transitions.
2016-03-19 14:22:11 +01:00
DLL ( void ) BS_ISteamController_ActivateActionSet ( ISteamController * lpSteamController , ControllerHandle_t * pControllerHandle , ControllerActionSetHandle_t * pActionSetHandle ) {
2016-02-23 13:25:34 +01:00
lpSteamController - > ActivateActionSet ( * pControllerHandle , * pActionSetHandle ) ;
2015-06-06 21:15:41 +02:00
}
2016-03-19 14:22:11 +01:00
DLL ( ControllerActionSetHandle_t * ) BS_ISteamController_GetCurrentActionSet ( ISteamController * lpSteamController , ControllerHandle_t * pControllerHandle ) {
2016-02-23 13:25:34 +01:00
return new ControllerActionSetHandle_t ( lpSteamController - > GetCurrentActionSet ( * pControllerHandle ) ) ;
2015-06-06 21:15:41 +02:00
}
2016-02-23 13:25:34 +01:00
// Lookup the handle for a digital action. Best to do this once on startup, and store the handles for all future API calls.
2016-03-19 14:22:11 +01:00
DLL ( ControllerDigitalActionHandle_t * ) BS_ISteamController_GetDigitalActionHandle ( ISteamController * lpSteamController , const char * pszActionName ) {
2016-02-23 13:25:34 +01:00
return new ControllerDigitalActionHandle_t ( lpSteamController - > GetDigitalActionHandle ( pszActionName ) ) ;
}
// Returns the current state of the supplied digital game action
2016-03-19 14:22:11 +01:00
DLL ( ControllerDigitalActionData_t * ) BS_ISteamController_GetDigitalActionData ( ISteamController * lpSteamController , ControllerHandle_t * pControllerHandle , ControllerDigitalActionHandle_t * pDigitalActionHandle ) {
2016-02-23 13:25:34 +01:00
return & lpSteamController - > GetDigitalActionData ( * pControllerHandle , * pDigitalActionHandle ) ;
}
// Get the origin(s) for a digital action within an action set. Returns the number of origins supplied in originsOut. Use this to display the appropriate on-screen prompt for the action.
// originsOut should point to a STEAM_CONTROLLER_MAX_ORIGINS sized array of EControllerActionOrigin handles
2016-03-19 14:22:11 +01:00
DLL ( int32_t ) BS_ISteamController_GetDigitalActionOrigins ( ISteamController * lpSteamController , ControllerHandle_t * pControllerHandle , ControllerActionSetHandle_t * pActionSetHandle , ControllerDigitalActionHandle_t * pDigitalActionHandle , EControllerActionOrigin * pEControllerActionOrigin ) {
2016-02-23 13:25:34 +01:00
return lpSteamController - > GetDigitalActionOrigins ( * pControllerHandle , * pActionSetHandle , * pDigitalActionHandle , pEControllerActionOrigin ) ;
}
// Lookup the handle for an analog action. Best to do this once on startup, and store the handles for all future API calls.
2016-03-19 14:22:11 +01:00
DLL ( ControllerAnalogActionHandle_t * ) BS_ISteamController_GetAnalogActionHandle ( ISteamController * lpSteamController , const char * pszActionName ) {
2016-02-23 13:25:34 +01:00
return new ControllerAnalogActionHandle_t ( lpSteamController - > GetAnalogActionHandle ( pszActionName ) ) ;
}
// Returns the current state of these supplied analog game action
2016-03-19 14:22:11 +01:00
DLL ( ControllerAnalogActionData_t * ) BS_ISteamController_GetAnalogActionData ( ISteamController * lpSteamController , ControllerHandle_t * pControllerHandle , ControllerAnalogActionHandle_t * pAnalogActionHandle ) {
2016-02-23 13:25:34 +01:00
return & lpSteamController - > GetAnalogActionData ( * pControllerHandle , * pAnalogActionHandle ) ;
}
// Get the origin(s) for an analog action within an action set. Returns the number of origins supplied in originsOut. Use this to display the appropriate on-screen prompt for the action.
// originsOut should point to a STEAM_CONTROLLER_MAX_ORIGINS sized array of EControllerActionOrigin handles
2016-03-19 14:22:11 +01:00
DLL ( int32_t ) BS_ISteamController_GetAnalogActionOrigins ( ISteamController * lpSteamController , ControllerHandle_t * pControllerHandle , ControllerActionSetHandle_t * pActionSetHandle , ControllerAnalogActionHandle_t * pAnalogActionHandle , EControllerActionOrigin * pEControllerActionOrigin ) {
2016-02-23 13:25:34 +01:00
return lpSteamController - > GetAnalogActionOrigins ( * pControllerHandle , * pActionSetHandle , * pAnalogActionHandle , pEControllerActionOrigin ) ;
}
2016-03-19 14:22:11 +01:00
DLL ( void ) BS_ISteamController_StopAnalogActionMomentum ( ISteamController * lpSteamController , ControllerHandle_t * pControllerHandle , ControllerAnalogActionHandle_t * pAnalogActionHandle ) {
2016-02-23 13:25:34 +01:00
lpSteamController - > StopAnalogActionMomentum ( * pControllerHandle , * pAnalogActionHandle ) ;
}
// Trigger a haptic pulse on a controller
2016-03-19 14:22:11 +01:00
DLL ( void ) BS_ISteamController_TriggerHapticPulse ( ISteamController * lpSteamController , ControllerHandle_t * pControllerHandle , ESteamControllerPad eTargetPad , uint32_t usDurationMicroSec ) {
2016-02-23 13:25:34 +01:00
lpSteamController - > TriggerHapticPulse ( * pControllerHandle , eTargetPad , ( uint16_t ) usDurationMicroSec ) ;
2016-02-23 23:39:40 +01:00
}
2016-03-19 14:22:11 +01:00
DLL ( void ) BS_ISteamController_TriggerRepeatedHapticPulse ( ISteamController * lpSteamController , ControllerHandle_t * pControllerHandle , ESteamControllerPad eTargetPad , uint32_t usDurationMicroSec , uint32_t usOffMicroSec , uint32_t unRepeat , uint32_t nFlags ) {
2016-02-23 23:39:40 +01:00
lpSteamController - > TriggerRepeatedHapticPulse ( * pControllerHandle , eTargetPad , usDurationMicroSec , usOffMicroSec , unRepeat , nFlags ) ;
2016-03-04 03:47:32 +01:00
}