4dad9e5d5b
- BeatSageUploader: audio_url 지원(UploadFromUrl), PollAndDownload 공통화, ZIP 500 오류 3회 재시도 - BeatSageConverter: info.dat 파싱(SongMetadata), BPM 자동 감지 → 노트 타이밍 변환에 적용 - SongCreatorManager: title/BPM 필수 입력 제거, 난이도 4개 자동 선택, GenerateFlowFromUrl 버그 수정 - NasPublisher: audioPath null 허용(URL 흐름에서 로컬 파일 없는 경우 스킵) - .gitignore/.gitattributes 초기 설정 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
181 lines
6.0 KiB
C#
181 lines
6.0 KiB
C#
using System;
|
|
using UnityEngine;
|
|
#if SDK_STEAM_VR
|
|
using Valve.VR;
|
|
#endif
|
|
|
|
namespace VRSDK
|
|
{
|
|
public class VR_SteamVRInput : VR_InputDevice
|
|
{
|
|
#if SDK_STEAM_VR
|
|
private SteamVR_Action_Single grabAction = null;
|
|
private SteamVR_Action_Boolean triggerAction = null;
|
|
private SteamVR_Action_Boolean primaryButtonAction = null;
|
|
private SteamVR_Action_Boolean secondaryButtonAction = null;
|
|
private SteamVR_Action_Boolean joystickPressAction = null;
|
|
private SteamVR_Action_Vector2 joystickInputAction = null;
|
|
|
|
|
|
public SteamVR_Input_Sources SteamControllerType { get { return InputController.ControllerType == VR_ControllerType.Right ? SteamVR_Input_Sources.RightHand : SteamVR_Input_Sources.LeftHand; } }
|
|
|
|
private bool isConnected = false;
|
|
#endif
|
|
|
|
public VR_SteamVRInput(VR_Controller controller) : base(controller)
|
|
{
|
|
#if SDK_STEAM_VR
|
|
InitializeSteamVR_Actions();
|
|
|
|
SteamVR_Behaviour_Pose steamController = controller.GetComponentInParent<SteamVR_Behaviour_Pose>();
|
|
steamController.onConnectedChanged.AddListener(delegate (SteamVR_Behaviour_Pose poseController, SteamVR_Input_Sources sources, bool state) { isConnected = state; });
|
|
#endif
|
|
}
|
|
|
|
#if SDK_STEAM_VR
|
|
private void InitializeSteamVR_Actions()
|
|
{
|
|
grabAction = SteamVR_Input.GetAction<SteamVR_Action_Single>("VRShooterKit", "Grab");
|
|
triggerAction = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("VRShooterKit", "Shoot");
|
|
primaryButtonAction = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("VRShooterKit", "PrimaryButton");
|
|
secondaryButtonAction = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("VRShooterKit", "SecondaryButton");
|
|
joystickPressAction = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("VRShooterKit", "JoystickPress");
|
|
joystickInputAction = SteamVR_Input.GetAction<SteamVR_Action_Vector2>("VRShooterKit", "Joystick");
|
|
}
|
|
#endif
|
|
|
|
public override float GetAxis1D(VR_InputButton button)
|
|
{
|
|
#if SDK_STEAM_VR
|
|
switch (button)
|
|
{
|
|
|
|
case VR_InputButton.Trigger:
|
|
return GetButton(button) ? 1.0f : 0.0f;
|
|
|
|
case VR_InputButton.Grip:
|
|
return grabAction.GetAxis(SteamControllerType);
|
|
}
|
|
#endif
|
|
|
|
return 0.0f;
|
|
}
|
|
|
|
public override bool GetButton(VR_InputButton button)
|
|
{
|
|
#if SDK_STEAM_VR
|
|
switch (button)
|
|
{
|
|
case VR_InputButton.Trigger:
|
|
return triggerAction.GetState(SteamControllerType);
|
|
|
|
case VR_InputButton.Grip:
|
|
return grabAction.GetAxis(SteamControllerType) > 0.65f;
|
|
|
|
case VR_InputButton.Primary:
|
|
return primaryButtonAction.GetState(SteamControllerType);
|
|
|
|
case VR_InputButton.Secondary:
|
|
return secondaryButtonAction.GetState(SteamControllerType);
|
|
case VR_InputButton.TumbstickPress:
|
|
return joystickPressAction.GetState(SteamControllerType);
|
|
}
|
|
#endif
|
|
return false;
|
|
}
|
|
|
|
public override bool GetButtonDown(VR_InputButton button)
|
|
{
|
|
#if SDK_STEAM_VR
|
|
switch (button)
|
|
{
|
|
case VR_InputButton.Trigger:
|
|
return triggerAction.GetStateDown(SteamControllerType);
|
|
|
|
case VR_InputButton.Grip:
|
|
return grabAction.GetAxis(SteamControllerType) > 0.65f;
|
|
|
|
case VR_InputButton.Primary:
|
|
return primaryButtonAction.GetStateDown(SteamControllerType);
|
|
|
|
case VR_InputButton.Secondary:
|
|
return secondaryButtonAction.GetStateDown(SteamControllerType);
|
|
case VR_InputButton.TumbstickPress:
|
|
return joystickPressAction.GetStateDown(SteamControllerType);
|
|
}
|
|
#endif
|
|
return false;
|
|
}
|
|
|
|
public override bool GetButtonUp(VR_InputButton button)
|
|
{
|
|
#if SDK_STEAM_VR
|
|
switch (button)
|
|
{
|
|
case VR_InputButton.Trigger:
|
|
return triggerAction.GetStateUp(SteamControllerType);
|
|
|
|
case VR_InputButton.Grip:
|
|
return grabAction.GetAxis(SteamControllerType) > 0.65f;
|
|
|
|
case VR_InputButton.Primary:
|
|
return primaryButtonAction.GetStateUp(SteamControllerType);
|
|
|
|
case VR_InputButton.Secondary:
|
|
return secondaryButtonAction.GetStateUp(SteamControllerType);
|
|
case VR_InputButton.TumbstickPress:
|
|
return joystickPressAction.GetStateUp(SteamControllerType);
|
|
}
|
|
#endif
|
|
|
|
return false;
|
|
}
|
|
|
|
public override string GetDeviceName()
|
|
{
|
|
#if SDK_STEAM_VR
|
|
return SteamControllerType.ToString();
|
|
#endif
|
|
|
|
return "";
|
|
}
|
|
|
|
public override Vector2 GetJoystick()
|
|
{
|
|
#if SDK_STEAM_VR
|
|
return joystickInputAction.GetAxis(SteamControllerType);
|
|
#endif
|
|
|
|
return Vector2.zero;
|
|
}
|
|
|
|
public override bool IsConnected()
|
|
{
|
|
#if SDK_STEAM_VR
|
|
return isConnected;
|
|
#endif
|
|
|
|
return false;
|
|
}
|
|
|
|
public override Quaternion GetRotationOffset()
|
|
{
|
|
return Quaternion.identity;
|
|
}
|
|
|
|
public override Vector3 GetPositionOffset()
|
|
{
|
|
return Vector3.zero;
|
|
}
|
|
|
|
public override Enum GetControllerType()
|
|
{
|
|
#if SDK_STEAM_VR
|
|
return SteamControllerType;
|
|
#endif
|
|
|
|
return default;
|
|
}
|
|
}
|
|
}
|