Chinese translated version of Documentation/input/notifier.txt
If you have any comment or update to the content, please contact the
original document maintainer directly. However, if you have a problem
communicating in English you can also ask the Chinese maintainer for
help. Contact the Chinese maintainer if this translation is outdated
or if there is a problem with the translation.
Chinese maintainer: 马煜晨 380319072@qq.com
---------------------------------------------------------------------
Documentation/input/notifier.txt 的中文翻译
如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。
中文版维护者: 马煜晨 380319072@qq.com
中文版翻译者: 马煜晨 380319072@qq.com
中文版校译者: 马煜晨 380319072@qq.com
以下为正文
---------------------------------------------------------------------
Keyboard notifier
键盘通知器
One can use register_keyboard_notifier to get called back on keyboard
events (see kbd_keycode() function for details). The passed structure is
keyboard_notifier_param:
一个可以用register_keyboard_notifier回调键盘相应(详见kbd_keycode())。
通过的结构为keyboard_notifier_param:
- 'vc' always provide the VC for which the keyboard event applies;
- 'down' is 1 for a key press event, 0 for a key release;
- 'shift' is the current modifier state, mask bit indexes are KG_*;
- 'value' depends on the type of event.
- 'vc' 为键盘响应应用提供VC;
- 'down' 1为按下键,0为放开键;
- 'shift' 是目前的修饰符状态,屏蔽位索引是KG_*;
- 'value' 由响应类型决定。
- KBD_KEYCODE events are always sent before other events, value is the keycode.
- KBD_UNBOUND_KEYCODE events are sent if the keycode is not bound to a keysym.
value is the keycode.
- KBD_UNICODE events are sent if the keycode -> keysym translation produced a
unicode character. value is the unicode value.
- KBD_KEYSYM events are sent if the keycode -> keysym translation produced a
non-unicode character. value is the keysym.
- KBD_POST_KEYSYM events are sent after the treatment of non-unicode keysyms.
That permits one to inspect the resulting LEDs for instance.
- KBD_KEYCODE 响应总是在其他事件之前送出,值是键码。
- KBD_UNBOUND_KEYCODE 响应被送出如果键码没在keysym中。值是键码。
- KBD_UNICODE 响应被送出如果keycode -> keysym转化提供统一的字符。值为统一码的值。
- KBD_KEYSYM 响应被送出如果keycode -> keysym转化提供不统一的的字符。值是keysym
- KBD_POST_KEYSYM 响应在没有统一的键码时送出。例如允许一个监督LEDS结果。
For each kind of event but the last, the callback may return NOTIFY_STOP in
order to "eat" the event: the notify loop is stopped and the keyboard event is
dropped.
对于所有的事件,回调会返回NOTIFY_STOP为了解决掉这个事件:通知循环停止且键盘响应
下降。
In a rough C snippet, we have:
在一个粗略的C片段中,我们有:
kbd_keycode(keycode) {
...
params.value = keycode;
if (notifier_call_chain(KBD_KEYCODE,¶ms) == NOTIFY_STOP)
|| !bound) {
notifier_call_chain(KBD_UNBOUND_KEYCODE,¶ms);
return;
}
if (unicode) {
param.value = unicode;
if (notifier_call_chain(KBD_UNICODE,¶ms) == NOTIFY_STOP)
return;
emit unicode;
return;
}
params.value = keysym;
if (notifier_call_chain(KBD_KEYSYM,¶ms) == NOTIFY_STOP)
return;
apply keysym;
notifier_call_chain(KBD_POST_KEYSYM,¶ms);
}
NOTE: This notifier is usually called from interrupt context.
注:这个通知常被称为中断上下文。