⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mousinfo.c

📁 Dos6.0
💻 C
📖 第 1 页 / 共 2 页
字号:
    }
  else
    NoMouseDriver (pMouse);


  /* Restore Microsoft Mouse state, unless it's a 7.04 mouse driver.  */
  /*   A bug in the 7.04 mouse driver will divide overflow and crash. */

  if (fbMouseState)
    if (pMouse->wMsMajorVersion != 7 && pMouse->wMsMinorVersion != 4)
      {
        inregs.x.ax = 0x0017;
        sregs.es    = FP_SEG (fbMouseState);
        inregs.x.dx = FP_OFF (fbMouseState);
        inregs.x.bx = wSize;
        int86x (0x33, &inregs, &outregs, &sregs);
        _ffree (fbMouseState);
      }
    else
      _ffree (fbMouseState);


  /* Store the mouse structure for future use */
  fpMouse = _fmalloc (sizeof (MOUSE_STRUCT));
  if (fpMouse != NULL)
    {
      _fmemcpy (fpMouse, (MOUSE_STRUCT FAR *) pMouse, sizeof (MOUSE_STRUCT));
      fMouseInfoLoaded = TRUE;
    }

  /* Clear the serial ports of stray characters */
  inp (0x03F8);   /* COM1: */
  inp (0x02F8);   /* COM2: */
  inp (0x03E8);   /* COM3: */
  inp (0x02E8);   /* COM4: */

  return (FALSE);
}


/*********************************************************************
 * NoMouseDriver - Sets the values in the mouse structure to reflect
 *                 the fact that there is no mouse driver present
 *                 in the system.
 *
 * pMouse - Mouse structure.
 *********************************************************************/

VOID NoMouseDriver (MOUSE_STRUCT *pMouse)
{
  pMouse->wOemMajorVersion = 0;
  pMouse->wOemMinorVersion = 0;
  pMouse->wMsMajorVersion  = 0;
  pMouse->wMsMinorVersion  = 0;
  pMouse->wDriverMfgr      = MOUSE_NO_MOUSE_DRIVER;
  strcpy (pMouse->szDriverMfgr, paszMouseMfgrs[MOUSE_NO_MOUSE_DRIVER]);
}


/*********************************************************************
 * SprintMouseInfo - Put mouse information into a set of strings to be
 *                   printed or displayed.
 *
 * Returns:  NULL if an error occured.
 *********************************************************************/

QSZ * SprintMouseInfo (MOUSE_STRUCT *pMouse,
                       CHAR szSumStrings[][MAX_SUMM_INFO + 5])
{
  WORD wNmbrStrings;        /* Number of strings                     */
  WORD wNmbrChars;          /* Number of characters in the strings   */
  WORD wIndent;             /* Indent amount for aligning colons     */
  WORD wIndex;              /* Index to mouse title strings          */
  WORD wRatioIndex;         /* Index for looking up the mouse ratio  */
  WORD i;                   /* Looping variable                      */
  CHAR chBuffer[80];        /* Local string                          */
  QSZ  *pqszStrings = NULL; /* Location for storing string pointers  */


  /* Summary Strings */
  if (szSumStrings != NULL)
    {
      /* Clear out the summary strings */
      szSumStrings[0][0] = '\0';
      szSumStrings[1][0] = '\0';


      /* Check to see if the driver is detected, */
      /*   but the hardware is not detected.     */
      if (pMouse->fHardwareInstalled  == FALSE &&
          (pMouse->wDriverMfgr        != MOUSE_NO_MOUSE_DRIVER ||
           pMouse->wMouseHardwareType == NO_MOUSE_INSTALLED))
        {
          strcpy (szSumStrings[0], "Driver Detected");
        }
      else
        {
          /* Mouse hardware type */
          strcpy (szSumStrings[0], pMouse->szMouseHardwareType);

          /* Is mouse driver version available */
          if (wDosMajor >= 10 || pMouse->wDriverMfgr == MOUSE_NO_MOUSE_DRIVER)
            return (NULL);
        }

      /* Mouse driver version */
      if (pMouse->wOemMajorVersion != 0)
        sprintf (chBuffer, " %x.%02x", pMouse->wOemMajorVersion,
                 pMouse->wOemMinorVersion);
      else
        sprintf (chBuffer, " %x.%02x", pMouse->wMsMajorVersion,
                 pMouse->wMsMinorVersion);

      if (strlen (szSumStrings[0]) + strlen (chBuffer) > MAX_SUMM_INFO)
        {
          i = 1;
          szSumStrings[i][0] = '\0';
        }
      else
        i = 0;

      strcat (szSumStrings[i], chBuffer);

      return (NULL);
    }



  /* Overestimate the amount of space required for the strings */

  for (wNmbrStrings = 0; paszMouseTitles[wNmbrStrings] != NULL;
       ++wNmbrStrings)
    ;

  ++wNmbrStrings;

  wNmbrChars = wNmbrStrings * MAX_MOUSE_LINE_LEN;


  /* Calculate the indent.  If there is an OEM version number, */
  /*   then the Microsoft version number line will have to be  */
  /*   displayed, and it is the longest line.  If not, then    */
  /*   the next longest line will be needed.                   */

  if (pMouse->wOemMajorVersion != 0)
    wIndent = MAX_MOUSE_TITLE;
  else
    wIndent = MAX_MOUSE_TITLE - 1;


  /* Allocate space for the pointer area and string area */
  pqszStrings = AllocStringSpace (wNmbrStrings, wNmbrChars);
  if (pqszStrings == NULL)
    return (NULL);


  /* Put the information in place */

  for (wIndex = 0, i = 0; paszMouseTitles[wIndex] != NULL; ++wIndex, ++i)
    {
      /* Determine if the "Microsoft Driver Version" line is required */
      if (wIndex == MOU_MS_DRIVER_VERSION &&
          pMouse->wOemMajorVersion == 0)
        {
          --i;
          continue;
        }


      /* Determine if the "DOS Driver Type" line is required */
      if (wIndex == MOU_DRIVER_FILE_TYPE &&
          pMouse->szDriverFileType[0] == '\0')
        {
          --i;
          continue;
        }


      /* Determine if the "Path to MOUSE.INI" line is required */
      if (wIndex == MOU_MOUSE_INI_PATH &&
          pMouse->szMouseIniPath[0] == '\0')
        {
          --i;
          continue;
        }


      /* Determine if Serial Mouse information is necessary */
      if (wIndex == MOU_COM_PORT || wIndex == MOU_COM_PORT_ADDRESS)
        if (pMouse->wMouseDriverType != SERIAL_MOUSE          &&
            pMouse->wMouseDriverType != LOGITECH_SERIAL_MOUSE &&
            pMouse->wMouseDriverType != BALLPOINT_MOUSE)
          {
            /* It's not a serial mouse, so skip it */
            --i;
            continue;
          }


      /* Most information is not available under OS/2 */
      if ((wDosMajor >= 10 ||
          pMouse->wDriverMfgr == MOUSE_NO_MOUSE_DRIVER) &&
          wIndex > MOU_DRIVER_MFGR)
        break;


      /* Put the title on the line */
      QstrcpyAlign (pqszStrings[i], paszMouseTitles[wIndex], wIndent);

      switch (wIndex)
        {
          case MOU_HARDWARE:
            {
              Qstrcat (pqszStrings[i], pMouse->szMouseHardwareType);
              break;
            }

          case MOU_DRIVER_MFGR:
            {
              Qstrcat (pqszStrings[i], pMouse->szDriverMfgr);
              break;
            }

          case MOU_DOS_DRIVER_TYPE:
            {
              Qstrcat (pqszStrings[i], pMouse->szMouseDriverType);
              break;
            }

          case MOU_DRIVER_FILE_TYPE:
            {
              Qstrcat (pqszStrings[i], pMouse->szDriverFileType);
              break;
            }

          case MOU_DOS_DRIVER_VERSION:
            {
              /* If there is an OEM version number, display it,    */
              /*   otherwise, display the Microsoft version number */

              if (pMouse->wOemMajorVersion != 0)
                sprintf (chBuffer, "%x.%02x", pMouse->wOemMajorVersion,
                         pMouse->wOemMinorVersion);
              else
                sprintf (chBuffer, "%x.%02x", pMouse->wMsMajorVersion,
                         pMouse->wMsMinorVersion);

              Qstrcat (pqszStrings[i], chBuffer);
              break;
            }

          case MOU_MS_DRIVER_VERSION:
            {
              sprintf (chBuffer, "%x.%02x", pMouse->wMsMajorVersion,
                       pMouse->wMsMinorVersion);
              Qstrcat (pqszStrings[i], chBuffer);
              break;
            }

          case MOU_MOUSE_IRQ:
            {
              sprintf (chBuffer, "%d", pMouse->wIrq);
              Qstrcat (pqszStrings[i], chBuffer);
              break;
            }

          case MOU_COM_PORT:
            {
              Qstrcat (pqszStrings[i], pMouse->szComPort);
              break;
            }

          case MOU_COM_PORT_ADDRESS:
            {
              if (pMouse->wComPort)
                {
                  sprintf (chBuffer, "%04XH", pMouse->wComPortAddress);
                  Qstrcat (pqszStrings[i], chBuffer);
                }
              break;
            }

          case MOU_NMBR_BUTTONS:
            {
              sprintf (chBuffer, "%d", pMouse->wNmbrButtons);
              Qstrcat (pqszStrings[i], chBuffer);
              break;
            }

          case MOU_H_SENSITIVITY:
            {
              sprintf (chBuffer, "%d", pMouse->wHMickeys);
              Qstrcat (pqszStrings[i], chBuffer);
              break;
            }

          case MOU_H_CURSOR_RATIO:
            {
              wRatioIndex = pMouse->wHMickeys / 5 - 1;
              if (wRatioIndex < MAX_MOUSE_RATIO_STRINGS)
                {
                  Qstrcat (pqszStrings[i], paszMouseRatios[wRatioIndex]);
                  Qstrcat (pqszStrings[i], pszColonOne);
                }
              else
                Qstrcat (pqszStrings[i], pszUndefined);
              break;
            }

          case MOU_V_SENSITIVITY:
            {
              sprintf (chBuffer, "%d", pMouse->wVMickeys);
              Qstrcat (pqszStrings[i], chBuffer);
              break;
            }

          case MOU_V_CURSOR_RATIO:
            {
              wRatioIndex = pMouse->wVMickeys / 5 - 1;
              if (wRatioIndex < MAX_MOUSE_RATIO_STRINGS)
                {
                  Qstrcat (pqszStrings[i], paszMouseRatios[wRatioIndex]);
                  Qstrcat (pqszStrings[i], pszColonOne);
                }
              else
                Qstrcat (pqszStrings[i], pszUndefined);
              break;
            }

          case MOU_THRESHOLD_SPEED:
            {
              sprintf (chBuffer, "%d", pMouse->wThresholdSpeed);
              Qstrcat (pqszStrings[i], chBuffer);
              break;
            }

          case MOU_LANGUAGE:
            {
              Qstrcat (pqszStrings[i], pMouse->szLanguage);
              break;
            }

          case MOU_MOUSE_INI_PATH:
            {
              Qstrcat (pqszStrings[i], pMouse->szMouseIniPath);
              break;
            }
        }

      /* Set the next pointer */
      PrepNextString (pqszStrings, i);
    }


  /* Set the last pointer to NULL */

  pqszStrings[i] = NULL;

  /* Return the pointer to pqszStrings */

  return (pqszStrings);
}


/*********************************************************************
 * AltPS2MouseChk - Another check for a PS/2 mouse.
 *********************************************************************/

BOOL AltPS2MouseChk (VOID)
{
  union REGS regs;

  /* PS/2 Pointing Device BIOS Interface -- Reset */

  regs.x.ax = 0xC201;
  regs.x.bx = 0xFFFF;
  int86 (0x15, &regs, &regs);

  /* Carry Flag set indicates error */

  if (regs.x.cflag || regs.x.bx == 0xFFFF)
    return (FALSE);
  else
    return (TRUE);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -