| 48 | # x is the position of the mouse on the x axis |
| 49 | # y is the position of the mouse on the y axis |
| 50 | def getMouseValues(file_input): |
| 51 | |
| 52 | buf = file_input.read(3) |
| 53 | |
| 54 | # if ran with Python 3 |
| 55 | # ord function will throw an exception, since |
| 56 | # buf[0] already is an integer, as opposed in Python 2 |
| 57 | # where buf[0] is a string |
| 58 | try: |
| 59 | button = ord(buf[0]) |
| 60 | except TypeError as msg: |
| 61 | button = buf[0] |
| 62 | if debug is True: |
| 63 | print(str(msg)) |
| 64 | |
| 65 | print(button) |
| 66 | left_button = (button & 0x1) > 0 |
| 67 | middle_button = (button & 0x4) > 0 |
| 68 | right_button = (button & 0x2) > 0 |
| 69 | x_axis, y_axis = struct.unpack("bb", buf[1:]) |
| 70 | |
| 71 | if debug is True: |
| 72 | print("Left but: {}, Middle but: {}, Right but: {}, x pos: {}, y pos: {}".format(left_button, middle_button, right_button, x_axis, y_axis)) |
| 73 | |
| 74 | return (left_button, middle_button, right_button, x_axis, y_axis) |
| 75 | |
| 76 | |
| 77 | def Main(): |