public Vector2 GetAxis(WVR_InputId _id) { if (!this._connected) { return(Vector2.zero); } bool _isTouchId = false; for (int _t = 0; _t < touchIds.Length; _t++) { if (_id == touchIds [_t]) { _isTouchId = true; break; } } if (!_isTouchId) { Log.e(LOG_TAG, "GetAxis, button " + _id + " does NOT have axis!"); return(Vector2.zero); } axis = Interop.WVR_GetInputAnalogAxis(DeviceType, _id); //Log.d (LOG_TAG, "GetAxis: {" + axis.x + ", " + axis.y + "}"); return(new Vector2(axis.x, axis.y)); }
private Vector2 GetAxis(WVR_AnalogState_t[] analogArray, WVR_InputId _id, WVR_AnalogType aType, int _count) { Vector2 axis = Vector2.zero; if (_count > 0) { for (int i = 0; i < _count; i++) { if (analogArray [i].id == _id && analogArray [i].type == aType) { axis.x = analogArray [i].axis.x; axis.y = _id == WVR_InputId.WVR_InputId_Alias1_Trigger ? 0 : analogArray [i].axis.y; // trigger does NOT have y value //if (Log.FLAG_BUTTON) // Log.d (LOG_TAG, "button " + _id + " x=" + axis.x + ", y=" + axis.y); break; } else { Log.e(LOG_TAG, "GetAxis() states unsynchronized! device: " + device + ", analogArray[" + i + "].id: " + analogArray [i].id + ", analogArray[" + i + "].type]: " + analogArray [i].type); } } } else { Log.e(LOG_TAG, "GetAxis() no axis!!"); } return(axis); }
private int GetTouchInputMapping(int touchIds_Index, keyMappingInputType status) { WVR_InputId _btn = touchIds[touchIds_Index]; bool _result = WaveVR_ButtonList.Instance.GetInputMappingPair(this.device, ref _btn); if (!_result) { PrintInfoLog("GetInputMappingPair failed."); return(-1); } int _index = -1; for (int i = 0; i < touchIds.Length; i++) { if (_btn == touchIds[i]) { _index = i; break; } } if (_index >= 0 && _index < touchIds.Length) { PrintInfoLog(status.ToString() + " button: " + touchIds[touchIds_Index] + " is mapped to " + _btn); } else { PrintInfoLog("Can't get index in touchIds."); } return(_index); }
public bool GetInputMappingPair(WaveVR_Controller.EDeviceType device, ref WVR_InputId destination) { if (!WaveVR.Instance.Initialized) { return(false); } // Default true in editor mode, destination will be equivallent to source. bool _result = true; WVR_DeviceType _type = WaveVR_Controller.Input(device).DeviceType; /* * uint _ret = Interop.WVR_GetInputMappingTable (_type, this.inputTable, WaveVR_ButtonList.inputTableSize); * for (int _i = 0; _i < (int)_ret; _i++) * { * PrintDebugLog ("GetInputMappingPair " + device + " table: " + _type + " " + this.inputTable [_i].source.id + " to " + inputTable [_i].destination.id); * if (this.inputTable [_i].destination.id == destination) * { * destination = this.inputTable [_i].source.id; * _result = true; * break; * } * } */ _result = Interop.WVR_GetInputMappingPair(_type, destination, ref this.inputPair); if (_result) { destination = this.inputPair.source.id; } return(_result); }
public Vector2 GetAxis(WVR_InputId _id) { if (!connected) { return(Vector2.zero); } if (_id != WVR_InputId.WVR_InputId_Alias1_Touchpad && _id != WVR_InputId.WVR_InputId_Alias1_Trigger) { Log.e(LOG_TAG, "GetAxis, button " + _id + " does NOT have axis!"); return(Vector2.zero); } #if UNITY_EDITOR || UNITY_STANDALONE if (isEditorMode) { var system = WaveVR_PoseSimulator.Instance; axis = system.GetAxis(DeviceType, _id); } else #endif { axis = Interop.WVR_GetInputAnalogAxis(DeviceType, _id); } //Log.d (LOG_TAG, "GetAxis: {" + axis.x + ", " + axis.y + "}"); return(new Vector2(axis.x, axis.y)); }
private void Update_TouchState(WVR_InputId _id) { if (AllowTouchActionInAFrame(_id)) { bool _touched = false; #if UNITY_EDITOR || UNITY_STANDALONE if (isEditorMode && !WaveVR.Instance.isSimulatorOn) { var system = WaveVR_PoseSimulator.Instance; _touched = system.GetButtonTouchState(DeviceType, _id); } else #endif { _touched = GetEventState_Touch(_id); /* * if(this._connected) * _touched = Interop.WVR_GetInputTouchState (DeviceType, _id); * if (_touched) * Log.gpl.d (LOG_TAG, "Update_TouchState(), " + DeviceType + " " + _id + " is touched." + "left-handed? " + IsLeftHanded); */ } for (int _t = 0; _t < touchIds.Length; _t++) { if (_id == touchIds [_t]) { prevState_touch [_t] = state_touch [_t]; state_touch [_t] = _touched; } } } }
/// <summary> /// Triggers the haptic pulse. /// This function is for vibrating 1 time during the "durationMicroSec" micro seconds with normal strength. /// For changing the frequency or the strength, please use "TriggerVibration" instead. /// </summary> /// <param name="_durationMicroSec">Duration micro sec.</param> /// <param name="_id">Identifier.</param> public void TriggerHapticPulse( uint durationMicroSec = 1000000, WVR_InputId id = WVR_InputId.WVR_InputId_Alias1_Touchpad ) { TriggerVibration(id, durationMicroSec, 1, WVR_Intensity.WVR_Intensity_Normal); }
public void TriggerHapticPulse( uint _durationMicroSec = 1000000, WVR_InputId _id = WVR_InputId.WVR_InputId_Alias1_Touchpad ) { WaveVR_Controller.Input(this.DeviceType).TriggerHapticPulse(); }
/// <summary> /// Check if button state is equivallent to specified state. /// </summary> /// <returns><c>true</c>, equal, <c>false</c> otherwise.</returns> /// <param name="_id">input button</param> public bool GetPress(WVR_InputId _id) { bool _state = false; switch (_id) { case WVR_InputId.WVR_InputId_Alias1_Menu: _state = (state.BtnPressed & Input_Mask_Menu) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_Grip: _state = (state.BtnPressed & Input_Mask_Grip) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_Touchpad: _state = (state.BtnPressed & Input_Mask_Touchpad) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_Trigger: _state = (state.BtnPressed & Input_Mask_Trigger) != 0 ? true : false; break; default: break; } return(_state); }
public bool GetInputButtonState(WVR_DeviceType type, WVR_InputId id) { bool pressed = false; switch (type) { case WVR_DeviceType.WVR_DeviceType_Controller_Right: for (int _p = 0; _p < pressIds.Length; _p++) { if (id == pressIds [_p]) { pressed = state_press_right [_p]; break; } } break; case WVR_DeviceType.WVR_DeviceType_Controller_Left: for (int _p = 0; _p < pressIds.Length; _p++) { if (id == pressIds [_p]) { pressed = state_press_left [_p]; break; } } break; default: break; } return(pressed); }
public bool GetInputTouchState(WVR_DeviceType type, WVR_InputId id) { bool touched = false; switch (type) { case WVR_DeviceType.WVR_DeviceType_Controller_Right: for (int _t = 0; _t < touchIds.Length; _t++) { if (id == touchIds [_t]) { touched = state_touch_right [_t]; break; } } break; case WVR_DeviceType.WVR_DeviceType_Controller_Left: for (int _t = 0; _t < touchIds.Length; _t++) { if (id == touchIds [_t]) { touched = state_touch_left [_t]; break; } } break; default: break; } return(touched); }
private void Update_PressState(WVR_InputId _id) { if (AllowPressActionInAFrame(_id)) { bool _pressed = false; #if UNITY_EDITOR || UNITY_STANDALONE if (isEditorMode && !WaveVR.Instance.isSimulatorOn) { var system = WaveVR_PoseSimulator.Instance; _pressed = system.GetButtonPressState(DeviceType, _id); } else #endif { _pressed = GetEventState_Press(_id); /* * if (this._connected) * _pressed = Interop.WVR_GetInputButtonState (DeviceType, _id); * if (_pressed) * Log.gpl.d (LOG_TAG, "Update_PressState(), " + DeviceType + " " + _id + " is pressed." + "left-handed? " + IsLeftHanded); */ } for (int _p = 0; _p < pressIds.Length; _p++) { if (_id == pressIds [_p]) { prevState_press [_p] = state_press [_p]; state_press [_p] = _pressed; } } } }
public bool GetInputMappingPair(WVR_DeviceType type, WVR_InputId destination, ref WVR_InputMappingPair_t pair) { WVR_InputMappingPair_t[] inputTable = new WVR_InputMappingPair_t[10]; switch (type) { case WVR_DeviceType.WVR_DeviceType_HMD: inputTable = inputTable_Hmd; break; case WVR_DeviceType.WVR_DeviceType_Controller_Right: inputTable = inputTable_Right; break; case WVR_DeviceType.WVR_DeviceType_Controller_Left: inputTable = inputTable_Left; break; default: break; } for (int i = 0; i < inputTable.Length; i++) { if (destination == inputTable [i].destination.id) { pair.source = inputTable [i].source; pair.destination = inputTable [i].destination; return(true); } } return(false); }
private void Update_TouchState(WVR_InputId _id) { if (AllowTouchActionInAFrame(_id)) { bool _touched = false; #if UNITY_EDITOR || UNITY_STANDALONE if (isEditorMode) { var system = WaveVR_PoseSimulator.Instance; _touched = system.GetButtonTouchState(DeviceType, _id); } else #endif { _touched = Interop.WVR_GetInputTouchState(DeviceType, _id); } for (int _t = 0; _t < touchIds.Length; _t++) { if (_id == touchIds [_t]) { prevState_touch [_t] = state_touch [_t]; state_touch [_t] = _touched; } } } }
private int GetPressInputMapping(int pressIds_Index, keyMappingInputType status) { WVR_InputId _btn = pressIds[pressIds_Index]; bool _result = WaveVR_ButtonList.Instance != null?WaveVR_ButtonList.Instance.GetInputMappingPair(this.device, ref _btn) : false; if (!_result) { PrintInfoLog("GetInputMappingPair failed[" + pressIds[pressIds_Index] + "]."); return(-1); } int _index = -1; for (int i = 0; i < pressIds.Length; i++) { if (pressObjectArrays[i].hasEffect && _btn == pressIds[i]) { _index = i; break; } } if (_index >= 0 && _index < pressIds.Length) { PrintInfoLog(status.ToString() + " button: " + pressIds[pressIds_Index] + " is mapped to " + _btn); } else { PrintInfoLog("Can't get index in pressIds."); } return(_index); }
private void updateDpadPressText() { if (this.dpad_press_text == null) { return; } WVR_DeviceType _type = WaveVR_Controller.Input(this.DeviceType).DeviceType; foreach (WVR_InputId _dpadId in this.dpadIds) { if (WaveVR_ButtonList.Instance != null && WaveVR_ButtonList.Instance.IsButtonAvailable(this.DeviceType, _dpadId)) { if (WaveVR_Controller.Input(this.DeviceType).GetPressDown(_dpadId)) { this.dpad_press_text.text = _dpadId.ToString(); PrintDebugLog("updateDpadPressText() " + _dpadId + " is pressed down."); WVR_InputId _btn = _dpadId; bool _result = WaveVR_ButtonList.Instance.GetInputMappingPair(this.DeviceType, ref _btn); if (_result) { PrintDebugLog("updateDpadPressText() " + _dpadId + " is mapping from " + _type + " button " + _btn); } } if (WaveVR_Controller.Input(this.DeviceType).GetPressUp(_dpadId)) { this.dpad_press_text.text = ""; PrintDebugLog("updateDpadPressText() " + _dpadId + " is pressed up."); } } } }
/// <summary> /// If true, button with _id is touched, else untouched.. /// </summary> /// <returns><c>true</c>, if touch was gotten, <c>false</c> otherwise.</returns> /// <param name="_id">WVR_ButtonId, id of button</param> public bool GetTouchUp(WVR_InputId _id) { bool _state = false; Update_TouchState(_id); switch (_id) { case WVR_InputId.WVR_InputId_Alias1_Touchpad: _state = ( (((state.BtnTouched & Input_Mask_Touchpad) == 0) && ((pre_state.BtnTouched & Input_Mask_Touchpad) != 0)) ? true : false); break; case WVR_InputId.WVR_InputId_Alias1_Trigger: _state = ( (((state.BtnTouched & Input_Mask_Trigger) == 0) && ((pre_state.BtnTouched & Input_Mask_Trigger) != 0)) ? true : false); break; default: break; } return(_state); }
/// <summary> /// Check if button state is equivallent to specified state. /// </summary> /// <returns><c>true</c>, equal, <c>false</c> otherwise.</returns> /// <param name="_id">input button</param> public bool GetPress(WVR_InputId _id) { bool _state = false; Update_PressState(_id); switch (_id) { case WVR_InputId.WVR_InputId_Alias1_Menu: _state = (state.BtnPressed & Input_Mask_Menu) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_Grip: _state = (state.BtnPressed & Input_Mask_Grip) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_DPad_Left: _state = (state.BtnPressed & Input_Mask_DPad_Left) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_DPad_Up: _state = (state.BtnPressed & Input_Mask_DPad_Up) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_DPad_Right: _state = (state.BtnPressed & Input_Mask_DPad_Right) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_DPad_Down: _state = (state.BtnPressed & Input_Mask_DPad_Down) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_Volume_Up: _state = (state.BtnPressed & Input_Mask_Volume_Up) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_Volume_Down: _state = (state.BtnPressed & Input_Mask_Volume_Down) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_Touchpad: _state = (state.BtnPressed & Input_Mask_Touchpad) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_Trigger: _state = (state.BtnPressed & Input_Mask_Trigger) != 0 ? true : false; break; case WVR_InputId.WVR_InputId_Alias1_Bumper: _state = (state.BtnPressed & Input_Mask_Bumper) != 0 ? true : false; break; default: break; } return(_state); }
public Vector2 GetAxis(WVR_InputId _id) { if (_id != WVR_InputId.WVR_InputId_Alias1_Touchpad && _id != WVR_InputId.WVR_InputId_Alias1_Trigger) { Log.e(LOG_TAG, "GetAxis, button " + _id + " does NOT have axis!"); return(Vector2.zero); } bool _connected = false; WVR_DeviceType _type = this.DeviceType; #if UNITY_EDITOR || UNITY_STANDALONE if (isEditorMode) { _connected = WaveVR_Controller.Input(this.DeviceType).connected; _type = WaveVR_Controller.Input(this.DeviceType).DeviceType; } else #endif { if (WaveVR.Instance != null) { WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.DeviceType); _connected = _device.connected; _type = _device.type; } } #if UNITY_EDITOR || UNITY_STANDALONE if (isEditorMode) { if (!WaveVR.Instance.isSimulatorOn) { var system = WaveVR_PoseSimulator.Instance; axis = system.GetAxis(_type, WVR_InputId.WVR_InputId_Alias1_Trigger); } else { if (_connected) { axis = WaveVR_Utils.WVR_GetInputAnalogAxis_S((int)_type, (int)_id); } } } else #endif { if (_connected) { axis = Interop.WVR_GetInputAnalogAxis(_type, _id); } } //Log.d (LOG_TAG, "GetAxis: {" + axis.x + ", " + axis.y + "}"); return(new Vector2(axis.x, axis.y)); }
public Vector2 GetAxis(WVR_InputId _id) { if (_id != WVR_InputId.WVR_InputId_Alias1_Touchpad && _id != WVR_InputId.WVR_InputId_Alias1_Trigger) { Log.e(LOG_TAG, "GetAxis, button " + _id + " does NOT have axis!"); return(Vector2.zero); } return(WaveVR_Controller.Input(this.DeviceType).GetAxis(_id)); }
public Vector2 GetAxis(WVR_InputId btn) { // No axis if disconnected or untouched. if (!_connected || !GetTouch(btn)) { return(Vector2.zero); } axis = Interop.WVR_GetInputAnalogAxis(DeviceType, btn); return(new Vector2(axis.x, axis.y)); }
public void SetEventState_Press(WVR_InputId btn, bool down) { for (int _p = 0; _p < pressIds.Length; _p++) { if (pressIds [_p] == btn) { event_state_press [_p] = down; Log.d(LOG_TAG, "SetEventState_Press() " + this.DeviceType + ", " + pressIds [_p] + ": " + event_state_press [_p]); break; } } }
public void TriggerHapticPulse( uint _durationMicroSec = 1000000, WVR_InputId _id = WVR_InputId.WVR_InputId_Alias1_Touchpad ) { if (!this.connected) { return; } Interop.WVR_TriggerVibration(DeviceType, _id, _durationMicroSec, 1, WVR_Intensity.WVR_Intensity_Normal); }
public void SetEventState_Touch(WVR_InputId btn, bool down) { for (int _t = 0; _t < touchIds.Length; _t++) { if (touchIds [_t] == btn) { event_state_touch [_t] = down; Log.d(LOG_TAG, "SetEventState_Touch() " + this.DeviceType + ", " + touchIds [_t] + ": " + event_state_touch [_t]); break; } } }
public bool GetInputMappingPair(WaveVR_Controller.EDeviceType device, ref EButtons destination) { bool _result = false; WVR_InputId _wbtn = (WVR_InputId)destination; _result = GetInputMappingPair(device, ref _wbtn); if (_result) { destination = GetEButtonsType(_wbtn); } return(_result); }
/// <summary> /// Triggers the vibration. /// </summary> /// <param name="id">Button ID.</param> /// <param name="durationMicroSec">Duration micro sec.</param> /// <param name="frequency">Frequency.</param> /// <param name="intensity">Vibration strength.</param> public void TriggerVibration( WVR_InputId id, uint durationMicroSec, uint frequency, WVR_Intensity intensity) { if (!this.connected) { return; } Interop.WVR_TriggerVibration(DeviceType, id, durationMicroSec, frequency, intensity); }
public bool GetInputMappingPair(WaveVR_Controller.EDeviceType device, ref WaveVR_ButtonList.EButtons destination) { WVR_InputId id = (WVR_InputId)destination; bool ret = GetInputMappingPair(device, ref id); if (ret) { destination = GetEButtonsType(id); } return(ret); }
private void _UpdateCanvas(WVR_DeviceType type, bool isDeviceConnected) { PrintDebugLog("_UpdateCanvas" + " type=" + type + " isDeviceConnected=" + isDeviceConnected); #if UNITY_ANDROID && !UNITY_EDITOR if (isDeviceConnected && (type == WVR_DeviceType.WVR_DeviceType_Controller_Left || type == WVR_DeviceType.WVR_DeviceType_Controller_Right)) { int mask_btn = Interop.WVR_GetInputDeviceCapability(type, WVR_InputType.WVR_InputType_Button); string mask_base2 = Convert.ToString(mask_btn, 2); PrintDebugLog("type=" + type + " mask_btn=" + mask_btn + " mask_base2=" + mask_base2); for (WVR_InputId id = WVR_InputId.WVR_InputId_0; id < WVR_InputId.WVR_InputId_Max; id++) { GameObject go = _FindGO(type, id); if (go) { //set unsupported button gray if ((mask_btn & (1 << (int)id)) == 0) { go.GetComponent <Image> ().color = Color.gray; } else { go.GetComponent <Image> ().color = Color.white; } } } //special treatment of digital trigger and trigger GameObject go_trigger = _FindGO(type, WVR_InputId.WVR_InputId_Alias1_Trigger); if (go_trigger) { if ((mask_btn & ((1 << (int)WVR_InputId.WVR_InputId_Alias1_Digital_Trigger) | (1 << (int)WVR_InputId.WVR_InputId_Alias1_Trigger))) == 0) { go_trigger.GetComponent <Image> ().color = Color.gray; } else { go_trigger.GetComponent <Image> ().color = Color.white; } } } #endif //set active state of the left or right canvas according to the connected state if (m_type2Canvas.ContainsKey(type)) { if (m_type2Canvas [type]) { m_type2Canvas [type].SetActive(isDeviceConnected); } } }
private GameObject _FindGO(WVR_DeviceType type, WVR_InputId id) { GameObject go = null; if (m_type2Dict.ContainsKey(type)) { if (m_type2Dict[type].ContainsKey(id)) { go = m_type2Dict [type] [id]; } } return(go); }
public bool GetEventState_Touch(WVR_InputId btn) { bool _touch = false; for (int _t = 0; _t < touchIds.Length; _t++) { if (touchIds [_t] == btn) { _touch = event_state_touch [_t]; break; } } return(_touch); }