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

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2010-04-20T22:02:58+02:00</updated>

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

		<entry>
		<author><name><![CDATA[pppoe]]></name></author>
		<updated>2010-04-20T22:02:58+02:00</updated>

		<published>2010-04-20T22:02:58+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=4164&amp;p=14192#p14192</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=4164&amp;p=14192#p14192"/>
		<title type="html"><![CDATA[Re: easylogger mouse and keyboard device]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=4164&amp;p=14192#p14192"><![CDATA[
my Email is <!-- e --><a href="mailto:jangs2003@seed.net.tw">jangs2003@seed.net.tw</a><!-- e --><br />this is only keyboard part~i need add mouse part~<br /><br />please help me~thank every body<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=3801">pppoe</a> — Tue Apr 20, 2010 10:02 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[pppoe]]></name></author>
		<updated>2010-04-20T22:00:59+02:00</updated>

		<published>2010-04-20T22:00:59+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=4164&amp;p=14191#p14191</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=4164&amp;p=14191#p14191"/>
		<title type="html"><![CDATA[easylogger mouse and keyboard device]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=4164&amp;p=14191#p14191"><![CDATA[
hi can help me fix this code<br />i want make a USB Composite Device (mouse + keyboard)<br />hope somebody can help me fix this code ~<br />thank you<br /><br />[CODE]<br /><br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/wdt.h&gt;<br />#include &lt;avr/eeprom.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;util/delay.h&gt;<br /><br />#include &quot;usbdrv.h&quot;<br />#include &quot;oddebug.h&quot;<br /><br />/*<br />Pin assignment:<br /><br /><br />PB0, PB2 = USB data lines<br />*/<br /><br />#define BIT_LED 4<br />#define BIT_KEY 1<br /><br /><br />#define UTIL_BIN4(x)        (uchar)((0##x &amp; 01000)/64 + (0##x &amp; 0100)/16 + (0##x &amp; 010)/4 + (0##x &amp; 1))<br />#define UTIL_BIN8(hi, lo)   (uchar)(UTIL_BIN4(hi) * 16 + UTIL_BIN4(lo))<br /><br />#ifndef NULL<br />#define NULL    ((void *)0)<br />#endif<br /><br />/* ------------------------------------------------------------------------- */<br /><br />static uchar    reportBuffer[2];    /* buffer for HID reports */<br />static uchar    idleRate;           /* in 4 ms units */<br /><br /><br />static uchar    FlagKey;<br /><br />/* ------------------------------------------------------------------------- */<br /><br />PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = { /* USB report descriptor */<br />    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 />    0x25, 0x65,                    //   LOGICAL_MAXIMUM (101)<br />    0x19, 0x00,                    //   USAGE_MINIMUM (Reserved (no event indicated))<br />    0x29, 0x65,                    //   USAGE_MAXIMUM (Keyboard Application)<br />    0x81, 0x00,                    //   INPUT (Data,Ary,Abs)<br />    0xc0                           // END_COLLECTION<br />};<br />/* We use a simplifed keyboard report descriptor which does not support the<br /> * boot protocol. We don't allow setting status LEDs and we only allow one<br /> * simultaneous key press (except modifiers). We can therefore use short<br /> * 2 byte input reports.<br /> * The report descriptor has been created with usb.org's &quot;HID Descriptor Tool&quot;<br /> * which can be downloaded from <!-- m --><a class="postlink" href="http://www.usb.org/developers/hidpage/">http://www.usb.org/developers/hidpage/</a><!-- m -->.<br /> * Redundant entries (such as LOGICAL_MINIMUM and USAGE_PAGE) have been omitted<br /> * for the second INPUT item.<br /> */<br /><br />/* Keyboard usage values, see usb.org's HID-usage-tables document, chapter<br /> * 10 Keyboard/Keypad Page for more codes.<br /> */<br />#define MOD_CONTROL_LEFT    (1&lt;&lt;0)<br />#define MOD_SHIFT_LEFT      (1&lt;&lt;1)<br />#define MOD_ALT_LEFT        (1&lt;&lt;2)<br />#define MOD_GUI_LEFT        (1&lt;&lt;3)<br />#define MOD_CONTROL_RIGHT   (1&lt;&lt;4)<br />#define MOD_SHIFT_RIGHT     (1&lt;&lt;5)<br />#define MOD_ALT_RIGHT       (1&lt;&lt;6)<br />#define MOD_GUI_RIGHT       (1&lt;&lt;7)<br /><br />// 修改1 ,定義上下左右<br />#define KEY_UP82<br />#define KEY_DOWN81<br />#define KEY_LEFT80<br />#define KEY_RIGHT79<br /><br />/* ------------------------------------------------------------------------- */<br /><br /><br />static void timerPoll(void)<br />{<br />static uchar timerCnt;<br />static uchar i;<br /><br />    if(TIFR &amp; (1 &lt;&lt; TOV1)){<br />        TIFR = (1 &lt;&lt; TOV1); /* clear overflow */<br />        if(++timerCnt &gt;= 63){       /* ~ 1 second interval */<br />    timerCnt = 0;<br />if (!FlagKey) {<br />FlagKey = 1;<br /><br />if (++i &gt; 3)<br />i=0;<br />switch (i) {<br />case 0:<br />reportBuffer[0] = 0;    /* no modifiers */<br />reportBuffer[1] = KEY_RIGHT;<br />break;<br />case 1:<br />reportBuffer[0] = 0;    /* no modifiers */<br />reportBuffer[1] = KEY_DOWN;<br />break;<br />case 2:<br />reportBuffer[0] = 0;    /* no modifiers */<br />reportBuffer[1] = KEY_LEFT;<br />break;<br />case 3:<br />reportBuffer[0] = 0;    /* no modifiers */<br />reportBuffer[1] = KEY_UP;<br />break;<br />}<br /><br />}<br />        }<br />    }<br />}<br />/* ------------------------------------------------------------------------- */<br /><br />static void timerInit(void)<br />{<br />    TCCR1 = 0x0b;           /* select clock: 16.5M/1k -&gt; overflow rate = 16.5M/256k = 62.94 Hz */<br />}<br /><br /><br />/* ------------------------------------------------------------------------- */<br />/* ------------------------ interface to USB driver ------------------------ */<br />/* ------------------------------------------------------------------------- */<br /><br />ucharusbFunctionSetup(uchar data[8])<br />{<br />usbRequest_t    *rq = (void *)data;<br /><br />    usbMsgPtr = reportBuffer;<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 />            /* we only have one report type, so don't look at wValue */<br />            reportBuffer[0] = 0;    /* no modifiers */<br />reportBuffer[1] = 0;<br />            return sizeof(reportBuffer);<br />        }else if(rq-&gt;bRequest == USBRQ_HID_GET_IDLE){<br />            usbMsgPtr = &amp;idleRate;<br />            return 1;<br />        }else if(rq-&gt;bRequest == USBRQ_HID_SET_IDLE){<br />            idleRate = rq-&gt;wValue.bytes[1];<br />        }<br />    }else{<br />        /* no vendor specific requests implemented */<br />    }<br />return 0;<br />}<br /><br />/* ------------------------------------------------------------------------- */<br />/* --------------------------------- main ---------------------------------- */<br />/* ------------------------------------------------------------------------- */<br /><br />int main(void)<br />{<br />uchar    i;<br /><br />/* Calibrate the RC oscillator to 8.25 MHz. The core clock of 16.5 MHz is<br /> * derived from the 66 MHz peripheral clock by dividing. We assume that the<br /> * EEPROM contains a calibration value in location 0. If no calibration value<br /> * has been stored during programming, we offset Atmel's 8 MHz calibration<br /> * value according to the clock vs OSCCAL diagram in the data sheet. This<br /> * seems to be sufficiently precise (&lt;= 1%).<br /> */<br />    uchar calibrationValue = eeprom_read_byte(0);<br />    if(calibrationValue != 0xff){<br />        OSCCAL = calibrationValue;  /* a calibration value is supplied */<br />    }else{<br />        /* we have no calibration value, assume 8 MHz calibration and adjust from there */<br />        if(OSCCAL &lt; 125){<br />            OSCCAL += 3;    /* should be 3.5 */<br />        }else if(OSCCAL &gt;= 128){<br />            OSCCAL += 7;    /* should be 7 */<br />        }else{  /* must be between 125 and 128 */<br />            OSCCAL = 127;   /* maximum possible avoiding discontinuity */<br />        }<br />    }<br />    odDebugInit();<br />    DDRB = (1 &lt;&lt; USB_CFG_DMINUS_BIT) | (1 &lt;&lt; USB_CFG_DPLUS_BIT);<br />    PORTB = 0;          /* indicate USB disconnect to host */<br />    for(i=0;i&lt;20;i++){  /* 300 ms disconnect, also allows our oscillator to stabilize */<br />        _delay_ms(15);<br />    }<br />    DDRB = 1 &lt;&lt; BIT_LED;    /* output for LED */<br />    PORTB = 1 &lt;&lt; BIT_KEY;   /* pull-up on key input */<br />    wdt_enable(WDTO_1S);<br />    timerInit();<br />    usbInit();<br />    sei();<br />    for(;;){    /* main event loop */<br />        wdt_reset();<br />        usbPoll();<br />        if(usbInterruptIsReady() ){ /* we can send another key */<br />         <br />            usbSetInterrupt(reportBuffer, sizeof(reportBuffer));<br />            FlagKey = 0;<br />        }<br />        timerPoll();<br />    }<br />    return 0;<br />}<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=3801">pppoe</a> — Tue Apr 20, 2010 10:00 pm</p><hr />
]]></content>
	</entry>
	</feed>
