乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Input event驅(qū)動

       nt_bookworm 2012-04-10

      Input event驅(qū)動

      Andrew Huang <bluedrum@163.com>


      Linux 專門對輸入設備。
      鍵盤,鼠標,手柄,觸摸屏。按鍵。封裝一個類驅(qū)動。
      主要統(tǒng)一與應用程序接口。這一類的設備結(jié)點都是在/dev/input/eventn( 0<=n) 
      用戶程序讀驅(qū)動的輸入都采用統(tǒng)一格式,即struct input_event,方便應用程序來讀寫



      Linux/input.h

      struct input_event {
          struct timeval time;
          __u16 type;
          __u16 code;
          __s32 value;
      };


      INPUT驅(qū)動查看

      查看設備結(jié)點
      ls -l /dev/input
      查看設備信息
      ls -l /proc/bus/input/
      cat /proc/bus/input/devices
      查看input class信息

       ls /sys/class/input


      input device 優(yōu)點

      統(tǒng)一應用程序使用外部輸入設備的接口。這樣簡化編程。
      Input core是沒有緩存隊列的,如果應用程序沒有及時取事件,則事件被丟棄。


      input輸入驅(qū)動編程

      輸入驅(qū)動數(shù)據(jù)結(jié)構(gòu)
       struct input_dev *input_dev;
      在驅(qū)動中必須動態(tài)分配input_dev結(jié)構(gòu),這里使用
      input_allocate_device();
      初始化input_dev的參數(shù)
      調(diào)用 input_register_device()注冊,
      退出時調(diào)用 input_unregister_device()


      與應用程序的交互

      Input 驅(qū)動的子系統(tǒng)已經(jīng)控制I/O,換句話read/write不需要驅(qū)動直接.
      驅(qū)動只需要input_report_xxx()上傳信息
      input_report_key()上傳按鍵
      input_report_abs() 絕對坐標
      它們最終調(diào)用input_event來向input core上傳信息,并最后轉(zhuǎn)交給應用程序.
      Input core沒有緩存事件信息,這樣在應用程序開始read前的信息全部被丟棄.


      input_dev 的初始化

      evbit 表示這個驅(qū)動支持哪一些事件,有兩種等效的方法
      set_bit(EV_KEY, input_dev->evbit); set_bit(EV_REL, input_dev->evbit);
      input_dev->evbit  = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);


      初始化/proc/bus/input/devices的信息

      #define DEVICE_NAME "s3c6410 gpio button"

          myinput_dev->name = DEVICE_NAME;
          myinput_dev->phys = "gpio-button/input100";
          
          myinput_dev->id.bustype = BUS_HOST;  //設備
          myinput_dev->id.vendor =  0x0001;
          myinput_dev->id.product = 0x0001;
          myinput_dev->id.version = 0x0001;


      cat /proc/bus/input/devices

      I: Bus=0019 Vendor=0001 Product=0001 Version=0001
      N: Name="s3c6410 gpio button"
      P: Phys=gpio-button/input100
      S: Sysfs=/class/input/input2
      U: Uniq=
      H: Handlers=kbd event2
      B: EV=3
      B: KEY=1680 0 0 10000002



      [root@urbetter 01]# insmod myinput.ko
       myinput_init 08:
      myinput_register_irq: rquest_irq: irq 101,name KYE1-UP
      myinput_register_irq: rquest_irq: irq 102,name KYE2-LEFT
      myinput_register_irq: rquest_irq: irq 103,name KYE3-RIGHT
      myinput_register_irq: rquest_irq: irq 104,name KYE4-DOWN
      myinput_register_irq: rquest_irq: irq 105,name KYE5-ESC
      myinput_register_irq: rquest_irq: irq 106,name KYE6-RETURN
      myinput_init: sizeof(evbit)=4,EV_CNT 32,BITS_LONGS 1
      myinput_init: sizeof(keybit)=96,KEY_CNT 768,BITS_LONGS 24
      input: s3c6410 gpio button as /class/input/input2
      [root@urbetter 01]# ls -l /dev/input
      crw-rw----    1 root     root      13,  64 Mar 23  2000 event0
      crw-rw----    1 root     root      13,  65 Mar 23  2000 event1
      crw-rw----    1 root     root      13,  66 Mar 23 12:08 event2
      crw-rw----    1 root     root      13,  63 Mar 23  2000 mice
      crw-rw----    1 root     root      13,  32 Mar 23  2000 mouse0



      USB鍵盤測試

      USB鍵盤是在 hid/usbhid/usbkbd.c

      I: Bus=0003 Vendor=413c Product=2003 Version=0110
      N: Name="Dell Dell USB Keyboard"
      P: Phys=usb-s3c24xx-1/input0
      S: Sysfs=/class/input/input2
      U: Uniq=
      H: Handlers=kbd event2
      B: EV=120013
      B: KEY=10000 7 ff9f207a c14057ff febeffdf ffefffff ffffffff fffffffe
      B: MSC=10
      B: LED=7


      [root@urbetter 01]# ls -l /dev/input
      crw-rw----    1 root     root      13,  64 Mar 23  2000 event0
      crw-rw----    1 root     root      13,  65 Mar 23  2000 event1
      crw-rw----    1 root     root      13,  66 Mar 23 14:17 event2
      crw-rw----    1 root     root      13,  67 Mar 23 14:19 event3
      crw-rw----    1 root     root      13,  63 Mar 23  2000 mice
      crw-rw----    1 root     root      13,  32 Mar 23  2000 mouse0

      usb 1-1: new low speed USB device using s3c2410-ohci and address 2
      usb 1-1: configuration #1 chosen from 1 choice
      input: Dell Dell USB Keyboard as /class/input/input2
      generic-usb 0003:413C:2003.0001: input: USB HID v1.10 Keyboard [Dell Dell USB Ke
      yboard] on usb-s3c24xx-1/input0

        本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多