Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / lcom / lab4.h @ 13

History | View | Annotate | Download (3.61 KB)

1 13 up20180614
#pragma once
2
3
#include <stdint.h>
4
5
struct packet {
6
  uint8_t bytes[3]; // mouse packet raw bytes
7
  bool rb, mb, lb;  // right, middle and left mouse buttons pressed
8
  int16_t delta_x;  // mouse x-displacement: rightwards is positive
9
  int16_t delta_y;  // mouse y-displacement: upwards is positive
10
  bool x_ov, y_ov;  // mouse x-displacement and y-displacement overflows
11
};
12
13
enum mouse_ev_t { LB_PRESSED,
14
                  LB_RELEASED,
15
                  RB_PRESSED,
16
                  RB_RELEASED,
17
                  BUTTON_EV,
18
                  MOUSE_MOV };
19
20
struct mouse_ev {
21
  enum mouse_ev_t type;
22
  int16_t delta_x, delta_y;
23
};
24
25
struct mouse_ev *(mouse_detect_event)(struct packet *pp);
26
27
/**
28
 * @brief To test packet reception via interrupts
29
 *
30
 * Displays the packets received from the mouse
31
 * Exits after receiving the number of packets specified in argument
32
 *
33
 * @param cnt Number of packets to receive and display before exiting
34
 *
35
 * @return Return 0 upon success and non-zero otherwise
36
 */
37
38
int (mouse_test_packet)(uint32_t cnt);
39
40
/**
41
 * @brief To test PS/2 remote mode operation
42
 *
43
 * Configures the PS/2 to operate in remote mode
44
 *
45
 * Periodically requests a packet from the mouse,
46
 * and displays the packets received from the mouse
47
 *
48
 * Exits after receiving the number of packets specified in argument
49
 *
50
 * @param period Period in milliseconds
51
 * @param cnt Number of packets to receive and display before exiting
52
 *
53
 * @return Return 0 upon success and non-zero otherwise
54
 */
55
56
int (mouse_test_remote)(uint16_t period, uint8_t cnt);
57
58
/**
59
 * @brief To test handling of more than one interrupt
60
 *
61
 *  Similar test_packet() except that it
62
 *  should terminate if no packets are received for idle_time seconds
63
 *
64
 * @param idle_time Number of seconds without packets before exiting
65
 *
66
 * @return Return 0 upon success and non-zero otherwise
67
 */
68
69
int (mouse_test_async)(uint8_t idle_time);
70
71
/**
72
 * @brief To test state machine implementation
73
 *
74
 *  Similar to mouse_test_packet() except that it
75
 *  should terminate if a gesture is detected.
76
 *
77
 * @return Return 0 upon success and non-zero otherwise
78
 */
79
80
int (mouse_test_gesture)(uint8_t x_len, uint8_t tolerance);
81
82
/**
83
 * @brief Handles mouse interrupts
84
 *
85
 * Reads the status register and the output buffer (OB).
86
 *
87
 * If there was some error, the byte read from the OB should be discarded.
88
 *
89
 * Must be defined using parenthesis around the function name:
90
 *
91
 *   void (mouse_ih)(void) {
92
 *
93
 * @param IH's take no arguments
94
 *
95
 * @return IH's take no values
96
 */
97
98
void (mouse_ih)(void);
99
100
/**
101
 * @brief To print a mouse packet
102
 *
103
 * Displays a mouse packet in a human readable way
104
 *
105
 * This function needs not be implemented: it is provided with the LCF
106
 *
107
 * @param pp Pointer to a struct which contains both the packet bytes
108
 *                                    and the parsed information.
109
 */
110
111
void (mouse_print_packet)(struct packet *pp);
112
113
/**
114
 * @brief Enables stream mode data reporting.
115
 *
116
 * Enables stream mode data reporting, by sending the respective command to the mouse.
117
 *
118
 * This function is provided by the LCF.
119
 *
120
 * In order to score points for your Lab 4 grade, you should implement this functionality yourself. * This can be done by defining your own function with the same functionality, or just by adding
121
 * this functionality somewhere in your code.
122
 *
123
 * @return Returns O on success, and non-zero otherwise
124
 */
125
126
int (mouse_enable_data_reporting)(void);
127
128
/**
129
 * @brief Returns Minix's default KBC command byte.
130
 *
131
 * This function is already implemented by the LCF: you must not implement it.
132
 *
133
 * @return Returns Minix's default KBC command byte
134
 */
135
136
uint8_t (minix_get_dflt_kbc_cmd_byte)(void);