Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ps2_mouse.h 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. Copyright 2011 Jun Wako <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef PS2_MOUSE_H
  15. #define PS2_MOUSE_H
  16. #include <stdbool.h>
  17. #define PS2_MOUSE_READ_DATA 0xEB
  18. /*
  19. * Data format:
  20. * byte|7 6 5 4 3 2 1 0
  21. * ----+--------------------------------------------------------------
  22. * 0|Yovflw Xovflw Ysign Xsign 1 Middle Right Left
  23. * 1| X movement(0-255)
  24. * 2| Y movement(0-255)
  25. */
  26. #define PS2_MOUSE_BTN_MASK 0x07
  27. #define PS2_MOUSE_BTN_LEFT 0
  28. #define PS2_MOUSE_BTN_RIGHT 1
  29. #define PS2_MOUSE_BTN_MIDDLE 2
  30. #define PS2_MOUSE_X_SIGN 4
  31. #define PS2_MOUSE_Y_SIGN 5
  32. #define PS2_MOUSE_X_OVFLW 6
  33. #define PS2_MOUSE_Y_OVFLW 7
  34. /*
  35. * Scroll by mouse move with pressing button
  36. */
  37. /* mouse button to start scrolling; set 0 to disable scroll */
  38. #ifndef PS2_MOUSE_SCROLL_BTN_MASK
  39. #define PS2_MOUSE_SCROLL_BTN_MASK (1<<PS2_MOUSE_BTN_MIDDLE)
  40. #endif
  41. /* send button event when button is released within this value(ms); set 0 to disable */
  42. #ifndef PS2_MOUSE_SCROLL_BTN_SEND
  43. #define PS2_MOUSE_SCROLL_BTN_SEND 300
  44. #endif
  45. /* divide virtical and horizontal mouse move by this to convert to scroll move */
  46. #ifndef PS2_MOUSE_SCROLL_DIVISOR_V
  47. #define PS2_MOUSE_SCROLL_DIVISOR_V 2
  48. #endif
  49. #ifndef PS2_MOUSE_SCROLL_DIVISOR_H
  50. #define PS2_MOUSE_SCROLL_DIVISOR_H 2
  51. #endif
  52. uint8_t ps2_mouse_init(void);
  53. void ps2_mouse_task(void);
  54. #endif