gnome 加快鼠標滾動速度的方法,全局有效 & YOGA 3 默認 Esc 鍵方法

各种窗口管理器和美化相关
回复
头像
dukelec
帖子: 410
注册时间: 2010-08-26 22:20
系统: Gentoo
来自: Canton

gnome 加快鼠標滾動速度的方法,全局有效 & YOGA 3 默認 Esc 鍵方法

#1

帖子 dukelec » 2012-06-15 14:29

之前用觸摸板,手指不怎麼累,現在公司的鼠標滾到手痛,左手痛了換右手,右手痛了再換回左手,今天終於頂唔順,搜了一下解決方法,下面這位總結的方法比較全:http://forum.ubuntu.org.cn/viewtopic.php?f=42&t=322880
但我沒有成功,ff 方法非全局不考慮,xorg.conf 改了也沒作用,沒看懂 xorg.conf 修改是什麼意思。

後來,我就諗到修改鼠標驅動,滾一下重複上報多次,修改內核代碼 driver/hid/hid-input.c 文件,找到函數 hidinput_hid_event 最後,修改原始:

代码: 全选

……

	/* report the usage code as scancode if the key status has changed */
	if (usage->type == EV_KEY && !!test_bit(usage->code, input->key) != value)
		input_event(input, EV_MSC, MSC_SCAN, usage->hid);

	input_event(input, usage->type, usage->code, value);

	if ((field->flags & HID_MAIN_ITEM_RELATIVE) && (usage->type == EV_KEY))
		input_event(input, usage->type, usage->code, 0);
}
添加後:

代码: 全选

……

	/* report the usage code as scancode if the key status has changed */
	if (usage->type == EV_KEY && !!test_bit(usage->code, input->key) != value)
		input_event(input, EV_MSC, MSC_SCAN, usage->hid);

	input_event(input, usage->type, usage->code, value);

	/* faster the wheel */
	if ((usage->type == EV_REL) && (usage->code == REL_WHEEL)) {
		input_event(input, usage->type, usage->code, value);
		input_event(input, usage->type, usage->code, value);
	}

	if ((field->flags & HID_MAIN_ITEM_RELATIVE) && (usage->type == EV_KEY))
		input_event(input, usage->type, usage->code, 0);
}
通過 ((usage->type == EV_REL) && (usage->code == REL_WHEEL)) 來過濾鼠標滾動,發現當前事件爲鼠標滾動後,額外多報兩次事件。

也就是說,現在滾一下相當於修改前滾三下!
:em11

PS:修改的內核代碼版本爲 3.2.0-rc7, 此文件應該很少更新,版本不是很重要,僅供參考。
上次由 dukelec 在 2015-06-08 10:04,总共编辑 1 次。
jtshs256
帖子: 22323
注册时间: 2010-07-19 21:41
系统: OS X

Re: gnome 加快鼠標滾動速度的方法,全局有效。

#2

帖子 jtshs256 » 2012-06-15 14:35

高端的这
躺平
头像
YeLee
论坛版主
帖子: 26406
注册时间: 2008-08-13 8:48
系统: Fundu i64
来自: 东海硇州,一双管钥。
联系:

Re: gnome 加快鼠標滾動速度的方法,全局有效。

#3

帖子 YeLee » 2012-06-15 15:55

睇上去好似好犀利哇。 :em11
◎当我站在道德的高度上俯视别人的时候,发现自己是多么渺小。
♥执着但不偏激,反对而不排斥,坚决捍卫矛盾体的存在方式。
★★★天气预报★★★
fcitx-yatable一个可以使用的码表输入法
[教程]几个实例攻克软件编译难关
Gentoo Development Guide
字体相关
头像
速腾1994
论坛版主
帖子: 17379
注册时间: 2008-11-01 20:43
系统: Arch+gnome

Re: gnome 加快鼠標滾動速度的方法,全局有效。

#4

帖子 速腾1994 » 2012-06-15 15:57

nnd调整鼠标速度都要动内核
这是什么世道3 :em20
头像
dukelec
帖子: 410
注册时间: 2010-08-26 22:20
系统: Gentoo
来自: Canton

Re: gnome 加快鼠標滾動速度的方法,全局有效。(update: 添加鍵盤自定義)

#5

帖子 dukelec » 2013-05-23 15:21

鼠標折騰完了繼續鍵盤。。。
係咁嘅,我買了 rapoo BT 鍵盤(MODE: E6100),上面 F1~F8 要配合 Fn 鍵先可以使用,默認爲多媒體鍵。。。
鍵盤爲公司台式機所用,多媒體鍵用不到,所以我想將 F1~F8 還原默認。。。

最開始用 xmodmap, 但 F6~F8 音量鍵不能被 xev 命令識別,試了 XF86AudioMute 等無效(註釋掉部分)。。。

代码: 全选

xmodmap -e "keysym XF86AudioNext = F5"
xmodmap -e "keysym XF86AudioPlay = F4"
xmodmap -e "keysym XF86AudioPrev = F3"
xmodmap -e "keysym XF86Search = F2"
xmodmap -e "keysym XF86HomePage = F1"
#xmodmap -e "keysym XF86AudioMute = F6"
#xmodmap -e "keysym XF86AudioLowerVolume = F7"
本來 F6~F8 就唔常用,諗住就咁算。。。
但確發現 ALT + F4 不能用,單獨 F4 可以用,但組合就死得。。。

然後就搵更底層嘅方法,命令 loadkeys 可以改純 console 嘅 keymap, 但 X11 環境冇任何反映。。。

最終,我修改了內核,在 drivers/input/input.c 嘅 input_event 函數裏面加了一句 if (type == 1) { ... } 一次過解決嗮所有問題。。。 :em11

代码: 全选

/**
 * input_event() - report new input event
 * @dev: device that generated the event
 * @type: type of the event
 * @code: event code
 * @value: value of the event
 *
 * This function should be used by drivers implementing various input
 * devices to report input events. See also input_inject_event().
 *
 * NOTE: input_event() may be safely used right after input device was
 * allocated with input_allocate_device(), even before it is registered
 * with input_register_device(), but the event will not reach any of the
 * input handlers. Such early invocation of input_event() may be used
 * to 'seed' initial state of a switch or initial position of absolute
 * axis, etc.
 */
void input_event(struct input_dev *dev,
		 unsigned int type, unsigned int code, int value)
{
	unsigned long flags;

	if (is_event_supported(type, dev->evbit, EV_MAX)) {

		spin_lock_irqsave(&dev->event_lock, flags);
		//printk("DUKE: dev=%p type=%d, code=%d, value=%d\n", dev, type, code, value);
		if (type == 1) {
			if (code == 172) code = 59; /* F1 */
			if (code == 217) code = 60; /* F2 */
			if (code == 165) code = 61; /* F3 */
			if (code == 164) code = 62; /* F4 */
			if (code == 163) code = 63; /* F5 */
			if (code == 113) code = 64; /* F6 */
			if (code == 114) code = 65; /* F7 */
			if (code == 115) code = 66; /* F8 */
		}
		input_handle_event(dev, type, code, value);
		spin_unlock_irqrestore(&dev->event_lock, flags);
	}
}
EXPORT_SYMBOL(input_event);
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: gnome 加快鼠標滾動速度的方法,全局有效。

#6

帖子 eexpress » 2013-05-23 16:04

nnnnd 谁教你动内核的。
不知道那是最底层的嘛。上面的wm可以随便就override你了啊。
● 鸣学
debub
帖子: 289
注册时间: 2010-05-16 18:17

Re: gnome 加快鼠標滾動速度的方法,全局有效。

#7

帖子 debub » 2013-05-23 18:06

果然大牛。我的kde是滚动太快了,喜好kde有调整选项,不用这么麻烦。

Intel G4560 + 8G DDR4
HD610 + GTX1050M
Windows10 + Manjaro kde
jtshs256
帖子: 22323
注册时间: 2010-07-19 21:41
系统: OS X

Re: gnome 加快鼠標滾動速度的方法,全局有效。

#8

帖子 jtshs256 » 2013-05-23 18:13

lz 简直是丧心病狂…… :em20
躺平
头像
qy117121
论坛版主
帖子: 50546
注册时间: 2007-12-14 13:40
系统: Winbuntu
来自: 志虚国乌由市
联系:

Re: gnome 加快鼠標滾動速度的方法,全局有效。

#9

帖子 qy117121 » 2013-05-23 18:25

jtshs256 写了:lz 简直是丧心病狂…… :em20
渠月 · QY   
本人只会灌水,不负责回答问题
无聊可以点一下→ http://u.nu/ubuntu

Ubuntu 20.04 快速设置指南,请配合浏浏览器自动翻译使用

邮箱 chuan@ubuntu.org.cn
头像
速腾1994
论坛版主
帖子: 17379
注册时间: 2008-11-01 20:43
系统: Arch+gnome

Re: gnome 加快鼠標滾動速度的方法,全局有效。

#10

帖子 速腾1994 » 2013-05-25 8:30

qy117121 写了:
jtshs256 写了:lz 简直是丧心病狂…… :em20
francis.tm
帖子: 134
注册时间: 2006-12-05 0:23
系统: Windows® 7
联系:

Re: gnome 加快鼠標滾動速度的方法,全局有效。

#11

帖子 francis.tm » 2013-05-25 14:53

这难道就是传说中的大神么……
.....Welcome to my Blog.....
http://blog.francistm.com
头像
Smallant
帖子: 90
注册时间: 2011-05-27 8:04
来自: 太原理工大学

Re: gnome 加快鼠標滾動速度的方法,全局有效。

#12

帖子 Smallant » 2013-05-25 15:13

传说中的开源软件“优越性”
头像
dukelec
帖子: 410
注册时间: 2010-08-26 22:20
系统: Gentoo
来自: Canton

Re: gnome 加快鼠標滾動速度的方法,全局有效。(update: 添加鍵盤自定義)

#13

帖子 dukelec » 2015-06-06 23:47

臥草,lenovo yoga 3 設置 BIOS 使用 F1~12 鍵之後默認 ESC 要加 Fn 才能用,且同樣方法內核抓不出打印。。。 :em20
dukelec 写了:鼠標折騰完了繼續鍵盤。。。
係咁嘅,我買了 rapoo BT 鍵盤(MODE: E6100),上面 F1~F8 要配合 Fn 鍵先可以使用,默認爲多媒體鍵。。。
鍵盤爲公司台式機所用,多媒體鍵用不到,所以我想將 F1~F8 還原默認。。。

最開始用 xmodmap, 但 F6~F8 音量鍵不能被 xev 命令識別,試了 XF86AudioMute 等無效(註釋掉部分)。。。

代码: 全选

xmodmap -e "keysym XF86AudioNext = F5"
xmodmap -e "keysym XF86AudioPlay = F4"
xmodmap -e "keysym XF86AudioPrev = F3"
xmodmap -e "keysym XF86Search = F2"
xmodmap -e "keysym XF86HomePage = F1"
#xmodmap -e "keysym XF86AudioMute = F6"
#xmodmap -e "keysym XF86AudioLowerVolume = F7"
本來 F6~F8 就唔常用,諗住就咁算。。。
但確發現 ALT + F4 不能用,單獨 F4 可以用,但組合就死得。。。

然後就搵更底層嘅方法,命令 loadkeys 可以改純 console 嘅 keymap, 但 X11 環境冇任何反映。。。

最終,我修改了內核,在 drivers/input/input.c 嘅 input_event 函數裏面加了一句 if (type == 1) { ... } 一次過解決嗮所有問題。。。 :em11

代码: 全选

/**
 * input_event() - report new input event
 * @dev: device that generated the event
 * @type: type of the event
 * @code: event code
 * @value: value of the event
 *
 * This function should be used by drivers implementing various input
 * devices to report input events. See also input_inject_event().
 *
 * NOTE: input_event() may be safely used right after input device was
 * allocated with input_allocate_device(), even before it is registered
 * with input_register_device(), but the event will not reach any of the
 * input handlers. Such early invocation of input_event() may be used
 * to 'seed' initial state of a switch or initial position of absolute
 * axis, etc.
 */
void input_event(struct input_dev *dev,
		 unsigned int type, unsigned int code, int value)
{
	unsigned long flags;

	if (is_event_supported(type, dev->evbit, EV_MAX)) {

		spin_lock_irqsave(&dev->event_lock, flags);
		//printk("DUKE: dev=%p type=%d, code=%d, value=%d\n", dev, type, code, value);
		if (type == 1) {
			if (code == 172) code = 59; /* F1 */
			if (code == 217) code = 60; /* F2 */
			if (code == 165) code = 61; /* F3 */
			if (code == 164) code = 62; /* F4 */
			if (code == 163) code = 63; /* F5 */
			if (code == 113) code = 64; /* F6 */
			if (code == 114) code = 65; /* F7 */
			if (code == 115) code = 66; /* F8 */
		}
		input_handle_event(dev, type, code, value);
		spin_unlock_irqrestore(&dev->event_lock, flags);
	}
}
EXPORT_SYMBOL(input_event);
头像
dukelec
帖子: 410
注册时间: 2010-08-26 22:20
系统: Gentoo
来自: Canton

Re: gnome 加快鼠標滾動速度的方法,全局有效。(update: 添加鍵盤自定義)

#14

帖子 dukelec » 2015-06-07 23:10

重複,待刪除。。。
上次由 dukelec 在 2015-06-07 23:15,总共编辑 1 次。
头像
dukelec
帖子: 410
注册时间: 2010-08-26 22:20
系统: Gentoo
来自: Canton

Re: gnome 加快鼠標滾動速度的方法,全局有效。(update: 添加鍵盤自定義)

#15

帖子 dukelec » 2015-06-07 23:13

dukelec 写了:臥草,lenovo yoga 3 設置 BIOS 使用 F1~12 鍵之後默認 ESC 要加 Fn 才能用,且同樣方法內核抓不出打印。。。 :em20
折騰了半天,終於搞掂。。。

文件 drivers/input/input.c 如下添加 if (type == 1 && code == 1) 區塊:

代码: 全选

struct input_dev *duke_dev = NULL;

void input_event(struct input_dev *dev,
		 unsigned int type, unsigned int code, int value)
{
	unsigned long flags;

	if (type == 1 && code == 1) {
		printk("%s: dev=%s type=%d, code=%d, value=%d\n", __FUNCTION__, dev->name, type, code, value);
		if (duke_dev == NULL && strcmp(dev->name, "AT Translated Set 2 keyboard") == 0) {
			printk("AT pressed.\n");
			duke_dev = dev;
		}
	}

	if (is_event_supported(type, dev->evbit, EV_MAX)) {

		spin_lock_irqsave(&dev->event_lock, flags);
		input_handle_event(dev, type, code, value);
		spin_unlock_irqrestore(&dev->event_lock, flags);
	}
}
EXPORT_SYMBOL(input_event);

文件 drivers/acpi/acpica/psxface.c 添加 printk("%s, parse: %s\n", __FUNCTION__, code_name); 所在區塊:

代码: 全选

#include <linux/input/mt.h>
extern struct input_dev *duke_dev;

acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
{
	……

	/*
	 * Execute the method. Performs parse simultaneously
	 */
	ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
			  "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n",
			  info->node->name.ascii, info->node, info->obj_desc));

	{
		char code_name[5];
		memcpy(code_name, info->node->name.ascii, 4);
		code_name[4] = '\0';
		printk("%s, parse: %s\n", __FUNCTION__, code_name); // _Q4B
		if (duke_dev != NULL && strcmp(code_name, "_Q4B") == 0) {
			printk("report Esc\n");
			input_event(duke_dev, 1, 1, 1);
			input_event(duke_dev, 1, 1, 0);
			input_sync(duke_dev);
		}
	}

	/* Create and init a Root Node */
	……
}
打印:

代码: 全选

^[[   46.827917] acpi_ps_execute_method, parse: _Q4B
[   46.827921] report Esc
[   46.827924] input_event: dev=AT Translated Set 2 keyboard type=1, code=1, value=1
[   46.827926] input_event: dev=AT Translated Set 2 keyboard type=1, code=1, value=0
^[[   47.210268] acpi_ps_execute_method, parse: _Q4B
[   47.210271] report Esc
[   47.210274] input_event: dev=AT Translated Set 2 keyboard type=1, code=1, value=1
[   47.210277] input_event: dev=AT Translated Set 2 keyboard type=1, code=1, value=0
^[[   47.460568] acpi_ps_execute_method, parse: _Q4B
[   47.460571] report Esc
[   47.460575] input_event: dev=AT Translated Set 2 keyboard type=1, code=1, value=1
[   47.460577] input_event: dev=AT Translated Set 2 keyboard type=1, code=1, value=0
另外跟聯想妹子的對話:
Screenshot_2015-06-07-23-00-40.png
Screenshot_2015-06-07-23-00-45.png
Screenshot_2015-06-07-23-01-04.png
回复