Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of PS2 by
PS2Mouse.h@1:f290d8dc0afc, 2014-01-24 (annotated)
- Committer:
- alexanderh
- Date:
- Fri Jan 24 09:47:28 2014 +0000
- Revision:
- 1:f290d8dc0afc
- Parent:
- 0:62b62530a82f
enabled debug prints
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pprasad7 | 0:62b62530a82f | 1 | /** |
| pprasad7 | 0:62b62530a82f | 2 | * PS/2 mouse interface control class (Version 0.0.1) |
| pprasad7 | 0:62b62530a82f | 3 | * |
| pprasad7 | 0:62b62530a82f | 4 | * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems) |
| pprasad7 | 0:62b62530a82f | 5 | * http://shinta.main.jp/ |
| pprasad7 | 0:62b62530a82f | 6 | */ |
| pprasad7 | 0:62b62530a82f | 7 | #ifndef _PS2_MOUSE_H_ |
| pprasad7 | 0:62b62530a82f | 8 | #define _PS2_MOUSE_H_ |
| pprasad7 | 0:62b62530a82f | 9 | |
| pprasad7 | 0:62b62530a82f | 10 | #include "PS2MS_INIT.h" |
| pprasad7 | 0:62b62530a82f | 11 | #include "PS2MS.h" |
| pprasad7 | 0:62b62530a82f | 12 | |
| pprasad7 | 0:62b62530a82f | 13 | class PS2Mouse { |
| pprasad7 | 0:62b62530a82f | 14 | public: |
| pprasad7 | 0:62b62530a82f | 15 | PS2Mouse(PinName clk_pin, PinName dat_pin); |
| pprasad7 | 0:62b62530a82f | 16 | ~PS2Mouse(); |
| pprasad7 | 0:62b62530a82f | 17 | typedef struct { |
| pprasad7 | 0:62b62530a82f | 18 | bool left; |
| pprasad7 | 0:62b62530a82f | 19 | bool center; |
| pprasad7 | 0:62b62530a82f | 20 | bool right; |
| pprasad7 | 0:62b62530a82f | 21 | int x; |
| pprasad7 | 0:62b62530a82f | 22 | int y; |
| pprasad7 | 0:62b62530a82f | 23 | int z; |
| pprasad7 | 0:62b62530a82f | 24 | } mouse_event_t; |
| pprasad7 | 0:62b62530a82f | 25 | bool processing(mouse_event_t *p); |
| pprasad7 | 0:62b62530a82f | 26 | private: |
| pprasad7 | 0:62b62530a82f | 27 | PS2MS_INIT ps2ms_init; |
| pprasad7 | 0:62b62530a82f | 28 | PS2MS ps2ms; |
| pprasad7 | 0:62b62530a82f | 29 | typedef struct { |
| pprasad7 | 0:62b62530a82f | 30 | union { |
| pprasad7 | 0:62b62530a82f | 31 | uint8_t byte; |
| pprasad7 | 0:62b62530a82f | 32 | struct { |
| pprasad7 | 0:62b62530a82f | 33 | uint8_t btnLeft:1; |
| pprasad7 | 0:62b62530a82f | 34 | uint8_t btnRight:1; |
| pprasad7 | 0:62b62530a82f | 35 | uint8_t btnCenter:1; |
| pprasad7 | 0:62b62530a82f | 36 | uint8_t always1:1; |
| pprasad7 | 0:62b62530a82f | 37 | uint8_t signX:1; |
| pprasad7 | 0:62b62530a82f | 38 | uint8_t signY:1; |
| pprasad7 | 0:62b62530a82f | 39 | uint8_t overflowX:1; |
| pprasad7 | 0:62b62530a82f | 40 | uint8_t overflowY:1; |
| pprasad7 | 0:62b62530a82f | 41 | } bit; |
| pprasad7 | 0:62b62530a82f | 42 | } byte1; |
| pprasad7 | 0:62b62530a82f | 43 | union { |
| pprasad7 | 0:62b62530a82f | 44 | uint8_t byte; |
| pprasad7 | 0:62b62530a82f | 45 | } byte2; |
| pprasad7 | 0:62b62530a82f | 46 | union { |
| pprasad7 | 0:62b62530a82f | 47 | uint8_t byte; |
| pprasad7 | 0:62b62530a82f | 48 | } byte3; |
| pprasad7 | 0:62b62530a82f | 49 | union { |
| pprasad7 | 0:62b62530a82f | 50 | uint8_t byte; |
| pprasad7 | 0:62b62530a82f | 51 | struct { |
| pprasad7 | 0:62b62530a82f | 52 | uint8_t value:7; |
| pprasad7 | 0:62b62530a82f | 53 | uint8_t signZ:1; |
| pprasad7 | 0:62b62530a82f | 54 | } bit; |
| pprasad7 | 0:62b62530a82f | 55 | } byte4; |
| pprasad7 | 0:62b62530a82f | 56 | } mouse_info_t; |
| pprasad7 | 0:62b62530a82f | 57 | mouse_info_t mi; |
| pprasad7 | 0:62b62530a82f | 58 | int cnt; |
| pprasad7 | 0:62b62530a82f | 59 | }; |
| pprasad7 | 0:62b62530a82f | 60 | |
| pprasad7 | 0:62b62530a82f | 61 | #endif |
