3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Quick Key Adapter, 10 Button HID Keyboard

Step 4Firmware

Firmware

This device's design is based on the Low Pin Count Development Kit hardware from Microchip, Microchip Solutions has example programs for that development kit so it is quite easy to get them running on the device covered in this Instructable.

For the purposes of this project I used the USB Device - HID - Keyboard example for the Low Pin Count Development Kit. But there are various other devices that could be programmed onto this hardware/device, anything that could use 10 switch inputs.

Included in the ZIP on Step 1 is the MPLAB project files, you must install the latest version of MPLAB and the latest release of C18 compiler. Microchip Downloads Can Be Found Here


Firmware Overview:

The included project files were taken and modified from Microchip's example code. They had wrote it in a way so it can run on multiple different PIC devices, so there is a lot of extra code not needed. The rest is mostly USB related code, the only function that was modified was the Keyboard() function.

ProcessIO() -> Keyboard() -> Check if IN endpoint is ready -> Check Switches ->Send Data -> ProcessIO()

The switches state are checked and compared to their previous state. if the states differ the switch is considered pressed and will fill a data buffer with/the required data then send it. Then continue checking the switches.

hid_report_in[0] = is the modifier byte, it holds the state of the shift, alt, ctrl, gui(windows) keys
hid_report_in[1] = 0; is reserved and always 0
hid_report_in[2] thru [7] // Can be a keycode, up to 6 keys can be pressed and reported at once
See the "HID Usage Tables" pg. 52 for keycodes

Modifier key chart:

Bit Key
0 LEFT CTRL
1 LEFT SHIFT
2 LEFT ALT
3 LEFT GUI
4 RIGHT CTRL
5 RIGHT SHIFT
6 RIGHT ALT
7 RIGHT GUI

Example:
         hid_report_in[0] = 4; //alt
         hid_report_in[0] = 8; //L GUI
         hid_report_in[0] = 7; //ctrl+alt + shift


Some commands need a second key sent or key combo sent, by setting filling the data bytes NextModKey and NextKey then setting AnotherFlag flag in the firmware, after the primary command is sent it will send another report with those key values.

Such as Minimize Window which the Windows hotkey is Alt+Spacebar, then press n.




« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
63
Followers
18
Author:ChromationSystems(www.chromationsystems.com)
Designing electronic creations from microcontrollers, LEDs and anything else I can pull out of a dumpster and make use of. Check my Profile