USB Keyboard


Closed Thread
Results 1 to 20 of 20

Thread: USB Keyboard

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139

    Default Re: USB Keyboard

    Thank you very much pedja089!

    Looks great and very close to what I need to do. have to add a small graphics display and test it on Win 10. Hope Win 10 do not pose any communication problem.

    Really appreciated.
    Ioannis

  2. #2
    Join Date
    Sep 2009
    Posts
    755

    Default Re: USB Keyboard

    I used it on win7, and if I remember correctly on XP. It should work on win10.
    You have keys.PBP, with all defined keys, also in .doc document you have codes.

    Also USBSERVICE should be called every 10mS or so. I wanted to implement it with DT INT, but newer did...
    It should be something like this

    Code:
    INCLUDE "DT_INTS-18.bas"
    INCLUDE "ReEnterPBP-18.bas"
     
    ASM
    INT_LIST  macro		; IntSource,       Label,       Type,  ResetFlag?
            INT_Handler   USB_INT,  _SERVICE_USB,       ASM,  yes 
        endm
        INT_CREATE		; Creates the interrupt processor
    ENDASM
    
    USBINIT                'INITIALIZE USB
    USBSERVICE             'SERVICE USB
    UIE = $7F              'ENABLE USB INTERRUPTS
    UEIE = $9F             'ENABLE USB ERROR INTERRUPTS
    @ INT_ENABLE  USB_INT
    
    
    SERVICE_USB:
        USBSERVICE
    @ INT_RETURN
    This code is also from forum, but never tried it.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139

    Default Re: USB Keyboard

    Thanks for this tip also. I had in mind to make this Interrupt driven service but in a later stage.

    Ioannis

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139

    Default Re: USB Keyboard

    Thanks to your help I am making a progress after a lot of experimenting. Sure I do not understand the whole process but anyway...

    I managed to enumerate the PIC and display on an open text file a short string of characters from an 8 byte buffer.

    How can this buffer made bigger? I changed these in the main program
    Code:
    USBBufferSizeTX con 16                                                                                    
    USBBufferSizeRX con 16
    USBBufferCount Var Byte
    USBBufferIn var byte[16]
    USBBufferOut Var Byte[16]
    but still sends only the half buffer.

    Then I changed in the hid_desc.bas file this line

    Code:
    retlw	0x10		; This should be the size of the endpoint buffer
    from 0x08 to 0x10 but still no joy. I attach the descriptor file.

    Any idea?

    Ioannis

    P.S. I also changed

    #define HID_INT_OUT_EP_SIZE 8

    in the descriptor file to 16 but still sends 8 byte buffer...
    Attached Files Attached Files
    Last edited by Ioannis; - 18th December 2021 at 21:06.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,653

    Default Re: USB Keyboard

    never tried it as hid kb but for a hid cdc anyway the data you need to send must be chunked into usb-tx buffer sized lumps
    then sent a multiple usb transmissions.

    what have you tried ?
    Warning I'm not a teacher

  6. #6
    Join Date
    Sep 2009
    Posts
    755

    Default Re: USB Keyboard

    It is not so easy to change buffer. You must change descriptor file, not just length(If I understand usb correctly).

    You can send one letter and modifier key at time.

    Use this

    Code:
     For i = 0 To 20	
                    lookup i,[KEY_V, KEY_A, KEY_L, KEY_U, KEY_E, KEY_ENTER, 0], USBBufferOut[2]
                    call DoUsbOut
                    IF USBBufferOut[2]=0 THEN EXIT
                Next i
    You can use array
    Code:
     For i = 0 To 20	
                      USBBufferOut[2]= MyArray[i]
                    call DoUsbOut
                    IF USBBufferOut[2]=0 THEN EXIT
                Next i

  7. #7
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967

    Default Re: USB Keyboard

    If you follow the HID descriptor fields, you will notice you need to change the report count for the report which has to carry more data. The endpoint buffer is just a holding place for the in/out data that is handled by the USB interrupt. I am not very conversant with HID at the moment, but can look it up as I have worked on HID keyboards with PSoC
    Last edited by Jerson; - 19th December 2021 at 03:43. Reason: removed signature

Similar Threads

  1. PIC18F14K50 USB Keyboard firmware
    By ScumariTec in forum USB
    Replies: 0
    Last Post: - 27th January 2021, 10:29
  2. USB keyboard emulator
    By Toley00 in forum USB
    Replies: 12
    Last Post: - 23rd January 2012, 00:57
  3. One USB keyboard to Two USB Ports
    By picnaut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th June 2009, 00:04
  4. Replies: 17
    Last Post: - 13th June 2008, 21:33
  5. Replies: 3
    Last Post: - 10th April 2008, 10:02

Members who have read this thread : 1

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