2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
32 #include <sys/types.h>
40 fb_render_func_t fb_render_cb;
43 kbd_event_func_t kbd_event_cb;
47 ptr_event_func_t ptr_event_cb;
53 console_init(int w, int h, void *fbaddr)
55 console.gc = bhyvegc_init(w, h, fbaddr);
59 console_set_fbaddr(void *fbaddr)
61 bhyvegc_set_fbaddr(console.gc, fbaddr);
64 struct bhyvegc_image *
65 console_get_image(void)
67 struct bhyvegc_image *bhyvegc_image;
69 bhyvegc_image = bhyvegc_get_image(console.gc);
71 return (bhyvegc_image);
75 console_fb_register(fb_render_func_t render_cb, void *arg)
77 console.fb_render_cb = render_cb;
84 if (console.fb_render_cb)
85 (*console.fb_render_cb)(console.gc, console.fb_arg);
89 console_kbd_register(kbd_event_func_t event_cb, void *arg, int pri)
91 if (pri > console.kbd_priority) {
92 console.kbd_event_cb = event_cb;
93 console.kbd_arg = arg;
94 console.kbd_priority = pri;
99 console_ptr_register(ptr_event_func_t event_cb, void *arg, int pri)
101 if (pri > console.ptr_priority) {
102 console.ptr_event_cb = event_cb;
103 console.ptr_arg = arg;
104 console.ptr_priority = pri;
109 console_key_event(int down, uint32_t keysym)
111 if (console.kbd_event_cb)
112 (*console.kbd_event_cb)(down, keysym, console.kbd_arg);
116 console_ptr_event(uint8_t button, int x, int y)
118 if (console.ptr_event_cb)
119 (*console.ptr_event_cb)(button, x, y, console.ptr_arg);