1
0

mouse 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 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\fP"
  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\fI [n]\fP"
  103. turns on mouse acceleration.
  104. .I N
  105. is an optional acceleration factor.
  106. .TP
  107. .B linear
  108. turns off mouse acceleration.
  109. .TP
  110. .B "res\fI n\fR"
  111. sets mouse resolution to a setting between 0 and
  112. 3 inclusive.
  113. .TP
  114. .B "hwaccel\fI on/off\fP"
  115. sets whether acceleration is done in hardware or
  116. software.
  117. By default, PS2 mice use hardware and serial mice use
  118. software.
  119. Some laptops (notably the IBM Thinkpad T23) don't
  120. implement hardware acceleration for external mice.
  121. .TP
  122. .B swap
  123. swaps the left and right buttons on the mouse.
  124. .TP
  125. .B "buttonmap\fI xyz\fP"
  126. numbers the left, middle, and right mouse buttons
  127. .IR x ,
  128. .IR y ,
  129. and
  130. .IR z ,
  131. respectively.
  132. If
  133. .I xyz
  134. is omitted, the default map, 123, is used.
  135. Thus in the default state writing
  136. .B "buttonmap 321
  137. swaps left and right buttons
  138. and writing
  139. .B "buttonmap 123
  140. or just
  141. .B buttonmap
  142. restores their usual meaning.
  143. Note that
  144. .B buttonmap
  145. messages are idempotent,
  146. unlike
  147. .BR swap .
  148. .TP
  149. .B reset
  150. clears the mouse
  151. to its default state.
  152. .PD
  153. .PP
  154. Not all mice interpret all messages; with some devices,
  155. some of the messages may be no-ops.
  156. .PP
  157. Cursors are described in
  158. .IR graphics (2).
  159. When read or written from or to the
  160. .B cursor
  161. file, they are represented in a 72-byte binary format.
  162. The first and second four bytes are little endian
  163. 32-bit numbers specifying the
  164. .I x
  165. and
  166. .I y
  167. coordinates of the cursor
  168. .IR offset ;
  169. the next 32 bytes are the
  170. .B clr
  171. bitmask,
  172. and the last 32 bytes the
  173. .B set
  174. bitmask.
  175. .PP
  176. Reading from the
  177. .B cursor
  178. file returns the current cursor information.
  179. Writing to the
  180. .B cursor
  181. file sets the current cursor information.
  182. A write of fewer than 72 bytes sets the
  183. cursor to the default, an arrow.
  184. .PP
  185. The
  186. .B mouse
  187. and
  188. .B cursor
  189. files are multiplexed by
  190. .IR rio (1)
  191. to give the illusion of a private mouse to each of its clients.
  192. The semantics are otherwise the same except that notification
  193. of a window resize is passed to the application using a
  194. .B mouse
  195. message beginning with
  196. .B r
  197. rather than
  198. .BR m ;
  199. see
  200. .IR rio (4)
  201. for details.
  202. .PP
  203. To cope with pointing devices with only two buttons, when the
  204. shift key is pressed, the right mouse button generates middle-button events.
  205. .SH SOURCE
  206. .B /sys/src/9/port/devmouse.c
  207. .SH "SEE ALSO
  208. .IR rio (4)
  209. .SH BUGS
  210. The cursor format is big endian while the
  211. rest of the graphics interface is little endian.