From 6fc1f31e314ad8c5eaac56179c52c5efb453815b Mon Sep 17 00:00:00 2001 From: doomchild Date: Thu, 3 Mar 2011 14:17:31 -0600 Subject: [PATCH] first commit --- library/python/pydfhack/window_io.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 library/python/pydfhack/window_io.py diff --git a/library/python/pydfhack/window_io.py b/library/python/pydfhack/window_io.py new file mode 100644 index 000000000..8be4ff9c0 --- /dev/null +++ b/library/python/pydfhack/window_io.py @@ -0,0 +1,25 @@ +from ctypes import * + +libdfhack.WindowIO_TypeStr.argtypes = [ c_void_p, c_char_p, c_uint, c_byte ] +libdfhack.WindowIO_TypeSpecial.argtypes = [ c_void_p, c_uint, c_uint, c_uint, c_uint ] + +class WindowIO(object): + def __init__(self, ptr): + self._window_io_ptr = ptr + + def type_str(self, s, delay = 0, use_shift = False): + c_shift = c_byte(0) + c_delay = c_int(delay) + c_s = c_char_p(s) + + if use_shift is True: + c_shift = c_byte(1) + + return libdfhack.WindowIO_TypeStr(self._window_io_ptr, c_s, c_delay, c_shift) > 0 + + def type_special(self, command, count = 1, delay = 0): + c_command = c_uint(command) + c_count = c_uint(count) + c_delay = c_uint(delay) + + return libdfhack.WindwIO_TypeSpecial(self._window_io_ptr, c_command, c_count, c_delay) > 0 \ No newline at end of file