<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forums.obdev.at/app.php/feed/topic/3295" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2009-10-05T11:26:53+02:00</updated>

	<author><name><![CDATA[Objective Development Forums]]></name></author>
	<id>https://forums.obdev.at/app.php/feed/topic/3295</id>

		<entry>
		<author><name><![CDATA[Urvin]]></name></author>
		<updated>2009-10-05T11:26:53+02:00</updated>

		<published>2009-10-05T11:26:53+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11218#p11218</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11218#p11218"/>
		<title type="html"><![CDATA[Re: Combining HID devices in one]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11218#p11218"><![CDATA[
Would it be better if I share the whole commented sources?<br />I still can't solve the problem.<br /><br />I don't want to use libusb because of some problems with installing it on different (win) computers and I don't need a hi-speed transfer.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=2829">Urvin</a> — Mon Oct 05, 2009 11:26 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Urvin]]></name></author>
		<updated>2009-10-02T10:13:43+02:00</updated>

		<published>2009-10-02T10:13:43+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11167#p11167</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11167#p11167"/>
		<title type="html"><![CDATA[Re: Combining HID devices in one]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11167#p11167"><![CDATA[
Please, help me!<br />I don't know how to solve this problem <img class="smilies" src="./../../../images/smilies/icon_cry.gif" alt=":cry:" title="Crying or Very sad" /> But I know that this is not a proplem of pc software - it works pretty with hid-data firmware.<br />I think that problem should be around report ids...<br /><br /><span style="color: #AAAAAA">I promise to buy a hobbyist license if this would work</span> <img class="smilies" src="./../../../images/smilies/icon_smile.gif" alt=":)" title="Smile" /><p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=2829">Urvin</a> — Fri Oct 02, 2009 10:13 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Urvin]]></name></author>
		<updated>2009-09-30T11:10:50+02:00</updated>

		<published>2009-09-30T11:10:50+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11147#p11147</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11147#p11147"/>
		<title type="html"><![CDATA[Re: Combining HID devices in one]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11147#p11147"><![CDATA[
Now I'm trying to teach my device how to transfer data, like hiddata example does.<br /><br />This is a part of hid descriptor:<br /><div class="codebox"><p>Code: </p><pre><code>    0x06, 0x00, 0xff,              // USAGE_PAGE (Vendor Defined Page 1)<br />    0x09, 0x01,                    // USAGE (Vendor Usage 1)<br />    0xa1, 0x01,                    // COLLECTION (Application)<br />    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)<br />    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)<br />    0x85, 0x04,                    //   REPORT_ID (4)<br />    0x75, 0x08,                    //   REPORT_SIZE (8)<br />    0x95, 0x80,                    //   REPORT_COUNT (128)<br />    0x09, 0x00,                    //   USAGE (Undefined)<br />    0xb2, 0x02, 0x01,              //   FEATURE (Data,Var,Abs,Buf)<br />    0xc0                           // END_COLLECTION</code></pre></div><br /><br />Through I have many arrays, i combine them using pointer array. These are variables and data array init function:<br /><div class="codebox"><p>Code: </p><pre><code>static uchar usbreportid = 4;<br />static uchar*   dataout&#91;128&#93;;<br />static uchar    currentAddress;<br />static uchar    bytesRemaining;<br /><br />static uchar buttonsADC&#91;32&#93;;<br />static uchar keycodes&#91;76&#93;;<br />static uchar canHoldButtons&#91;17&#93;;<br /><br />static void dataoutInit(void)<br />{<br />   uchar i=0;<br />   <br />   // 0<br />   dataout&#91;0&#93; = &amp;usbreportid;<br />   <br />   //32<br />   for(i=0; i&lt;32; i++)<br />   {<br />      dataout&#91;i+1&#93; = &amp;buttonsADC&#91;i&#93;;<br />   }<br />   <br />   // 48<br />   for(i=0; i&lt;16; i++)<br />   {<br />      dataout&#91;i+33&#93; = &amp;canHoldButtons&#91;i+1&#93;;<br />   }<br />   <br />   // 124<br />   for(i=0; i&lt;76; i++)<br />   {<br />      dataout&#91;i+ 49&#93; = &amp;keycodes&#91;i&#93;;<br />   }<br />}<br /></code></pre></div><br /><br />usbFunctionSetup (without keyboard and volume control part)<br /><div class="codebox"><p>Code: </p><pre><code>uchar   usbFunctionSetup(uchar data&#91;8&#93;)<br />{<br />usbRequest_t    *rq = (void *)data;<br />   <br />    if((rq-&gt;bmRequestType &amp; USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS){    /* class request type */<br />        if(rq-&gt;bRequest == USBRQ_HID_GET_REPORT){  /* wValue: ReportType (highbyte), ReportID (lowbyte) */<br />         if (rq-&gt;wValue.bytes&#91;0&#93; == 1) <br />                        // ...<br />         else if (rq-&gt;wValue.bytes&#91;0&#93; == 4) // If data transfer report<br />         {<br />            bytesRemaining = 128;<br />            currentAddress = 0;<br />            return USB_NO_MSG;<br />         }<br />         <br />         return 0;<br />      }<br />      else if(rq-&gt;bRequest == USBRQ_HID_SET_REPORT)<br />      {<br />         if (rq-&gt;wValue.bytes&#91;0&#93; == 4)<br />         {<br />            bytesRemaining = 128;<br />            currentAddress = 0;<br />            return USB_NO_MSG;<br />         }<br />      }<br />        else if(rq-&gt;bRequest == USBRQ_HID_GET_IDLE)<br />   {<br />            usbMsgPtr = &amp;idleRate;<br />            return 1;<br />        }<br />   else if(rq-&gt;bRequest == USBRQ_HID_SET_IDLE)<br />   {<br />            idleRate = rq-&gt;wValue.bytes&#91;1&#93;;<br />        }<br />    }<br />   else<br />   {<br />        /* no vendor specific requests implemented */<br />    }<br />   return 0;<br />}</code></pre></div><br /><br />and usbFunctionRead:<br /><div class="codebox"><p>Code: </p><pre><code>uchar usbFunctionRead(uchar *data, uchar len)<br />{<br />   if(len &gt; bytesRemaining)<br />        len = bytesRemaining;<br />   <br />   uchar i=0;<br />   <br />   for (i=0; i&lt;len; i++)<br />   {<br />      if (currentAddress + i &lt;= 124) <br />      {<br />         data&#91;i&#93; = *dataout&#91;currentAddress + i&#93;;<br />      }<br />      else<br />      {<br />         data&#91;i&#93; = 123; // Just meaningless bytes<br />      }<br />   }<br />   <br />   currentAddress += len;<br />        bytesRemaining -= len;<br /><br />   return len;<br />}</code></pre></div><br /><br />Host application function call:<br /><div class="codebox"><p>Code: </p><pre><code>#define USBREPORTBUFFERLEN 129<br />#define USB_REPORT_ID 4<br /><br />usbDevice_t* usbDevice;<br />char usbReportBuffer&#91;USBREPORTBUFFERLEN&#93;;<br /><br />void read_hid_device()<br />{<br />    int len = USBREPORTBUFFERLEN;<br /><br />    int err = usbhidGetReport(usbDevice, USB_REPORT_ID, usbReportBuffer, &amp;len);<br /><br />    if (err != 0)<br />    {<br />        cout&lt;&lt;&quot;Error reading data: &quot;&lt;&lt;usbErrorMessage(err)&lt;&lt;endl;  // usbErrorMessage returns string with error description<br />    }<br />    else<br />    {<br />        //success<br />    }<br />}<br /></code></pre></div><br /><br /><br />In my host application I can connect to device, but if I want to read device data I always get &quot;Error reading data: communication error with device&quot;.<br /><br />What I'm doing wrong?<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=2829">Urvin</a> — Wed Sep 30, 2009 11:10 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Urvin]]></name></author>
		<updated>2009-09-29T12:25:03+02:00</updated>

		<published>2009-09-29T12:25:03+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11134#p11134</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11134#p11134"/>
		<title type="html"><![CDATA[Re: Combining HID devices in one]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11134#p11134"><![CDATA[
<img src="http://funkyimg.com/u2/249/971/bo.gif" class="postimage" alt="Image" /><br />That's great! Now I can emulate keyboard and use volume and playback control.<br />Thanks!<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=2829">Urvin</a> — Tue Sep 29, 2009 12:25 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[herbert12345]]></name></author>
		<updated>2009-09-24T00:37:00+02:00</updated>

		<published>2009-09-24T00:37:00+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11088#p11088</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11088#p11088"/>
		<title type="html"><![CDATA[Re: Combining HID devices in one]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11088#p11088"><![CDATA[
You need an additional collection in your report descriptor:<br /><br />PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] =<br />{   // USB report descriptor<br />    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)<br />    0x09, 0x06,                    // USAGE (Keyboard)<br />    0xa1, 0x01,                    // COLLECTION (Application)<br />    0x85, 0x01,                    //   REPORT_ID (1)<br />    0x05, 0x07,                    //   USAGE_PAGE (Keyboard)<br />    0x19, 0xe0,                    //   USAGE_MINIMUM (Keyboard LeftControl)<br />    0x29, 0xe7,                    //   USAGE_MAXIMUM (Keyboard RightGUI)<br />    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)<br />    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)<br />    0x75, 0x01,                    //   REPORT_SIZE (1)<br />    0x95, 0x08,                    //   REPORT_COUNT (8)<br />    0x81, 0x02,                    //   INPUT (Data,Var,Abs)<br />    0x95, 0x06,                    //   REPORT_COUNT (6)<br />    0x75, 0x08,                    //   REPORT_SIZE (8)<br />    0x25, 0x65,                    //   LOGICAL_MAXIMUM (101)<br />    0x19, 0x00,                    //   USAGE_MINIMUM (Reserved (no event indicated))<br />    0x29, 0x65,                    //   USAGE_MAXIMUM (101)<br />    0x81, 0x00,                    //   INPUT (Data,Ary,Abs)<br />    0xc0,                          // END_COLLECTION<br /><br />    0x05, 0x0c,                    // USAGE_PAGE (Consumer Devices)<br />    0x09, 0x01,                    // USAGE (Consumer Control)<br />    0xa1, 0x01,                    // COLLECTION (Application)<br />    0x85, 0x02,                    //   REPORT_ID (2)<br />    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)<br />    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)<br />    0x09, 0xe9,                    //   USAGE (Volume Up)<br />    0x09, 0xea,                    //   USAGE (Volume Down)<br />    0x75, 0x01,                    //   REPORT_SIZE (1)<br />    0x95, 0x02,                    //   REPORT_COUNT (2)<br />    0x81, 0x02,                    //   INPUT (Data,Var,Abs)<br />    0x09, 0xe2,                    //   USAGE (Mute)<br />    0x95, 0x01,                    //   REPORT_COUNT (1)<br />    0x81, 0x06,                    //   INPUT (Data,Var,Rel)<br />    0x95, 0x05,                    //   REPORT_COUNT (5)<br />    0x81, 0x03,                    //   INPUT (Cnst,Var,Abs)<br />    0xc0                           // END_COLLECTION<br />};<br /><br />This solution works well on my pc running WinXP and my MacBook running SnowLeopard.<br />(you have to change your main code a little bit to support the 2 report ids)<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=2861">herbert12345</a> — Thu Sep 24, 2009 12:37 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Grendel]]></name></author>
		<updated>2009-09-23T23:31:50+02:00</updated>

		<published>2009-09-23T23:31:50+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11082#p11082</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11082#p11082"/>
		<title type="html"><![CDATA[Re: Combining HID devices in one]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11082#p11082"><![CDATA[
<blockquote><div><cite>Urvin wrote:</cite>..if I send decimal 128 (Keyboard Volume Up) the volume should increment... No effect in Windows, nor Ubuntu.<br /><br />Ok, I found another way, <a href="http://www.microsoft.com/whdc/archive/audctrl.mspx" class="postlink">microsoft documents</a> say:<br /><div class="codebox"><p>Code: </p><pre><code>Consumer Page Audio Controls Supported in Windows Operating Systems<br />0xE2    Mute<br />0xE9    Volume Increment<br />0xEA    Volume Decrement</code></pre></div></div></blockquote><br />Which one are you using ? Should be the ones defined by the HID Usage Tables document (0x7F, 0x80, 0x81).<br /><br />Also, for Windows (XP) check the following:<br /><br />- Is your &quot;HID Input Service&quot; running ? If not, start it and set it to &quot;Automatic&quot;. <br />- If the service was running or you get an error starting it, check if the &quot;ServiceDll&quot; registry entry in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HidServ\Parameters is %SystemRoot%\System32\hidserv.dll (type is REG_EXPAND_SZ).<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=101">Grendel</a> — Wed Sep 23, 2009 11:31 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2009-09-23T09:16:27+02:00</updated>

		<published>2009-09-23T09:16:27+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11071#p11071</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11071#p11071"/>
		<title type="html"><![CDATA[Re: Combining HID devices in one]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11071#p11071"><![CDATA[
I've changed hid header to this<br /><div class="codebox"><p>Code: </p><pre><code>    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)<br />    0x09, 0x06,                    // USAGE (Keyboard)<br />    0xa1, 0x01,                    // COLLECTION (Application)<br />    0x05, 0x07,                    //   USAGE_PAGE (Keyboard)<br />    0x19, 0xe0,                    //   USAGE_MINIMUM (Keyboard LeftControl)<br />    0x29, 0xe7,                    //   USAGE_MAXIMUM (Keyboard Right GUI)<br />    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)<br />    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)<br />    0x75, 0x01,                    //   REPORT_SIZE (1)<br />    0x95, 0x08,                    //   REPORT_COUNT (8)<br />    0x81, 0x02,                    //   INPUT (Data,Var,Abs)<br />    0x95, 0x01,                    //   REPORT_COUNT (1)<br />    0x75, 0x08,                    //   REPORT_SIZE (8)<br />    0x26, 0xa4, 0x00,              //   LOGICAL_MAXIMUM (164)<br />    0x19, 0x00,                    //   USAGE_MINIMUM (Reserved (no event indicated))<br />    0x29, 0xa4,                    //   USAGE_MAXIMUM (Keyboard ExSel)<br />    0x81, 0x00,                    //   INPUT (Data,Ary,Abs)<br />    0xc0                           // END_COLLECTION</code></pre></div><br /><br />It still works like a char keyboard, but no media effect obtained.<p>Statistics: Posted by Guest — Wed Sep 23, 2009 9:16 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Grendel]]></name></author>
		<updated>2009-09-22T20:48:22+02:00</updated>

		<published>2009-09-22T20:48:22+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11064#p11064</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11064#p11064"/>
		<title type="html"><![CDATA[Re: Combining HID devices in one]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11064#p11064"><![CDATA[
<blockquote><div><cite>Urvin wrote:</cite>I tried to send keycodes and modifiers and... it works! Going deeper, i've changed a line of HID descriptor to<br /><div class="codebox"><p>Code: </p><pre><code>0x25, 0x85,                    //   LOGICAL_MAXIMUM (133)</code></pre></div> to use external keycodes (referencing usb.org hid document), and decided if I send decimal 128 (Keyboard Volume Up) the volume should increment... No effect in Windows, nor Ubuntu.</div></blockquote><br />Most values in the report descriptor are signed, 0x85 is -123. For 133 as logical max use:<br /><br /><div class="codebox"><p>Code: </p><pre><code>0x26, 0x85, 0x00,          // LOGICAL_MAXIMUM (133)</code></pre></div><br />Note that the report descripter size increases by 1.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=101">Grendel</a> — Tue Sep 22, 2009 8:48 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Urvin]]></name></author>
		<updated>2009-09-22T11:12:48+02:00</updated>

		<published>2009-09-22T11:12:48+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11061#p11061</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11061#p11061"/>
		<title type="html"><![CDATA[Combining HID devices in one]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=3295&amp;p=11061#p11061"><![CDATA[
Hi!<br />I'm a beginner with V-USB, but I have great plans! I decided to begin my learning process with modifying code of EasyLogger. So, I want to create a USB multimedia keyboard on ATTity45 microcontroller. The multimedia functions I wanna use are volume control and a 'mute' button.<br /><br />I tried to send keycodes and modifiers and... it works! Going deeper, i've changed a line of HID descriptor to<br /><div class="codebox"><p>Code: </p><pre><code>0x25, 0x85,                    //   LOGICAL_MAXIMUM (133)</code></pre></div> to use external keycodes (referencing usb.org hid document), and decided if I send decimal 128 (Keyboard Volume Up) the volume should increment... No effect in Windows, nor Ubuntu.<br /><br />Ok, I found another way, <a href="http://www.microsoft.com/whdc/archive/audctrl.mspx" class="postlink">microsoft documents</a> say:<br /><div class="codebox"><p>Code: </p><pre><code>Consumer Page Audio Controls Supported in Windows Operating Systems<br />0xE2    Mute<br />0xE9    Volume Increment<br />0xEA    Volume Decrement</code></pre></div><br />and there is an example of usage in hid header:<br /><div class="codebox"><p>Code: </p><pre><code>Usage Page (Consumer)<br />Usage (Consumer Control)<br />Collection (Application)<br />    Logical Minimum (0)<br />    Logical Maximum (1)<br />    Usage (Volume Increment)<br />    Usage (Volume Decrement)<br />    Report Size (1)<br />    Report Count (2)<br />    Input (Data, Variable, Absolute, Preferred)<br />    Usage (Mute)<br />    Report Count (1)<br />    Input (Data, Variable, Relative, Preferred)<br />    Report Count (5)<br />    Input (Constant)<br />End Collection</code></pre></div><br /><br />And the question is... How can I combine and use keyboard and volume control together?  <img class="smilies" src="./../../../images/smilies/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /> <br /><br /><span style="color: #999999">The next step is to combine that with the third hid device, that sends two bytes to computer and receives about 40 bytes. My own win application should work with this device.</span><p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=2829">Urvin</a> — Tue Sep 22, 2009 11:12 am</p><hr />
]]></content>
	</entry>
	</feed>
