ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

ps2pp.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:     ReactOS i8042 (ps/2 keyboard-mouse controller) driver
00003  * LICENSE:     GPL - See COPYING in the top level directory
00004  * FILE:        drivers/input/i8042prt/ps2pp.c
00005  * PURPOSE:     ps2pp protocol handling
00006  * PROGRAMMERS: Copyright Martijn Vernooij (o112w8r02@sneakemail.com)
00007  *              Copyright 2006-2007 Hervé Poussineau (hpoussin@reactos.org)
00008  */
00009 
00010 /* INCLUDES ****************************************************************/
00011 
00012 #include "i8042prt.h"
00013 
00014 /* FUNCTIONS *****************************************************************/
00015 
00016 VOID
00017 i8042MouHandlePs2pp(
00018     IN PI8042_MOUSE_EXTENSION DeviceExtension,
00019     IN UCHAR Input)
00020 {
00021     UCHAR PktType;
00022     PMOUSE_INPUT_DATA MouseInput;
00023 
00024     MouseInput = DeviceExtension->MouseBuffer + DeviceExtension->MouseInBuffer;
00025 
00026     /* First, collect 3 bytes for a packet
00027      * We can detect out-of-sync only by checking
00028      * the whole packet anyway.
00029      *
00030      * If bit 7 and 8 of the first byte are 0, its
00031      * a normal packet.
00032      *
00033      * Otherwise, the packet is different, like this:
00034      * 1: E  1 b3 b2  1  x  x  x
00035      * 2: x  x b1 b0 x1 x0  1  0
00036      * 3: x  x  x  x  x  x x1 x0
00037      *
00038      * b3-0 form a code that specifies the packet type:
00039      *
00040      * 0  Device Type
00041      * 1  Rollers and buttons
00042      * 2   Reserved
00043      * 3   Reserved
00044      * 4  Device ID
00045      * 5  Channel & Battery
00046      * 6  Wireless notifications
00047      * 7   Reserved
00048      * 8  ShortID LSB (ShortID is a number that is supposed to differentiate
00049      * 9  ShortID MSB  between your mouse and your neighbours')
00050      * 10  Reserved
00051      * 11 Mouse capabilities
00052      * 12 Remote control LSB
00053      * 13 Remote control MSB
00054      * 14  Reserved
00055      * 15 Extended packet
00056      */
00057 
00058     switch (DeviceExtension->MouseState)
00059     {
00060         case MouseIdle:
00061         case XMovement:
00062             DeviceExtension->MouseLogiBuffer[DeviceExtension->MouseState] = Input;
00063             DeviceExtension->MouseState++;
00064             break;
00065 
00066         case YMovement:
00067             DeviceExtension->MouseLogiBuffer[2] = Input;
00068             DeviceExtension->MouseState = MouseIdle;
00069 
00070             /* first check if it's a normal packet */
00071 
00072             if (!(DeviceExtension->MouseLogiBuffer[0] & 0xC0))
00073             {
00074                 DeviceExtension->MouseState = MouseIdle;
00075                 i8042MouHandle(DeviceExtension, DeviceExtension->MouseLogiBuffer[0]);
00076                 i8042MouHandle(DeviceExtension, DeviceExtension->MouseLogiBuffer[1]);
00077                 i8042MouHandle(DeviceExtension, DeviceExtension->MouseLogiBuffer[2]);
00078                 /* We could care about wether MouseState really
00079                  * advances, but we don't need to because we're
00080                  * only doing three bytes anyway, so the packet
00081                  * will never complete if it's broken.
00082                  */
00083                 return;
00084             }
00085 
00086             /* sanity check */
00087             if (((DeviceExtension->MouseLogiBuffer[0] & 0x48) != 0x48) ||
00088                (((DeviceExtension->MouseLogiBuffer[1] & 0x0C) >> 2) !=
00089                  (DeviceExtension->MouseLogiBuffer[2] & 0x03)))
00090                 {
00091                     WARN_(I8042PRT, "Ps2pp packet fails sanity checks\n");
00092                     return;
00093                 }
00094 
00095             /* Now get the packet type */
00096             PktType = ((DeviceExtension->MouseLogiBuffer[0] & 0x30) >> 2) |
00097                       ((DeviceExtension->MouseLogiBuffer[1] & 0x30) >> 4);
00098 
00099             switch (PktType)
00100             {
00101                 case 0:
00102                     /* The packet contains the device ID, but we
00103                      * already read that in the initialization
00104                      * sequence. Ignore it.
00105                      */
00106                     return;
00107                 case 1:
00108                     RtlZeroMemory(MouseInput, sizeof(MOUSE_INPUT_DATA));
00109                     if (DeviceExtension->MouseLogiBuffer[2] & 0x10)
00110                         MouseInput->RawButtons |= MOUSE_BUTTON_4_DOWN;
00111 
00112                     if (DeviceExtension->MouseLogiBuffer[2] & 0x20)
00113                         MouseInput->RawButtons |= MOUSE_BUTTON_5_DOWN;
00114 
00115                     if (DeviceExtension->MouseLogiBuffer[2] & 0x0F)
00116                     {
00117                         MouseInput->ButtonFlags |= MOUSE_WHEEL;
00118                         if (DeviceExtension->MouseLogiBuffer[2] & 0x08)
00119                             MouseInput->ButtonData = (DeviceExtension->MouseLogiBuffer[2] & 0x07) - 8;
00120                         else
00121                             MouseInput->ButtonData = DeviceExtension->MouseLogiBuffer[2] & 0x07;
00122                     }
00123                     i8042MouHandleButtons(
00124                         DeviceExtension,
00125                         MOUSE_BUTTON_4_DOWN | MOUSE_BUTTON_5_DOWN);
00126                     DeviceExtension->MouseHook.QueueMousePacket(DeviceExtension->MouseHook.CallContext);
00127                     return;
00128                 default:
00129                     /* These are for things that would probably
00130                      * be handled by logitechs own driver.
00131                      */
00132                     return;
00133             }
00134 
00135         default:
00136             WARN_(I8042PRT, "Unexpected input state for ps2pp!\n");
00137     }
00138 }

Generated on Thu May 24 2012 04:28:19 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.