all hw modules now controllable via single generic ctl function.
dcpu16_interrupt(hw->vm, keyboard->interrupt_message);
}
}
-
-void keyboard_vnc_associate(struct dcpu16_hw *hw, rfbScreenInfoPtr rfbScreen) {
- rfbScreen->screenData = hw;
- rfbScreen->kbdAddEvent = keyboard_rfbevent_;
-}
#endif /* HAVE_LIBVNCSERVER */
static
#ifdef HAVE_LIBVNCSERVER
/* create and return a new screen, easiest to do here because we know the screen dimensions */
-rfbScreenInfoPtr lem1802_rfb_new(int argc, char *argv[]) {
+static
+rfbScreenInfoPtr lem1802_rfb_new_(int argc, char *argv[]) {
rfbScreenInfoPtr s;
int paddedWidth = PIX_X + ( (PIX_X & 3) ? (4 - (PIX_X & 3)) : 0 );
int height = PIX_Y;
{ NULL, NULL, NULL }
};
-
-char *lem1802_renderers_iter(void **iterp, char **name, char **args) {
+static
+char *lem1802_renderers_iter_(void **iterp, char **name, char **args) {
struct renderer_ **r = (struct renderer_ **)iterp;
if (*r == NULL)
return (*r)->name;
}
+static
int lem1802_data_init_(struct dcpu16_hw *hw, void *data) {
(void)data;
return 0;
}
+static
void lem1802_data_free_(struct dcpu16_hw *hw) {
if (hw) {
if (hw->data) {
}
static struct dcpu16_hw_ctl_cmd ctl_[] = {
- { "blink_rate", "const unsigned int *rate", "unsigned int *rate", "sets or gets cycles per blink toggle" },
- { "refresh_rate", "const unsigned int *rate", "unsigned int *rate", "sets or gets cycles per screen refresh" },
+ { "blink_rate", "const unsigned int *", "unsigned int *", "sets or gets cycles per blink toggle" },
+ { "refresh_rate", "const unsigned int *", "unsigned int *", "sets or gets cycles per screen refresh" },
#ifdef HAVE_LIBVNCSERVER
+ { "new_rfbScreen", "struct { int argc; char **argv;} *", "rfbScreenInfoPtr *", "allocates a new rfb screen" },
{ "associate_rfbScreen", "rfbScreenInfoPtr", "NULL", "associates this lem1802 instance with an rfb display" },
#endif /* HAVE_LIBVNCSERVER */
+ { "renderers_iter", "void **", "struct {char *name; char *args;} *", "returns the next renderer this module is capable of using" },
{ "renderer", "const char *", "NULL", "sets this lem1802 instance to use renderer" },
{ "renderer_data", "void *", "NULL", "sets renderer-specific data" },
{ NULL, NULL, NULL, NULL }
};
+
+static
int lem1802_data_ctl_(struct dcpu16_hw *hw, const char *cmd, void *data_in, void *data_out) {
if (strcmp(cmd, "blink_rate") == 0) {
struct lem1802_ *display = (struct lem1802_ *)hw->data;
}
#ifdef HAVE_LIBVNCSERVER
+ if (strcmp(cmd, "new_rfbScreen") == 0) {
+ struct args_ { int argc; char **argv;} *in = (struct args_ *)data_in;
+ rfbScreenInfoPtr *s_out = (rfbScreenInfoPtr *)data_out;
+
+ if (in == NULL || s_out == NULL)
+ return -EFAULT;
+
+ *s_out = lem1802_rfb_new_(in->argc, in->argv);
+
+ return 0;
+ }
+
if (strcmp(cmd, "associate_rfbScreen") == 0) {
struct lem1802_ *display = (struct lem1802_ *)hw->data;
- rfbScreenInfoPtr rfbScreen = (rfbScreenInfoPtr)data_out;
- (void)data_in;
+ rfbScreenInfoPtr rfbScreen = (rfbScreenInfoPtr)data_in;
+ (void)data_out;
if (rfbScreen == NULL)
return -EFAULT;
}
#endif /* HAVE_LIBVNCSERVER */
+ if (strcmp(cmd, "renderers_iter") == 0) {
+ void **iterp = (void **)data_in;
+ struct packed_out_ {
+ char *name;
+ char *args;
+ } *parg = (struct packed_out_ *)data_out;
+
+ if (iterp == NULL || parg == NULL)
+ return -EFAULT;
+
+ (void)lem1802_renderers_iter_(iterp, &parg->name, &parg->args);
+
+ return 0;
+ }
+
if (strcmp(cmd, "renderer") == 0) {
struct lem1802_ *display = (struct lem1802_ *)hw->data;
char *renderer = (char *)data_in;
#ifndef LEM1802_H_WH5E5NOE
#define LEM1802_H_WH5E5NOE
-#ifdef HAVE_LIBVNCSERVER
-#include "rfb/rfb.h"
-#endif /* HAVE_LIBVNCSERVER */
-
#include "dcpu16.h"
extern struct dcpu16_hw_module dcpu16_hw_module_lem1802;
-char *lem1802_renderers_iter(void **, char **, char **);
-
-#ifdef HAVE_LIBVNCSERVER
-rfbScreenInfoPtr lem1802_rfb_new(int argc, char *argv[]);
-#endif /* HAVE_LIBVNCSERVER */
-
#endif /* LEM1802_H_WH5E5NOE */
#ifdef HAVE_LIBVNCSERVER
static struct dynamic_array rfbScreens_;
-/* wups, kbdAddEvent isn't null by default, so I guess track things externally */
+/* wups, kbdAddEvent isn't null by default, so I guess track associations externally */
struct rfb_instance_ {
rfbScreenInfoPtr screen;
struct dcpu16_hw *attached_display;
struct rfb_instance_ *rfbScreen_next_available_display_(struct dynamic_array *rfbScreens, int argc, char *argv[]) {
size_t i;
struct rfb_instance_ new_instance, *s;
+ struct packed_args_ {
+ int argc;
+ char **argv;
+ } parg = { argc, argv };
fprintf(stderr, "DEBUG: rfbScreens->entries:%zu\n", rfbScreens->entries);
return s;
}
- new_instance.screen = lem1802_rfb_new(argc, argv);
+ if (dcpu16_hw_module_lem1802.ctl(NULL, "new_rfbScreen", &parg, &new_instance.screen)) {
+ fprintf(stderr, "failed to allocate new rfbScreen");
+ return NULL;
+ }
+
new_instance.attached_display = NULL;
new_instance.attached_keyboard = NULL;
s = dynarray_add(rfbScreens, &new_instance);
struct rfb_instance_ *rfbScreen_next_available_keyboard_(struct dynamic_array *rfbScreens, int argc, char *argv[]) {
size_t i;
struct rfb_instance_ new_instance, *s;
+ struct packed_args_ {
+ int argc;
+ char **argv;
+ } parg = { argc, argv };
for (i = 0; i < rfbScreens->entries; i++) {
s = (struct rfb_instance_ *)DYNARRAY_ITEM(*rfbScreens, i);
return s;
}
- new_instance.screen = lem1802_rfb_new(argc, argv);
+ if (dcpu16_hw_module_lem1802.ctl(NULL, "new_rfbScreen", &parg, &new_instance.screen)) {
+ fprintf(stderr, "failed to allocate new rfbScreen");
+ return NULL;
+ }
+
new_instance.attached_display = NULL;
new_instance.attached_keyboard = NULL;
s = dynarray_add(rfbScreens, &new_instance);
struct renderer_ {
char *name;
char *args;
- int (*renderer)(void *, void *, size_t, size_t);
- } *r;
- char *name, *args;
+ } renderer;
void *iter;
fprintf(f, "\tdisplay renderer [renderer data]\n");
fprintf(f, "Supported renderers:\n");
- if (dcpu16_hw_module_lem1802.ctl(NULL, "get_renderers", NULL, &r)) {
- fprintf(stderr, "error fetching list of renderers\n");
- return;
- }
-
- while (r->name) {
- fprintf(f, "name:%s args:%s\n", r->name, r->args);
- }
-
iter = NULL;
- while ( (lem1802_renderers_iter(&iter, &name, &args)) ) {
- fprintf(f, "\t%s %s\n", name, args);
- }
+ do {
+ if (dcpu16_hw_module_lem1802.ctl(NULL, "renderers_iter", &iter, &renderer)) {
+ fprintf(stderr, "error fetching next renderer\n");
+ break;
+ }
+ if (iter == NULL || renderer.name == NULL)
+ break;
+
+ fprintf(f, "\t%s %s\n", renderer.name, renderer.args);
+ } while (iter);
}
COMMAND_IMPL(keyboard) {