displaydev.psdisplay
displaydev.psdisplay
- class displaydev.psdisplay.PSDevices(id, display=None)[source]
Bases:
WebInputUnified input for a PyScript canvas, registered as an appdev HOST device.
Captures all available browser input on a single HTML element and turns it into
eventsobjects (matching the desktop SDL2 / PyGame event stream), drained throughread:Pointer (mouse via Pointer Events):
MOUSEMOTION/MOUSEBUTTONDOWN/MOUSEBUTTONUP.Touch / pen (Pointer Events with
pointerTypeother thanmouse):FINGERDOWN/FINGERUP/FINGERMOTIONwithpointerIdasfinger_id, so LVGL gesture recognizers see multipoint contacts (same contract as SDL/pygame fingers). A finger move also givesMOUSEMOTIONwithtouch=True, and a finger down or up aButtonwithtouch=True, so drag code written for the mouse works.Wheel:
MOUSEWHEEL(also consumed by encoder devices).Keyboard:
KEYDOWN/KEYUPwith SDL-style key codes, names and modifier masks (left/right modifier variants via key location).Gamepad (Gamepad API, polled on each
read):JOYAXISMOTION,JOYBUTTONDOWN/JOYBUTTONUP.
Quit chord handling is configured on
PSDisplayviaquit_chord(default(keys.K_AC_BACK, 0)for browser/TV Back).HostEventsapplies the chord when constructed withdisplay=.Note
The element must be focused to receive key events. The constructor sets
tabindexand calls_focus_canvasso keyboard input goes to the game; pointer down on the canvas refocuses it.- Parameters:
- class displaydev.psdisplay.PSDisplay(id, width=None, height=None, *, quiet=False)[source]
Bases:
CanvasDisplayEmulate a display on a PyScript HTML canvas.
- Parameters:
- property touch_scale
CSS layout pixels per framebuffer pixel, read live.
HostEventsDevicedivides mouse coordinates by this, the same contract asSDLDisplay’s window scale. It is the inverse of_pointer_scale, and it is read at each event because the page can resize the canvas (amax-widthrule, a window resize) afterinithas run.