public DeviceCapability ToRRInfo() { var info = new DeviceCapability(); CopyTo(info); return(info); }
public static int GetDeviceCaps(IHandle hDC, DeviceCapability nIndex) { int caps = GetDeviceCaps((HDC)hDC.Handle, nIndex); GC.KeepAlive(hDC); return(caps); }
public static int GetDeviceCaps(HandleRef hDC, DeviceCapability nIndex) { int caps = GetDeviceCaps(hDC.Handle, nIndex); GC.KeepAlive(hDC.Wrapper); return(caps); }
/// <summary> /// Gets the capability class for a <see cref="DeviceCapability"/> /// </summary> /// <param name="capability">The <see cref="DeviceCapability"/></param> /// <returns>The class of the <see cref="DeviceCapability"/></returns> public static DeviceCapabilityClass GetClass(DeviceCapability capability) { if (_hashAxes.Contains(capability)) { return(DeviceCapabilityClass.ControllerAxis); } if (_hashButtons.Contains(capability)) { return(DeviceCapabilityClass.ControllerFaceButton); } if (_hashHats.Contains(capability)) { return(DeviceCapabilityClass.ControllerDirectional); } if (_hashKeyboardKeys.Contains(capability)) { return(DeviceCapabilityClass.Keyboard); } if (_hashMouseButton.Contains(capability)) { return(DeviceCapabilityClass.MouseButton); } if (_hashMouseCursor.Contains(capability)) { return(DeviceCapabilityClass.MouseCursor); } // only 2 rumble, probably don't need to hash this. if (DeviceCapabilityClasses._rumble.Contains(capability)) { return(DeviceCapabilityClass.Rumble); } return(DeviceCapabilityClass.None); }
public static int GetDeviceCaps(HandleRef hdc, DeviceCapability index) { int caps = GetDeviceCaps(hdc.Handle, index); GC.KeepAlive(hdc.Wrapper); return(caps); }
public void EnrichMessage(DeviceMetadata metadata) { if (metadata != null) { this.Capabilities = metadata.Capability; } }
/// <summary> /// Gets a device capability represented as an array /// </summary> /// <param name="capability">Capability to retrieve</param> /// <returns>value of capability specified in capability argument</returns> private T[] GetArrayCapability <T>(DeviceCapability capability, ReadArray <T> readArray, int itemByteSize) { uint numOutputs = UnsafeNativeMethods.DeviceCapabilitiesW(this._deviceName, this._portName, capability, SafeMemoryHandle.Null, this._devMode); if (numOutputs < 1) { return(Array.Empty <T>()); } HGlobalBuffer buffer = new HGlobalBuffer((int)(numOutputs * itemByteSize)); try { numOutputs = UnsafeNativeMethods.DeviceCapabilitiesW(this._deviceName, this._portName, capability, buffer.Handle, this._devMode); if (numOutputs >= 0) { return(readArray(buffer, itemByteSize)); } } finally { buffer.Release(); } return(null); }
private async Task TestExecuteAsync(DeviceCapability deviceCapability, string cmd) { await _raspberryClient.ExecuteDeviceAsync(DeviceId, new DeviceExecuteModel { Capability = deviceCapability.Id, Command = cmd, Component = ComponentLabel }); }
public static bool IsCapabilitySupported(string firmware, DeviceCapability capability) { return(IsTS(firmware) ? IsTS_Supported(firmware, capability) : IsYB(firmware) ? IsYB_Supported(firmware, capability) : IsGF(firmware) ? IsGF_Supported(firmware, capability) : false); }
/// <summary> /// Acquires image. /// </summary> private void acquireImageButton_Click(object sender, EventArgs e) { acquireImageButton.Enabled = false; try { // select the default device if (!_deviceManager.ShowDefaultDeviceSelectionDialog()) { MessageBox.Show("Device is not selected."); acquireImageButton.Enabled = true; return; } if (_currentDevice != null) { UnsubscribeFromDeviceEvents(); } // get reference to the selected device Device device = _deviceManager.DefaultDevice; _currentDevice = device; // subscribe to the device events SubscribeToDeviceEvents(); // set acquisition parameters device.ShowUI = false; device.DisableAfterAcquire = true; // open the device device.Open(); // determine if device supports the extended image info DeviceCapability extendedImageInfoCap = device.Capabilities.Find(DeviceCapabilityId.IExtImageInfo); if (extendedImageInfoCap == null) { // close the device device.Close(); MessageBox.Show("Device does not support extended image information."); acquireImageButton.Enabled = true; return; } // specify that image info is necessary AddExtendedImageInfoToRetrieveList(device); // start the asynchronous image acquisition process device.Acquire(); } catch (TwainException ex) { MessageBox.Show(GetFullExceptionMessage(ex), "Error"); acquireImageButton.Enabled = true; } }
public DeviceCapability GetCapabilityFromSpecs(DeviceCapability _cap) { DeviceCapability matchCap = null; foreach (DeviceCapability cap in m_Capabilities) { if (cap.Equals(_cap)) { matchCap = cap; } } return(matchCap); }
void CheckDeviceCapability(DeviceCapability deviceCapability) { m_ARButton.button.interactable = false; m_VRButton.button.interactable = false; if (deviceCapability.HasFlag(DeviceCapability.ARCapability)) { m_ARButton.button.interactable = true; } if (deviceCapability.HasFlag(DeviceCapability.VRCapability)) { m_VRButton.button.interactable = true; } }
public DeviceCapability GetBestSizeCapability() { DeviceCapability bestCap = m_Capabilities[0]; int maxPixels = bestCap.NumberOfPixels; for (int i = 1; i < m_Capabilities.Count; i++) { if (m_Capabilities[i].NumberOfPixels > maxPixels) { bestCap = m_Capabilities[i]; maxPixels = bestCap.NumberOfPixels; } } return(bestCap); }
private void FillValueList(object values, DeviceCapability capability) { if (values == null) { return; } object[] vals = values as object[]; if (vals == null) { this.listValues.Items.Add(values); } else if (vals.Length > 0) { this.listValues.Items.AddRange(vals); } }
private void getMethodComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { Cursor = Cursors.Wait; DeviceCapabilityInfo deviceCapabilityInfo = (DeviceCapabilityInfo)supportedCapabilitiesListBox.SelectedItem; DeviceCapability cap = deviceCapabilityInfo.DeviceCapability; DeviceCapabilityUsageMode usageMode = DeviceCapabilityUsageMode.Get; if (getMethodComboBox.SelectedItem != null) { usageMode = (DeviceCapabilityUsageMode)getMethodComboBox.SelectedItem; } GetCapValue(cap, usageMode); Cursor = Cursors.Arrow; }
/// <inheritdoc/> public string this[DeviceCapability element] { get { if (this.elementMappings.TryGetValue(element, out string?mappedValue) && mappedValue != null) { return(mappedValue); } if (this.elementMappings.TryGetValue(DeviceCapability.None, out string?noElement) && noElement != null) { return(noElement); } return(string.Empty); } }
private static extern int GetDeviceCaps(IntPtr hdc, DeviceCapability nIndex);
public override void PromptDeviceSelector() { DelegatesPool dp = DelegatesPool.Instance(); if (dp.DeactivateKeyboardHandler != null) { dp.DeactivateKeyboardHandler(); } bool reconnected = false; // Ask the user which device he wants to use or which size/framerate. formDevicePicker fdp = new formDevicePicker(ListDevices(), m_CurrentVideoDevice, DisplayDevicePropertyPage); if(fdp.ShowDialog() == DialogResult.OK) { DeviceDescriptor dev = fdp.SelectedDevice; if(dev == null || dev.Empty) { log.DebugFormat("Selected device is null or empty."); if(m_CurrentVideoDevice != null) { // From something to empty. Disconnect(); } } else if(dev.Network) { if(m_CurrentVideoDevice == null || !m_CurrentVideoDevice.Network) { // From empty or non-network to network. log.DebugFormat("Selected network camera - connect with default parameters"); reconnected = ConnectToDevice(dev); } else { // From network to network. log.DebugFormat("Network camera - parameters changed - connect with new parameters"); // Parameters were set on the dialog. We don't care if the parameters were actually changed. DeviceDescriptor netDevice = new DeviceDescriptor(ScreenManagerLang.Capture_NetworkCamera, fdp.SelectedUrl, fdp.SelectedFormat); reconnected = ConnectToDevice(netDevice); } } else { if(m_CurrentVideoDevice == null || m_CurrentVideoDevice.Network || dev.Identification != m_CurrentVideoDevice.Identification) { // From network or different capture device to capture device. log.DebugFormat("Selected capture device"); reconnected = ConnectToDevice(dev); } else { // From same capture device - caps changed. DeviceCapability cap = fdp.SelectedCapability; if(cap != null && !cap.Equals(m_CurrentVideoDevice.SelectedCapability)) { log.DebugFormat("Capture device, capability changed."); m_CurrentVideoDevice.SelectedCapability = cap; //PreferencesManager.CapturePreferences.UpdateDeviceConfiguration(m_CurrentVideoDevice.Identification, cap); //PreferencesManager.Save(); if(m_bIsGrabbing) { m_VideoSource.Stop(); } ((VideoCaptureDevice)m_VideoSource).DesiredFrameSize = cap.FrameSize; ((VideoCaptureDevice)m_VideoSource).DesiredFrameRate = cap.Framerate; m_FrameSize = cap.FrameSize; m_FramesInterval = 1000 / (double)cap.Framerate; log.Debug(String.Format("New capability: {0}", cap.ToString())); m_bSizeChanged = true; if(m_bIsGrabbing) { m_VideoSource.Start(); } } } } if(reconnected) m_Container.Connected(); } fdp.Dispose(); if(dp.ActivateKeyboardHandler != null) { dp.ActivateKeyboardHandler(); } }
private bool ConnectToDevice(DeviceDescriptor _device) { log.DebugFormat("Connecting to {0}", _device.Name); Disconnect(); bool created = false; if(_device.Network) { // Network Camera. Connect to last used url. // The user will have to open the dialog again if parameters have changed or aren't good. // Parse URL for inline username:password. string login = ""; string pass = ""; Uri networkCameraUrl = new Uri(_device.NetworkCameraUrl); if(!string.IsNullOrEmpty(networkCameraUrl.UserInfo)) { string [] split = networkCameraUrl.UserInfo.Split(new Char [] {':'}); if(split.Length == 2) { login = split[0]; pass = split[1]; } } if(_device.NetworkCameraFormat == NetworkCameraFormat.JPEG) { JPEGStream source = new JPEGStream(_device.NetworkCameraUrl); if(!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(pass)) { source.Login = login; source.Password = pass; } m_VideoSource = source; } else { MJPEGStream source = new MJPEGStream(_device.NetworkCameraUrl); if(!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(pass)) { source.Login = login; source.Password = pass; } m_VideoSource = source; } /*PreferencesManager.CapturePreferences.NetworkCameraFormat = _device.NetworkCameraFormat; PreferencesManager.CapturePreferences.NetworkCameraUrl = _device.NetworkCameraUrl; PreferencesManager.Save();*/ created = true; } else { m_VideoSource = new VideoCaptureDevice(_device.Identification); VideoCaptureDevice captureDevice = m_VideoSource as VideoCaptureDevice; if(captureDevice != null) { if((captureDevice.VideoCapabilities != null) && (captureDevice.VideoCapabilities.Length > 0)) { // Import the capabilities of the device. foreach(VideoCapabilities vc in captureDevice.VideoCapabilities) { DeviceCapability dc = new DeviceCapability(vc.FrameSize, vc.FrameRate); _device.Capabilities.Add(dc); log.Debug(String.Format("Device Capability. {0}", dc.ToString())); } DeviceCapability selectedCapability = null; // Check if we already know this device and have a preferred configuration. /*foreach(DeviceConfiguration conf in PreferencesManager.CapturePreferences.DeviceConfigurations) { if(conf.ID == _device.Identification) { // Try to find the previously selected capability. selectedCapability = _device.GetCapabilityFromSpecs(conf.Capability); if(selectedCapability != null) log.Debug(String.Format("Picking capability from preferences: {0}", selectedCapability.ToString())); } }*/ /*if(selectedCapability == null) { // Pick the one with max frame size. selectedCapability = _device.GetBestSizeCapability(); log.Debug(String.Format("Picking a default capability (best size): {0}", selectedCapability.ToString())); PreferencesManager.CapturePreferences.UpdateDeviceConfiguration(_device.Identification, selectedCapability); PreferencesManager.Save(); }*/ _device.SelectedCapability = selectedCapability; captureDevice.DesiredFrameSize = selectedCapability.FrameSize; captureDevice.DesiredFrameRate = selectedCapability.Framerate; m_FrameSize = selectedCapability.FrameSize; m_FramesInterval = 1000 / (double)selectedCapability.Framerate; } else { captureDevice.DesiredFrameRate = 0; } created = true; } } if(created) { m_CurrentVideoDevice = _device; m_VideoSource.NewFrame += new NewFrameEventHandler( VideoDevice_NewFrame ); m_VideoSource.VideoSourceError += new VideoSourceErrorEventHandler( VideoDevice_VideoSourceError ); m_bIsConnected = true; } else { log.Error("Couldn't create the capture device."); } return created; }
internal static extern int GetDeviceCaps(DCHandle dcHandle, DeviceCapability index);
public IEnumerable<ActionType> GetByDeviceTypeId(DeviceCapability deviceCapability) { return DataContext.ActionTypes .Where(t => t.DeviceCapability == deviceCapability); }
public void CopyTo(DeviceCapability device_option) { device_option.capability_identifier = capability_identifier?.ToRRInfo(); device_option.subcapabilities = subcapabilities?.Select(x => x?.ToRRInfo()).ToList(); }
public static extern int GetDeviceCaps( HDC hdc, DeviceCapability nIndex);
public static partial int GetDeviceCaps(IntPtr hdc, DeviceCapability index);
internal static extern int GetDeviceCaps(DeviceContextHandle deviceContextHandle, DeviceCapability index);
public bool Exists(string name, DeviceCapability capability) { return true; }
/// <summary> /// Gets a device capability represented as an integer /// </summary> /// <param name="capability">Capability to retrieve</param> /// <returns>value of capability specified in capability argument</returns> private uint GetIntCapability(DeviceCapability capability) { return(UnsafeNativeMethods.DeviceCapabilitiesW(this._deviceName, this._portName, capability, SafeMemoryHandle.Null, this._devMode)); }
public bool Exists(string name, DeviceCapability capability) { return DataContext.Devices .Any(d => d.Name == name && d.Capability == capability); }
public static extern uint DeviceCapabilitiesW(string pDevice, string pPort, DeviceCapability fwCapabilities, SafeMemoryHandle pOutput, SafeMemoryHandle pDevMode);
public static extern bool DeviceHasCapability(IntPtr device, DeviceCapability capability);
private void DisplayConfControls(DeviceDescriptor _currentDevice) { if (_currentDevice != null) { lblConfig.Visible = !_currentDevice.Network; lblNoConf.Visible = !_currentDevice.Network; btnDeviceProperties.Visible = !_currentDevice.Network; cmbCapabilities.Visible = !_currentDevice.Network; lblUrl.Visible = _currentDevice.Network; lblStreamType.Visible = _currentDevice.Network; cmbUrl.Visible = _currentDevice.Network; cmbStreamType.Visible = _currentDevice.Network; if (_currentDevice.Network) { btnCamcorder.Image = Resources.camera_network2; PreferencesManager pm = PreferencesManager.Instance(); // Recently used cameras. cmbUrl.Text = _currentDevice.NetworkCameraUrl; if (pm.RecentNetworkCameras.Count > 0) { foreach (string url in pm.RecentNetworkCameras) { cmbUrl.Items.Add(url); } } else { cmbUrl.Items.Add(_currentDevice.NetworkCameraUrl); } // Type of streams supported. cmbStreamType.Items.Add("JPEG"); cmbStreamType.Items.Add("MJPEG"); if (_currentDevice.NetworkCameraFormat == NetworkCameraFormat.JPEG) { cmbStreamType.SelectedIndex = 0; } else if (_currentDevice.NetworkCameraFormat == NetworkCameraFormat.MJPEG) { cmbStreamType.SelectedIndex = 1; } else { _currentDevice.NetworkCameraFormat = NetworkCameraFormat.JPEG; cmbStreamType.SelectedIndex = 0; } } else { btnCamcorder.Image = Resources.camera_selected; int selectedCap = 0; for (int i = 0; i < _currentDevice.Capabilities.Count; i++) { DeviceCapability dc = _currentDevice.Capabilities[i]; cmbCapabilities.Items.Add(dc); if (dc == _currentDevice.SelectedCapability) { selectedCap = i; } } if (_currentDevice.Capabilities.Count > 0) { cmbCapabilities.SelectedIndex = selectedCap; lblNoConf.Visible = false; cmbCapabilities.Visible = true; } else { lblNoConf.Visible = true; cmbCapabilities.Visible = false; } } } else { btnCamcorder.Image = Resources.camera_notfound; // No device currently selected. lblConfig.Visible = false; lblNoConf.Visible = false; btnDeviceProperties.Visible = false; cmbCapabilities.Visible = false; lblUrl.Visible = false; lblStreamType.Visible = false; cmbUrl.Visible = false; cmbStreamType.Visible = false; } }
public string this[DeviceCapability capability] => Enums.AsString(capability);
/// <summary> /// Gets a device capability represented as an array /// </summary> /// <typeparam name="T">Capability item type</typeparam> /// <param name="capability">Capability to retrieve</param> /// <param name="readItem">Delegate to marshal a single capability item from unmanaged memory</param> /// <returns>An array of capabilities specified by the capability arg or null if the call fails</returns> private T[] GetArrayCapability <T>(DeviceCapability capability, ReadArray <T> readItem) where T : struct { return(GetArrayCapability <T>(capability, readItem, Marshal.SizeOf(typeof(T)))); }
public static extern int GetDeviceCaps(IntPtr hDC, DeviceCapability cap);