3 initemu, regkeyfn, flushmouse, flushscreen, flushaudio, screenwipe \- graphical emulator-like software scaffolding
13 void flushmouse(int discard);
16 void flushscreen(void);
19 void flushaudio(int (*fn)(void));
22 void regkeyfn(Rune r, void (*fn)(void));
25 void regkey(char *joyk, Rune r, int k);
28 void initemu(int dx, int dy, int bpp, ulong chan,
30 int dokey, void(*kproc)(void*));
33 implements common user interfaces for programs controlled
34 with a joypad or a limited number of keys.
37 initializes the display for the given internal screen size
47 pixel format descriptor to be used for an internal framebuffer (see
53 a keyboard process is started which sets a 64-bit wide bit vector for input keys.
57 Pressing the key corresponding to the
64 with the key bit vector.
67 registers an additional rune and a callback for the keyboard process.
69 Normally, a joypad process is also started, and parses standard input for key presses.
72 is false, only the joypad process will be started.
75 is a valid function pointer,
76 it will be used for keyboard processing instead of the library-provided one,
77 and no joypad process will be started.
87 is called, a framebuffer of the specifized size is allocated,
88 and may be accessed via
91 scales the framebuffer to fit the greatest multiple of the framebuffer's
93 The scaling is horizontal only and needs to be taken into account for drawing
96 Typically, mouse event handling is followed by drawing the final image from the
97 internal framebuffer render and writing a constant amount of audio samples,
98 thereby synchronizing the program's framerate to the audio writes.
106 while(nbrecv(mc->c, &m) > 0){
110 flushaudio(audioout);
113 Besides window resizing, mouse events are discarded by default.
118 will let the user program handle mouse events prior to flushing the screen (see
122 handles re-scaling and re-allocating the buffers used, as well as drawing to
123 the screen, either directly, or by duplicating pre-scaled scanlines.
132 input selection are confusing.
134 A greater effort should be made to simplify automatic scaling for user programs.
137 first appeared in 9front in May, 2018.