add video capture

This commit is contained in:
Lephenixnoir 2023-04-30 03:24:59 +02:00
parent 12db355f64
commit cdb5b595e2
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 38 additions and 0 deletions

View File

@ -111,9 +111,44 @@ static int text_size(char const *str, int length)
#include <gint/keyboard.h>
#include <gint/display.h>
#include <gint/drivers/r61524.h>
#include <gint/usb.h>
#include <gint/usb-ff-bulk.h>
#include <libprof.h>
#define vram gint_vram
bool videocapture = false;
static void hook_prefrag(int id, void *fragment, int size)
{
if(!videocapture)
return;
if(!usb_is_open()) {
static usb_interface_t const *intf[] = { &usb_ff_bulk, NULL };
usb_open(intf, GINT_CALL_NULL);
usb_open_wait();
}
int pipe = usb_ff_bulk_output();
if(id == 0) {
usb_fxlink_header_t h;
usb_fxlink_image_t sh;
int size = azrp_width * azrp_height * 2;
usb_fxlink_fill_header(&h, "fxlink", "video", size + sizeof sh);
sh.width = htole32(azrp_width);
sh.height = htole32(azrp_height);
sh.pixel_format = htole32(USB_FXLINK_IMAGE_RGB565);
usb_write_sync(pipe, &h, sizeof h, false);
usb_write_sync(pipe, &sh, sizeof sh, false);
}
usb_write_sync(pipe, fragment, size, false);
if(id == azrp_frag_count - 1)
usb_commit_sync(pipe);
}
static int platform_update(struct input *input)
{
key_event_t e;
@ -132,6 +167,8 @@ static int platform_update(struct input *input)
input->roll_left = true;
if(e.key == KEY_F2)
input->roll_right = true;
if(e.key == KEY_F6 && keydown(KEY_VARS))
videocapture = !videocapture;
if(e.key == KEY_EXE && keydown(KEY_VARS))
input->RESET_LEVEL = true;
if(e.key == KEY_MINUS && keydown(KEY_VARS))
@ -171,6 +208,7 @@ static void init(void)
cd_vfx_configure();
azrp_shader_clear_configure();
azrp_shader_image_p8_configure();
azrp_hook_set_prefrag(hook_prefrag);
}
static void quit(void)