mirror of
				https://github.com/node-red/node-red-nodes.git
				synced 2025-03-01 10:37:43 +00:00 
			
		
		
		
	Fix Pi keyboard an mouse events
This commit is contained in:
		| @@ -171,24 +171,19 @@ if len(sys.argv) > 2: | ||||
|                 data = 0 | ||||
|  | ||||
|     elif cmd == "mouse":  # catch mice button events | ||||
|         file = open( "/dev/input/mice", "rb" ) | ||||
|         f = open( "/dev/input/mice", "rb" ) | ||||
|         oldbutt = 0 | ||||
|  | ||||
|         def getMouseEvent(): | ||||
|           global oldbutt | ||||
|           global pin | ||||
|           buf = file.read(3) | ||||
|           pin = pin & 0x07 | ||||
|           button = ord( buf[0] ) & pin # mask out just the required button(s) | ||||
|           if button != oldbutt:  # only send if changed | ||||
|               oldbutt = button | ||||
|               print(button) | ||||
|  | ||||
|         while True: | ||||
|             try: | ||||
|                 getMouseEvent() | ||||
|                 buf = f.read(3) | ||||
|                 pin = pin & 0x07 | ||||
|                 button = struct.unpack('3b',buf)[0] & pin # mask out just the required button(s) | ||||
|                 if button != oldbutt:  # only send if changed | ||||
|                     oldbutt = button | ||||
|                     print(button) | ||||
|             except: | ||||
|                 file.close() | ||||
|                 f.close() | ||||
|                 sys.exit(0) | ||||
|  | ||||
|     elif cmd == "kbd":  # catch keyboard button events | ||||
| @@ -196,7 +191,7 @@ if len(sys.argv) > 2: | ||||
|             while not os.path.isdir("/dev/input/by-path"): | ||||
|                 sleep(10) | ||||
|             infile = subprocess.check_output("ls /dev/input/by-path/ | grep -m 1 'kbd'", shell=True).strip() | ||||
|             infile_path = "/dev/input/by-path/" + infile | ||||
|             infile_path = "/dev/input/by-path/" + infile.decode("utf-8") | ||||
|             EVENT_SIZE = struct.calcsize('llHHI') | ||||
|             file = open(infile_path, "rb") | ||||
|             event = file.read(EVENT_SIZE) | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "node-red-node-pi-gpio", | ||||
|   "version": "2.0.0", | ||||
|   "version": "2.0.1", | ||||
|   "description": "The basic Node-RED node for Pi GPIO", | ||||
|   "dependencies"  : { | ||||
|   }, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user