| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  | import base | 
					
						
							| 
									
										
										
										
											2023-11-02 19:17:25 +00:00
										 |  |  | from base import log | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  | from pynput import mouse | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MouseEvents(): | 
					
						
							|  |  |  |     def __init__(self): | 
					
						
							|  |  |  |         listener = mouse.Listener( | 
					
						
							|  |  |  |             on_move=on_move, | 
					
						
							|  |  |  |             on_click=on_click, | 
					
						
							|  |  |  |             on_scroll=on_scroll) | 
					
						
							|  |  |  |         listener.start() | 
					
						
							| 
									
										
										
										
											2023-10-30 19:43:35 +00:00
										 |  |  |          | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  | # MOUSE EVENTS/LISTENER     | 
					
						
							|  |  |  | def on_move(x, y): | 
					
						
							|  |  |  |     if base.data["move"]: | 
					
						
							| 
									
										
										
										
											2023-10-30 19:43:35 +00:00
										 |  |  |          | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  |         if base.data["mouse_distance_x"] == 0: | 
					
						
							|  |  |  |             base.data["mouse_distance_x"] = base.sights.get(base.data["active_sight"]).pos().x()-x | 
					
						
							|  |  |  |         if base.data["mouse_distance_y"] == 0: | 
					
						
							|  |  |  |             base.data["mouse_distance_y"] = base.sights.get(base.data["active_sight"]).pos().y()-y | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |         x_point = x+base.data["mouse_distance_x"] | 
					
						
							|  |  |  |         y_point = y+base.data["mouse_distance_y"] | 
					
						
							| 
									
										
										
										
											2023-11-02 19:17:25 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         log.byCode("MES1000E",str(x_point) + " x " + str(y_point)) | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  |         base.sights.get(base.data["active_sight"]).move(x_point, y_point) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def on_click(x, y, button, pressed): | 
					
						
							|  |  |  |     if pressed: | 
					
						
							| 
									
										
										
										
											2023-11-02 19:17:25 +00:00
										 |  |  |         log.byCode("MES1001E", base.data["active_sight"]) | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  |     else: | 
					
						
							| 
									
										
										
										
											2023-11-02 19:17:25 +00:00
										 |  |  |         log.byCode("MES1002E", base.data["active_sight"]) | 
					
						
							| 
									
										
										
										
											2023-05-17 10:16:15 +00:00
										 |  |  |         base.data["mouse_distance_x"] = 0 | 
					
						
							|  |  |  |         base.data["mouse_distance_y"] = 0 | 
					
						
							|  |  |  |         base.data["move"] = False | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def on_scroll(x, y, dx, dy): | 
					
						
							| 
									
										
										
										
											2023-11-02 19:17:25 +00:00
										 |  |  |     if dy < 0: | 
					
						
							|  |  |  |         log.byCode("MES1003E", 'Scrolled {0} at {1}'.format('down',(x, y))) | 
					
						
							|  |  |  |     else: | 
					
						
							|  |  |  |         log.byCode("MES1004E", 'Scrolled {0} at {1}'.format('up',(x, y))) |