40 lines
		
	
	
		
			639 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			40 lines
		
	
	
		
			639 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								package input
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import (
							 | 
						||
| 
								 | 
							
									"log"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									"zworld/plugins/system/input/keys"
							 | 
						||
| 
								 | 
							
									"zworld/plugins/system/input/mouse"
							 | 
						||
| 
								 | 
							
								)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								type nopHandler struct{}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func (h *nopHandler) KeyEvent(e keys.Event)    {}
							 | 
						||
| 
								 | 
							
								func (h *nopHandler) MouseEvent(e mouse.Event) {}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func NopHandler() Handler {
							 | 
						||
| 
								 | 
							
									return &nopHandler{}
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								type debugger struct {
							 | 
						||
| 
								 | 
							
									Handler
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func DebugMiddleware(next Handler) Handler {
							 | 
						||
| 
								 | 
							
									return &debugger{next}
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func (d debugger) KeyEvent(e keys.Event) {
							 | 
						||
| 
								 | 
							
									log.Printf("%+v\n", e)
							 | 
						||
| 
								 | 
							
									if d.Handler != nil {
							 | 
						||
| 
								 | 
							
										d.Handler.KeyEvent(e)
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func (d debugger) MouseEvent(e mouse.Event) {
							 | 
						||
| 
								 | 
							
									log.Printf("%+v\n", e)
							 | 
						||
| 
								 | 
							
									if d.Handler != nil {
							 | 
						||
| 
								 | 
							
										d.Handler.MouseEvent(e)
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								}
							 |