2024-05-15 15:44:45 -04:00
|
|
|
#include "vanilla.h"
|
|
|
|
|
|
|
|
#include <signal.h>
|
2024-06-13 21:43:58 -04:00
|
|
|
#include <string.h>
|
2024-05-15 15:44:45 -04:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2024-06-19 14:58:02 -04:00
|
|
|
#include "gamepad/command.h"
|
2024-05-18 15:55:00 -04:00
|
|
|
#include "gamepad/gamepad.h"
|
2024-05-20 19:17:24 -04:00
|
|
|
#include "gamepad/input.h"
|
2024-06-13 21:43:58 -04:00
|
|
|
#include "gamepad/video.h"
|
2024-05-15 15:44:45 -04:00
|
|
|
#include "status.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "vanilla.h"
|
|
|
|
|
2024-08-05 03:38:26 -04:00
|
|
|
int vanilla_start(vanilla_event_handler_t event_handler, void *context)
|
2024-05-15 15:44:45 -04:00
|
|
|
{
|
2024-08-06 06:11:25 -04:00
|
|
|
return connect_as_gamepad_internal(event_handler, context, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int vanilla_start_udp(vanilla_event_handler_t event_handler, void *context, uint32_t server_address)
|
|
|
|
{
|
|
|
|
return connect_as_gamepad_internal(event_handler, context, server_address);
|
2024-05-15 15:44:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void vanilla_stop()
|
|
|
|
{
|
|
|
|
force_interrupt();
|
|
|
|
}
|
|
|
|
|
2024-06-13 21:38:24 -04:00
|
|
|
void vanilla_set_button(int button, int32_t value)
|
2024-05-15 15:44:45 -04:00
|
|
|
{
|
2024-05-20 23:25:55 -04:00
|
|
|
set_button_state(button, value);
|
2024-05-15 15:44:45 -04:00
|
|
|
}
|
2024-05-20 19:17:24 -04:00
|
|
|
|
|
|
|
void vanilla_set_touch(int x, int y)
|
|
|
|
{
|
|
|
|
set_touch_state(x, y);
|
2024-05-24 11:37:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void default_logger(const char *format, va_list args)
|
|
|
|
{
|
|
|
|
vprintf(format, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
void (*custom_logger)(const char *, va_list) = default_logger;
|
|
|
|
void vanilla_log(const char *format, ...)
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
va_start(va, format);
|
|
|
|
|
|
|
|
if (custom_logger) {
|
|
|
|
custom_logger(format, va);
|
2024-05-29 03:09:17 -04:00
|
|
|
custom_logger("\n", va);
|
2024-05-24 11:37:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vanilla_log_no_newline(const char *format, ...)
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
va_start(va, format);
|
|
|
|
|
2024-05-24 13:04:08 -04:00
|
|
|
vanilla_log_no_newline_va(format, va);
|
2024-05-24 11:37:54 -04:00
|
|
|
|
|
|
|
va_end(va);
|
|
|
|
}
|
|
|
|
|
2024-05-24 13:04:08 -04:00
|
|
|
void vanilla_log_no_newline_va(const char *format, va_list args)
|
|
|
|
{
|
|
|
|
if (custom_logger) {
|
|
|
|
custom_logger(format, args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-24 11:37:54 -04:00
|
|
|
void vanilla_install_logger(void (*logger)(const char *, va_list))
|
|
|
|
{
|
|
|
|
custom_logger = logger;
|
2024-06-13 21:43:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void vanilla_request_idr()
|
|
|
|
{
|
|
|
|
request_idr();
|
|
|
|
}
|
|
|
|
|
|
|
|
void vanilla_retrieve_sps_pps_data(void *data, size_t *size)
|
|
|
|
{
|
|
|
|
if (data != NULL) {
|
|
|
|
memcpy(data, sps_pps_params, MIN(*size, sizeof(sps_pps_params)));
|
|
|
|
}
|
|
|
|
*size = sizeof(sps_pps_params);
|
2024-06-19 14:58:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void vanilla_set_region(int region)
|
|
|
|
{
|
|
|
|
set_region(region);
|
2024-06-19 16:11:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void vanilla_set_battery_status(int battery_status)
|
|
|
|
{
|
|
|
|
set_battery_status(battery_status);
|
2024-05-20 19:17:24 -04:00
|
|
|
}
|