?? mseries.c
字號:
} else if (receiveBuffer[i] == 'B') {
Print(DeviceExtension, DBG_SS_INFO,
("Detected Ballpoint\n"));
mouseType = BALLPOINT;
break;
}
}
if (i >= count) {
//
// Special case: If another device is connected (CSeries, for
// example) and this device sends a character (movement), the
// minimum power up time might not be respected. Take
// care of this unlikely case.
//
if (count != 0) {
SerialMouseWait(DeviceExtension, -CSER_POWER_UP);
}
Print(DeviceExtension, DBG_SS_ERROR | DBG_SS_INFO,
("No MSeries detected\n"));
mouseType = NO_MOUSE;
}
//
// Make sure that all subsequent reads are blocking and do not timeout
//
if (mouseType != NO_MOUSE) {
SerialMouseSetReadTimeouts(DeviceExtension, 0);
}
Print(DeviceExtension, DBG_SS_INFO,
("mouse type is %d\n", (ULONG) mouseType));
return mouseType;
}
BOOLEAN
MSerHandlerMP(
IN PDEVICE_EXTENSION DeviceExtension,
IN PMOUSE_INPUT_DATA CurrentInput,
IN PHANDLER_DATA HandlerData,
IN UCHAR Value,
IN UCHAR LineState
)
/*++
Routine Description:
This is the protocol handler routine for the Microsoft Plus protocol.
Arguments:
CurrentInput - Pointer to the report packet.
HandlerData - Instance specific static data for the handler.
Value - The input buffer value.
LineState - The serial port line state.
Return Value:
Returns TRUE if the handler has a complete report ready.
--*/
{
BOOLEAN retval = FALSE;
ULONG middleButton;
Print(DeviceExtension, DBG_HANDLER_TRACE, ("MP protocol handler, enter\n"));
if ((Value & MP_SYNCH_BIT) && (HandlerData->State != STATE0)) {
if ((HandlerData->State != STATE3)) {
//
// We definitely have a synchronization problem (likely a data
// overrun).
//
HandlerData->Error++;
}
else if ((HandlerData->PreviousButtons & MOUSE_BUTTON_3) != 0) {
//
// We didn't receive the expected fourth byte. Missed it?
// Reset button 3 to zero.
//
HandlerData->PreviousButtons ^= MOUSE_BUTTON_3;
HandlerData->Error++;
}
Print(DeviceExtension, DBG_HANDLER_ERROR,
("Synch error. State: %u\n",
HandlerData->State
));
HandlerData->State = STATE0;
}
else if (!(Value & MP_SYNCH_BIT) && (HandlerData->State == STATE0)) {
HandlerData->Error++;
Print(DeviceExtension, DBG_HANDLER_ERROR,
("Synch error. State: %u\n",
HandlerData->State
));
goto LExit;
}
//
// Check for a line state error.
//
//
// Set the untranslated value.
//
HandlerData->Raw[HandlerData->State] = Value;
Print(DeviceExtension, DBG_HANDLER_NOISE,
("State%u\n", HandlerData->State));
switch (HandlerData->State) {
case STATE0:
case STATE1:
HandlerData->State++;
break;
case STATE2:
HandlerData->State++;
//
// Build the report.
//
CurrentInput->RawButtons =
(HandlerData->Raw[0] & MP_BUTTON_LEFT) >> MP_BUTTON_LEFT_SR;
CurrentInput->RawButtons |=
(HandlerData->Raw[0] & MP_BUTTON_RIGHT) >> MP_BUTTON_RIGHT_SR;
CurrentInput->RawButtons |=
HandlerData->PreviousButtons & MOUSE_BUTTON_3;
CurrentInput->LastX =
(SCHAR)(HandlerData->Raw[1] |
((HandlerData->Raw[0] & MP_UPPER_MASKX) << MP_UPPER_MASKX_SL));
CurrentInput->LastY =
(SCHAR)(HandlerData->Raw[2] |
((HandlerData->Raw[0] & MP_UPPER_MASKY) << MP_UPPER_MASKY_SL));
retval = TRUE;
break;
case STATE3:
HandlerData->State = STATE0;
middleButton =
(HandlerData->Raw[STATE3] & MP_BUTTON_MIDDLE) >> MP_BUTTON_MIDDLE_SR;
//
// Send a report only if the middle button state changed.
//
if (middleButton ^ (HandlerData->PreviousButtons & MOUSE_BUTTON_3)) {
//
// Toggle the state of the middle button.
//
CurrentInput->RawButtons ^= MP_BUTTON_MIDDLE_MASK;
CurrentInput->LastX = 0;
CurrentInput->LastY = 0;
//
// Send the report one more time.
//
retval = TRUE;
}
break;
default:
Print(DeviceExtension, DBG_HANDLER_ERROR,
("MP Handler failure: incorrect state value.\n"
));
ASSERT(FALSE);
}
LExit:
Print(DeviceExtension, DBG_HANDLER_TRACE, ("MP protocol handler: exit\n"));
return retval;
}
BOOLEAN
MSerHandlerBP(
IN PDEVICE_EXTENSION DeviceExtension,
IN PMOUSE_INPUT_DATA CurrentInput,
IN PHANDLER_DATA HandlerData,
IN UCHAR Value,
IN UCHAR LineState
)
/*++
Routine Description:
This is the protocol handler routine for the Microsoft Ballpoint protocol.
Arguments:
CurrentInput - Pointer to the report packet.
HandlerData - Instance specific static data for the handler.
Value - The input buffer value.
LineState - The serial port line state.
Return Value:
Returns TRUE if the handler has a complete report ready.
--*/
{
BOOLEAN retval = FALSE;
Print(DeviceExtension, DBG_HANDLER_TRACE, ("BP protocol handler, enter\n"));
//
// Check for synchronization errors.
//
if ((Value & BP_SYNCH_BIT) && (HandlerData->State != STATE0)) {
HandlerData->Error++;
Print(DeviceExtension, DBG_HANDLER_ERROR,
("Synch error. State: %u\n", HandlerData->State
));
HandlerData->State = STATE0;
}
else if (!(Value & BP_SYNCH_BIT) && (HandlerData->State == STATE0)) {
HandlerData->Error++;
Print(DeviceExtension, DBG_HANDLER_ERROR,
("Synch error. State: %u\n", HandlerData->State
));
goto LExit;
}
//
// Check for a line state error.
//
//
// Set the untranslated value.
//
HandlerData->Raw[HandlerData->State] = Value;
Print(DeviceExtension, DBG_HANDLER_NOISE,
("State%u\n", HandlerData->State));
switch (HandlerData->State) {
case STATE0:
case STATE1:
case STATE2:
HandlerData->State++;
break;
case STATE3:
HandlerData->State = STATE0;
//
// Build the report.
//
CurrentInput->RawButtons =
(HandlerData->Raw[0] & BP_BUTTON_LEFT) >> BP_BUTTON_LEFT_SR;
CurrentInput->RawButtons |=
(HandlerData->Raw[0] & BP_BUTTON_RIGHT) >> BP_BUTTON_RIGHT_SR;
CurrentInput->LastX = HandlerData->Raw[3] & BP_SIGN_MASKX ?
(LONG)(HandlerData->Raw[1] | (ULONG)(-1 & ~0xFF) |
((HandlerData->Raw[0] & BP_UPPER_MASKX) << BP_UPPER_MASKX_SL)):
(LONG)(HandlerData->Raw[1] |
((HandlerData->Raw[0] & BP_UPPER_MASKX) << BP_UPPER_MASKX_SL));
CurrentInput->LastY = HandlerData->Raw[3] & BP_SIGN_MASKY ?
(LONG)(HandlerData->Raw[2] | (ULONG)(-1 & ~0xFF) |
((HandlerData->Raw[0] & BP_UPPER_MASKY) << BP_UPPER_MASKY_SL)):
(LONG)(HandlerData->Raw[2] |
((HandlerData->Raw[0] & BP_UPPER_MASKY) << BP_UPPER_MASKY_SL));
retval = TRUE;
break;
default:
Print(DeviceExtension, DBG_HANDLER_ERROR,
("BP Handler failure: incorrect state value.\n"
));
ASSERT(FALSE);
}
LExit:
Print(DeviceExtension, DBG_HANDLER_TRACE, ("BP protocol handler: exit\n"));
return retval;
}
BOOLEAN
MSerHandlerZ(
IN PDEVICE_EXTENSION DeviceExtension,
IN PMOUSE_INPUT_DATA CurrentInput,
IN PHANDLER_DATA HandlerData,
IN UCHAR Value,
IN UCHAR LineState
)
/*++
Routine Description:
This is the protocol handler routine for the Microsoft Magellan Mouse
(wheel mouse)
Arguments:
CurrentInput - Pointer to the report packet.
HandlerData - Instance specific static data for the handler.
Value - The input buffer value.
LineState - The serial port line state.
Return Value:
Returns TRUE if the handler has a complete report ready.
--*/
{
BOOLEAN retval = FALSE;
ULONG middleButton;
CHAR zMotion = 0;
Print(DeviceExtension, DBG_HANDLER_TRACE, ("Z protocol handler, enter\n"));
if ((Value & Z_SYNCH_BIT) && (HandlerData->State != STATE0)) {
if ((HandlerData->State != STATE3)) {
//
// We definitely have a synchronization problem (likely a data
// overrun).
//
HandlerData->Error++;
}
Print(DeviceExtension, DBG_HANDLER_ERROR,
("Z Synch error #1. State: %u\n", HandlerData->State
));
HandlerData->State = STATE0;
}
else if (!(Value & Z_SYNCH_BIT) && (HandlerData->State == STATE0)) {
HandlerData->Error++;
Print(DeviceExtension, DBG_HANDLER_ERROR,
("Z Synch error #2. State: %u\n", HandlerData->State
));
goto LExit;
}
//
// Check for a line state error.
//
//
// Set the untranslated value.
//
HandlerData->Raw[HandlerData->State] = Value;
Print(DeviceExtension, DBG_HANDLER_NOISE,
("Z State%u\n", HandlerData->State));
switch (HandlerData->State) {
case STATE0:
case STATE1:
case STATE2:
HandlerData->State++;
break;
case STATE3:
//
// Check to see if the mouse is going to the high bits of
// the wheel movement. If not, this is the last bit - transition
// back to state0
//
if((HandlerData->Raw[STATE3] & Z_EXTRA_BIT) == 0) {
HandlerData->State = STATE0;
HandlerData->Raw[STATE4] = 0;
retval = TRUE;
}
else {
HandlerData->State++;
}
break;
case STATE4:
Print(DeviceExtension, DBG_HANDLER_NOISE,
("Z Got that 5th byte\n"));
HandlerData->State = STATE0;
retval = TRUE;
break;
default:
Print(DeviceExtension, DBG_HANDLER_ERROR,
("Z Handler failure: incorrect state value.\n"
));
ASSERT(FALSE);
}
if (retval) {
CurrentInput->RawButtons = 0;
if(HandlerData->Raw[STATE0] & Z_BUTTON_LEFT) {
CurrentInput->RawButtons |= MOUSE_BUTTON_LEFT;
}
if(HandlerData->Raw[STATE0] & Z_BUTTON_RIGHT) {
CurrentInput->RawButtons |= MOUSE_BUTTON_RIGHT;
}
if(HandlerData->Raw[STATE3] & Z_BUTTON_MIDDLE) {
CurrentInput->RawButtons |= MOUSE_BUTTON_MIDDLE;
}
CurrentInput->LastX =
(SCHAR)(HandlerData->Raw[STATE1] |
((HandlerData->Raw[0] & Z_UPPER_MASKX) << Z_UPPER_MASKX_SL));
CurrentInput->LastY =
(SCHAR)(HandlerData->Raw[STATE2] |
((HandlerData->Raw[0] & Z_UPPER_MASKY) << Z_UPPER_MASKY_SL));
//
// If the extra bit isn't set then the 4th byte contains
// a 4 bit signed quantity for the wheel movement. if it
// is set, then we need to combine the z info from the
// two bytes
//
if((HandlerData->Raw[STATE3] & Z_EXTRA_BIT) == 0) {
zMotion = HandlerData->Raw[STATE3] & Z_LOWER_MASKZ;
//
// Sign extend the 4 bit
//
if(zMotion & 0x08) {
zMotion |= 0xf0;
}
} else {
zMotion = ((HandlerData->Raw[STATE3] & Z_LOWER_MASKZ) |
((HandlerData->Raw[STATE4] & Z_UPPER_MASKZ)
<< Z_UPPER_MASKZ_SL));
}
if(zMotion == 0) {
CurrentInput->ButtonData = 0;
} else {
CurrentInput->ButtonData = 0x0078;
if(zMotion & 0x80) {
CurrentInput->ButtonData = 0x0078;
} else {
CurrentInput->ButtonData = 0xff88;
}
CurrentInput->ButtonFlags |= MOUSE_WHEEL;
}
}
LExit:
Print(DeviceExtension, DBG_HANDLER_TRACE, ("Z protocol handler: exit\n"));
return retval;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -