Revision 255
deleting mouse_macros.h
proj/include/mouse_macros.h | ||
---|---|---|
1 | 1 |
#ifndef MOUSE_MACROS_H_INCLUDED |
2 | 2 |
#define MOUSE_MACROS_H_INCLUDED |
3 | 3 |
|
4 |
/* Mouse Data Packet */ |
|
5 |
// Byte 0 - Button States |
|
6 |
#define LEFT_BUTTON BIT(0) /* @brief Left button click event*/ |
|
7 |
#define RIGHT_BUTTON BIT(1) /* @brief Right button click event */ |
|
8 |
#define MIDDLE_BUTTON BIT(2) /* @brief Middle button click event */ |
|
9 |
#define FIRST_BYTE_ID BIT(3) /* @brief Identifier of first byte of packet CAREFUL: Not 100% accurate */ |
|
10 |
#define MSB_X_DELTA BIT(4) /* @brief Most significant bit of X delta */ |
|
11 |
#define MSB_Y_DELTA BIT(5) /* @brief Most significant bit of Y delta */ |
|
12 |
#define X_OVERFLOW BIT(6) /* @brief X delta overflowed */ |
|
13 |
#define Y_OVERFLOW BIT(7) /* @brief Y delta overflowed */ |
|
14 |
// Byte 1 - X delta |
|
15 |
// Byte 2 - Y delta |
|
16 | 4 |
|
17 |
/* Mouse Commands */ |
|
18 |
#define RESET 0xFF /* @brief Reset mouse */ |
|
19 |
#define RESEND 0xFE /* @brief Resend command */ |
|
20 |
#define DEFAULT 0xF6 /* @brief Set default values */ |
|
21 |
#define DIS_DATA_REP 0xF5 /* @brief Disable Data Reporting */ |
|
22 |
#define ENABLE_DATA_REP 0xF4 /* @brief Enable Data Reporting */ |
|
23 |
#define SET_SAMPLE_RT 0xF3 /* @brief Sets state sampling rate */ |
|
24 |
#define SET_REMOTE_MD 0xF0 /* @brief Sets Mouse on Remote Mode, data on request */ |
|
25 |
#define READ_DATA 0xEB /* @brief Sends data packet request */ |
|
26 |
#define SET_STREAM_MD 0xEA /* @brief Sets mouse on Stream Mode, data on events */ |
|
27 |
#define STATUS_REQUEST 0xE9 /* @brief Get mouse configuration */ |
|
28 |
#define SET_RESOLUTION 0xE8 /* @brief Sets resolution for mouse movement */ |
|
29 |
#define SCALING_ACC_MD 0xE7 /* @brief Sets scaling on acceleration mode */ |
|
30 |
#define SCALING_LIN_MD 0xE6 /* @brief Sets scaling on linear mode */ |
|
31 | 5 |
|
32 |
/* Mouse Controller Responses */ |
|
33 |
#define ACK_OK 0xFA /* @brief Operation sucessful */ |
|
34 |
#define ACK_INVALID 0xFE /* @brief Invalid Byte, first occurence */ |
|
35 |
#define ACK_ERROR 0xFC /* @brief Invalid Byte on resend */ |
|
36 | 6 |
|
7 |
|
|
37 | 8 |
#endif // MOUSE_MACROS_H_INCLUDED |
proj/src/mouse.c | ||
---|---|---|
4 | 4 |
|
5 | 5 |
#include "errors.h" |
6 | 6 |
#include "kbc_macros.h" |
7 |
#include "mouse_macros.h" |
|
8 | 7 |
#include "kbc.h" |
9 | 8 |
|
9 |
/* Mouse Data Packet */ |
|
10 |
// Byte 0 - Button States |
|
11 |
#define LEFT_BUTTON BIT(0) /* @brief Left button click event*/ |
|
12 |
#define RIGHT_BUTTON BIT(1) /* @brief Right button click event */ |
|
13 |
#define MIDDLE_BUTTON BIT(2) /* @brief Middle button click event */ |
|
14 |
#define FIRST_BYTE_ID BIT(3) /* @brief Identifier of first byte of packet CAREFUL: Not 100% accurate */ |
|
15 |
#define MSB_X_DELTA BIT(4) /* @brief Most significant bit of X delta */ |
|
16 |
#define MSB_Y_DELTA BIT(5) /* @brief Most significant bit of Y delta */ |
|
17 |
#define X_OVERFLOW BIT(6) /* @brief X delta overflowed */ |
|
18 |
#define Y_OVERFLOW BIT(7) /* @brief Y delta overflowed */ |
|
19 |
// Byte 1 - X delta |
|
20 |
// Byte 2 - Y delta |
|
21 |
|
|
22 |
/* Mouse Commands */ |
|
23 |
#define RESET 0xFF /* @brief Reset mouse */ |
|
24 |
#define RESEND 0xFE /* @brief Resend command */ |
|
25 |
#define DEFAULT 0xF6 /* @brief Set default values */ |
|
26 |
#define DIS_DATA_REP 0xF5 /* @brief Disable Data Reporting */ |
|
27 |
#define ENABLE_DATA_REP 0xF4 /* @brief Enable Data Reporting */ |
|
28 |
#define SET_SAMPLE_RT 0xF3 /* @brief Sets state sampling rate */ |
|
29 |
#define SET_REMOTE_MD 0xF0 /* @brief Sets Mouse on Remote Mode, data on request */ |
|
30 |
#define READ_DATA 0xEB /* @brief Sends data packet request */ |
|
31 |
#define SET_STREAM_MD 0xEA /* @brief Sets mouse on Stream Mode, data on events */ |
|
32 |
#define STATUS_REQUEST 0xE9 /* @brief Get mouse configuration */ |
|
33 |
#define SET_RESOLUTION 0xE8 /* @brief Sets resolution for mouse movement */ |
|
34 |
#define SCALING_ACC_MD 0xE7 /* @brief Sets scaling on acceleration mode */ |
|
35 |
#define SCALING_LIN_MD 0xE6 /* @brief Sets scaling on linear mode */ |
|
36 |
|
|
37 |
/* Mouse Controller Responses */ |
|
38 |
#define ACK_OK 0xFA /* @brief Operation sucessful */ |
|
39 |
#define ACK_INVALID 0xFE /* @brief Invalid Byte, first occurence */ |
|
40 |
#define ACK_ERROR 0xFC /* @brief Invalid Byte on resend */ |
|
41 |
|
|
10 | 42 |
int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id) { |
11 | 43 |
if (interrupt_id == NULL) return NULL_PTR; |
12 | 44 |
*interrupt_id = interrupt_bit; |
Also available in: Unified diff