public void OnSelectedInputChanged() { var devNumber = InputSources.IndexOf(SelectedInput.Value); DataMaster.Setting.DevNumber = devNumber; DataMaster.Setting.MicChanel = SelectedInput.Value.Channels; }
public AvatarSelectionCarouselDialog(InputProcessorBase inputProcessor, RaceStartScene.AvatarSelectionButtonHandler sceneButtonHandler, Scene.ObjectRegistrationHandler registrationHandler, Scene.ObjectUnregistrationHandler unregistrationHandler) : base(registrationHandler, unregistrationHandler) { ActionButtonPressHandler = SelectionHandler; InputSources.Add(inputProcessor); Height = Dialog_Height; CarouselCenter = new Vector2(Definitions.Back_Buffer_Center.X, Carousel_Center_Y); CarouselRadii = new Vector2(Carousel_Horizontal_Radius, Carousel_Vertical_Radius); _itemRenderDepths = new Range(Minimum_Item_Render_Depth, Maximum_Item_Render_Depth); _itemScales = new Range(Minimum_Item_Scale, Maximum_Item_Scale); _inputProcessor = inputProcessor; _sendButtonActionToScene = sceneButtonHandler; _captionsForButtonsNotActivatedByGamepadStartButton.Add("Back"); AddIconButton("previous", new Vector2(Definitions.Back_Buffer_Center.X - 450, 175), Button.ButtonIcon.Previous, Color.DodgerBlue); AddIconButton("next", new Vector2(Definitions.Back_Buffer_Center.X + 450, 175), Button.ButtonIcon.Next, Color.DodgerBlue); AddButton("Back", new Vector2(Definitions.Left_Button_Column_X, 325), Button.ButtonIcon.Back, Color.DodgerBlue, 0.7f); AddButton("Select", new Vector2(Definitions.Right_Button_Column_X, 325), Button.ButtonIcon.Play, Color.LawnGreen, 0.7f); SetupButtonLinkagesAndDefaultValues(); registrationHandler(this); }
public bool Parse(byte[] report) { if (report[0] != 0 || report[1] != 0x047 || report.Length != 9) { return(false); } VersionMajor = report[2] >> 4; VersionMinor = report[2] & 0x0f; HardwareRevision = report[3] & 0x0f; DevType = (DeviceType)(report[3] >> 4); var v = new Version(VersionMajor, VersionMinor); if (v >= Version.Parse("1.5")) { IsLegacy = false; Output = (OutputMode)report[4]; Inputs = (InputSources)report[5]; } else { IsLegacy = true; NGC = (NGCMode)report[4]; N64 = (N64Mode)report[5]; SNES = (SnesMode)report[6]; } DeviceID = (ushort)((report[7] << 8) | report[8]); PICRevision = (byte)(DeviceID & 0x0F); DeviceID &= 0xFFF0; return(true); }
public void OnSelectedInputChanged() { var devNumber = InputSources.IndexOf(SelectedInput.Value); DataMaster.Setting.DevNumber = devNumber; DataMaster.Setting.MicChanel = SelectedInput.Value.Channels; ReleaseResource(); try { _inputStream = new WaveIn { DeviceNumber = devNumber, WaveFormat = new WaveFormat(44100, SelectedInput.Value.Channels) }; _inputStream.DataAvailable += InputStreamOnDataAvailable; _waveWriter = new WaveFileWriter("sample.wav", _inputStream.WaveFormat); _inputStream.StartRecording(); } catch (Exception) { OpenMicFailedPage(); } }
public AreaSelectionCarouselDialog(Scene.ObjectRegistrationHandler registrationHandler, Scene.ObjectUnregistrationHandler unregistrationHandler) : base(registrationHandler, unregistrationHandler) { _boxCaption = Translator.Translation("Select Course"); Height = Dialog_Height; TopYWhenInactive = Definitions.Back_Buffer_Height; CarouselCenter = new Vector2(Definitions.Back_Buffer_Center.X, Carousel_Center_Y); CarouselRadii = new Vector2(Carousel_Horizontal_Radius, Carousel_Vertical_Radius); RotationSpeedInDegrees = Rotation_Speed_In_Degrees; _itemRenderDepths = new Range(Minimum_Item_Render_Depth, Maximum_Item_Render_Depth); _itemScales = new Range(Minimum_Item_Scale, Maximum_Item_Scale); InputSources.Add(KeyboardInputProcessor.CreateForPlayerOne()); InputSources.Add(KeyboardInputProcessor.CreateForPlayerTwo()); AddIconButton("previous", new Vector2(Definitions.Back_Buffer_Center.X - 450, 305), Button.ButtonIcon.Previous, Color.DodgerBlue); AddIconButton("next", new Vector2(Definitions.Back_Buffer_Center.X + 450, 305), Button.ButtonIcon.Next, Color.DodgerBlue); AddButton("Back", new Vector2(Definitions.Left_Button_Column_X, 625), Button.ButtonIcon.Back, Color.DodgerBlue, 0.7f); AddButton("Select", new Vector2(Definitions.Right_Button_Column_X, 625), Button.ButtonIcon.Play, Color.LawnGreen, 0.7f); SetupButtonLinkagesAndDefaultValues(); registrationHandler(this); _cancelButtonCaption = "Back"; }
public override void _Update() { // Select whichever input is present first if (!gamepadSource.IsPresent()) { InputSources inputSources = InputSources.Instance; if (inputSources.netGamepad.IsPresent()) { SelectGamepadSource(inputSources.netGamepad); } else if (inputSources.hidGamepad.IsPresent()) { SelectGamepadSource(inputSources.hidGamepad); } else if (inputSources.unityGamepad.IsPresent()) { SelectGamepadSource(inputSources.unityGamepad); } } else { if (useJoyAdjustedDir) { Vector2 joy = gamepadSource.leftJoyVector; if (AbsoluteJoystickDrag) { adjustedTargetRot = buildWorldTargetRot(joy); } else { adjustedTargetRot *= buildLocalTargetVector(joy, dragSpeed * Time.deltaTime); } } /*aButtonState.ApplyState(gamepadSource.aButtonState.pressed); * bButtonState.ApplyState(gamepadSource.bButtonState.pressed); * xButtonState.ApplyState(gamepadSource.xButtonState.pressed); * yButtonState.ApplyState(gamepadSource.yButtonState.pressed); * startButtonState.ApplyState(gamepadSource.startButtonState.pressed);*/ } bool prev = m_Select; m_Select = (this as ITargetingInputSource).IsSelectPressed(); if (prev != m_Select) { OnSelectChanged(this, m_Select); } prev = m_Menu; m_Menu = (this as ITargetingInputSource).IsMenuPressed(); if (prev != m_Menu) { OnMenuChanged(this, m_Menu); } base._Update(); }
public RaceCharacterSelectionCarouselDialog(SelectionButtonHandler sceneButtonHandler, Scene.ObjectRegistrationHandler registrationHandler, Scene.ObjectUnregistrationHandler unregistrationHandler) : base(registrationHandler, unregistrationHandler) { _sendButtonActionToScene = sceneButtonHandler; AddButton("Back", new Vector2(Definitions.Left_Button_Column_X, 325), Button.ButtonIcon.B, Color.Red, 0.7f); AddButton("Select", new Vector2(Definitions.Right_Button_Column_X, 325), Button.ButtonIcon.A, Color.LawnGreen, 0.7f); Height = Race_Character_Selection_Dialog_Height; InputSources.Add(null); }
/// <summary> /// Manual update function, invoked by InputShellMap, after all input controls have been updated /// </summary> public void _Update() { // Fire all queued actions now that state is fully updated ControlStateBase.FireActions(); // Beam activation logic InputSources inputSources = InputSources.Instance; bool beamActive = inputSources.touch6D.IsActiveTargetingSource(); beamActive |= inputSources.hands.IsActiveTargetingSource() && ((ITargetingInputSource)inputSources.hands).IsSelectPressed(); #if UNITY_EDITOR beamActive = true; #endif // beamController.SetBeamActive(beamActive); }
private void RasterizeAcceleratorOverlay( UIOperationContext context, ref ImperativeRenderer labelRenderer, ref ImperativeRenderer targetRenderer, Control control, InputID id, bool showFocused = false, Control forControl = null ) { if (id == null) { throw new ArgumentNullException("id"); } var gamePadMode = InputSources.FirstOrDefault() is GamepadVirtualKeyboardAndCursor; OverlayStringBuilder.Clear(); id.Format(OverlayStringBuilder, gamePadMode); RasterizeAcceleratorOverlay( context, ref labelRenderer, ref targetRenderer, control, OverlayStringBuilder, showFocused ); }
/// <summary> /// Initialization. Stores all input sources from InputSources which implement ITargetingInputSource /// </summary> /// <param name="_inputSources"></param> public void Init(InputSources _inputSources) { inputSources = _inputSources; foreach (InputSourceBase source in inputSources.sources) { //if( source.GetType().IsAssignableFrom(typeof(ITargetingInputSource))) if (source is ITargetingInputSource) { TargetingSources.Add(source as ITargetingInputSource); TargetingSourceBases.Add(source); } } if (debugPrint) { Debug.Log("TargetingSources: " + TargetingSources.Count); } CurrentTargetingSource = inputSources.hands; }
/// <summary> /// Initialization. Gets all input sources that exist in the scene, then sorts virtual sources /// to the end. Finally, the input source fields in InputSources are automatically assigned using reflection. /// </summary> public void Init(GameObject owner) { Instance = this; // Currently looks for all input sources in scene sources = GameObject.FindObjectsOfType <InputSourceBase>(); // Sort so that virtual sources are after physical for (int i = 0; i < sources.Length; ++i) { // If we find a virtual source, look for non-virtual sources if (sources[i].IsVirtual) { int h = sources.Length - 1; for (; h > i; --h) { // Found a non-virtual source, swap them if (!sources[h].IsVirtual) { InputSourceBase temp = sources[i]; sources[i] = sources[h]; sources[h] = temp; break; } } // There were no non-virtual sources after this one! if (h <= i) { break; } } } List <InputSourceBase> addedSources = new List <InputSourceBase>(); // Auto-assign all InputSourceBase fields to the corresponding instance #if USE_WINRT foreach (FieldInfo field in GetType().GetTypeInfo().DeclaredFields) #else FieldInfo[] myFields = GetType().GetFields(); foreach (FieldInfo field in myFields) #endif { // Found an InputSourceBase field #if USE_WINRT if (field.FieldType.GetTypeInfo().IsSubclassOf(typeof(InputSourceBase))) #else if (field.FieldType.IsSubclassOf(typeof(InputSourceBase))) #endif { // Con: Must create in editor, Pro: can configure properties // Find the matching component bool didSet = false; foreach (InputSourceBase isb in sources) { if (isb.GetType() == field.FieldType) { field.SetValue(this, isb); didSet = true; break; } } if (!didSet) { //Debug.LogError("Didn't find InputSourceBase for field " + field.Name); // Pro: Don't need to create in editor, Con: can't configure // Create the component if not found. It will just have default values. Component c = owner.AddComponent(field.FieldType); field.SetValue(this, c); addedSources.Add(c as InputSourceBase); } } else if (field.FieldType.IsArray #if USE_WINRT && field.FieldType.GetElementType().GetTypeInfo().IsSubclassOf(typeof(InputSourceBase)) #else && field.FieldType.GetElementType().IsSubclassOf(typeof(InputSourceBase)) #endif ) { Type elementType = field.FieldType.GetElementType(); List <InputSourceBase> typeSources = new List <InputSourceBase>(); foreach (InputSourceBase isb in sources) { if (isb.GetType() == elementType) { typeSources.Add(isb); } } object[] arr = (object[])Array.CreateInstance(elementType, typeSources.Count); for (int index = 0; index < arr.Length; index++) { arr[index] = typeSources[index]; } field.SetValue(this, arr); } } // Add the added soruces back into the source array InputSourceBase[] newSourceArray = new InputSourceBase[addedSources.Count + sources.Length]; sources.CopyTo(newSourceArray, 0); addedSources.CopyTo(newSourceArray, sources.Length); sources = newSourceArray; ConfigureActiveSources(); }