diff options
Diffstat (limited to 'tmk_core/protocol/ps2_mouse.h')
| -rw-r--r-- | tmk_core/protocol/ps2_mouse.h | 84 |
1 files changed, 73 insertions, 11 deletions
diff --git a/tmk_core/protocol/ps2_mouse.h b/tmk_core/protocol/ps2_mouse.h index 27d9790d4..e11c705fc 100644 --- a/tmk_core/protocol/ps2_mouse.h +++ b/tmk_core/protocol/ps2_mouse.h | |||
| @@ -20,15 +20,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | 20 | ||
| 21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
| 22 | 22 | ||
| 23 | #define PS2_MOUSE_READ_DATA 0xEB | ||
| 24 | |||
| 25 | /* | 23 | /* |
| 26 | * Data format: | 24 | * Data format: |
| 27 | * byte|7 6 5 4 3 2 1 0 | 25 | * byte|7 6 5 4 3 2 1 0 |
| 28 | * ----+-------------------------------------------------------------- | 26 | * ----+---------------------------------------------------------------- |
| 29 | * 0|Yovflw Xovflw Ysign Xsign 1 Middle Right Left | 27 | * 0|[Yovflw][Xovflw][Ysign ][Xsign ][ 1 ][Middle][Right ][Left ] |
| 30 | * 1| X movement(0-255) | 28 | * 1|[ X movement(0-255) ] |
| 31 | * 2| Y movement(0-255) | 29 | * 2|[ Y movement(0-255) ] |
| 32 | */ | 30 | */ |
| 33 | #define PS2_MOUSE_BTN_MASK 0x07 | 31 | #define PS2_MOUSE_BTN_MASK 0x07 |
| 34 | #define PS2_MOUSE_BTN_LEFT 0 | 32 | #define PS2_MOUSE_BTN_LEFT 0 |
| @@ -39,10 +37,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 39 | #define PS2_MOUSE_X_OVFLW 6 | 37 | #define PS2_MOUSE_X_OVFLW 6 |
| 40 | #define PS2_MOUSE_Y_OVFLW 7 | 38 | #define PS2_MOUSE_Y_OVFLW 7 |
| 41 | 39 | ||
| 42 | |||
| 43 | /* | ||
| 44 | * Scroll by mouse move with pressing button | ||
| 45 | */ | ||
| 46 | /* mouse button to start scrolling; set 0 to disable scroll */ | 40 | /* mouse button to start scrolling; set 0 to disable scroll */ |
| 47 | #ifndef PS2_MOUSE_SCROLL_BTN_MASK | 41 | #ifndef PS2_MOUSE_SCROLL_BTN_MASK |
| 48 | #define PS2_MOUSE_SCROLL_BTN_MASK (1<<PS2_MOUSE_BTN_MIDDLE) | 42 | #define PS2_MOUSE_SCROLL_BTN_MASK (1<<PS2_MOUSE_BTN_MIDDLE) |
| @@ -58,9 +52,77 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 58 | #ifndef PS2_MOUSE_SCROLL_DIVISOR_H | 52 | #ifndef PS2_MOUSE_SCROLL_DIVISOR_H |
| 59 | #define PS2_MOUSE_SCROLL_DIVISOR_H 2 | 53 | #define PS2_MOUSE_SCROLL_DIVISOR_H 2 |
| 60 | #endif | 54 | #endif |
| 55 | /* multiply reported mouse values by these */ | ||
| 56 | #ifndef PS2_MOUSE_X_MULTIPLIER | ||
| 57 | #define PS2_MOUSE_X_MULTIPLIER 1 | ||
| 58 | #endif | ||
| 59 | #ifndef PS2_MOUSE_Y_MULTIPLIER | ||
| 60 | #define PS2_MOUSE_Y_MULTIPLIER 1 | ||
| 61 | #endif | ||
| 62 | #ifndef PS2_MOUSE_V_MULTIPLIER | ||
| 63 | #define PS2_MOUSE_V_MULTIPLIER 1 | ||
| 64 | #endif | ||
| 65 | /* For some mice this will need to be 0x0F */ | ||
| 66 | #ifndef PS2_MOUSE_SCROLL_MASK | ||
| 67 | #define PS2_MOUSE_SCROLL_MASK 0xFF | ||
| 68 | #endif | ||
| 69 | #ifndef PS2_MOUSE_INIT_DELAY | ||
| 70 | #define PS2_MOUSE_INIT_DELAY 1000 | ||
| 71 | #endif | ||
| 72 | |||
| 73 | enum ps2_mouse_command_e { | ||
| 74 | PS2_MOUSE_RESET = 0xFF, | ||
| 75 | PS2_MOUSE_RESEND = 0xFE, | ||
| 76 | PS2_MOSUE_SET_DEFAULTS = 0xF6, | ||
| 77 | PS2_MOUSE_DISABLE_DATA_REPORTING = 0xF5, | ||
| 78 | PS2_MOUSE_ENABLE_DATA_REPORTING = 0xF4, | ||
| 79 | PS2_MOUSE_SET_SAMPLE_RATE = 0xF3, | ||
| 80 | PS2_MOUSE_GET_DEVICE_ID = 0xF2, | ||
| 81 | PS2_MOUSE_SET_REMOTE_MODE = 0xF0, | ||
| 82 | PS2_MOUSE_SET_WRAP_MODE = 0xEC, | ||
| 83 | PS2_MOUSE_READ_DATA = 0xEB, | ||
| 84 | PS2_MOUSE_SET_STREAM_MODE = 0xEA, | ||
| 85 | PS2_MOUSE_STATUS_REQUEST = 0xE9, | ||
| 86 | PS2_MOUSE_SET_RESOLUTION = 0xE8, | ||
| 87 | PS2_MOUSE_SET_SCALING_2_1 = 0xE7, | ||
| 88 | PS2_MOUSE_SET_SCALING_1_1 = 0xE6, | ||
| 89 | }; | ||
| 61 | 90 | ||
| 91 | typedef enum ps2_mouse_resolution_e { | ||
| 92 | PS2_MOUSE_1_COUNT_MM, | ||
| 93 | PS2_MOUSE_2_COUNT_MM, | ||
| 94 | PS2_MOUSE_4_COUNT_MM, | ||
| 95 | PS2_MOUSE_8_COUNT_MM, | ||
| 96 | } ps2_mouse_resolution_t; | ||
| 97 | |||
| 98 | typedef enum ps2_mouse_sample_rate_e { | ||
| 99 | PS2_MOUSE_10_SAMPLES_SEC = 10, | ||
| 100 | PS2_MOUSE_20_SAMPLES_SEC = 20, | ||
| 101 | PS2_MOUSE_40_SAMPLES_SEC = 40, | ||
| 102 | PS2_MOUSE_60_SAMPLES_SEC = 60, | ||
| 103 | PS2_MOUSE_80_SAMPLES_SEC = 80, | ||
| 104 | PS2_MOUSE_100_SAMPLES_SEC = 100, | ||
| 105 | PS2_MOUSE_200_SAMPLES_SEC = 200, | ||
| 106 | } ps2_mouse_sample_rate_t; | ||
| 107 | |||
| 108 | void ps2_mouse_init(void); | ||
| 62 | 109 | ||
| 63 | uint8_t ps2_mouse_init(void); | ||
| 64 | void ps2_mouse_task(void); | 110 | void ps2_mouse_task(void); |
| 65 | 111 | ||
| 112 | void ps2_mouse_disable_data_reporting(void); | ||
| 113 | |||
| 114 | void ps2_mouse_enable_data_reporting(void); | ||
| 115 | |||
| 116 | void ps2_mouse_set_remote_mode(void); | ||
| 117 | |||
| 118 | void ps2_mouse_set_stream_mode(void); | ||
| 119 | |||
| 120 | void ps2_mouse_set_scaling_2_1(void); | ||
| 121 | |||
| 122 | void ps2_mouse_set_scaling_1_1(void); | ||
| 123 | |||
| 124 | void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution); | ||
| 125 | |||
| 126 | void ps2_mouse_set_sample_rate(ps2_mouse_sample_rate_t sample_rate); | ||
| 127 | |||
| 66 | #endif | 128 | #endif |
