• evdev module-----ecodes.py


     1 # encoding: utf-8
     2 
     3 '''
     4 This modules exposes most integer constants defined in ``linux/input.h``.
     5 
     6 Exposed constants::
     7 
     8     KEY, ABS, REL, SW, MSC, LED, BTN, REP, SND, ID, EV, BUS, SYN
     9 
    10 This module also provides numerous reverse and forward mappings that are best
    11 illustrated by a few examples::
    12 
    13     >>> evdev.ecodes.KEY_A
    14     30
    15 
    16     >>> evdev.ecodes.ecodes['KEY_A']
    17     30
    18 
    19     >>> evdev.ecodes.KEY[30]
    20     'KEY_A'
    21 
    22     >>> evdev.ecodes.REL[0]
    23     'REL_X'
    24 
    25     >>> evdev.ecodes.EV[evdev.EV_KEY]
    26     'EV_KEY'
    27 
    28     >>> evdev.ecodes.bytype[EV_REL][0]
    29     'REL_X'
    30 '''
    31 
    32 from inspect import getmembers
    33 from evdev import _ecodes
    34 
    35 
    36 #: mapping of names to values
    37 ecodes = {}
    38 
    39 prefixes = 'KEY ABS REL SW MSC LED BTN REP SND ID EV BUS SYN'
    40 g = globals()
    41 
    42 for k,v in getmembers(_ecodes):
    43     for i in prefixes.split():
    44         if k.startswith(i):
    45             g.setdefault(i, {})[v] = k
    46             ecodes[k] = v
    47 
    48 
    49 #: keys are a combination of all BTN and KEY codes
    50 keys = {}
    51 keys.update(BTN)
    52 keys.update(KEY)
    53 
    54 # make keys safe to use for the default list of uinput device
    55 # capabilities
    56 del keys[_ecodes.KEY_MAX]
    57 del keys[_ecodes.KEY_CNT]
    58 
    59 #: mapping of event types to other value/name mappings
    60 bytype = {
    61     _ecodes.EV_KEY: keys,
    62     _ecodes.EV_ABS: ABS,
    63     _ecodes.EV_REL: REL,
    64     _ecodes.EV_SW:  SW,
    65     _ecodes.EV_MSC: MSC,
    66     _ecodes.EV_LED: LED,
    67     _ecodes.EV_REP: REP,
    68     _ecodes.EV_SND: SND,
    69     _ecodes.EV_SYN: SYN, }
    70 
    71 from evdev._ecodes import *
    72 
    73 # cheaper than whitelisting in an __all__
    74 del k, v, i, getmembers, g, prefixes
  • 相关阅读:
    IOS compare 字符串比较
    Cocoa Touch事件处理流程--响应者链
    真机测试及布署Code Sign error问题总结
    CG_INLINE,inline 内联函数
    objective-c static变量的使用总结
    iOS用户信息单例的创建
    UITextField-修改占位文字和光标的颜色,大小
    iOS应用程序生命周期(前后台切换,应用的各种状态)详解
    深入理解RunLoop
    jQuery文件上传插件uploadify
  • 原文地址:https://www.cnblogs.com/winditsway/p/5665838.html
Copyright © 2020-2023  润新知