* Compare mouse button state with previous value, and report changes. * @param newButtonState New button state. * @return \c 0x2D if no change, \c 0x41 for change in first button state, * \c 0x42 for change in second button state, bit 11 means 'button released'. */
| 231 | * \c 0x42 for change in second button state, bit 11 means 'button released'. |
| 232 | */ |
| 233 | uint16 Mouse_CheckButtons(uint16 newButtonState) |
| 234 | { |
| 235 | uint8 change; |
| 236 | uint16 result; |
| 237 | |
| 238 | newButtonState &= 0xFF; |
| 239 | |
| 240 | result = 0x2D; |
| 241 | change = newButtonState ^ g_prevButtonState; |
| 242 | if (change == 0) return result; |
| 243 | |
| 244 | g_prevButtonState = newButtonState & 0xFF; |
| 245 | |
| 246 | if ((change & 0x2) != 0) { |
| 247 | result = 0x42; |
| 248 | if ((newButtonState & 0x2) == 0) { |
| 249 | result |= 0x800; /* RELEASE */ |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | if ((change & 0x1) != 0) { |
| 254 | result = 0x41; |
| 255 | if ((newButtonState & 0x1) == 0) { |
| 256 | result |= 0x800; /* RELEASE */ |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | return result; |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * If the mouse has moved, update its coordinates, and update the region flags. |
no outgoing calls
no test coverage detected