示例#1
0
文件: request.py 项目: oN0/Nagstamon
class QueryKeymap(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Opcode(44),
        rq.Pad(1),
        rq.RequestLength(),
        )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.FixedList('map', 32, rq.Card8Obj),
        )
示例#2
0
文件: request.py 项目: oN0/Nagstamon
class GetKeyboardControl(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Opcode(103),
        rq.Pad(1),
        rq.RequestLength(),
        )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Card8('global_auto_repeat'),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Card32('led_mask'),
        rq.Card8('key_click_percent'),
        rq.Card8('bell_percent'),
        rq.Card16('bell_pitch'),
        rq.Card16('bell_duration'),
        rq.Pad(2),
        rq.FixedList('auto_repeats', 32, rq.Card8Obj),
        )
示例#3
0
class KeymapNotify(rq.Event):
    _code = X.KeymapNotify
    _fields = rq.Struct(rq.Card8('type'),
                        rq.FixedList('data', 31, rq.Card8Obj, pad=0))
示例#4
0
))

_struct_test('list pad', (
    (None, lambda name: rq.LengthOf('lc8', 1), None, pack('B', 2)),
    (None, lambda name: rq.LengthOf('lc16', 2), None, pack('H', 3)),
    (None, lambda name: rq.LengthOf('lc32', 4), None, pack('L', 5)),
    ('lc8', lambda name: rq.List(name, rq.Card8, pad=1), [0x42, 0xc3],
     lambda v: pack('2B2x', *v)),
    ('lc16', lambda name: rq.List(name, rq.Card16, pad=1), [666, 1, 60143],
     lambda v: pack('3H2x', *v)),
    ('lc32', lambda name: rq.List(name, rq.Card32, pad=1),
     [0xf02facb, 666, 1, 0x1043, 0xdeadbeef], lambda v: pack('5L', *v)),
))

_struct_test('fixed list', (
    ('lc8', lambda name: rq.FixedList(name, 2, rq.Card8, pad=0), [0x42, 0xc3],
     lambda v: pack('2B', *v)),
    ('lc16', lambda name: rq.FixedList(name, 3, rq.Card16, pad=0),
     [666, 1, 60143], lambda v: pack('3H', *v)),
    ('lc32', lambda name: rq.FixedList(name, 5, rq.Card32, pad=0),
     [0xf02facb, 666, 1, 0x1043, 0xdeadbeef], lambda v: pack('5L', *v)),
))

_struct_test('fixed list pad', (
    ('lc8p', lambda name: rq.FixedList(name, 2, rq.Card8, pad=1), [0x42, 0xc3],
     lambda v: pack('2B2x', *v)),
    ('lc16p', lambda name: rq.FixedList(name, 3, rq.Card16, pad=1),
     [666, 1, 60143], lambda v: pack('3H2x', *v)),
    ('lc32p', lambda name: rq.FixedList(name, 5, rq.Card32, pad=1),
     [0xf02facb, 666, 1, 0x1043, 0xdeadbeef], lambda v: pack('5L', *v)),
))