The mouse operations can be described in assembly language, or in other languages such as C, C++, etc.
1. Initialize the mouse driver:
For example: Interrupt number INT33h Function 16h Sub-function 17h
Interrupt number: used to request service
Function number: used to determine which service the user expects to obtain
Sub-function number: further specifies the desired service
Call register: set the parameters required by the called service function
Return register: return the execution result
of the service function Calling process: set parameters Interrupt number INT33h Function 15h BX register ES:DX Function 16h Function 17h ES:DX
2. Show or hide the mouse cursor
Functions 1 and 2 of interrupt 33h set the mouse cursor to "on" and "off" respectively. The mouse driver keeps tracking the movement of the mouse and updates its position on the screen when the mouse moves.
The mouse program usually turns the cursor on from the beginning until the end of the program.
The mouse driver uses cursor flags as a hierarchical method of showing and hiding the cursor. The cursor flag is set to -1 when it is first turned on; function 1 adds the flag to 0 to make the cursor appear. Function 2 decrements the flag by 1 and hides the cursor when the flag is negative.
3. Setting the shape of the text mouse cursor
When working in video text mode, the mouse driver generates two types of cursors:
(1) Hardware cursor, which is a regular screen cursor generated by the video hardware and consists of horizontal scan lines.
(2) Software or attribute cursor, in which case the mouse driver writes data at the screen position where the cursor appears. The driver changes the character displayed at this position or changes the character's attributes, making it flash, background color, etc.
(3) Interrupt 33h function Ah sets the type of text cursor: AX stores the function number; BX stores the cursor or software cursor selection; CX stores the starting scan line; DX stores the ending scan line.
4. Set the shape of the graphic mouse cursor
Function 9h of interrupt 33h sets the shape of the mouse cursor in graphics mode and defines a point in the cursor as the hotspot. The cursor consists of a 16 x 16-bit video mask and a 16 x 16-bit cursor mask.
5. Get or set the position of the mouse cursor
Function 4h of interrupt 33h is used to set the position of the mouse cursor, and function 3h is used to report the position of the cursor. AX stores the function number, CX is assigned the X coordinate, and DX is assigned the Y coordinate. P200 Example 7-4
6. Limit the mouse cursor to a part of the screen
The mouse cursor can be limited to a rectangular area on the screen. The horizontal range of the mouse cursor movement is set by the function 7h of interrupt 33h, and the vertical range is set by 8h. P201 Example 7-5
7. Define the screen area where the mouse cursor is not displayed
Function 10h of interrupt 33h defines an area of the screen that will be automatically turned off when the mouse enters the area. When entering, CX stores the left column number of the protected domain, SI stores the right column number; DX stores the first row number, and DI stores the last row number.
Example 7-6 Set a rectangular area ranging from columns 10 to 50 and rows 5 to 30.
MOV AX, 10h; Function number
MOV CX, 10; Left column
MOV SI, 50; Right column
MOV DX, 5; First row
MOV DI, 30; Last row
INT 33h; Call interrupt to set domain
8. Tracking Mouse Movements
Interrupt 33h function Bh reports the actual distance the mouse has moved (measured in meters) since the last call to this function. This function returns the relative horizontal displacement in CX and the relative vertical displacement in DX. Example 7-7 Query the relative displacement of the mouse cursor.
MOV AX, 0Bh
INT 33h
MOV HORZ_MOTION, CX
MOV VERT_MOTION, DX
9. Set the ratio of mouse and cursor movement
The program can change the ratio of mouse movement relative to mouse cursor movement. Most mice have a resolution of 200 meters per inch. Moving a certain number of meters in a certain direction translates to one pixel of mouse cursor movement. By default, 8 meters moves one pixel horizontally; 16 meters moves one pixel vertically.
Function Fh of interrupt 21h can change the meter-pixel ratio.
Function 13h of interrupt 33h changes the threshold that produces double rate. The default value is 64 meters per second. P202 Example 7-8
10. Monitoring Mouse Buttons
Functions 5h and 6h of interrupt 33h report information about the mouse buttons. Both functions return a button status byte in AX reporting the current status of button 2 or 3. This status byte is returned by function 3h of interrupt 21h. It reports the position of the mouse cursor.
Functions 5h and 6h of interrupt 33h keep track of button presses and button releases.
11. Intercepting single click, double click, and drag events
Many programs that use a mouse need to detect single and double clicks of the mouse, and track drag events for button presses.
12. Create a mouse interrupt routine
Create a routine in function Ch of INT 33h. At entry, ES:DX points to a bit pattern stored in the routine CX to set several routine events that should be called. The pattern is:
Previous article:Mouse application design
Next article:Keyboard application design
- Popular Resources
- Popular amplifiers
- High signal-to-noise ratio MEMS microphone drives artificial intelligence interaction
- Advantages of using a differential-to-single-ended RF amplifier in a transmit signal chain design
- ON Semiconductor CEO Appears at Munich Electronica Show and Launches Treo Platform
- ON Semiconductor Launches Industry-Leading Analog and Mixed-Signal Platform
- Analog Devices ADAQ7767-1 μModule DAQ Solution for Rapid Development of Precision Data Acquisition Systems Now Available at Mouser
- Domestic high-precision, high-speed ADC chips are on the rise
- Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
- Using capacitive PGA, Naxin Micro launches high-precision multi-channel 24/16-bit Δ-Σ ADC
- Fully Differential Amplifier Provides High Voltage, Low Noise Signals for Precision Data Acquisition Signal Chain
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【Development Kit for nRF52840】+ Hardware Review
- [Repost] Comparison between aluminum electrolytic capacitors and tantalum capacitors
- Programming example: CPU card response data command
- How to use multiple devices to study radiation signals - Part 1
- Tianjin - Recruiting embedded software and hardware engineers - fresh graduates preferred
- Flash memory failure characteristics
- [RVB2601 Creative Application Development] User Experience 05 -- TCP Client
- CXA-L10A Tube Lamp Inverter
- Transistor User Manual
- How do pressure sensors work at high temperatures?