mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-13 15:18:07 +03:00
Controller tests
This commit is contained in:
parent
ae1f648fa6
commit
1c5cdd2d39
@ -11,17 +11,18 @@ namespace Steamworks
|
||||
{
|
||||
[TestClass]
|
||||
[DeploymentItem( "steam_api64.dll" )]
|
||||
[DeploymentItem( "controller_config/game_actions_252490.vdf" )]
|
||||
public class InputTest
|
||||
{
|
||||
|
||||
[TestMethod]
|
||||
public void ControllerList()
|
||||
{
|
||||
foreach ( var c in SteamInput.Controllers )
|
||||
foreach ( var controller in SteamInput.Controllers )
|
||||
{
|
||||
Console.WriteLine( "Got Contorller!" );
|
||||
Console.Write( $"Controller: {controller}" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
@ -410,11 +410,11 @@ namespace Steamworks
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
private delegate SteamInputType FGetInputTypeForHandle( IntPtr self, InputHandle_t inputHandle );
|
||||
private delegate InputType FGetInputTypeForHandle( IntPtr self, InputHandle_t inputHandle );
|
||||
private FGetInputTypeForHandle _GetInputTypeForHandle;
|
||||
|
||||
#endregion
|
||||
internal SteamInputType GetInputTypeForHandle( InputHandle_t inputHandle )
|
||||
internal InputType GetInputTypeForHandle( InputHandle_t inputHandle )
|
||||
{
|
||||
return _GetInputTypeForHandle( Self, inputHandle );
|
||||
}
|
||||
@ -476,11 +476,11 @@ namespace Steamworks
|
||||
|
||||
#region FunctionMeta
|
||||
[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;
|
||||
|
||||
#endregion
|
||||
internal InputActionOrigin TranslateActionOrigin( SteamInputType eDestinationInputType, InputActionOrigin eSourceOrigin )
|
||||
internal InputActionOrigin TranslateActionOrigin( InputType eDestinationInputType, InputActionOrigin eSourceOrigin )
|
||||
{
|
||||
return _TranslateActionOrigin( Self, eDestinationInputType, eSourceOrigin );
|
||||
}
|
||||
|
@ -1436,7 +1436,7 @@ namespace Steamworks
|
||||
//
|
||||
// ESteamInputType
|
||||
//
|
||||
internal enum SteamInputType : int
|
||||
public enum InputType : int
|
||||
{
|
||||
Unknown = 0,
|
||||
SteamController = 1,
|
||||
|
@ -20,8 +20,6 @@ namespace Steamworks
|
||||
{
|
||||
_internal = new ISteamInput();
|
||||
_internal.Init();
|
||||
|
||||
_internal.DoInit();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
@ -36,9 +34,15 @@ namespace Steamworks
|
||||
|
||||
internal static void InstallEvents()
|
||||
{
|
||||
Internal.DoInit();
|
||||
Internal.RunFrame();
|
||||
|
||||
// None?
|
||||
}
|
||||
|
||||
|
||||
static InputHandle_t[] queryArray = new InputHandle_t[STEAM_CONTROLLER_MAX_COUNT];
|
||||
|
||||
/// <summary>
|
||||
/// Return a list of connected controllers. Will return null if none found.
|
||||
/// </summary>
|
||||
@ -46,12 +50,11 @@ namespace Steamworks
|
||||
{
|
||||
get
|
||||
{
|
||||
var array = new InputHandle_t[STEAM_CONTROLLER_MAX_COUNT];
|
||||
var num = Internal.GetConnectedControllers( array );
|
||||
var num = Internal.GetConnectedControllers( queryArray );
|
||||
|
||||
for ( int i = 0; i < num; i++ )
|
||||
{
|
||||
yield return new Controller( array[num] );
|
||||
yield return new Controller( queryArray[i] );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,5 +10,9 @@ namespace Steamworks
|
||||
{
|
||||
this.inputHandle = inputHandle_t;
|
||||
}
|
||||
|
||||
public InputType InputType => SteamInput.Internal.GetInputTypeForHandle( inputHandle );
|
||||
|
||||
public override string ToString() => $"{InputType}.{inputHandle.Value}";
|
||||
}
|
||||
}
|
@ -39,6 +39,7 @@ public static class Cleanup
|
||||
type = type.Replace( "SteamNetworkingMicroseconds", "long" );
|
||||
type = type.Replace( "SteamNetworkingSocketsDebugOutputType", "DebugOutputType" );
|
||||
type = type.Replace( "SteamNetworkingGetConfigValueResult", "NetConfigResult" );
|
||||
type = type.Replace( "SteamInputType", "InputType" );
|
||||
|
||||
return type;
|
||||
}
|
||||
@ -75,6 +76,7 @@ public static class Cleanup
|
||||
if ( name == "P2PSend" ) return "public";
|
||||
if ( name == "RoomEnter" ) return "public";
|
||||
if ( name == "P2PSessionError" ) return "public";
|
||||
if ( name == "InputType" ) return "public";
|
||||
|
||||
return "internal";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user