The Mouse and the Keyboard

原创 2001年05月22日 05:59:00
 

The Mouse and the Keyboard

If life were like the movies, traditional input devices would have given way long ago to speech-recognition units, 3D headsets, and other human-machine interface gadgets. At present, however, the two most common input devices remain the mouse and the keyboard. Microsoft Windows handles some mouse and keyboard input itself, automatically dropping down a menu, for example, when the user clicks an item on the menu bar, and sending the application a WM_COMMAND message when an item is selected from the menu. It's entirely possible to write a full-featured Windows program that processes no mouse or keyboard input directly, but as an application developer, you'll eventually discover the need to read input from the mouse and keyboard directly. And when you do, you'll need to know about the mouse and keyboard interfaces that Windows provides.

Not surprisingly, mouse and keyboard input comes in the form of messages. Device drivers process mouse and keyboard interrupts and place the resultant event notifications in a systemwide queue known as the raw input queue. Entries in the raw input queue have WM_ message identifiers just as conventional messages do, but the data in them requires further processing before it is meaningful to an application. A dedicated thread owned by the operating system monitors the raw input queue and transfers each message that shows up there to the appropriate thread message queue. The "cooking" of the message data is performed later, in the context of the receiving application, and the message is ultimately retrieved and dispatched just as any other message is.

This input model differs from that of 16-bit Windows, which stored mouse and keyboard messages in a single systemwide input queue until they were retrieved by an application. This arrangement proved to be an Achilles' heel of sorts because it meant that an application that failed to dispose of input messages in a timely manner could prevent other applications from doing the same. Win32's asynchronous input model solves this problem by using the raw input queue as a temporary holding buffer and moving input messages to thread message queues at the earliest opportunity. (In 32-bit Windows, each thread that calls certain Windows API functions is given its own message queue, so a multithreaded application can have not one, but many, message queues.) A 32-bit application that goes too long without checking the message queue responds sluggishly to user input, but it doesn't affect the responsiveness of other applications running on the system.

Learning to respond to mouse and keyboard input in a Windows application is largely a matter of learning about which messages to process. This chapter introduces mouse and keyboard messages and the various functions, both in MFC and the API, that are useful for processing them. We'll apply the concepts presented here to the real world by developing three sample applications:

TicTac, a tic-tac-toe game that demonstrates how to respond to mouse clicks

MouseCap, a simple drawing program that demonstrates how mouse capturing works and how nonclient-area mouse messages are processed

VisualKB, a typing program that brings mouse and keyboard handlers together under one roof and lists the keyboard messages it receives

We have a lot of ground to cover, so let's get started.

HID - Keyboard键盘和Mouse鼠标实例

hid报告描述符生成工具Dt.exe以及hid-keyboard键盘和mouse鼠标实例报告描述符范例键     盘鼠      标项  目编码项   目编码Usage Page (Gener...
  • jonytsx
  • jonytsx
  • 2010年07月12日 15:48
  • 2823

USB Optical Mouse/USB Keyboard驱动问题

USB Optical Mouse/USB Keyboard驱动问题
  • greenhill520
  • greenhill520
  • 2015年05月30日 14:44
  • 1310

usbhid类之mouse、keyboard

1、mouse的8 bytes 2、keyboard的8 bytes
  • luckywang1103
  • luckywang1103
  • 2014年09月21日 13:54
  • 4127

Firefox Keyboard and Mouse Shortcuts

http://www.7is7.com/software/firefox/shortcuts.html
  • feixian49
  • feixian49
  • 2008年06月28日 14:58
  • 136

LYOS —— Driver for Keyboard & Mouse

LYOS —— 一个最基本的操作系统
  • qvjunping
  • qvjunping
  • 2017年08月18日 14:37
  • 96

Python编程.Bluetooth HID Mouse and Keyboard(二)

根据Bluetooth HID协议,从Socket连接的角度来看,蓝牙设备其实是L2CAP连接的Host端。下面我就来实践这个Host端的流程。当然,根据上一篇文章的介绍,我首先要用C语言实现一些友好...
  • huipengzhao
  • huipengzhao
  • 2014年01月16日 11:42
  • 2995

qt5.3.2 everywhere evdev keyboard&mouse

看到没有?!最关键的参数:-mtdev   -evdev ,因为运行的时候需要输入: ./zsy.bin -platform linuxfb -plugin evdevkeyboard=/dev/in...
  • shell_albert
  • shell_albert
  • 2015年05月15日 11:26
  • 2807

Android input 输入系统学习

Android  Input 输入系统学习 Android输入设备的映射 使用指令dumpsys input 可以看到以下信息 130|shell@cv6a638_base:/ # du...
  • kehyuanyu
  • kehyuanyu
  • 2015年09月19日 11:35
  • 2516

keybd_event,mouse_event 模拟产生键盘事件、鼠标事件的使用

模拟鼠标产生鼠标事件、键盘事件有时候非常有用,比如在自动化测试中。源程序在:http://download.csdn.net/detail/dijkstar/4035890 关键程序: 比如一个应...
  • dijkstar
  • dijkstar
  • 2012年01月30日 16:11
  • 8747

Python编程.Bluetooth HID Mouse and Keyboard(四)

#!/usr/bin/env python import Tkinter,sys,time,platform import log class Point: def __init__(se...
  • huipengzhao
  • huipengzhao
  • 2014年01月20日 15:32
  • 2455
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:The Mouse and the Keyboard
举报原因:
原因补充:

(最多只允许输入30个字)