2 * Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
30 #include <sys/types.h>
38 fb_render_func_t fb_render_cb;
41 kbd_event_func_t kbd_event_cb;
45 ptr_event_func_t ptr_event_cb;
51 console_init(int w, int h, void *fbaddr)
53 console.gc = bhyvegc_init(w, h, fbaddr);
57 console_set_fbaddr(void *fbaddr)
59 bhyvegc_set_fbaddr(console.gc, fbaddr);
62 struct bhyvegc_image *
63 console_get_image(void)
65 struct bhyvegc_image *bhyvegc_image;
67 bhyvegc_image = bhyvegc_get_image(console.gc);
69 return (bhyvegc_image);
73 console_fb_register(fb_render_func_t render_cb, void *arg)
75 console.fb_render_cb = render_cb;
82 if (console.fb_render_cb)
83 (*console.fb_render_cb)(console.gc, console.fb_arg);
87 console_kbd_register(kbd_event_func_t event_cb, void *arg, int pri)
89 if (pri > console.kbd_priority) {
90 console.kbd_event_cb = event_cb;
91 console.kbd_arg = arg;
92 console.kbd_priority = pri;
97 console_ptr_register(ptr_event_func_t event_cb, void *arg, int pri)
99 if (pri > console.ptr_priority) {
100 console.ptr_event_cb = event_cb;
101 console.ptr_arg = arg;
102 console.ptr_priority = pri;
107 console_key_event(int down, uint32_t keysym)
109 if (console.kbd_event_cb)
110 (*console.kbd_event_cb)(down, keysym, console.kbd_arg);
114 console_ptr_event(uint8_t button, int x, int y)
116 if (console.ptr_event_cb)
117 (*console.ptr_event_cb)(button, x, y, console.ptr_arg);