def main(): import signal import sys def SIGINT_handler(*_, **__): print('\nA SIGINT (CTRL-C) signal is detected') foohid.destroy("FooHID simple u2f", u2fCallback) sys.exit(0) t.stop() signal.signal(signal.SIGINT, SIGINT_handler) t = StoppableThread(u2fWorker) t.daemon = True t.start() print("t.start") try: foohid.destroy("FooHID simple u2f") except: pass foohid.create( "FooHID simple u2f", struct.pack('{0}B'.format(len(report_descriptor)), *report_descriptor), "SN 123", 2, 3) foohid.subscribe("FooHID simple u2f", u2fCallback) from CoreFoundation import CFRunLoopRun runner = CFRunLoopRun()
import foohid import struct import random import time joypad = (0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00, 0x25, 0x01, 0x95, 0x10, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x09, 0x32, 0x09, 0x33, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 0x95, 0x04, 0x81, 0x02, 0xc0, 0xc0) try: foohid.destroy("FooHID simple joypad") except: pass foohid.create("FooHID simple joypad", struct.pack('{0}B'.format(len(joypad)), *joypad), "SN 123", 2, 3) try: while True: x = random.randrange(0, 255) y = random.randrange(0, 255) z = random.randrange(0, 255) rx = random.randrange(0, 255) foohid.send("FooHID simple joypad", struct.pack('H4B', 0, x, y, z, rx)) time.sleep(1) except KeyboardInterrupt: foohid.destroy("FooHID simple joypad")
import foohid for i in range(1, 10): foohid.create("FooHID {0}".format(i), "xxx") print(foohid.list()) for i in range(1, 10): foohid.destroy("FooHID {0}".format(i))
def SIGINT_handler(*_, **__): print('\nA SIGINT (CTRL-C) signal is detected') foohid.destroy("FooHID simple u2f", u2fCallback) sys.exit(0) t.stop()
import foohid import struct import time keyboard = (0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0, 0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81, 0x02, 0x95, 0x01, 0x75, 0x08, 0x81, 0x01, 0x95, 0x05, 0x75, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x05, 0x91, 0x02, 0x95, 0x01, 0x75, 0x03, 0x91, 0x01, 0x95, 0x06, 0x75, 0x08, 0x15, 0x00, 0x25, 0x65, 0x05, 0x07, 0x19, 0x00, 0x29, 0x65, 0x81, 0x00, 0x09, 0x00, 0x75, 0x08, 0x95, 0x01, 0x15, 0x00, 0x25, 0x7f, 0xb1, 0x02, 0xc0) try: foohid.destroy("FooHID simple keyboard") except: pass foohid.create("FooHID simple keyboard", struct.pack('{0}B'.format(len(keyboard)), *keyboard), "SN 123", 2, 3) try: while True: # press "a" key foohid.send("FooHID simple keyboard", struct.pack('8B', 0, 0, 4, 0, 0, 0, 0, 0)) time.sleep(0.1) foohid.send("FooHID simple keyboard", struct.pack('8B', 0, 0, 0, 0, 0, 0, 0, 0)) time.sleep(0.5) except KeyboardInterrupt:
import foohid import struct import random import time mouse = (0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x03, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, 0xc0, 0xc0) try: foohid.destroy("FooHID simple mouse") except: pass foohid.create("FooHID simple mouse", struct.pack('{0}B'.format(len(mouse)), *mouse), "SN 123", 2, 3) try: while True: x = random.randrange(0, 255) y = random.randrange(0, 255) foohid.send("FooHID simple mouse", struct.pack('3B', 0, x, y)) time.sleep(1) except KeyboardInterrupt: foohid.destroy("FooHID simple mouse")