Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the 4th and 5th keys of Microsoft mouse in linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how linux uses the 4th and 5th keys of Microsoft mouse. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

(1) first explain the handling of mouse buttons and rollers in linux.

In linux, the wheel is treated as two buttons, one for rolling up and the other for rolling down. So take IE2.0 as an example, there are seven buttons: three on the left, one on the right, one on each side, and two rollers.

(2) modify X configuration

First of all, let's consider the situation that your machine has only one mouse, because my experiment was conducted on an IBM notebook, and Microsoft mouse is my second mouse (don't forget, the notebook itself has one). The situation of more than one is a bit complicated, which will be described later.

The configuration file / etc/X11/XF86Config or / etc/X11/XF86Config-4 that needs to be modified, if you have both, change the second one.

Find a paragraph about the mouse, usually like this.

Code:

Section InputDevice

Identifier Mouse0

Driver mouse

Option Device / dev/mouse

Option Protocol IMPS/2

Option Emulate3buttons no

Option ZAxisMapping 4 5

Option Buttons 5

EndSection

The Identifier and Device fields vary from machine to machine, and we don't have to worry about it. What we need to modify are other fields. The modified configuration is as follows:

Code:

Section InputDevice

Identifier Mouse0

Driver mouse

Option Device / dev/mouse

Option Protocol ExplorerPS/2

Option Emulate3Buttons no

Option ZAxisMapping 6 7

Option Buttons 7

EndSection

Description:

The Option Device field describes the type of mouse. Here, it is changed to the type of Microsoft mouse. If it is a mouse of other models, such as Luoji, it should be feasible as long as the model code is entered correctly. As for the ordinary 5-button mouse, can I use IMPS/2? I haven't tried it.

The Option Buttons field indicates the number of mouse buttons, and the calculation method has been mentioned earlier.

The Option ZAxisMapping field indicates which two buttons to map the wheel to. This is also a more intentional place. No matter how many buttons your mouse has, the normal situation should be 4 / 5. But X can only recognize the last two buttons as the mouse, so it must be changed to 6 / 7, and the consequence is: the buttons on the left and right sides have become rollers, and the rollers have become buttons on both sides, but don't be afraid, there is a way to solve icon_smile.gif.

(3) restart X

After the configuration has been modified, restart X and take a look at our results. Type xev at the command line to test.

Move the mouse into that small window, press each button of the mouse and scroll the wheel up and down respectively. Button 1 should appear in the window. The words button 7. (note: not when pressing, it must be released. This is how the mouse works, hehe)

If you can see button 1... Button 7, congratulations on your upcoming success.

Now we have to solve the problem of inverted rollers and buttons on both sides. Enter on the command line

Code:

Xmodmap-e pointer = 1 2 3 6 7 4 5

Turn the inverted button order back to "positive"! Now that all the settings are complete, find a browser that supports 4 and 5 keys, such as Firefox.

How, under the linux, you can also easily "forward", "backward" it.

Let's talk about other issues.

(1) since you need to manually execute xmodmap-e pointer = 12367 / 45 every time you start X, how can it be executed automatically?

This is outside the scope of this article, but considering the convenience of use, I'd better write a little bit.

Since this command must be executed every time X is started, it is useless to write it in a file such as .bashrc. Some systems don't work either .xinitrc or .xsession. It seems that the problem is very complicated, different linux hairstyle versions and desktop systems are different.

Let me take RedHat as an example.

If you use Gnome, do this: create an executable script in your own directory, such as mouse.sh

Code:

#! / usr/bin/bash

Xmodmap-e pointer = 1 2 3 6 7 4 5

Don't forget chmod + x mouse.sh after saving

Enter gnome, find session in Settings-> other settings, and add mouse.sh to the startup program.

If you use KDE, create a .kdestart file in your own directory and write

Code:

#! / usr/bin/bash

Xmodmap-e pointer = 1 2 3 6 7 4 5

That's it.

(2) how to configure correctly on systems with more than one mouse (such as IBM laptops)?

The configuration is actually the same, but the problem is that xmodmap only seems to support CorePointer, that is, the first mouse, so the default configuration, your Microsoft mouse wheel is the left and right keys, "right" will not come.

My solution is to manually disable the mouse that comes with the laptop. (I don't know if it is possible to set the USB mouse to CorePointer, I haven't tried it, heh heh).

This is the end of this article on "how to use the 4th and 5th keys of Microsoft mouse in linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report