aboutsummaryrefslogtreecommitdiffstats
path: root/offset_layout.py
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:35 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:35 -0800
commitf721e3ac031f892af46f255a47d7f54a91317b30 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /offset_layout.py
parentbae1bc39312d5019bd9a5b8d840a529213a69a17 (diff)
downloadexternal_qemu-f721e3ac031f892af46f255a47d7f54a91317b30.zip
external_qemu-f721e3ac031f892af46f255a47d7f54a91317b30.tar.gz
external_qemu-f721e3ac031f892af46f255a47d7f54a91317b30.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'offset_layout.py')
-rwxr-xr-xoffset_layout.py111
1 files changed, 0 insertions, 111 deletions
diff --git a/offset_layout.py b/offset_layout.py
deleted file mode 100755
index 6c2f879..0000000
--- a/offset_layout.py
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/usr/bin/python
-
-import re
-import sys
-import getopt
-
-DX = DY = PX = PY = KX = KY = 0
-
-_RE_LINE = re.compile("^\s*(?P<keyword>[\w-]+)\s+{\s*$")
-_RE_XY = re.compile("^(?P<start>\s*)(?P<xy>[x|y]\s+)(?P<num>\d+)(?P<end>\s*)$")
-
-def main():
- ParseArgs()
- ParseInput()
-
-def Usage():
- print >>sys.stderr, """
- Usage: %s --dx offset-x-display --dy offset-y-display --px offset-x-phone-buttons --py offset-y-phone-buttons --kx offset-x-keyboard --ky offset-y-keyboard < layout > layout2.
-
- Unspecified offsets default to 0 (unchanged).
- Reads from stdin, outputs to stdout.
- Phone buttons: soft-left/top/righ/bottom, home, dpad, dial, power, etc.
- Keyboard is the soft keyboard.
-
- If your shell doesn't let you use negative integers, use _ for minus sign,
- i.e. --dx _40 --dy _42 for <-40,-42).
- """ % (sys.argv[0])
- sys.exit(1)
-
-def ParseArgs():
- global DX, DY, PX, PY, KX, KY
- try:
- options, args = getopt.getopt(sys.argv[1:], "", ["dx=", "dy=", "px=", "py=", "kx=", "ky="])
- for opt, value in options:
- if opt in ["--dx"]:
- DX = int(value.replace("_", "-"))
- elif opt in ["--dy"]:
- DY = int(value.replace("_", "-"))
- elif opt in ["--px"]:
- PX = int(value.replace("_", "-"))
- elif opt in ["--py"]:
- PY = int(value.replace("_", "-"))
- elif opt in ["--kx"]:
- KX = int(value.replace("_", "-"))
- elif opt in ["--ky"]:
- KY = int(value.replace("_", "-"))
- else:
- Usage()
- except getopt.error, msg:
- Usage()
-
-def ParseInput():
- global DX, DY, PX, PY, KX, KY
-
- PHONE = [ "soft-left", "home", "back", "dpad-up", "dpad-down", "dpad-left", "dpad-right", "dpad-center", "phone-dial", "phone-hangup", "power", "volume-up", "volume-down" ]
- KEYBOARD = [ "DEL", "CAP", "CAP2", "PERIOD", "ENTER", "ALT", "SYM", "AT", "SPACE", "SLASH", "COMMA", "ALT2" ]
-
- mode = None
- while True:
- line = sys.stdin.readline()
- if not line:
- return
- m_line = _RE_LINE.match(line)
- if m_line:
- keyword = m_line.group("keyword")
- if keyword in ["display", "button"]:
- mode = keyword
- is_phone = False
- is_keyboard = False
- print >>sys.stderr, "Mode:", mode
- else:
- if mode == "button" and "{" in line:
- is_phone = keyword in PHONE
- is_keyboard = (len(keyword) == 1 and keyword.isalnum())
- if not is_keyboard:
- is_keyboard = keyword in KEYBOARD
- elif "}" in line:
- is_phone = False
- is_keyboard = False
- if mode == "display":
- mode = None
- else:
- m_xy = _RE_XY.match(line)
- if m_xy:
- x = 0
- y = 0
- if mode == "display":
- x = DX
- y = DY
- elif mode == "button" and is_phone:
- x = PX
- y = PY
- elif mode == "button" and is_keyboard:
- x = KX
- y = KY
- if x or y:
- d = m_xy.groupdict()
- n = int(d["num"])
- if d["xy"].startswith("x"):
- n += x
- else:
- n += y
- d["num"] = n
- line = "%(start)s%(xy)s%(num)s%(end)s" % d
- sys.stdout.write(line)
-
-
-
-
-if __name__ == "__main__":
- main()