EV को / proc / बस / इनपुट / उपकरणों के डेटा में समझाएँ


12

क्या कोई मुझे समझा सकता है कि EVमूल्य क्या /proc/bus/input/devicesहै?

कीबोर्ड में हमेशा मूल्य होता है 120013। क्यों?


कृपया ध्यान दें: कीबोर्ड में हमेशा कुछ नहीं होता है 0x120013, लेकिन कम से कम वे करेंगे। आप नहीं करना चाहते हैं if(ev == 0x120013){ isKeyboard = true; }, आप करना चाहते हैंif((ev & 0x120013) == 0x120013){ isKeyboard = true; }
एंडी

जवाबों:


22

यह bitmaskडिवाइस द्वारा समर्थित घटनाओं के लिए प्रतिनिधित्व करता है।

devicesएक एटी कीबोर्ड के लिए प्रवेश का नमूना :

I: Bus=0011 Vendor=0001 Product=0001 Version=ab41
N: Name="AT Translated Set 2 keyboard"
P: Phys=isa0060/serio0/input0
S: Sysfs=/devices/platform/i8042/serio0/input/input2
U: Uniq=
H: Handlers=sysrq kbd event2 
B: PROP=0
B: EV=120013
B: KEY=20000 200 20 0 0 0 0 500f 2100002 3803078 f900d401 feffffdf ffefffff ffffffff fffffffe
B: MSC=10
B: LED=7

Bके लिए सामने खड़ा में bitmap, N, P, S, U, Hइसी नाम मूल्य में बस पहले अक्षर हैं और Iके लिए है IDआदेश में फैशन:

  • I => @id: id of the device (struct input_id)
    • Bus     => id.bustype
    • Vendor  => id.vendor
    • Product => id.product
    • Version => id.version
  • N => name of the device.
  • P => physical path to the device in the system hierarchy.
  • S => sysfs path.
  • U => unique identification code for the device (if device has it).
  • H => list of input handles associated with the device.
  • B => bitmaps
    • PROP => device properties and quirks.
    • EV   => types of events supported by the device.
    • KEY  => keys/buttons this device has.
    • MSC  => miscellaneous events supported by the device.
    • LED  => leds present on the device.

Bitmasks

जैसा कि आप जानते हैं कि कंप्यूटर बाइनरी में सौदा करते हैं, इसलिए:

1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
...

इसलिए यदि मेरे पास एक बिटमैप है जिसका मूल्य 5एक शब्द में 0 और 2 होता है, तो दूसरा प्रत्येक नंबर को एक नाम दे सकता है और जांच सकता है कि क्या वे एक मूल्य के अनुरूप हैं।

उदाहरण के लिए

A = 1,  001
B = 2,  010
C = 4,  100

फिर अगर मेरे पास MYVAR = 5जो 101बाइनरी में है तो यह जांच करेगा:

MYVAR & A == TRUE   (101 & 001 => 001)
MYVAR & B == FALSE  (101 & 010 => 000)
MYVAR & C == TRUE   (101 & 100 => 100 )

इस प्रकार मेरे संस्करण में A और C हैं।


कर्नेल थोड़ा अधिक परिष्कृत / जटिल तरीके का उपयोग करता है, और ऑफसेट द्वारा बिट्स सेट करता है। एक कारण यह है कि अधिक बिट्स तब एक कंप्यूटर में उपलब्ध है (सीपीयू) पूर्णांक का उपयोग किया जाता है। उदाहरण के लिए KEYबिटमैप को देखें।

तो, अगर हम कहते हैं:

A = 0
B = 1
C = 6
...

और तब

target = 0;
set_bit(A, target);  => target ==      0001
set_bit(C, target);  => target == 0100 0001

डिकोडिंग 120013

मान 120013एक हेक्साडेसिमल है। बाइनरी के रूप में यह हमें देता है:

0x120013 == 0001 0010 0000 0000 0001 0011 binary
               1    2    0    0    1    3

सही संख्या से वे हैं:

   2            1               <= offset (10's)
3210 9876 5432 1098 7654 3210   <= offset (counted from right)
0001 0010 0000 0000 0001 0011   <= binary

Set bits are:
   0, 1, 4, 17, 20

फिर input.hआप जांच लें कि वे इसके अनुरूप हैं:

   0  EV_SYN (0x00)
   1  EV_KEY (0x01)
   4  EV_MSC (0x04)
  17  EV_LED (0x11)
  20  EV_REP (0x14)

यह जांचने के लिए कि उन्हें कर्नेल डॉक्यूमेंटेशन द्वारा एक त्वरित परिचय दिया गया है ।

* EV_SYN:
  - Used as markers to separate events. Events may be separated in time or in
    space, such as with the multitouch protocol.

* EV_KEY:
  - Used to describe state changes of keyboards, buttons, or other key-like
    devices.

* EV_MSC:
  - Used to describe miscellaneous input data that do not fit into other types.

* EV_LED:
  - Used to turn LEDs on devices on and off.

* EV_REP:
  - Used for autorepeating devices.

यह , "EDIT 2 (जारी)):" विशेष रूप से, ब्याज की हो सकती है।


2
यह उत्तर आश्चर्यजनक है!
अनीश रामास्वामी
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.