私のスチームコントローラーは今日到着し、スチームコントローラーのボタンが押されているかどうかをチェックするコードを実装しようとしていました. Steamworks.NET ラッパーを使用しています。しかし、どういうわけか GetControllerState は常に 0 を返し、その理由はわかりません。何か案は?
これは私のコードです:
Dim SteamAPI_Initialized As Boolean
Dim Controller_Initialized As Boolean
Private Sub OnEnable()
SteamAPI_Initialized = Steamworks.SteamAPI.Init()
If SteamAPI_Initialized Then
Controller_Initialized = Steamworks.SteamController.Init("C:\Users\User\AppData\Local\Temporary Projects\WindowsApplication1\bin\Debug\controller.vdf")
End If
If Not SteamAPI_Initialized Then
MsgBox("Failed to initialize SteamAPI!")
ElseIf Not Controller_Initialized Then
MsgBox("Failed to initialize SteamController!")
End If
End Sub
Private Sub OnDisable()
If Controller_Initialized Then
Steamworks.SteamController.Shutdown()
End If
If SteamAPI_Initialized Then
Steamworks.SteamAPI.Shutdown()
End If
End Sub
Private state As New Steamworks.SteamControllerState_t
Private Sub CH_Button1_Click(sender As Object, e As EventArgs) Handles CH_Button1.Click
OnEnable()
Timer1.Enabled = True
End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
OnDisable()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If Controller_Initialized Then
Steamworks.SteamAPI.RunCallbacks()
Steamworks.SteamController.RunFrame()
If Steamworks.SteamController.GetControllerState(0, state) Then 'always returns 0
If (state.ulButtons And Steamworks.Constants.STEAM_BUTTON_LEFTPAD_CLICKED_MASK) <> 0 Then
MsgBox("RIGHT_TRIGGER")
End If
End If
End If
End Sub