def start(port=23, verbose=0, splash=True): global ps2socket global verbose_l global client_list global client_busy global ps2port ps2port = ps2.ps2(clk=26, data=25, qbit_us=16, byte_us=150, f0_us=50000) alloc_emergency_exception_buf(100) verbose_l = verbose client_list = [] client_busy = False ps2socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ps2socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) ps2socket.bind(('0.0.0.0', port)) ps2socket.listen(0) ps2socket.setsockopt(socket.SOL_SOCKET, _SO_REGISTER_HANDLER, accept_ps2_connect)
_SO_REGISTER_HANDLER = const(20) _COMMAND_TIMEOUT = const(300) # Global variables ps2socket = None client_list = [] verbose_l = 0 client_busy = False ps2port = ps2.ps2( # v3.0.x kbd_clk=26, # gp[11] kbd_data=25, # gn[11] mouse_clk=26, # mouse_data=25, # # v3.1.4 #kbd_clk = 22, # wifi_gpio22 #kbd_data = 21, # wifi_gpio21 #mouse_clk = 22, # wifi_gpio27 #mouse_data = 21, # wifi_gpio26 qbit_us=16, byte_us=150, f0delay_us=50000) # ASCII to PS/2 SET2 scancode conversion table # from http://www.vetra.com/scancodes.html asc2scan = { '`': bytearray(b'\x0E\xF0\x0E'), '~': bytearray(b'\x12\x0E\xF0\x0E\xF0\x12'), '1': bytearray(b'\x16\xF0\x16'), '!': bytearray(b'\x12\x16\xF0\x16\xF0\x12'), '2': bytearray(b'\x1E\xF0\x1E'),
from ps2 import ps2 if __name__ == '__main__': ps2()
# LICENSE=BSD # telnet to ESP32 and type # keystrokes should be converted to PS/2 signals import socket import network import uos from gc import collect from time import sleep_us, localtime from micropython import alloc_emergency_exception_buf from micropython import const from uctypes import addressof import ps2 ps2port = ps2.ps2(kbd_clk=26, kbd_data=25, qbit_us=16, byte_us=150) # constant definitions _SO_REGISTER_HANDLER = const(20) _COMMAND_TIMEOUT = const(300) # Global variables ps2socket = None client_list = [] verbose_l = 0 client_busy = False # ASCII to PS/2 SET2 scancode conversion table # from http://www.vetra.com/scancodes.html asc2scan = { '`': bytearray(b'\x0E\xF0\x0E'),
import uos import gc from time import sleep_us from struct import unpack from micropython import alloc_emergency_exception_buf from micropython import const from uctypes import addressof import ps2 ps2port = ps2.ps2( # v3.0.x #kbd_clk = 26, # gp[11] #kbd_data = 25, # gn[11] #mouse_clk = 17, # wifi_gpio17 #mouse_data = 16, # wifi_gpio16 # v3.1.4 kbd_clk=22, # wifi_gpio22 kbd_data=21, # wifi_gpio21 mouse_clk=22, # wifi_gpio27 mouse_data=21, # wifi_gpio26 qbit_us=16, byte_us=150) # constant definitions _SO_REGISTER_HANDLER = const(20) _COMMAND_TIMEOUT = const(300) # Global variables ps2socket = None client_list = [] verbose_l = 0
import socket import network import uos from gc import collect from time import sleep_us from struct import unpack from micropython import alloc_emergency_exception_buf from micropython import const from uctypes import addressof import ps2 ps2port=ps2.ps2( kbd_clk = 26, # gp[11] kbd_data = 25, # gn[11] mouse_clk = 17, # wifi_gpio17 mouse_data = 16, # wifi_gpio16 qbit_us=16, byte_us=150 ) # constant definitions _SO_REGISTER_HANDLER = const(20) _COMMAND_TIMEOUT = const(300) # Global variables ps2socket = None client_list = [] verbose_l = 0 client_busy = False mouse = 0 # global tracker: 0 keyboard, 1 mouse
# LICENSE=BSD # PS/2 receiver converts from TCP to PS/2 # use linux_keyboard.py or pygame_mouse.py on host side # edit ps2port (see below) import socket import network import uos import gc from time import sleep_ms, localtime from micropython import alloc_emergency_exception_buf import ps2 # keyboard ps2port = ps2.ps2(qbit_us=16, byte_us=150, f0_us=50000, n=0) # 3-byte mouse (PS/2 legacy, no wheel) #ps2port=ps2.ps2(qbit_us=16,byte_us=150,f0_us=0,n=3,n_us=1000) # 4-byte mouse (PS/2 with wheel) #ps2port=ps2.ps2(qbit_us=16,byte_us=150,f0_us=0,n=4,n_us=1000) # constant definitions _SO_REGISTER_HANDLER = const(20) _COMMAND_TIMEOUT = const(300) # Global variables ps2socket = None client_list = [] verbose_l = 0