diff options
author | tmk <nobody@nowhere> | 2011-01-02 23:52:13 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2011-01-02 23:52:13 +0900 |
commit | 2a562a4191a5b9e88731efb5eabd921821f25f7e (patch) | |
tree | 20f5bb311ff99ced3dd8ee2d9430e2fbe8183f7b /usb_mouse.c | |
parent | 1ed336a06499c1baee2421141d59d115f0ee3c4b (diff) |
Add PS/2 mouse support to connect TrackPoint Unit.
Change build options: Makefile and config.h. See README.
Diffstat (limited to 'usb_mouse.c')
-rw-r--r-- | usb_mouse.c | 57 |
1 files changed, 13 insertions, 44 deletions
diff --git a/usb_mouse.c b/usb_mouse.c index 98292bdd84..319b65a1cb 100644 --- a/usb_mouse.c +++ b/usb_mouse.c @@ -5,40 +5,18 @@ #include "debug.h" -static bool is_sent = false; +uint8_t usb_mouse_protocol=1; -// which buttons are currently pressed -uint8_t mouse_buttons=0; -// protocol setting from the host. We use exactly the same report -// either way, so this variable only stores the setting since we -// are required to be able to report which setting is in use. -uint8_t mouse_protocol=1; - - -// Set the mouse buttons. To create a "click", 2 calls are needed, -// one to push the button down and the second to release it -int8_t usb_mouse_buttons(uint8_t left, uint8_t middle, uint8_t right) -{ - uint8_t mask=0; - - if (left) mask |= 1; - if (middle) mask |= 4; - if (right) mask |= 2; - mouse_buttons = mask; - return usb_mouse_move(0, 0, 0, 0); -} - -// Move the mouse. x, y and wheel are -127 to 127. Use 0 for no movement. -int8_t usb_mouse_move(int8_t x, int8_t y, int8_t wheel, int8_t hwheel) +int8_t usb_mouse_send(int8_t x, int8_t y, int8_t wheel_v, int8_t wheel_h, uint8_t buttons) { uint8_t intr_state, timeout; if (!usb_configured()) return -1; if (x == -128) x = -127; if (y == -128) y = -127; - if (wheel == -128) wheel = -127; - if (hwheel == -128) hwheel = -127; + if (wheel_v == -128) wheel_v = -127; + if (wheel_h == -128) wheel_h = -127; intr_state = SREG; cli(); UENUM = MOUSE_ENDPOINT; @@ -56,34 +34,25 @@ int8_t usb_mouse_move(int8_t x, int8_t y, int8_t wheel, int8_t hwheel) cli(); UENUM = MOUSE_ENDPOINT; } - UEDATX = mouse_buttons; + UEDATX = buttons; UEDATX = x; UEDATX = y; - if (mouse_protocol) { - UEDATX = wheel; - UEDATX = hwheel; + if (usb_mouse_protocol) { + UEDATX = wheel_v; + UEDATX = wheel_h; } UEINTX = 0x3A; SREG = intr_state; - is_sent = true; return 0; } -void usb_mouse_clear(void) { - is_sent = false; -} - -bool usb_mouse_is_sent(void) { - return is_sent; -} - -void usb_mouse_print(int8_t mouse_x, int8_t mouse_y, int8_t wheel_v, int8_t wheel_h) { +void usb_mouse_print(int8_t x, int8_t y, int8_t wheel_v, int8_t wheel_h, uint8_t buttons) { if (!debug_mouse) return; - print("mouse btn|x y v h: "); - phex(mouse_buttons); print("|"); - phex(mouse_x); print(" "); - phex(mouse_y); print(" "); + print("usb_mouse[btn|x y v h]: "); + phex(buttons); print("|"); + phex(x); print(" "); + phex(y); print(" "); phex(wheel_v); print(" "); phex(wheel_h); print("\n"); } |