1 / 23

Keyboard, Mouse, and Joystick Interfaces

This article explains the interfaces for keyboards, mice, and joysticks. It covers the protocols, scan codes, and mappings for these input devices. It also provides resources and Verilog code for implementing the interfaces.

gcasey
Download Presentation

Keyboard, Mouse, and Joystick Interfaces

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COMP541Input Devices: Keyboards, Mice and Joysticks Montek Singh Apr 16, 2012

  2. Keyboard Interface

  3. PS/2 Keyboard • Uses a synchronous serial protocol • What does that mean? • Each symbol is transmitted bit-by-bit • 8 data bits + 3 control bits

  4. Physical Interface • Two lines • Clock (15-20KHz) • Data • Normally high, asserted low • Read: • pp 13-14 of Nexys 3 manual

  5. Protocol • Bidirectional • Kybd-to-host and host-to-kybd on same wires • CAPS LOCK light for example • Assert low • To send, keyboard starts clocking • sends successive bit on positive edge of clock • host reads bits on negative edges of clock • You shouldn’t need to send to kybd

  6. Protocol • 11 bits • a start bit: always 0 • 8 bits of data • lsb first • one parity bit (odd) • a stop bit: always 1 • Clocked by keyboard • Value should be latched by FPGA on neg edge of keyboard clock Illustration from http://www.beyondlogic.org/keyboard/keybrd.htm

  7. What is Sent • ASCII is not sent! • Scan codes for keys • Most keys have an 8-bit (single byte) scancode • Some have two bytes • A few have even more! • Most (not all, be careful!) keyboards use these scancodes: Illustration from Nexys 3 manual

  8. Scan Codes • Normally translated by software • You remap your keys, for example • Software takes care of • Shift, caps lock, control

  9. Some Scan Codes Long • Two code sequence common • Have a look at Break key!

  10. Even More Complicated • Scan code generated when you press • And when you release • Two bytes: F0 followed by key scan code • Example: • Space pressed, 29 sent • Space released, F0 29 sent • If you hold key, scan code repeated

  11. Resources • Information http://www.beyondlogic.org/keyboard/keybrd.htm • Scan codes http://www.barcodeman.com/altek/mule/scandoc.php • My Verilog for keyboard is on the class website

  12. My Verilog • Have Verilog for keyboard • Have tested it with the FPGA kit; seems to work fine • To use: • You should memory-map the character code register • give the keyboard a memory address so the CPU can read it using lw instructions • Handle presses and releases appropriately in software • maybe add another register to indicate that a new character has arrived..??

  13. Mice

  14. Mouse • Very similar interface (clk & data) • But: 3 words sent w/ mouse movement or button press • Read • pp 14-15 of Nexys 3 manual

  15. Movement • Movement is relative • XS, YS are sign (+ is up/right) • XV, YV are overflow (too fast) • L, R are buttons

  16. Scroll Wheel, etc. • Extensions to original 2 button PS/2 mouse • See http://www.computer-engineering.org/ps2mouse/

  17. Joystick (Courtesy Anselmo Lastra)

  18. Atari 2600 Joystick (we only have 2-3) http://www.atariarchives.org

  19. We Have Sega Joypads (we have 5-6) • Enhanced version with more buttons • Has mux • Select pin chooses first or second set of buttons, L/R http://pinouts.ru/data/genesiscontroller_pinout.shtml

  20. Six Button Use • See • http://www.cs.cmu.edu/~chuck/infopg/segasix.txt • Use select to use buttons B & C • To use X, Y, Z, need to pulse select

  21. NEXYS Mappings (PMOD JA) • We have to connect them using wires… PMOD JA is 10-pin connector nearest VGA connector

  22. Suggestion • Create FF for Select • Memory map so you can set from CPU • Memory map the input signals • I would not latch them • Please power off when plugging or unplugging Sega joypads! • Careful when plugging in PCB

  23. Links • http://pinouts.ru/data/JoystickAtari2600_pinout.shtml • http://pinouts.ru/data/genesiscontroller_pinout.shtml • http://www.epanorama.net/documents/joystick/ataristick.html • http://www.epanorama.net/documents/joystick/tvgames.html • http://www.cs.cmu.edu/~chuck/infopg/segasix.txt

More Related