1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
# -*- coding: utf-8 -*-
# fakemaps.py
# invent fake keyboard maps for testing
# Copyright (c) 2005 by Matthias Urlichs <smurf@smurf.noris.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License as
# published by the Free Software Foundation. See the file COPYING.txt
# or (on Debian systems) /usr/share/common-licenses/GPL-2 for details.
"""\
This module exports 'maps()', which is a function that returns a list of
keyboard maps with various interesting features.
Among the tested variants are:
- addditional key, key missing
- swapped keys
- relabeled keys
- totally different keys
- totally different keycodes
"""
import sys
from keymapper.keymap import Keymap, STD, SHIFT, ALT
if sys.version_info[0] >= 3:
text_type = str
else:
text_type = unicode
def gen_map(name, *keys):
"""synthesize a Keymap"""
map = Keymap(name)
for sym, code, mod in keys:
map.add(text_type(sym), code, mod)
return map
def maps():
"""return a list of nicely incompatible keyboards"""
yield gen_map(
"std",
("A", 1, STD),
("B", 2, STD),
("C", 3, STD),
("D", 4, STD),
("E", 5, STD),
)
# Swap two keys
yield gen_map(
"swapped",
("B", 1, STD),
("A", 2, STD),
("C", 3, STD),
("D", 4, STD),
("E", 5, STD),
)
# Remove a key
yield gen_map(
"removed", (u"α", 1, STD), ("B", 2, STD), ("C", 3, STD), ("D", 4, STD)
)
# Duplicate a key
yield gen_map(
"duped", ("A", 1, STD), ("B", 2, STD), ("C", 3, STD), ("A", 4, STD)
)
# Add a new key
yield gen_map(
"add_new",
("A", 1, STD),
("B", 2, STD),
("C", 3, STD),
("D", 4, STD),
("E", 5, STD),
("G", 11, STD),
)
# Add a key we know from somewhere
yield gen_map(
"add_known",
("A", 1, STD),
("B", 2, STD),
("C", 3, STD),
("D", 4, STD),
("E", 5, STD),
("F", 7, STD),
)
# Relabel a key
yield gen_map(
"relabel",
("A", 1, STD),
("B", 2, STD),
("C", 3, STD),
("D", 4, STD),
("F", 5, STD),
)
# Totally different keys
yield gen_map(
"diff_keys",
("aa", 1, STD),
("bb", 2, STD),
("cc", 3, STD),
("dd", 4, STD),
("ee", 5, STD),
)
# Totally different codes
yield gen_map(
"diff_codes",
("A", 6, STD),
("B", 7, STD),
("C", 8, STD),
("D", 9, STD),
("F", 10, STD),
)
# Small keyboard ;-)
yield gen_map(
"small",
("A", 1, STD),
("B", 1, SHIFT),
("C", 1, ALT),
("D", 2, STD),
("E", 2, ALT),
)
|