mouse 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. .TH MOUSE 3
  2. .SH NAME
  3. mouse, cursor \- kernel mouse interface
  4. .SH SYNOPSIS
  5. .nf
  6. .B bind -a #m /dev
  7. .B /dev/mouse
  8. .B /dev/mousein
  9. .B /dev/mousectl
  10. .B /dev/cursor
  11. .fi
  12. .SH DESCRIPTION
  13. The
  14. .I mouse
  15. device provides an interface to the mouse.
  16. There is also a cursor associated with the screen;
  17. it is always displayed at the current mouse position.
  18. .PP
  19. Reading the
  20. .B mouse
  21. file returns the mouse status: its position and button state.
  22. The read blocks until the state has changed since the last read.
  23. The read returns 49 bytes: the letter
  24. .B m
  25. followed by four decimal strings, each 11 characters
  26. wide followed by a blank:
  27. .I x
  28. and
  29. .IR y ,
  30. coordinates of the mouse position in the screen image;
  31. .IR buttons ,
  32. a bitmask with the
  33. 1, 2, and 4 bits set when the
  34. mouse's left, middle, and right buttons,
  35. respectively, are down;
  36. and
  37. .IR msec ,
  38. a time stamp, in units of milliseconds.
  39. .PP
  40. Writing the
  41. .B mouse
  42. file, in the same format,
  43. causes the mouse cursor to move to the position specified by the
  44. .I x
  45. and
  46. .I y
  47. coordinates of the message.
  48. The
  49. .I buttons
  50. and
  51. .I msec
  52. fields are ignored and may be omitted.
  53. .PP
  54. Writes to the
  55. .B mousein
  56. file are processed as if they were generated by the
  57. mouse hardware itself,
  58. as extra mouse events to be processed and passed back via
  59. the
  60. .B mouse
  61. file.
  62. The
  63. .B mousein
  64. file, which is exclusive-use and may be opened
  65. only by the host owner, is intended for controlling devices, such as USB mice,
  66. that are managed by user-level software.
  67. Each event should consist of
  68. the letter
  69. .B m
  70. followed by delta
  71. .IR x ,
  72. delta
  73. .IR y ,
  74. and
  75. .IR buttons
  76. as space-separated decimal numbers.
  77. .PP
  78. Writing to the
  79. .B mousectl
  80. file configures and controls the mouse.
  81. The messages are:
  82. .TF ps2intellimouse
  83. .TP
  84. .B serial\fI n\fR
  85. sets serial port
  86. .I n
  87. to be the mouse port.
  88. .TP
  89. .B ps2
  90. sets the PS2 port to be the mouse port.
  91. .TP
  92. .B intellimouse
  93. uses the wheel on a Microsoft Intellimouse
  94. as the middle button.
  95. .TP
  96. .B ps2intellimouse
  97. is equivalent to a write of
  98. .B ps2
  99. followed by a write of
  100. .BR intellimouse .
  101. .TP
  102. .B accelerated
  103. turns on mouse acceleration.
  104. .TP
  105. .B linear
  106. turns off mouse acceleration
  107. .TP
  108. .B res \fIn\fR
  109. sets mouse resolution to a setting between 0 and
  110. 3 inclusive.
  111. .TP
  112. .B hwaccel \fIon/off\fR
  113. sets whether acceleration is done in hardware or
  114. software.
  115. By default, PS2 mice use hardware and serial mice use
  116. software.
  117. Some laptops (notably the IBM Thinkpad T23) don't
  118. implement hardware acceleration for external mice.
  119. .TP
  120. .B swap
  121. swaps the left and right buttons on the mouse.
  122. .TP
  123. .B buttonmap \fIxyz\fR
  124. numbers the left, middle, and right mouse buttons
  125. .IR x ,
  126. .IR y ,
  127. and
  128. .IR z ,
  129. respectively.
  130. If
  131. .I xyz
  132. is omitted, the default map, 123, is used.
  133. Thus in the default state writing
  134. .B "buttonmap 321
  135. swaps left and right buttons
  136. and writing
  137. .B "buttonmap 123
  138. or just
  139. .B buttonmap
  140. restores their usual meaning.
  141. Note that
  142. .B buttonmap
  143. messages are idempotent,
  144. unlike
  145. .BR swap .
  146. .TP
  147. .B reset
  148. clears the mouse
  149. to its default state.
  150. .PD
  151. .PP
  152. Not all mice interpret all messages; with some devices,
  153. some of the messages may be no-ops.
  154. .PP
  155. Cursors are described in
  156. .IR graphics (2).
  157. When read or written from or to the
  158. .B cursor
  159. file, they are represented in a 72-byte binary format.
  160. The first and second four bytes are little endian
  161. 32-bit numbers specifying the
  162. .I x
  163. and
  164. .I y
  165. coordinates of the cursor
  166. .IR offset ;
  167. the next 32 bytes are the
  168. .B clr
  169. bitmask,
  170. and the last 32 bytes the
  171. .B set
  172. bitmask.
  173. .PP
  174. Reading from the
  175. .B cursor
  176. file returns the current cursor information.
  177. Writing to the
  178. .B cursor
  179. file sets the current cursor information.
  180. A write of fewer than 72 bytes sets the
  181. cursor to the default, an arrow.
  182. .PP
  183. The
  184. .B mouse
  185. and
  186. .B cursor
  187. files are multiplexed by
  188. .IR rio (1)
  189. to give the illusion of a private mouse to each of its clients.
  190. The semantics are otherwise the same except that notification
  191. of a window resize is passed to the application using a
  192. .B mouse
  193. message beginning with
  194. .B r
  195. rather than
  196. .BR m ;
  197. see
  198. .IR rio (4)
  199. for details.
  200. .PP
  201. To cope with pointing devices with only two buttons, when the
  202. shift key is pressed, the right mouse button generates middle-button events.
  203. .SH SOURCE
  204. .B /sys/src/9/port/devmouse.c
  205. .SH "SEE ALSO
  206. .IR rio (4)
  207. .SH BUGS
  208. The cursor format is big endian while the
  209. rest of the graphics interface is little endian.