Merge pull request #933 from priyadi/ps2_mouse_init_user2

Implemented weak ps2_mouse_init_user()
This commit is contained in:
Jack Humbert 2016-12-04 13:52:17 -05:00 committed by GitHub
commit 082f7ed3d3
2 changed files with 55 additions and 46 deletions

View File

@ -28,52 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* ============================= MACROS ============================ */
#define PS2_MOUSE_SEND(command, message) \
do { \
uint8_t rcv = ps2_host_send(command); \
if (debug_mouse) { \
print((message)); \
xprintf(" command: %X, result: %X, error: %X \n", command, rcv, ps2_error); \
} \
} while(0)
#define PS2_MOUSE_SEND_SAFE(command, message) \
do { \
if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \
ps2_mouse_disable_data_reporting(); \
} \
PS2_MOUSE_SEND(command, message); \
if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \
ps2_mouse_enable_data_reporting(); \
} \
} while(0)
#define PS2_MOUSE_SET_SAFE(command, value, message) \
do { \
if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \
ps2_mouse_disable_data_reporting(); \
} \
PS2_MOUSE_SEND(command, message); \
PS2_MOUSE_SEND(value, "Sending value"); \
if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \
ps2_mouse_enable_data_reporting(); \
} \
} while(0)
#define PS2_MOUSE_RECEIVE(message) \
do { \
uint8_t rcv = ps2_host_recv_response(); \
if (debug_mouse) { \
print((message)); \
xprintf(" result: %X, error: %X \n", rcv, ps2_error); \
} \
} while(0)
static enum ps2_mouse_mode_e {
PS2_MOUSE_STREAM_MODE,
PS2_MOUSE_REMOTE_MODE,
} ps2_mouse_mode = PS2_MOUSE_STREAM_MODE;
static report_mouse_t mouse_report = {};
static inline void ps2_mouse_print_report(report_mouse_t *mouse_report);
@ -108,6 +62,12 @@ void ps2_mouse_init(void) {
#ifdef PS2_MOUSE_USE_2_1_SCALING
ps2_mouse_set_scaling_2_1();
#endif
ps2_mouse_init_user();
}
__attribute__((weak))
void ps2_mouse_init_user(void) {
}
void ps2_mouse_task(void) {

View File

@ -19,6 +19,53 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PS2_MOUSE_H
#include <stdbool.h>
#include "debug.h"
#define PS2_MOUSE_SEND(command, message) \
do { \
uint8_t rcv = ps2_host_send(command); \
if (debug_mouse) { \
print((message)); \
xprintf(" command: %X, result: %X, error: %X \n", command, rcv, ps2_error); \
} \
} while(0)
#define PS2_MOUSE_SEND_SAFE(command, message) \
do { \
if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \
ps2_mouse_disable_data_reporting(); \
} \
PS2_MOUSE_SEND(command, message); \
if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \
ps2_mouse_enable_data_reporting(); \
} \
} while(0)
#define PS2_MOUSE_SET_SAFE(command, value, message) \
do { \
if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \
ps2_mouse_disable_data_reporting(); \
} \
PS2_MOUSE_SEND(command, message); \
PS2_MOUSE_SEND(value, "Sending value"); \
if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \
ps2_mouse_enable_data_reporting(); \
} \
} while(0)
#define PS2_MOUSE_RECEIVE(message) \
do { \
uint8_t rcv = ps2_host_recv_response(); \
if (debug_mouse) { \
print((message)); \
xprintf(" result: %X, error: %X \n", rcv, ps2_error); \
} \
} while(0)
static enum ps2_mouse_mode_e {
PS2_MOUSE_STREAM_MODE,
PS2_MOUSE_REMOTE_MODE,
} ps2_mouse_mode = PS2_MOUSE_STREAM_MODE;
/*
* Data format:
@ -107,6 +154,8 @@ typedef enum ps2_mouse_sample_rate_e {
void ps2_mouse_init(void);
void ps2_mouse_init_user(void);
void ps2_mouse_task(void);
void ps2_mouse_disable_data_reporting(void);