<?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/6014" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2011-09-28T15:19:51+02:00</updated>

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

		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2011-09-28T15:19:51+02:00</updated>

		<published>2011-09-28T15:19:51+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=6014&amp;p=19736#p19736</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=6014&amp;p=19736#p19736"/>
		<title type="html"><![CDATA[Re: Help on Mouse HID with features]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=6014&amp;p=19736#p19736"><![CDATA[
Nobody knows ? <br /><br />I really need help...<br /><br />regards, <br />hc.<p>Statistics: Posted by Guest — Wed Sep 28, 2011 3:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2011-09-15T20:42:50+02:00</updated>

		<published>2011-09-15T20:42:50+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=6014&amp;p=19625#p19625</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=6014&amp;p=19625#p19625"/>
		<title type="html"><![CDATA[Help on Mouse HID with features]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=6014&amp;p=19625#p19625"><![CDATA[
Hi everyone. <br /><br />I'm actually using V-USB in a HID mouse code on Atmega 328P. The mouse port (descriptor, mvt...) is working very well. But the bad things came when I tried to implements HID features. I'd like to be able to read a mouse speed param using a HID feature request from a PC and to change it from PC to mouse. <br /><br />My question is HOW ? <br /><br />I'm using SimpleHIDwrite3 from usb.org on the PC host to read and write HID features. <br /><br />here is my descriptor: <br /><br /><div class="codebox"><p>Code: </p><pre><code>  0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)<br />       0x09, 0x02,                    // USAGE (Mouse)<br />       0xa1, 0x01,                    // COLLECTION (Application)<br />       0x09, 0x01,                    //   USAGE (Pointer)<br />       0x75, 0x08,                    //   REPORT_SIZE (8)<br />       0x95, 0x02,                    //   REPORT_COUNT (2)<br />       0xb2, 0x02, 0x01,              //   FEATURE (Data,Var,Abs,Buf)       0xb1, 0x00,                    //     FEATURE (Data,Ary,Abs)<br />       0xa1, 0x00,                    //   COLLECTION (Physical)<br />       0x05, 0x09,                    //     USAGE_PAGE (Button)<br />       0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)<br />       0x29, 0x03,                    //     USAGE_MAXIMUM (Button 3)<br />       0x15, 0x00,                    //     LOGICAL_MINIMUM (0)<br />       0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)<br />       0x95, 0x03,                    //     REPORT_COUNT (3)<br />       0x75, 0x01,                    //     REPORT_SIZE (1)<br />       0x81, 0x02,                    //     INPUT (Data,Var,Abs)<br />       0x95, 0x01,                    //     REPORT_COUNT (1)<br />       0x75, 0x05,                    //     REPORT_SIZE (5)<br />       0x81, 0x03,                    //     INPUT (Cnst,Var,Abs)<br />       0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)<br />       0x09, 0x30,                    //     USAGE (X)<br />       0x09, 0x31,                    //     USAGE (Y)<br />       0x09, 0x38,                    //     USAGE (Wheel)<br />       0x15, 0x81,                    //     LOGICAL_MINIMUM (-127)<br />       0x25, 0x7f,                    //     LOGICAL_MAXIMUM (127)<br />       0x75, 0x08,                    //     REPORT_SIZE (8)<br />       0x95, 0x03,                    //     REPORT_COUNT (3)<br />       0x81, 0x06,                    //     INPUT (Data,Var,Rel)<br />       0xc0,                          //   END_COLLECTION<br />       0xc0                           // END_COLLECTION<br /></code></pre></div><br /><br />my main.c is : <br /><br /><div class="codebox"><p>Code: </p><pre><code><br />/../<br /><br />typedef struct{<br />    uchar   buttonMask;<br />    char    dx;<br />    char    dy;<br />    char    dWheel;<br />}report_t;<br /><br />static report_t reportBuffer;<br /><br />/* ------------------------------------------------------------------------- */<br /><br />usbMsgLen_t usbFunctionSetup(uchar setupData&#91;8&#93;)<br />{<br />    usbRequest_t *rq = (void *)setupData;   // cast to structured data for parsing<br />    switch(rq-&gt;bRequest){<br />    case 1:<br />        currentPosition = 0;                // initialize position index<br />        bytesRemaining = rq-&gt;wLength.word;  // store the amount of data requested<br />        return USB_NO_MSG;                          // tell driver to use usbFunctionRead()<br />    }<br />    return 0;                               // ignore all unknown requests<br />}<br />/* ------------------------------------------------------------------------- */<br /><br /><br />uchar usbFunctionRead(uchar *data, uchar len)<br />{<br />    uchar i;<br />    if(len &gt; bytesRemaining)                // len is max chunk size<br />        len = bytesRemaining;               // send an incomplete chunk<br />    bytesRemaining -= len;<br />    for(i = 0; i &lt; len; i++)<br />        data&#91;i&#93; = getData(currentPosition); // copy the data to the buffer<br />    return len;                             // return real chunk size<br />}<br /><br />int __attribute__((noreturn)) main(void)<br />{<br /><br />    wdt_enable(WDTO_1S);<br /><br />    /* RESET status: all port bits are inputs without pull-up.<br />     * That's the way we need D+ and D-. Therefore we don't need any<br />     * additional hardware initialization.<br />     */<br /><br />    PORTB |= (1 &lt;&lt; PB0) | (1 &lt;&lt; PB1); // enable pullups on button pins<br /><br />    _delay_ms(100);<br /><br />    usbInit();<br />    usbDeviceDisconnect();  /* enforce re-enumeration, do this while interrupts are disabled! */<br /><br />   uchar i = 0;<br />    while(--i){             /* fake USB disconnect for &gt; 250 ms */<br />        wdt_reset();<br />        _delay_ms(1);<br />    }<br />    usbDeviceConnect();<br /><br />    sei();<br /><br />    for(;;){                /* main event loop */<br /><br />       reportBuffer.buttonMask = left_button_released;<br /><br />       wdt_reset();<br /><br />       usbPoll();<br /><br />        if(usbInterruptIsReady()){<br /><br />           getMouseMovement();<br /><br />            //DBG1(0x03, 0, 0);   /* debug output: interrupt report prepared */<br /><br />            usbSetInterrupt((void *)&amp;reportBuffer, sizeof(reportBuffer));<br /><br />        }<br />    }<br />} <br /><br />/* ------------------------------------------------------------------------- */<br /><br /></code></pre></div><br /><br />I read the page from <!-- m --><a class="postlink" href="http://vusb.wikidot.com/">http://vusb.wikidot.com/</a><!-- m -->,  USB_CFG_IMPLEMENT_FN_READ and USB_CFG_IMPLEMENT_FN_WRITE are set to 1. <br />A code exemple could be very appreciated. <br /><br />Do someone have some clues ? <br /><br />Regards, <br />hc<p>Statistics: Posted by Guest — Thu Sep 15, 2011 8:42 pm</p><hr />
]]></content>
	</entry>
	</feed>
