123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- using System;
- using UnityEngine;
- public class OvrControllerButtons : AVRControllerButtons
- {
- protected override void Awake()
- {
- base.Awake();
- this.m_eType = AVRControllerButtons.TYPE.TOUCH;
- this.m_goHandModel = base.transform.Find("HandPlayer").gameObject;
- }
- public override bool ShowHand
- {
- get
- {
- return this.m_goHandModel.activeSelf;
- }
- set
- {
- this.m_goHandModel.SetActive(value);
- }
- }
- public override void Haptic(byte f_byFoce, float f_fTime)
- {
- byte[] array = new byte[(int)(320f * f_fTime)];
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = f_byFoce;
- }
- this.m_HapticsClip = new OVRHapticsClip(array, array.Length);
- if (this.m_bHandL)
- {
- OVRHaptics.LeftChannel.Mix(this.m_HapticsClip);
- }
- else
- {
- OVRHaptics.RightChannel.Mix(this.m_HapticsClip);
- }
- }
- public override bool GetPressDown(AVRControllerButtons.BTN f_eBtn)
- {
- if (f_eBtn != AVRControllerButtons.BTN.VIRTUAL_GRUB)
- {
- return OVRInput.GetDown((OVRInput.RawButton)this.m_aryBtn2RealOvr[(int)f_eBtn, (!this.m_bHandL) ? 1 : 0], OVRInput.Controller.Active);
- }
- if (this.m_bHandL)
- {
- return (OVRInput.GetDown(OVRInput.RawButton.LHandTrigger, OVRInput.Controller.Active) && OVRInput.GetDown(OVRInput.RawButton.LIndexTrigger, OVRInput.Controller.Active)) || (!OVRInput.Get(OVRInput.RawButton.LHandTrigger, OVRInput.Controller.Active) && OVRInput.GetDown(OVRInput.RawButton.LIndexTrigger, OVRInput.Controller.Active)) || (!OVRInput.Get(OVRInput.RawButton.LIndexTrigger, OVRInput.Controller.Active) && OVRInput.GetDown(OVRInput.RawButton.LHandTrigger, OVRInput.Controller.Active));
- }
- return (OVRInput.GetDown(OVRInput.RawButton.RHandTrigger, OVRInput.Controller.Active) && OVRInput.GetDown(OVRInput.RawButton.RIndexTrigger, OVRInput.Controller.Active)) || (!OVRInput.Get(OVRInput.RawButton.RHandTrigger, OVRInput.Controller.Active) && OVRInput.GetDown(OVRInput.RawButton.RIndexTrigger, OVRInput.Controller.Active)) || (!OVRInput.Get(OVRInput.RawButton.RIndexTrigger, OVRInput.Controller.Active) && OVRInput.GetDown(OVRInput.RawButton.RHandTrigger, OVRInput.Controller.Active));
- }
- public override bool GetPress(AVRControllerButtons.BTN f_eBtn)
- {
- if (f_eBtn == AVRControllerButtons.BTN.VIRTUAL_GRUB)
- {
- return (!this.m_bHandL) ? (OVRInput.Get(OVRInput.RawButton.RHandTrigger, OVRInput.Controller.Active) || OVRInput.Get(OVRInput.RawButton.RIndexTrigger, OVRInput.Controller.Active)) : (OVRInput.Get(OVRInput.RawButton.LHandTrigger, OVRInput.Controller.Active) || OVRInput.Get(OVRInput.RawButton.LIndexTrigger, OVRInput.Controller.Active));
- }
- return OVRInput.Get((OVRInput.RawButton)this.m_aryBtn2RealOvr[(int)f_eBtn, (!this.m_bHandL) ? 1 : 0], OVRInput.Controller.Active);
- }
- public override bool GetPressUp(AVRControllerButtons.BTN f_eBtn)
- {
- if (f_eBtn == AVRControllerButtons.BTN.VIRTUAL_GRUB)
- {
- return (!this.m_bHandL) ? ((!OVRInput.Get(OVRInput.RawButton.RIndexTrigger, OVRInput.Controller.Active) && OVRInput.GetUp(OVRInput.RawButton.RHandTrigger, OVRInput.Controller.Active)) || (!OVRInput.Get(OVRInput.RawButton.RHandTrigger, OVRInput.Controller.Active) && OVRInput.GetUp(OVRInput.RawButton.RIndexTrigger, OVRInput.Controller.Active))) : ((!OVRInput.Get(OVRInput.RawButton.LIndexTrigger, OVRInput.Controller.Active) && OVRInput.GetUp(OVRInput.RawButton.LHandTrigger, OVRInput.Controller.Active)) || (!OVRInput.Get(OVRInput.RawButton.LHandTrigger, OVRInput.Controller.Active) && OVRInput.GetUp(OVRInput.RawButton.LIndexTrigger, OVRInput.Controller.Active)));
- }
- return OVRInput.GetUp((OVRInput.RawButton)this.m_aryBtn2RealOvr[(int)f_eBtn, (!this.m_bHandL) ? 1 : 0], OVRInput.Controller.Active);
- }
- public override bool GetTouchDown(AVRControllerButtons.TOUCH f_eTouch)
- {
- return OVRInput.GetDown((OVRInput.RawTouch)this.m_aryTouch2RealOvr[(int)f_eTouch, (!this.m_bHandL) ? 1 : 0], OVRInput.Controller.Active);
- }
- public override bool GetTouch(AVRControllerButtons.TOUCH f_eTouch)
- {
- return OVRInput.Get((OVRInput.RawTouch)this.m_aryTouch2RealOvr[(int)f_eTouch, (!this.m_bHandL) ? 1 : 0], OVRInput.Controller.Active);
- }
- public override bool GetTouchUp(AVRControllerButtons.TOUCH f_eTouch)
- {
- return OVRInput.GetUp((OVRInput.RawTouch)this.m_aryTouch2RealOvr[(int)f_eTouch, (!this.m_bHandL) ? 1 : 0], OVRInput.Controller.Active);
- }
- public override Vector2 GetAxis()
- {
- return OVRInput.Get((!this.m_bHandL) ? OVRInput.RawAxis2D.RThumbstick : OVRInput.RawAxis2D.LThumbstick, OVRInput.Controller.Active);
- }
- public override float GetTriggerRate()
- {
- if (this.m_bHandL)
- {
- return OVRInput.Get(OVRInput.RawAxis1D.LIndexTrigger, OVRInput.Controller.Active);
- }
- return OVRInput.Get(OVRInput.RawAxis1D.RIndexTrigger, OVRInput.Controller.Active);
- }
- private void Update()
- {
- }
- private uint[,] m_aryBtn2RealOvr = new uint[,]
- {
- {
- 512U,
- 2U
- },
- {
- 256U,
- 1U
- },
- {
- 1024U,
- 4U
- },
- {
- 536870912U,
- 134217728U
- },
- {
- 1048576U,
- 1048576U
- },
- {
- 268435456U,
- 67108864U
- },
- {
- 1024U,
- 4U
- },
- {
- 536870912U,
- 134217728U
- }
- };
- private uint[,] m_aryTouch2RealOvr = new uint[,]
- {
- {
- 4096U,
- 16U
- },
- {
- 1024U,
- 4U
- },
- {
- 2048U,
- 8U
- },
- {
- 512U,
- 2U
- },
- {
- 256U,
- 1U
- }
- };
- private GameObject m_goHandModel;
- private OVRHapticsClip m_HapticsClip;
- }
|