<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[James's Programming Page — HidSharp Feature request: HID device in write-only or read-only mode]]></title>
		<link>https://swforum.seekye.com/topic/10170/</link>
		<atom:link href="https://swforum.seekye.com/feed/rss/topic/10170/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in HidSharp Feature request: HID device in write-only or read-only mode.]]></description>
		<lastBuildDate>Sun, 22 Mar 2026 13:36:16 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: HidSharp Feature request: HID device in write-only or read-only mode]]></title>
			<link>https://swforum.seekye.com/post/13188/#p13188</link>
			<description><![CDATA[<p>Just wanted to add one more practical workaround (and which I&#039;ve implemented myself for now):<br />Instead of always forcing Read+Write access, try opening the device multiple times with falling back to reduced access modes if the full one fails. </p><div class="codebox"><pre><code>IntPtr handle = NativeMethods.CreateFileFromDevice(path, NativeMethods.EFileAccess.Read | NativeMethods.EFileAccess.Write, NativeMethods.EFileShare.Read | NativeMethods.EFileShare.Write);
if (handle == (IntPtr)(-1))
{
    handle = NativeMethods.CreateFileFromDevice(path, NativeMethods.EFileAccess.Read, NativeMethods.EFileShare.Read | NativeMethods.EFileShare.Write);
}

if (handle == (IntPtr)(-1))
{
    handle = NativeMethods.CreateFileFromDevice(path, NativeMethods.EFileAccess.Write, NativeMethods.EFileShare.Read | NativeMethods.EFileShare.Write);
}

if (handle == (IntPtr)(-1))
{
    throw DeviceException.CreateIOException(Device, &quot;Unable to open HID class device (&quot; + path + &quot;).&quot;, Marshal.GetHRForLastWin32Error());
}</code></pre></div><p>To make this even cleaner in HidSharp, it would be great if after a successful open, the HidStream (or a new DeviceStream base) exposed read-only properties like:<br /></p><div class="codebox"><pre><code>public bool CanRead { get; }     // true if GENERIC_READ was granted
public bool CanWrite { get; }    // true if GENERIC_WRITE was granted</code></pre></div><p>This would allow user code to gracefully check capabilities at runtime (e.g. skip async read loops if !CanRead, or show a warning if !CanWrite).<br />Many devices (especially mice) will happily accept writes without read access, but HidSharp&#039;s current TryOpen always requests both → which fails with Access Denied (5) or Sharing Violation (32) on protected input devices.<br />This fallback strategy has worked reliably for me on several gaming mice where I only send RGB/DPI Feature Reports.<br />What do you think — would something like configurable access fallbacks or post-open CanRead/CanWrite props be feasible to add?<br />Thanks again!</p>]]></description>
			<author><![CDATA[null@example.com (vondollie)]]></author>
			<pubDate>Sun, 22 Mar 2026 13:36:16 +0000</pubDate>
			<guid>https://swforum.seekye.com/post/13188/#p13188</guid>
		</item>
		<item>
			<title><![CDATA[HidSharp Feature request: HID device in write-only or read-only mode]]></title>
			<link>https://swforum.seekye.com/post/13187/#p13187</link>
			<description><![CDATA[<p>Hi James,</p><p>I have one use-case where the current API is quite painful to work around, and I think adding support for write-only or read-only opening would help a lot of people.</p><p>My scenario:<br />I need to send Feature Reports to a HID mouse (mostly to control RGB lighting, DPI stages, polling rate, etc. on gaming mice).</p><p>On Windows:<br />The mouse is opened successfully with GENERIC_WRITE access<br />Writing Feature Reports (via HidD_SetFeature) works perfectly<br />But Windows refuses to open the same device with GENERIC_READ access.<br />When I do device.TryOpen(out var stream) in HidSharp, it requests both read and write access and fails.</p><p>Feature request / suggestion<br />An OpenMode / Access option in TryOpen(OpenConfiguration)</p><p>Something like:<br />var config = new OpenConfiguration();<br />config.SetOption(OpenOption.ReadAccess, true);<br />config.SetOption(OpenOption.WriteAccess, true);<br />device.TryOpen(config, out var stream);</p><p>This would allow clean write-only usage for exactly the kind of devices that Windows protects from being read (mice, some keyboards, touchpads, etc.) while still letting us send output/feature reports.</p><p>Thanks for considering this.</p>]]></description>
			<author><![CDATA[null@example.com (vondollie)]]></author>
			<pubDate>Sat, 21 Mar 2026 22:49:30 +0000</pubDate>
			<guid>https://swforum.seekye.com/post/13187/#p13187</guid>
		</item>
	</channel>
</rss>
