![](/media/cache/profiles/1006ff12c465532f8c574aeaa4461b16.50x50_q85.jpg)
A test program for PS2 library.
mylib/PS2/PS2Mouse.h@4:47b51250a168, 2010-10-13 (annotated)
- Committer:
- shintamainjp
- Date:
- Wed Oct 13 10:50:55 2010 +0000
- Revision:
- 4:47b51250a168
First version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shintamainjp | 4:47b51250a168 | 1 | /** |
shintamainjp | 4:47b51250a168 | 2 | * PS/2 mouse interface control class (Version 0.0.1) |
shintamainjp | 4:47b51250a168 | 3 | * |
shintamainjp | 4:47b51250a168 | 4 | * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems) |
shintamainjp | 4:47b51250a168 | 5 | * http://shinta.main.jp/ |
shintamainjp | 4:47b51250a168 | 6 | */ |
shintamainjp | 4:47b51250a168 | 7 | #ifndef _PS2_MOUSE_H_ |
shintamainjp | 4:47b51250a168 | 8 | #define _PS2_MOUSE_H_ |
shintamainjp | 4:47b51250a168 | 9 | |
shintamainjp | 4:47b51250a168 | 10 | #include "PS2MS_INIT.h" |
shintamainjp | 4:47b51250a168 | 11 | #include "PS2MS.h" |
shintamainjp | 4:47b51250a168 | 12 | |
shintamainjp | 4:47b51250a168 | 13 | class PS2Mouse { |
shintamainjp | 4:47b51250a168 | 14 | public: |
shintamainjp | 4:47b51250a168 | 15 | PS2Mouse(PinName clk_pin, PinName dat_pin); |
shintamainjp | 4:47b51250a168 | 16 | ~PS2Mouse(); |
shintamainjp | 4:47b51250a168 | 17 | typedef struct { |
shintamainjp | 4:47b51250a168 | 18 | bool left; |
shintamainjp | 4:47b51250a168 | 19 | bool center; |
shintamainjp | 4:47b51250a168 | 20 | bool right; |
shintamainjp | 4:47b51250a168 | 21 | int x; |
shintamainjp | 4:47b51250a168 | 22 | int y; |
shintamainjp | 4:47b51250a168 | 23 | int z; |
shintamainjp | 4:47b51250a168 | 24 | } mouse_event_t; |
shintamainjp | 4:47b51250a168 | 25 | bool processing(mouse_event_t *p); |
shintamainjp | 4:47b51250a168 | 26 | private: |
shintamainjp | 4:47b51250a168 | 27 | PS2MS_INIT ps2ms_init; |
shintamainjp | 4:47b51250a168 | 28 | PS2MS ps2ms; |
shintamainjp | 4:47b51250a168 | 29 | typedef struct { |
shintamainjp | 4:47b51250a168 | 30 | union { |
shintamainjp | 4:47b51250a168 | 31 | uint8_t byte; |
shintamainjp | 4:47b51250a168 | 32 | struct { |
shintamainjp | 4:47b51250a168 | 33 | uint8_t btnLeft:1; |
shintamainjp | 4:47b51250a168 | 34 | uint8_t btnRight:1; |
shintamainjp | 4:47b51250a168 | 35 | uint8_t btnCenter:1; |
shintamainjp | 4:47b51250a168 | 36 | uint8_t always1:1; |
shintamainjp | 4:47b51250a168 | 37 | uint8_t signX:1; |
shintamainjp | 4:47b51250a168 | 38 | uint8_t signY:1; |
shintamainjp | 4:47b51250a168 | 39 | uint8_t overflowX:1; |
shintamainjp | 4:47b51250a168 | 40 | uint8_t overflowY:1; |
shintamainjp | 4:47b51250a168 | 41 | } bit; |
shintamainjp | 4:47b51250a168 | 42 | } byte1; |
shintamainjp | 4:47b51250a168 | 43 | union { |
shintamainjp | 4:47b51250a168 | 44 | uint8_t byte; |
shintamainjp | 4:47b51250a168 | 45 | } byte2; |
shintamainjp | 4:47b51250a168 | 46 | union { |
shintamainjp | 4:47b51250a168 | 47 | uint8_t byte; |
shintamainjp | 4:47b51250a168 | 48 | } byte3; |
shintamainjp | 4:47b51250a168 | 49 | union { |
shintamainjp | 4:47b51250a168 | 50 | uint8_t byte; |
shintamainjp | 4:47b51250a168 | 51 | struct { |
shintamainjp | 4:47b51250a168 | 52 | uint8_t value:7; |
shintamainjp | 4:47b51250a168 | 53 | uint8_t signZ:1; |
shintamainjp | 4:47b51250a168 | 54 | } bit; |
shintamainjp | 4:47b51250a168 | 55 | } byte4; |
shintamainjp | 4:47b51250a168 | 56 | } mouse_info_t; |
shintamainjp | 4:47b51250a168 | 57 | mouse_info_t mi; |
shintamainjp | 4:47b51250a168 | 58 | int cnt; |
shintamainjp | 4:47b51250a168 | 59 | }; |
shintamainjp | 4:47b51250a168 | 60 | |
shintamainjp | 4:47b51250a168 | 61 | #endif |