PS2 Library

Dependents:   Pong Brickbreaker

Committer:
wjohnsto
Date:
Sun Feb 27 23:34:31 2011 +0000
Revision:
0:ce15490e89e9

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wjohnsto 0:ce15490e89e9 1 /**
wjohnsto 0:ce15490e89e9 2 * PS/2 mouse interface control class (Version 0.0.1)
wjohnsto 0:ce15490e89e9 3 *
wjohnsto 0:ce15490e89e9 4 * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
wjohnsto 0:ce15490e89e9 5 * http://shinta.main.jp/
wjohnsto 0:ce15490e89e9 6 */
wjohnsto 0:ce15490e89e9 7 #ifndef _PS2_MOUSE_H_
wjohnsto 0:ce15490e89e9 8 #define _PS2_MOUSE_H_
wjohnsto 0:ce15490e89e9 9
wjohnsto 0:ce15490e89e9 10 #include "PS2MS_INIT.h"
wjohnsto 0:ce15490e89e9 11 #include "PS2MS.h"
wjohnsto 0:ce15490e89e9 12
wjohnsto 0:ce15490e89e9 13 class PS2Mouse {
wjohnsto 0:ce15490e89e9 14 public:
wjohnsto 0:ce15490e89e9 15 PS2Mouse(PinName clk_pin, PinName dat_pin);
wjohnsto 0:ce15490e89e9 16 ~PS2Mouse();
wjohnsto 0:ce15490e89e9 17 typedef struct {
wjohnsto 0:ce15490e89e9 18 bool left;
wjohnsto 0:ce15490e89e9 19 bool center;
wjohnsto 0:ce15490e89e9 20 bool right;
wjohnsto 0:ce15490e89e9 21 int x;
wjohnsto 0:ce15490e89e9 22 int y;
wjohnsto 0:ce15490e89e9 23 int z;
wjohnsto 0:ce15490e89e9 24 } mouse_event_t;
wjohnsto 0:ce15490e89e9 25 bool processing(mouse_event_t *p);
wjohnsto 0:ce15490e89e9 26 private:
wjohnsto 0:ce15490e89e9 27 PS2MS_INIT ps2ms_init;
wjohnsto 0:ce15490e89e9 28 PS2MS ps2ms;
wjohnsto 0:ce15490e89e9 29 typedef struct {
wjohnsto 0:ce15490e89e9 30 union {
wjohnsto 0:ce15490e89e9 31 uint8_t byte;
wjohnsto 0:ce15490e89e9 32 struct {
wjohnsto 0:ce15490e89e9 33 uint8_t btnLeft:1;
wjohnsto 0:ce15490e89e9 34 uint8_t btnRight:1;
wjohnsto 0:ce15490e89e9 35 uint8_t btnCenter:1;
wjohnsto 0:ce15490e89e9 36 uint8_t always1:1;
wjohnsto 0:ce15490e89e9 37 uint8_t signX:1;
wjohnsto 0:ce15490e89e9 38 uint8_t signY:1;
wjohnsto 0:ce15490e89e9 39 uint8_t overflowX:1;
wjohnsto 0:ce15490e89e9 40 uint8_t overflowY:1;
wjohnsto 0:ce15490e89e9 41 } bit;
wjohnsto 0:ce15490e89e9 42 } byte1;
wjohnsto 0:ce15490e89e9 43 union {
wjohnsto 0:ce15490e89e9 44 uint8_t byte;
wjohnsto 0:ce15490e89e9 45 } byte2;
wjohnsto 0:ce15490e89e9 46 union {
wjohnsto 0:ce15490e89e9 47 uint8_t byte;
wjohnsto 0:ce15490e89e9 48 } byte3;
wjohnsto 0:ce15490e89e9 49 union {
wjohnsto 0:ce15490e89e9 50 uint8_t byte;
wjohnsto 0:ce15490e89e9 51 struct {
wjohnsto 0:ce15490e89e9 52 uint8_t value:7;
wjohnsto 0:ce15490e89e9 53 uint8_t signZ:1;
wjohnsto 0:ce15490e89e9 54 } bit;
wjohnsto 0:ce15490e89e9 55 } byte4;
wjohnsto 0:ce15490e89e9 56 } mouse_info_t;
wjohnsto 0:ce15490e89e9 57 mouse_info_t mi;
wjohnsto 0:ce15490e89e9 58 int cnt;
wjohnsto 0:ce15490e89e9 59 };
wjohnsto 0:ce15490e89e9 60
wjohnsto 0:ce15490e89e9 61 #endif