HID Keyboard Example


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by Kamikaze47 View Post
    Hi,
    I realize I am resurrecting an old thread here, but I'm trying to get an 18F4550 to act as a "virtual keyboard". I've used Merfy's KBDDESC.ASM (above) and i've managed to get the PC to detect it as a keyboard, and can send keystrokes, however when I do, it seems to send the keystroke over and over and over until I send another one.
    If I do this for example (and keep in mind this line is only run once):
    USBOut 1, buffer, 8, endgame
    where buffer=[0,0,$14,0,0,0,0,0] ' ($14=q)
    the pc types "qqqqqqqqqqqqqqqqqqqqqq....." and on forever.
    any suggestions?
    Not really sure if this has anything to do with your problem...
    http://www.beyondlogic.org/keyboard/keybrd.htm

    Looks to me like you you're on the right track...just not all the way there yet.
    You've told the PC that you've pressed the 'q' key, but you haven't told the PC that you've released it, therefore, it repeats.
    The first paragraph of the link above has some good info in it on the whole keyboard theory...should give you all the answers you need.

  2. #2
    Join Date
    Aug 2008
    Posts
    66

    Question

    Quote Originally Posted by skimask View Post
    Not really sure if this has anything to do with your problem...
    http://www.beyondlogic.org/keyboard/keybrd.htm

    Looks to me like you you're on the right track...just not all the way there yet.
    You've told the PC that you've pressed the 'q' key, but you haven't told the PC that you've released it, therefore, it repeats.
    The first paragraph of the link above has some good info in it on the whole keyboard theory...should give you all the answers you need.
    I can't seem to get the USB to work with PIC18F4550 using the KBDDESC.ASM

    I keep getting USB error if i plug in the PIC.

    Code:
    buffer	Var	Byte[8]
    loopcnt	Var	Byte
    state	Var	Byte
    
    Define  OSC     48
    
    
    
    	Pause 10
    
    	USBInit
    	
    	buffer[0] = 0
    	buffer[1] = 0
    	buffer[2] = 0
                    buffer[3] = 0
                    buffer[4] = 0
    	buffer[5] = 0
    	buffer[6] = 0
                     buffer[7] = 0
    
    movecursor:
       
      
                   buffer[0] = 0
    	buffer[1] = 0
    	buffer[2] = $14
                    buffer[3] = 0
    
    endgame:
    			USBService	' Must service USB regularly
    			USBOut 1, buffer, 8, endgame  ' Send buffer to endpoint 1
    	while(1)
    	wend
    	Goto movecursor	' Do it forever


    Anyone knows what is wrong ?

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429

    Default

    what speed external clock are you using?

    and what configs are you using?
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  4. #4
    Join Date
    Aug 2008
    Posts
    66

    Default

    Using 20Mhz crystal.

    Config is:

    __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L


    __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H

    I have tried using diff cap recommended in this forum.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Try this
    Code:
    DEFINE OSC 48
    @ __CONFIG   _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    @ __CONFIG   _CONFIG1H, _FOSC_HSPLL_HS_1H
    @ __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
    @ __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H 
    @ __CONFIG    _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L &_XINST_OFF_4L
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2006
    Location
    Venezuela - Caracas
    Posts
    48

    Default

    I use KBDDESC.txt

    USBOut 1, buffer, 8, endgame

    t = $0
    where buffer=[t,0,$14,0,0,0,0,0] ' ($14=q) OK

    t = $2
    buffer=[t,0,$33,0,0,0,0,0]' ($33 = /) error

    i need send "?" = #33 + shift = $2
    ..: Don't worry, be happy :..

Similar Threads

  1. USB hid maker help please.
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd April 2013, 14:49
  2. i cant get 18f2550 work as HID
    By Ahmadabuomar in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 13th October 2009, 16:39
  3. AT/PS2 Keybord - PIC Interface?
    By Kamikaze47 in forum Code Examples
    Replies: 73
    Last Post: - 9th August 2009, 16:10
  4. One USB keyboard to Two USB Ports
    By picnaut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th June 2009, 00:04
  5. My wish: AT Keyboard and Mouse commands
    By sayzer in forum PBP Wish List
    Replies: 0
    Last Post: - 4th February 2006, 08:23

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts