Last change
on this file since 57:f52efb9ba3d8 was 54:fb6a875ea5d2, checked in by István Váradi <ivaradi@…>, 12 years ago |
Added support for the hotkey functions in the C++ client and a test program as well
|
File size:
1.4 KB
|
Line | |
---|
1 | # Test program for the Python client library: hotkey handling
|
---|
2 |
|
---|
3 | #------------------------------------------------------------------------------
|
---|
4 |
|
---|
5 | import time
|
---|
6 |
|
---|
7 | #------------------------------------------------------------------------------
|
---|
8 |
|
---|
9 | if __name__ == "__main__":
|
---|
10 | from xplra import XPlane, ProtocolException
|
---|
11 |
|
---|
12 | xplane = XPlane()
|
---|
13 |
|
---|
14 | try:
|
---|
15 | print "Connecting to X-Plane..."
|
---|
16 | xplane.connect()
|
---|
17 | print "Connected to X-Plane."
|
---|
18 | print
|
---|
19 |
|
---|
20 | print "Registering hotkeys: Ctrl+A, Shift+B, Ctrl+Shift+C, Ctrl+Q..."
|
---|
21 | xplane.registerHotkeys([0x0241, 0x0142, 0x0343, 0x0251])
|
---|
22 | print "Registered hotkeys..."
|
---|
23 | print
|
---|
24 |
|
---|
25 | print "Listening to hotkeys..."
|
---|
26 | while True:
|
---|
27 | states = xplane.queryHotkeys()
|
---|
28 | message = ""
|
---|
29 | if states[3]: break
|
---|
30 | if states[0]:
|
---|
31 | if message: message += ", "
|
---|
32 | message += "Ctrl+A"
|
---|
33 | if states[1]:
|
---|
34 | if message: message += ", "
|
---|
35 | message += "Shift+B"
|
---|
36 | if states[2]:
|
---|
37 | if message: message += ", "
|
---|
38 | message += "Ctrl+Shift+C"
|
---|
39 | if message:
|
---|
40 | message += " pressed"
|
---|
41 | xplane.showMessage(message, 3.0)
|
---|
42 |
|
---|
43 | time.sleep(0.5)
|
---|
44 |
|
---|
45 | except Exception as e:
|
---|
46 | print ">>>>>>>>>>>>>>>>>>>>>> Exception caught:", str(e)
|
---|
47 | finally:
|
---|
48 | xplane.unregisterHotkeys()
|
---|
49 | xplane.disconnect()
|
---|
Note:
See
TracBrowser
for help on using the repository browser.