![](/media/cache/profiles/1006ff12c465532f8c574aeaa4461b16.50x50_q85.jpg)
A test program for PS2 library.
main.cpp@2:b06d5cea5b11, 2010-09-29 (annotated)
- Committer:
- shintamainjp
- Date:
- Wed Sep 29 14:12:59 2010 +0000
- Revision:
- 2:b06d5cea5b11
- Parent:
- 1:e5eac8a97060
- Child:
- 3:a3ba8d3e3958
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shintamainjp | 0:aabf6427c82e | 1 | /** |
shintamainjp | 0:aabf6427c82e | 2 | * Test program. |
shintamainjp | 0:aabf6427c82e | 3 | * |
shintamainjp | 0:aabf6427c82e | 4 | * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems) |
shintamainjp | 0:aabf6427c82e | 5 | * http://shinta.main.jp/ |
shintamainjp | 0:aabf6427c82e | 6 | */ |
shintamainjp | 0:aabf6427c82e | 7 | |
shintamainjp | 0:aabf6427c82e | 8 | #include "mbed.h" |
shintamainjp | 2:b06d5cea5b11 | 9 | #include "TextLCD.h" |
shintamainjp | 2:b06d5cea5b11 | 10 | #include "PS2Mouse.h" |
shintamainjp | 2:b06d5cea5b11 | 11 | #include "PS2Keyboard.h" |
shintamainjp | 0:aabf6427c82e | 12 | |
shintamainjp | 2:b06d5cea5b11 | 13 | TextLCD lcd(p24, p26, p27, p28, p29, p30); |
shintamainjp | 2:b06d5cea5b11 | 14 | PS2Keyboard ps2kb(p12, p11); |
shintamainjp | 2:b06d5cea5b11 | 15 | PS2Mouse ps2ms(p23, p22); |
shintamainjp | 0:aabf6427c82e | 16 | |
shintamainjp | 0:aabf6427c82e | 17 | int main() { |
shintamainjp | 2:b06d5cea5b11 | 18 | PS2Mouse::mouse_event_t evt_ms; |
shintamainjp | 2:b06d5cea5b11 | 19 | PS2Keyboard::keyboard_event_t evt_kb; |
shintamainjp | 2:b06d5cea5b11 | 20 | |
shintamainjp | 2:b06d5cea5b11 | 21 | lcd.locate(0, 0); |
shintamainjp | 2:b06d5cea5b11 | 22 | lcd.printf("> Mouse <"); |
shintamainjp | 2:b06d5cea5b11 | 23 | lcd.locate(0, 1); |
shintamainjp | 2:b06d5cea5b11 | 24 | lcd.printf("> Keyboard <"); |
shintamainjp | 1:e5eac8a97060 | 25 | |
shintamainjp | 0:aabf6427c82e | 26 | while (1) { |
shintamainjp | 2:b06d5cea5b11 | 27 | if (ps2ms.processing(&evt_ms)) { |
shintamainjp | 2:b06d5cea5b11 | 28 | lcd.locate(0, 0); |
shintamainjp | 2:b06d5cea5b11 | 29 | lcd.printf("%c%c%c:%4d,%4d,%2d", |
shintamainjp | 2:b06d5cea5b11 | 30 | evt_ms.left ? 'L' : '.', |
shintamainjp | 2:b06d5cea5b11 | 31 | evt_ms.center ? 'C' : '.', |
shintamainjp | 2:b06d5cea5b11 | 32 | evt_ms.right ? 'R' : '.', |
shintamainjp | 2:b06d5cea5b11 | 33 | evt_ms.x, evt_ms.y, evt_ms.z); |
shintamainjp | 0:aabf6427c82e | 34 | } |
shintamainjp | 2:b06d5cea5b11 | 35 | if (ps2kb.processing(&evt_kb)) { |
shintamainjp | 2:b06d5cea5b11 | 36 | lcd.locate(0, 1); |
shintamainjp | 2:b06d5cea5b11 | 37 | for (int i = 0; i < evt_kb.length; i++) { |
shintamainjp | 2:b06d5cea5b11 | 38 | lcd.printf("%02X", evt_kb.scancode[i]); |
shintamainjp | 1:e5eac8a97060 | 39 | } |
shintamainjp | 2:b06d5cea5b11 | 40 | for (int i = 0; i < 16 - evt_kb.length * 2; i++) { |
shintamainjp | 2:b06d5cea5b11 | 41 | lcd.printf("-"); |
shintamainjp | 2:b06d5cea5b11 | 42 | } |
shintamainjp | 1:e5eac8a97060 | 43 | } |
shintamainjp | 0:aabf6427c82e | 44 | } |
shintamainjp | 0:aabf6427c82e | 45 | } |