CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

usb keyboard auto repeat / typematic

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
guy



Joined: 21 Oct 2005
Posts: 297

View user's profile Send private message Visit poster's website

usb keyboard auto repeat / typematic
PostPosted: Tue Feb 03, 2015 9:58 am     Reply with quote

I need to implement a keyboard with the USB HID library. I have done it before but now I need to add auto repeat / typematic (when a key is held down it repeats itself). Is there an option for that or do I have to manually program it?
Thanks!!
guy



Joined: 21 Oct 2005
Posts: 297

View user's profile Send private message Visit poster's website

solution!
PostPosted: Thu Feb 05, 2015 1:21 pm     Reply with quote

Darren from CCS tech support helped me with this one so I'll share it with you:
Quote:
While the key is held down the BIOS and OS handle what to do.

So the auto repeat is handled in the BIOS/Windows. I looked into the example code in ex_usb_keyboard.c and saw that in each iteration usb_keyboard_task() sends either a character or an empty array which signals that no key is pressed.
Code:

/////////////////////////////////////////////////////////////////////////////
//
// usb_keyboard_task()
//
// Sends a packet of keyboard data.  The protocol was specified in the HID
// report descriptor (see usb_desc_kbmouse.h), and is:
//     tx_msg[0] = modifier (see kb_modifier_t)
//     tx_msg[1] = const 0
//     tx_msg[2:6] = an array of held down keys.  a=4, b=5, etc.
//                   if msg[2:7]={0} then no keys are held down
//
//     rx_msg[0] = 5bit bitmap of led status
//
/////////////////////////////////////////////////////////////////////////////


What I did is to make tx_msg a global array that is NOT cleared each time but instead keeps track of the pressed keys (in index 2-6 of the array). When a key is released the suitable entry in the array is set to 0 which signals Key Released. Works great! My code is a little sloppy so I didn't upload it but let me know if someone needs actual code.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group