Controller tests

This commit is contained in:
Garry Newman 2019-06-19 16:18:12 +01:00
parent ae1f648fa6
commit 1c5cdd2d39
8 changed files with 171 additions and 13 deletions

View File

@ -11,17 +11,18 @@ namespace Steamworks
{ {
[TestClass] [TestClass]
[DeploymentItem( "steam_api64.dll" )] [DeploymentItem( "steam_api64.dll" )]
[DeploymentItem( "controller_config/game_actions_252490.vdf" )]
public class InputTest public class InputTest
{ {
[TestMethod] [TestMethod]
public void ControllerList() public void ControllerList()
{ {
foreach ( var c in SteamInput.Controllers ) foreach ( var controller in SteamInput.Controllers )
{ {
Console.WriteLine( "Got Contorller!" ); Console.Write( $"Controller: {controller}" );
} }
} }
} }
} }

View File

@ -0,0 +1,74 @@
"In Game Actions"
{
"actions"
{
"InGameControls"
{
"title" "#Set_Ingame"
"StickPadGyro"
{
"Move"
{
"title" "#Action_Move"
"input_mode" "joystick_move"
}
"Camera"
{
"title" "#Action_Camera"
"input_mode" "absolute_mouse"
}
}
"AnalogTrigger"
{
"Throttle" "#Action_Throttle"
}
"Button"
{
"fire" "#Action_Fire"
"Jump" "#Action_Jump"
"pause_menu" "#Action_Menu"
}
}
"MenuControls"
{
"title" "#Set_Menu"
"StickPadGyro"
{
}
"AnalogTrigger"
{
}
"Button"
{
"menu_up" "#Menu_Up"
"menu_down" "#Menu_Down"
"menu_left" "#Menu_Left"
"menu_right" "#Menu_Right"
"menu_select" "#Menu_Select"
"menu_cancel" "#Menu_Cancel"
"pause_menu" "#Action_ReturnToGame"
}
}
}
"localization"
{
"english"
{
"Set_Ingame" "In-Game Controls"
"Set_Menu" "Menu Controls"
"Action_Move" "Movement"
"Action_Camera" "Camera"
"Action_Throttle" "Throttle"
"Action_Fire" "Fire Weapon"
"Action_Jump" "Jump"
"Action_Menu" "Pause Menu"
"Action_ReturnToGame" "Return To Game"
"Menu_Up" "Up"
"Menu_Down" "Down"
"Menu_Left" "Left"
"Menu_Right" "Right"
"Menu_Select" "Select"
"Menu_Cancel" "Cancel"
}
}
}

View File

@ -0,0 +1,74 @@
"In Game Actions"
{
"actions"
{
"InGameControls"
{
"title" "#Set_Ingame"
"StickPadGyro"
{
"Move"
{
"title" "#Action_Move"
"input_mode" "joystick_move"
}
"Camera"
{
"title" "#Action_Camera"
"input_mode" "absolute_mouse"
}
}
"AnalogTrigger"
{
"Throttle" "#Action_Throttle"
}
"Button"
{
"fire" "#Action_Fire"
"Jump" "#Action_Jump"
"pause_menu" "#Action_Menu"
}
}
"MenuControls"
{
"title" "#Set_Menu"
"StickPadGyro"
{
}
"AnalogTrigger"
{
}
"Button"
{
"menu_up" "#Menu_Up"
"menu_down" "#Menu_Down"
"menu_left" "#Menu_Left"
"menu_right" "#Menu_Right"
"menu_select" "#Menu_Select"
"menu_cancel" "#Menu_Cancel"
"pause_menu" "#Action_ReturnToGame"
}
}
}
"localization"
{
"english"
{
"Set_Ingame" "In-Game Controls"
"Set_Menu" "Menu Controls"
"Action_Move" "Movement"
"Action_Camera" "Camera"
"Action_Throttle" "Throttle"
"Action_Fire" "Fire Weapon"
"Action_Jump" "Jump"
"Action_Menu" "Pause Menu"
"Action_ReturnToGame" "Return To Game"
"Menu_Up" "Up"
"Menu_Down" "Down"
"Menu_Left" "Left"
"Menu_Right" "Right"
"Menu_Select" "Select"
"Menu_Cancel" "Cancel"
}
}
}

View File

@ -410,11 +410,11 @@ namespace Steamworks
#region FunctionMeta #region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )] [UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate SteamInputType FGetInputTypeForHandle( IntPtr self, InputHandle_t inputHandle ); private delegate InputType FGetInputTypeForHandle( IntPtr self, InputHandle_t inputHandle );
private FGetInputTypeForHandle _GetInputTypeForHandle; private FGetInputTypeForHandle _GetInputTypeForHandle;
#endregion #endregion
internal SteamInputType GetInputTypeForHandle( InputHandle_t inputHandle ) internal InputType GetInputTypeForHandle( InputHandle_t inputHandle )
{ {
return _GetInputTypeForHandle( Self, inputHandle ); return _GetInputTypeForHandle( Self, inputHandle );
} }
@ -476,11 +476,11 @@ namespace Steamworks
#region FunctionMeta #region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )] [UnmanagedFunctionPointer( CallingConvention.ThisCall )]
private delegate InputActionOrigin FTranslateActionOrigin( IntPtr self, SteamInputType eDestinationInputType, InputActionOrigin eSourceOrigin ); private delegate InputActionOrigin FTranslateActionOrigin( IntPtr self, InputType eDestinationInputType, InputActionOrigin eSourceOrigin );
private FTranslateActionOrigin _TranslateActionOrigin; private FTranslateActionOrigin _TranslateActionOrigin;
#endregion #endregion
internal InputActionOrigin TranslateActionOrigin( SteamInputType eDestinationInputType, InputActionOrigin eSourceOrigin ) internal InputActionOrigin TranslateActionOrigin( InputType eDestinationInputType, InputActionOrigin eSourceOrigin )
{ {
return _TranslateActionOrigin( Self, eDestinationInputType, eSourceOrigin ); return _TranslateActionOrigin( Self, eDestinationInputType, eSourceOrigin );
} }

View File

@ -1436,7 +1436,7 @@ namespace Steamworks
// //
// ESteamInputType // ESteamInputType
// //
internal enum SteamInputType : int public enum InputType : int
{ {
Unknown = 0, Unknown = 0,
SteamController = 1, SteamController = 1,

View File

@ -20,8 +20,6 @@ namespace Steamworks
{ {
_internal = new ISteamInput(); _internal = new ISteamInput();
_internal.Init(); _internal.Init();
_internal.DoInit();
} }
return _internal; return _internal;
@ -36,9 +34,15 @@ namespace Steamworks
internal static void InstallEvents() internal static void InstallEvents()
{ {
Internal.DoInit();
Internal.RunFrame();
// None? // None?
} }
static InputHandle_t[] queryArray = new InputHandle_t[STEAM_CONTROLLER_MAX_COUNT];
/// <summary> /// <summary>
/// Return a list of connected controllers. Will return null if none found. /// Return a list of connected controllers. Will return null if none found.
/// </summary> /// </summary>
@ -46,12 +50,11 @@ namespace Steamworks
{ {
get get
{ {
var array = new InputHandle_t[STEAM_CONTROLLER_MAX_COUNT]; var num = Internal.GetConnectedControllers( queryArray );
var num = Internal.GetConnectedControllers( array );
for ( int i = 0; i < num; i++ ) for ( int i = 0; i < num; i++ )
{ {
yield return new Controller( array[num] ); yield return new Controller( queryArray[i] );
} }
} }

View File

@ -10,5 +10,9 @@ namespace Steamworks
{ {
this.inputHandle = inputHandle_t; this.inputHandle = inputHandle_t;
} }
public InputType InputType => SteamInput.Internal.GetInputTypeForHandle( inputHandle );
public override string ToString() => $"{InputType}.{inputHandle.Value}";
} }
} }

View File

@ -39,6 +39,7 @@ public static class Cleanup
type = type.Replace( "SteamNetworkingMicroseconds", "long" ); type = type.Replace( "SteamNetworkingMicroseconds", "long" );
type = type.Replace( "SteamNetworkingSocketsDebugOutputType", "DebugOutputType" ); type = type.Replace( "SteamNetworkingSocketsDebugOutputType", "DebugOutputType" );
type = type.Replace( "SteamNetworkingGetConfigValueResult", "NetConfigResult" ); type = type.Replace( "SteamNetworkingGetConfigValueResult", "NetConfigResult" );
type = type.Replace( "SteamInputType", "InputType" );
return type; return type;
} }
@ -75,6 +76,7 @@ public static class Cleanup
if ( name == "P2PSend" ) return "public"; if ( name == "P2PSend" ) return "public";
if ( name == "RoomEnter" ) return "public"; if ( name == "RoomEnter" ) return "public";
if ( name == "P2PSessionError" ) return "public"; if ( name == "P2PSessionError" ) return "public";
if ( name == "InputType" ) return "public";
return "internal"; return "internal";
} }