A optical beam breaker detector that appears to aPC as a USB keyboard, typing characters when the beam is broken

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers USBKeyboard.h Source File

USBKeyboard.h

00001 /* mbed Microcontroller Library - USBKeyboard
00002  * Copyright (c) 2007-2008, sford, pwright
00003  */
00004  
00005 #include "Stream.h"
00006 #include "usbhid.h"
00007 
00008 #ifndef USBKEYBOARD_H
00009 #define USBKEYBOARD_H
00010 
00011 /* Class: USBKeyboard
00012  *  Emulate a USB Keyboard
00013  *
00014  * This class will enumerate as a USB Keyboard to a host computer. 
00015  * The host should be connected using the USB Device interface pins (D+, D-, GND)
00016  */
00017 class USBKeyboard : public Stream {
00018 public:
00019 
00020 #if 0 // Inhereted from Stream, for documentation only
00021 
00022     /* Function: putc
00023      *  Send a character keypress
00024      *
00025      * Variables:
00026      *  c - The character to send
00027      */
00028     int putc(int c);
00029 
00030     /* Function: printf
00031      *  Send a formated string of character keypresses
00032      *
00033      * Variables:
00034      *  format - A printf-style format string, followed by the 
00035      *      variables to use in formating the string.
00036      */
00037     int printf(const char* format, ...);
00038 
00039 #endif
00040 
00041     virtual int _putc(int value);    
00042     virtual int _getc();
00043 private:
00044     usbhid _usbhid;
00045 };
00046 
00047 
00048 #endif