feat: bemanitools 6 initial refactoring drop, alpha 1

**THIS IS A HIGHLY WORK/DEVELOPMENT IN PROGRESS VERSION**

**THINGS ARE BROKEN AND EVERYTHING IS SUBJECT TO CHANGE**

First cut after massive refactoring with most critical and fundamental changes implemented.
We need to start somewhere, and this might be as good as anything else, so we can get started
with testing, bug fixing and iterating for the next releases.

The following list is non-exhaustive, does not guarantee anything does work, yet, and is supposed
to give a high level idea of what all of this is about. Updated documentation will reflect all of
this at some later point in time in more detail.

* A common "core" now abstracts logging, thread, property and configuration infrastructure and
  provides a common interface. This is used by bemanitools internally as well as all tools, hooks
  and APIs provided and don't depend on the game, version of the game or AVS version available
  anymore
* New bemanitools (public) API
  * Versioned API allowing for handling incremental API changes as well as breaking changes by
    providing a new/different version when necessary
  * Unified interfaces for bemanitools core API, i.e. logging, threads, configuration
  * SDK with examples (TBD)
  * Dogfooding approach: Bemanitools uses its own (public) API to implement and provide fundamental
    features like configurable keyboard implementations for IO or hooks for different games and
    versions
* All bemanitools hooks and IO libraries have been or are about to be re-worked to use the new APIs
* New hook API allows for more fine grained runtime control when stages of the hook are to be
  executed, i.e. pre AVS, before main game, iat hooking instead of relying purely on DllMain
  (which is still a compatible option though)
* launcher as a replacement for bootstrap: Bring it significantly closer to the original bootstrap
  by supporting completely vanilla data and bootstrap.xml configurations to run the games. Note
  that bemanitools does not include any code or means to run DRM'd data, only decrypted
* inject is also being reworked to use as much of the same "infrastructure" as launcher to provide
  a more seamless bootstrapping process for games that keeps pre-eapki data as vanilla as possible
Summary:

Test Plan:
Summary:

Test Plan:
Summary:

Test Plan:
Summary:

Test Plan:
This commit is contained in:
icex2
2024-08-15 11:34:31 +02:00
parent 106b908f17
commit 57e68f928a
692 changed files with 19534 additions and 8278 deletions
+11
View File
@@ -0,0 +1,11 @@
dlls += acio-mgr
libs_acio-mgr := \
aciodrv \
iface-core \
core \
util \
src_acio-mgr := \
dllmain.c \
mgr.c \
+20
View File
@@ -0,0 +1,20 @@
LIBRARY acio-mgr
EXPORTS
; Bemanitools 6 API
bt_module_core_log_api_set
bt_module_acio_mgr_api_get
; Not exporting as these are called in DllMain
; bt_acio_mgr_init
; bt_acio_mgr_fini
DllMain@12 @1 NONAME
; Direct API
bt_acio_mgr_port_init
bt_acio_mgr_port_fini
bt_acio_mgr_node_count_get
bt_acio_mgr_node_product_ident_get
bt_acio_mgr_port_packet_submit
bt_acio_mgr_port_checkout
bt_acio_mgr_port_checkin
@@ -1,15 +1,15 @@
#include <windows.h>
#include "manager-init.h"
#include "acio-mgr/internal.h"
BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
{
if (reason == DLL_PROCESS_ATTACH) {
_aciomgr_init();
bt_acio_mgr_init();
}
if (reason == DLL_PROCESS_DETACH) {
_aciomgr_fini();
bt_acio_mgr_fini();
}
return TRUE;
+7
View File
@@ -0,0 +1,7 @@
#ifndef ACIO_MGR_INTERNAL_T
#define ACIO_MGR_INTERNAL_T
void bt_acio_mgr_init();
void bt_acio_mgr_fini();
#endif
@@ -4,40 +4,43 @@
#include <stdatomic.h>
#include "aciomgr/manager-init.h"
#include "aciomgr/manager.h"
#include "acio/acio.h"
#include "aciodrv/device.h"
#include "core/log.h"
#include "acio-mgr/internal.h"
#include "api/core/log.h"
#include "iface-core/log.h"
#include "sdk/module/acio/mgr.h"
#include "sdk/module/core/log.h"
#include "util/array.h"
#define MAX_PORT_PATH_LENGTH 256
struct aciomgr_port_dispatcher {
typedef struct bt_acio_mgr_port_dispatcher {
CRITICAL_SECTION cs;
atomic_size_t references;
struct aciodrv_device_ctx *device;
char path[MAX_PORT_PATH_LENGTH];
int baud;
bool has_failure;
};
} bt_acio_mgr_port_dispatcher_t;
static void _aciomgr_setup_port_dispatcher(
struct aciomgr_port_dispatcher *dispatcher, const char *path, int baud);
static void _bt_acio_mgr_setup_port_dispatcher(
bt_acio_mgr_port_dispatcher_t *dispatcher, const char *path, int baud);
static void
_aciomgr_destroy_port_dispatcher(struct aciomgr_port_dispatcher *dispatcher);
_bt_acio_mgr_destroy_port_dispatcher(bt_acio_mgr_port_dispatcher_t *dispatcher);
// DLL-globals
static atomic_bool running;
static CRITICAL_SECTION mgr_cs;
static struct array active_ports;
static void _aciomgr_setup_port_dispatcher(
struct aciomgr_port_dispatcher *dispatcher, const char *path, int baud)
static void _bt_acio_mgr_setup_port_dispatcher(
bt_acio_mgr_port_dispatcher_t *dispatcher, const char *path, int baud)
{
InitializeCriticalSection(&dispatcher->cs);
@@ -56,17 +59,17 @@ static void _aciomgr_setup_port_dispatcher(
}
static void
_aciomgr_destroy_port_dispatcher(struct aciomgr_port_dispatcher *dispatcher)
_bt_acio_mgr_destroy_port_dispatcher(bt_acio_mgr_port_dispatcher_t *dispatcher)
{
aciodrv_device_close(dispatcher->device);
DeleteCriticalSection(&dispatcher->cs);
}
void _aciomgr_init()
void bt_acio_mgr_init()
{
if (running) {
log_warning("_aciomgr_init called when already running");
_aciomgr_fini();
bt_acio_mgr_fini();
}
InitializeCriticalSection(&mgr_cs);
array_init(&active_ports);
@@ -74,7 +77,7 @@ void _aciomgr_init()
running = true;
}
void _aciomgr_fini()
void bt_acio_mgr_fini()
{
if (!running) {
log_warning("_aciomgr_fini called when not running");
@@ -85,16 +88,8 @@ void _aciomgr_fini()
array_fini(&active_ports);
}
void aciomgr_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal)
{
core_log_impl_set(misc, warning, info, fatal);
}
struct aciomgr_port_dispatcher *aciomgr_port_init(const char *path, int baud)
bt_acio_mgr_port_dispatcher_t *
bt_acio_mgr_port_init(const char *path, uint32_t baud)
{
if (!running) {
log_warning("aciomgr_port_init: called when not running");
@@ -106,12 +101,12 @@ struct aciomgr_port_dispatcher *aciomgr_port_init(const char *path, int baud)
return NULL;
}
struct aciomgr_port_dispatcher *entry;
bt_acio_mgr_port_dispatcher_t *entry;
EnterCriticalSection(&mgr_cs);
for (size_t i = 0; i < active_ports.nitems; i++) {
entry = array_item(struct aciomgr_port_dispatcher, &active_ports, i);
entry = array_item(bt_acio_mgr_port_dispatcher_t, &active_ports, i);
if (strcmp(entry->path, path) == 0) {
// found
@@ -126,8 +121,8 @@ struct aciomgr_port_dispatcher *aciomgr_port_init(const char *path, int baud)
}
}
entry = array_append(struct aciomgr_port_dispatcher, &active_ports);
_aciomgr_setup_port_dispatcher(entry, path, baud);
entry = array_append(bt_acio_mgr_port_dispatcher_t, &active_ports);
_bt_acio_mgr_setup_port_dispatcher(entry, path, baud);
done:
if (!entry->has_failure) {
@@ -143,7 +138,7 @@ done:
return entry;
}
void aciomgr_port_fini(struct aciomgr_port_dispatcher *dispatcher)
void bt_acio_mgr_port_fini(bt_acio_mgr_port_dispatcher_t *dispatcher)
{
if (!running) {
log_warning("aciomgr_port_fini: called when not running");
@@ -155,30 +150,31 @@ void aciomgr_port_fini(struct aciomgr_port_dispatcher *dispatcher)
LeaveCriticalSection(&mgr_cs);
if (dispatcher->references == 0) {
_aciomgr_destroy_port_dispatcher(dispatcher);
_bt_acio_mgr_destroy_port_dispatcher(dispatcher);
}
}
// this function don't require the lock
uint8_t aciomgr_get_node_count(struct aciomgr_port_dispatcher *dispatcher)
uint8_t
bt_acio_mgr_node_count_get(const bt_acio_mgr_port_dispatcher_t *dispatcher)
{
return aciodrv_device_get_node_count(dispatcher->device);
}
// this function don't require the lock
bool aciomgr_get_node_product_ident(
struct aciomgr_port_dispatcher *dispatcher,
bool bt_acio_mgr_node_product_ident_get(
const bt_acio_mgr_port_dispatcher_t *dispatcher,
uint8_t node_id,
char product[ACIOMGR_NODE_PRODUCT_CODE_LEN])
char product[BT_ACIO_MGR_NODE_PRODUCT_CODE_LEN])
{
return aciodrv_device_get_node_product_ident(
dispatcher->device, node_id, product);
}
bool aciomgr_port_submit_packet(
struct aciomgr_port_dispatcher *dispatcher,
struct ac_io_message *msg,
int max_resp_size)
bool bt_acio_mgr_port_packet_submit(
bt_acio_mgr_port_dispatcher_t *dispatcher,
bt_acio_message_t *msg,
uint32_t max_resp_size)
{
// CS's although lightweight, may still be a burden, short circuit
if (dispatcher->references > 1) {
@@ -192,8 +188,8 @@ bool aciomgr_port_submit_packet(
return aciodrv_send_and_recv(dispatcher->device, msg, max_resp_size);
}
struct aciodrv_device_ctx *
aciomgr_port_checkout(struct aciomgr_port_dispatcher *dispatcher)
bt_acio_drv_device_ctx_t *
bt_acio_mgr_port_checkout(bt_acio_mgr_port_dispatcher_t *dispatcher)
{
if (dispatcher->references > 1) {
EnterCriticalSection(&dispatcher->cs);
@@ -202,9 +198,27 @@ aciomgr_port_checkout(struct aciomgr_port_dispatcher *dispatcher)
return dispatcher->device;
}
void aciomgr_port_checkin(struct aciomgr_port_dispatcher *dispatcher)
void bt_acio_mgr_port_checkin(bt_acio_mgr_port_dispatcher_t *dispatcher)
{
if (dispatcher->references > 1) {
LeaveCriticalSection(&dispatcher->cs);
}
}
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
{
bt_core_log_api_set(api);
}
void bt_module_acio_mgr_api_get(bt_acio_mgr_api_t *api)
{
api->version = 1;
api->v1.port_init = bt_acio_mgr_port_init;
api->v1.port_fini = bt_acio_mgr_port_fini;
api->v1.node_count_get = bt_acio_mgr_node_count_get;
api->v1.node_product_ident_get = bt_acio_mgr_node_product_ident_get;
api->v1.port_packet_submit = bt_acio_mgr_port_packet_submit;
api->v1.port_checkout = bt_acio_mgr_port_checkout;
api->v1.port_checkin = bt_acio_mgr_port_checkin;
}
+15 -7
View File
@@ -5,9 +5,8 @@
#include "aciodrv/device.h"
#include "aciodrv/panb.h"
#include "core/thread.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "iface-core/thread.h"
static int auto_poll_proc(void *auto_poll_param);
static int auto_poll_threadid;
@@ -41,6 +40,8 @@ static int auto_poll_proc(void *param)
bool aciodrv_proc_panb_init(struct aciodrv_device_ctx *device)
{
bt_core_thread_result_t result;
log_assert(device);
if (!aciodrv_panb_start_auto_input(device, 0, AC_IO_PANB_NUM_NODES)) {
@@ -50,8 +51,10 @@ bool aciodrv_proc_panb_init(struct aciodrv_device_ctx *device)
auto_poll_stop = false;
InitializeCriticalSection(&keypair_lock);
InitializeCriticalSection(&auto_poll_stop_lock);
auto_poll_threadid =
core_thread_create(auto_poll_proc, (void *) device, 0x4000, 0);
result = bt_core_thread_create(
auto_poll_proc, (void *) device, 0x4000, 0, &auto_poll_threadid);
bt_core_thread_fatal_on_error(result);
return true;
}
@@ -77,12 +80,17 @@ bool aciodrv_proc_panb_get_state(uint8_t *button_state)
void aciodrv_proc_panb_fini(struct aciodrv_device_ctx *device)
{
bt_core_thread_result_t result;
EnterCriticalSection(&auto_poll_stop_lock);
auto_poll_stop = true;
LeaveCriticalSection(&auto_poll_stop_lock);
core_thread_join(auto_poll_threadid, NULL);
core_thread_destroy(auto_poll_threadid);
result = bt_core_thread_join(auto_poll_threadid, NULL);
bt_core_thread_fatal_on_error(result);
result = bt_core_thread_destroy(auto_poll_threadid);
bt_core_thread_fatal_on_error(result);
DeleteCriticalSection(&keypair_lock);
DeleteCriticalSection(&auto_poll_stop_lock);
+1 -1
View File
@@ -7,7 +7,7 @@
#include "aciodrv/port.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "util/hex.h"
#include "util/mem.h"
+1 -1
View File
@@ -7,7 +7,7 @@
#include "aciodrv/device.h"
#include "core/log.h"
#include "iface-core/log.h"
bool aciodrv_h44b_init(struct aciodrv_device_ctx *device, uint8_t node_id)
{
+1 -1
View File
@@ -5,7 +5,7 @@
#include "aciodrv/device.h"
#include "aciodrv/icca.h"
#include "core/log.h"
#include "iface-core/log.h"
static bool aciodrv_icca_queue_loop_start(
struct aciodrv_device_ctx *device, uint8_t node_id)
+1 -1
View File
@@ -5,7 +5,7 @@
#include "aciodrv/device.h"
#include "core/log.h"
#include "iface-core/log.h"
static bool
aciodrv_kfca_watchdog_start(struct aciodrv_device_ctx *device, uint8_t node_id)
+1 -1
View File
@@ -5,7 +5,7 @@
#include "aciodrv/device.h"
#include "aciodrv/panb.h"
#include "core/log.h"
#include "iface-core/log.h"
bool aciodrv_panb_start_auto_input(
struct aciodrv_device_ctx *device, uint8_t node_id, uint8_t node_count)
+1 -1
View File
@@ -6,7 +6,7 @@
#include <windows.h>
#include "core/log.h"
#include "iface-core/log.h"
HANDLE aciodrv_port_open(const char *port_path, int baud)
{
+1 -1
View File
@@ -5,7 +5,7 @@
#include "aciodrv/device.h"
#include "core/log.h"
#include "iface-core/log.h"
static bool aciodrv_rvol_change_expand_mode(
struct aciodrv_device_ctx *device, uint8_t node_id, uint8_t mode)
+1 -1
View File
@@ -5,7 +5,7 @@
#include "acioemu/addr.h"
#include "acioemu/emu.h"
#include "core/log.h"
#include "iface-core/log.h"
void ac_io_emu_cmd_assign_addrs(
struct ac_io_emu *emu, const struct ac_io_message *req, uint8_t node_count)
+1 -1
View File
@@ -14,7 +14,7 @@
#include "acioemu/emu.h"
#include "acioemu/pipe.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "hook/iohook.h"
+4 -4
View File
@@ -11,7 +11,7 @@
#include "acioemu/emu.h"
#include "bemanitools/jbio.h"
#include "iface-io/jb.h"
#include "util/hex.h"
@@ -54,14 +54,14 @@ void ac_io_emu_h44b_dispatch_request(
case AC_IO_H44B_CMD_SET_OUTPUTS:
/* Not using the struct ac_io_h44b_output here */
for (int i = 0; i < 6; i++) {
jb_io_set_rgb_led(
(enum jb_io_rgb_led) i,
bt_io_jb_rgb_led_set(
(enum bt_io_jb_rgb_led) i,
req->cmd.raw[i * 3],
req->cmd.raw[i * 3 + 1],
req->cmd.raw[i * 3 + 2]);
}
jb_io_write_lights();
bt_io_jb_lights_write();
ac_io_emu_h44b_send_status(h44b, req, 0x00);
+2 -2
View File
@@ -6,14 +6,14 @@
#include "acioemu/emu.h"
#include "api/io/jb.h"
struct ac_io_emu_h44b {
struct ac_io_emu *emu;
uint8_t unit_no;
// TODO
};
void acioemu_h44b_init(void);
void ac_io_emu_h44b_init(
struct ac_io_emu_h44b *h44b, struct ac_io_emu *emu, uint8_t unit_no);
+1 -1
View File
@@ -6,7 +6,7 @@
#include "acioemu/emu.h"
#include "acioemu/hdxs.h"
#include "core/log.h"
#include "iface-core/log.h"
static void ac_io_emu_hdxs_cmd_send_version(
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req);
+21 -19
View File
@@ -12,7 +12,7 @@
#include "acioemu/emu.h"
#include "acioemu/icca.h"
#include "bemanitools/eamio.h"
#include "iface-io/eam.h"
#include "util/crc.h"
#include "util/time.h"
@@ -58,6 +58,7 @@ void ac_io_emu_icca_init(
memset(icca, 0, sizeof(*icca));
icca->emu = emu;
icca->unit_no = unit_no;
// queue must be started
icca->fault = true;
@@ -156,20 +157,20 @@ void ac_io_emu_icca_dispatch_request(
switch (misc->subcmd) {
case AC_IO_ICCA_SUBCMD_CARD_SLOT_CLOSE:
cmd = EAM_IO_CARD_SLOT_CMD_CLOSE;
cmd = BT_IO_EAM_CARD_SLOT_CMD_CLOSE;
break;
case AC_IO_ICCA_SUBCMD_CARD_SLOT_OPEN:
cmd = EAM_IO_CARD_SLOT_CMD_OPEN;
cmd = BT_IO_EAM_CARD_SLOT_CMD_OPEN;
break;
case AC_IO_ICCA_SUBCMD_CARD_SLOT_EJECT:
cmd = EAM_IO_CARD_SLOT_CMD_EJECT;
cmd = BT_IO_EAM_CARD_SLOT_CMD_EJECT;
icca->engaged = false;
break;
case 3:
cmd = EAM_IO_CARD_SLOT_CMD_READ;
cmd = BT_IO_EAM_CARD_SLOT_CMD_READ;
break;
default:
@@ -182,7 +183,7 @@ void ac_io_emu_icca_dispatch_request(
}
if (cmd != 0xFF) {
if (!eam_io_card_slot_cmd(icca->unit_no, cmd)) {
if (!bt_io_eam_card_slot_cmd_send(icca->unit_no, cmd)) {
log_warning(
"Eamio failed to handle slot cmd %d for node %d",
cmd,
@@ -326,33 +327,34 @@ static void ac_io_emu_icca_send_state(
uint8_t sensor_state;
bool card_full_insert;
if (!eam_io_poll(icca->unit_no)) {
if (!bt_io_eam_poll(icca->unit_no)) {
log_warning("Polling eamio failed");
}
memset(&resp, 0, sizeof(resp));
keypad = eam_io_get_keypad_state(icca->unit_no);
sensor_state = eam_io_get_sensor_state(icca->unit_no);
keypad = bt_io_eam_keypad_state_get(icca->unit_no);
sensor_state = bt_io_eam_sensor_state_get(icca->unit_no);
keypad_rise = keypad & (icca->last_keypad ^ keypad);
card_full_insert = sensor_state & (1 << EAM_IO_SENSOR_FRONT) &&
sensor_state & (1 << EAM_IO_SENSOR_BACK);
card_full_insert = sensor_state & (1 << BT_IO_EAM_SENSOR_STATE_FRONT) &&
sensor_state & (1 << BT_IO_EAM_SENSOR_STATE_BACK);
if (sensor_state != icca->last_sensor) {
if (card_full_insert) {
if (!eam_io_card_slot_cmd(
icca->unit_no, EAM_IO_CARD_SLOT_CMD_READ)) {
if (!bt_io_eam_card_slot_cmd_send(
icca->unit_no, BT_IO_EAM_CARD_SLOT_CMD_READ)) {
log_warning(
"EAM_IO_CARD_SLOT_CMD_READ to unit %d failed",
"BT_IO_EAM_CARD_SLOT_CMD_READ to unit %d failed",
icca->unit_no);
}
icca->card_result =
eam_io_read_card(icca->unit_no, icca->uid, sizeof(icca->uid));
icca->card_result = bt_io_eam_card_read(
icca->unit_no, icca->uid, sizeof(icca->uid));
// fault if sensor says to read but we got no card
icca->fault = (icca->card_result == EAM_IO_CARD_NONE);
icca->fault =
(icca->card_result == BT_IO_EAM_READ_CARD_RESULT_NONE);
} else {
icca->fault = false;
}
@@ -385,11 +387,11 @@ static void ac_io_emu_icca_send_state(
body->sensor_state = 0;
if (sensor_state & (1 << EAM_IO_SENSOR_FRONT)) {
if (sensor_state & (1 << BT_IO_EAM_SENSOR_STATE_FRONT)) {
body->sensor_state |= AC_IO_ICCA_FLAG_FRONT_SENSOR;
}
if (sensor_state & (1 << EAM_IO_SENSOR_BACK)) {
if (sensor_state & (1 << BT_IO_EAM_SENSOR_STATE_BACK)) {
body->sensor_state |= AC_IO_ICCA_FLAG_REAR_SENSOR;
}
+3
View File
@@ -6,6 +6,8 @@
#include "acioemu/emu.h"
#include "api/io/eam.h"
enum ac_io_emu_icca_version {
v150 = 0x5,
v160 = 0x6,
@@ -20,6 +22,7 @@ enum ac_io_emu_icca_version {
struct ac_io_emu_icca {
struct ac_io_emu *emu;
uint8_t unit_no;
bool fault;
bool engaged;
uint8_t last_sensor;
+1 -1
View File
@@ -7,7 +7,7 @@
#include "acio/acio.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "util/iobuf.h"
#include "util/list.h"
-10
View File
@@ -1,10 +0,0 @@
dlls += aciomgr
libs_aciomgr := \
core \
aciodrv \
util \
src_aciomgr := \
dllmain.c \
manager.c \
-12
View File
@@ -1,12 +0,0 @@
LIBRARY aciomgr
EXPORTS
aciomgr_set_loggers
aciomgr_port_init
aciomgr_port_fini
aciomgr_get_node_count
aciomgr_get_node_product_ident
aciomgr_port_submit_packet
aciomgr_port_checkout
aciomgr_port_checkin
DllMain@12 @1 NONAME
-8
View File
@@ -1,8 +0,0 @@
#ifndef ACIOMGR_MANAGER_INIT_H
#define ACIOMGR_MANAGER_INIT_H
// internal, used by DllMain
void _aciomgr_init();
void _aciomgr_fini();
#endif
+1
View File
@@ -6,6 +6,7 @@ libs_aciotest := \
aciodrv \
aciodrv-proc \
util \
iface-core
src_aciotest := \
icca.c \
+5 -6
View File
@@ -17,12 +17,10 @@
#include "core/log-bt-ext.h"
#include "core/log-bt.h"
#include "core/log.h"
#include "core/thread-crt-ext.h"
#include "core/log-sink-std.h"
#include "core/thread-crt.h"
#include "core/thread.h"
#include "core/log.h"
#include "iface-core/log.h"
static uint8_t aciotest_cnt = 0;
static uint8_t bi2a_mode = 255;
@@ -119,10 +117,11 @@ int main(int argc, char **argv)
}
}
core_thread_crt_ext_impl_set();
core_log_bt_ext_impl_set();
core_log_bt_core_api_set();
core_thread_crt_core_api_set();
core_log_bt_ext_init_with_stdout();
core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
struct aciodrv_device_ctx *device =
aciodrv_device_open_path(argv[1], atoi(argv[2]));
+2 -2
View File
@@ -12,11 +12,11 @@
#include "asio/asio-reghook.h"
#include "core/log.h"
#include "hook/com-proxy.h"
#include "hook/table.h"
#include "iface-core/log.h"
#include "util/defs.h"
#include "util/str.h"
#include "util/time.h"
+3 -3
View File
@@ -1,8 +1,8 @@
#include "asio/config-asio.h"
#include "cconfig/cconfig-util.h"
#include "core/log.h"
#include "asio/config-asio.h"
#include "iface-core/log.h"
#define ASIOHOOK_CONFIG_IO_FORCE_ASIO_KEY "asio.force_asio"
#define ASIOHOOK_CONFIG_IO_FORCE_WASAPI_KEY "asio.force_wasapi"
+13
View File
@@ -0,0 +1,13 @@
avslibs += avs-ext
libs_avs-ext := \
iface-core \
src_avs-ext := \
fs.c \
error.c \
log.c \
property-ext.c \
property-node.c \
property.c \
thread.c \
@@ -1,16 +1,20 @@
#include "avs-util/error.h"
#include "avs-ext/error.h"
#include "util/defs.h"
struct avs_util_avs_error_str {
struct avs_ext_error_str {
avs_error error;
const char *msg;
};
static const char *avs_util_error_unknown = "unknown error";
static const char *_avs_ext_error_unknown = "unknown error";
// Source: https://github.com/spicetools/spicetools
static const struct avs_util_avs_error_str AVS_UTIL_ERRORS[] = {
static const struct avs_ext_error_str _avs_ext_errors[] = {
{0x80070002, "cannot find file or directory"},
{0x80070009, "invalid data type"},
{0x80070012, "TODO unknown error code"},
{0x80070016, "invalid parameter"},
{0x80092000, "invalid type"},
{0x80092001, "type cannot use as array"},
{0x80092002, "invalid"},
@@ -85,25 +89,25 @@ static const struct avs_util_avs_error_str AVS_UTIL_ERRORS[] = {
{0x80092280, "finger-print differs"},
{0x800922C0, "operation is not supported"}};
const char *avs_util_error_str(avs_error error)
const char *avs_ext_error_str(avs_error error)
{
int i;
for (i = 0; i < lengthof(AVS_UTIL_ERRORS); i++) {
if (error == AVS_UTIL_ERRORS[i].error) {
return AVS_UTIL_ERRORS[i].msg;
for (i = 0; i < lengthof(_avs_ext_errors); i++) {
if (error == _avs_ext_errors[i].error) {
return _avs_ext_errors[i].msg;
}
}
return avs_util_error_unknown;
return _avs_ext_error_unknown;
}
const char *avs_util_property_error_get_and_clear(struct property *prop)
const char *avs_ext_property_error_get_and_clear(struct property *prop)
{
avs_error error;
error = property_get_error(prop);
property_clear_error(prop);
return avs_util_error_str(error);
return avs_ext_error_str(error);
}
+10
View File
@@ -0,0 +1,10 @@
#ifndef AVS_EXT_ERROR_H
#define AVS_EXT_ERROR_H
#include "imports/avs.h"
const char *avs_ext_error_str(avs_error error);
const char *avs_ext_error_property_error_get_and_clear(struct property *prop);
#endif
+33
View File
@@ -0,0 +1,33 @@
#define LOG_MODULE "avs-ext-fs"
#include "api/core/log.h"
#include "iface-core/log.h"
#include "imports/avs.h"
void avs_ext_fs_dir_list_log(
const char *path, bt_core_log_message_t log_message)
{
avs_desc desc;
const char *dirent_name;
desc = avs_fs_opendir(path);
if (!desc) {
log_warning("Opening directory '%s' failed", path);
return;
}
log_message(LOG_MODULE, "Directory contents of: %s", path);
dirent_name = avs_fs_readdir(desc);
while (dirent_name != NULL) {
log_message(LOG_MODULE, " %s", dirent_name);
dirent_name = avs_fs_readdir(desc);
}
avs_fs_closedir(desc);
}
+9
View File
@@ -0,0 +1,9 @@
#ifndef AVS_EXT_FS_H
#define AVS_EXT_FS_H
#include "api/core/log.h"
void avs_ext_fs_dir_list_log(
const char *path, bt_core_log_message_t log_message);
#endif
+27
View File
@@ -0,0 +1,27 @@
#include "api/core/log.h"
#include "avs-ext/log.h"
#include "iface-core/log.h"
#include "imports/avs.h"
static void _avs_ext_log_core_api_get(bt_core_log_api_t *api)
{
log_assert(api);
api->version = 1;
api->v1.misc = log_body_misc;
api->v1.info = log_body_info;
api->v1.warning = log_body_warning;
api->v1.fatal = log_body_fatal;
}
void avs_ext_log_core_api_set()
{
bt_core_log_api_t api;
_avs_ext_log_core_api_get(&api);
bt_core_log_api_set(&api);
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef AVS_EXT_LOG_H
#define AVS_EXT_LOG_H
#include "api/core/log.h"
void avs_ext_log_core_api_set();
#endif
+71
View File
@@ -0,0 +1,71 @@
#include "avs-ext/error.h"
#include "avs-ext/property-internal.h"
#include "imports/avs.h"
#include "iface-core/log.h"
#include "main/core/property.h"
#include "util/mem.h"
#include "avs-ext/fs.h"
void avs_ext_property_ext_avs_file_load(
const char *path, core_property_t **property_)
{
avs_desc desc;
void *buffer;
int nbytes;
avs_error error;
struct property *prop;
avs_ext_property_internal_property_t *property;
log_assert(path);
log_assert(property_);
desc = avs_fs_open(path, AVS_FILE_READ, AVS_FILE_FLAG_SHARE_READ);
if (AVS_IS_ERROR(desc)) {
log_fatal(
"%s: Error opening avs property file: %s",
path,
avs_ext_error_str(desc));
}
nbytes = property_read_query_memsize(avs_fs_read, desc, 0, 0);
if (AVS_IS_ERROR(nbytes)) {
log_fatal(
"%s: Error querying avs property file: ",
path,
avs_ext_error_str(nbytes));
}
buffer = xmalloc(nbytes);
prop = property_create(
PROPERTY_FLAG_READ | PROPERTY_FLAG_WRITE | PROPERTY_FLAG_CREATE |
PROPERTY_FLAG_APPEND,
buffer,
nbytes);
avs_fs_lseek(desc, 0, AVS_SEEK_SET);
error = property_insert_read(prop, 0, avs_fs_read, desc);
if (AVS_IS_ERROR(error)) {
log_fatal(
"%s: Error reading avs property file: %s",
path,
avs_ext_error_str(error));
}
avs_fs_close(desc);
*property_ = xmalloc(sizeof(avs_ext_property_internal_property_t));
property = (avs_ext_property_internal_property_t *) *property_;
property->property = prop;
}
+9
View File
@@ -0,0 +1,9 @@
#ifndef AVS_EXT_PROPERTY_EXT_H
#define AVS_EXT_PROPERTY_EXT_H
#include "main/core/property.h"
void avs_ext_property_ext_avs_file_load(
const char *path, core_property_t **property);
#endif
+26
View File
@@ -0,0 +1,26 @@
#ifndef AVS_EXT_PROPERTY_INTERNAL_H
#define AVS_EXT_PROPERTY_INTERNAL_H
#include "core/property-node.h"
#include "core/property.h"
#include "imports/avs.h"
typedef struct avs_ext_property_internal_property {
struct property *property;
} avs_ext_property_internal_property_t;
_Static_assert(
sizeof(avs_ext_property_internal_property_t) <= sizeof(core_property_t),
"Not enough space for stack allocations");
typedef struct avs_ext_property_internal_node {
avs_ext_property_internal_property_t *property;
struct property_node *node;
} avs_ext_property_internal_node_t;
_Static_assert(
sizeof(avs_ext_property_internal_node_t) <= sizeof(core_property_node_t),
"Not enough space for stack allocations");
#endif
File diff suppressed because it is too large Load Diff
+16
View File
@@ -0,0 +1,16 @@
#ifndef AVS_EXT_PROPERTY_NODE_H
#define AVS_EXT_PROPERTY_NODE_H
#include "imports/avs.h"
#include "main/core/property-node.h"
void avs_ext_property_node_core_api_get(core_property_node_api_t *api);
void avs_ext_property_node_core_api_set();
// Don't use this unless you need to interface directly with avs
struct property_node *
avs_ext_property_node_avs_property_node_get(const core_property_node_t *node);
#endif
+389
View File
@@ -0,0 +1,389 @@
#define LOG_MODULE "avs-ext-property"
#include <windows.h>
#include <errno.h>
#include <stdio.h>
#include "avs-ext/error.h"
#include "avs-ext/property-internal.h"
#include "avs-ext/property-node.h"
#include "avs-ext/property.h"
#include "iface-core/log.h"
#include "imports/avs.h"
#include "util/mem.h"
#define AVS_PROPERTY_STRUCTURE_META_SIZE 576
typedef void (*avs_ext_property_rewinder_t)(uint32_t context);
struct avs_ext_property_str_read_handle {
const char *buffer;
size_t buffer_len;
size_t offset;
};
static void _avs_ext_property_free(core_property_t **property_);
static size_t
_avs_ext_property_str_read(uint32_t context, void *bytes, size_t nbytes)
{
int result;
struct avs_ext_property_str_read_handle *handle;
result = 0;
handle = TlsGetValue(context);
if (handle->offset < handle->buffer_len) {
result = min(nbytes, handle->buffer_len - handle->offset);
memcpy(bytes, (const void *) (handle->buffer + handle->offset), result);
handle->offset += result;
}
return result;
}
static void _avs_ext_property_str_rewind(uint32_t context)
{
struct avs_ext_property_str_read_handle *handle;
handle = TlsGetValue(context);
handle->offset = 0;
}
static size_t
_avs_ext_property_fread(uint32_t context, void *bytes, size_t nbytes)
{
FILE *f;
f = TlsGetValue(context);
return fread(bytes, 1, nbytes, f);
}
static void _avs_ext_property_frewind(uint32_t context)
{
FILE *f = TlsGetValue(context);
rewind(f);
}
static core_property_result_t _avs_ext_property_do_load(
avs_reader_t reader,
avs_ext_property_rewinder_t rewinder,
uint32_t context,
const char *name,
avs_ext_property_internal_property_t **property)
{
struct property *prop;
void *buffer;
int nbytes;
nbytes = property_read_query_memsize(reader, context, 0, 0);
if (nbytes < 0) {
return CORE_PROPERTY_RESULT_ERROR_INTERNAL;
}
buffer = xmalloc(nbytes);
prop = property_create(
PROPERTY_FLAG_READ | PROPERTY_FLAG_WRITE | PROPERTY_FLAG_CREATE |
PROPERTY_FLAG_APPEND,
buffer,
nbytes);
if (!prop) {
free(buffer);
return CORE_PROPERTY_RESULT_ERROR_ALLOC;
}
rewinder(context);
if (!property_insert_read(prop, 0, reader, context)) {
property_destroy(prop);
free(buffer);
return CORE_PROPERTY_RESULT_ERROR_READ;
}
*property = xmalloc(sizeof(avs_ext_property_internal_property_t));
(*property)->property = prop;
return CORE_PROPERTY_RESULT_SUCCESS;
}
static core_property_result_t
_avs_ext_property_create(size_t size, core_property_t **property_)
{
avs_ext_property_internal_property_t *property;
void *buffer;
struct property *prop;
if (size > UINT32_MAX) {
return CORE_PROPERTY_RESULT_ERROR_INTERNAL;
}
buffer = xmalloc(size);
prop = property_create(
PROPERTY_FLAG_READ | PROPERTY_FLAG_WRITE | PROPERTY_FLAG_CREATE |
PROPERTY_FLAG_APPEND,
buffer,
(uint32_t) size);
if (!prop) {
free(buffer);
return CORE_PROPERTY_RESULT_ERROR_ALLOC;
}
*property_ = xmalloc(sizeof(core_property_t));
property = (avs_ext_property_internal_property_t *) (*property_);
property->property = prop;
return CORE_PROPERTY_RESULT_SUCCESS;
}
static core_property_result_t
_avs_ext_property_file_load(const char *path, core_property_t **property)
{
FILE *file;
uint32_t f_keyhole;
core_property_result_t result;
file = fopen(path, "r");
if (!file) {
switch (errno) {
case EACCES:
return CORE_PROPERTY_RESULT_ERROR_PERMISSIONS;
case ENOENT:
return CORE_PROPERTY_RESULT_NOT_FOUND;
default:
return CORE_PROPERTY_RESULT_ERROR_INTERNAL;
}
}
/* AVS callbacks are only given a 32-bit context parameter, even in 64-bit
builds of AVS. We allocate a 32-bit TLS key and pass the context in this
manner instead. Inefficient, but it works. */
f_keyhole = TlsAlloc();
TlsSetValue(f_keyhole, file);
result = _avs_ext_property_do_load(
_avs_ext_property_fread,
_avs_ext_property_frewind,
f_keyhole,
path,
(avs_ext_property_internal_property_t **) property);
TlsFree(f_keyhole);
fclose(file);
return result;
}
static core_property_result_t
_avs_ext_property_str_load(const char *str, core_property_t **property)
{
struct avs_ext_property_str_read_handle read_handle;
uint32_t s_keyhole;
core_property_result_t result;
read_handle.buffer = str;
read_handle.buffer_len = strlen(str);
read_handle.offset = 0;
s_keyhole = TlsAlloc();
TlsSetValue(s_keyhole, &read_handle);
result = _avs_ext_property_do_load(
_avs_ext_property_str_read,
_avs_ext_property_str_rewind,
s_keyhole,
"<string>",
(avs_ext_property_internal_property_t **) property);
TlsFree(s_keyhole);
return result;
}
static core_property_result_t
_avs_ext_property_size(const core_property_t *property_, size_t *size)
{
avs_ext_property_internal_property_t *property;
avs_error error;
property = (avs_ext_property_internal_property_t *) property_;
// Returns the size of the actual data in the property structure only
// Hence, using that size only, allocating another buffer for a copy
// of this might fail or copying the data will fail because the buffer
// is too small
error = property_query_size(property->property);
if (AVS_IS_ERROR(error)) {
return CORE_PROPERTY_RESULT_ERROR_INTERNAL;
}
// Hack: *2 to have enough space and not cut off data when cloning/copying
// property data because...reasons? I haven't figured this one out and
// there doesn't seem to be an actual API call for that to return the
// "true" size that allows the caller to figure out how much memory
// they have to allocate to create a copy of the property structure
// with property_create and
*size = (AVS_PROPERTY_STRUCTURE_META_SIZE + error) * 2;
return CORE_PROPERTY_RESULT_SUCCESS;
}
static core_property_result_t _avs_ext_property_clone(
const core_property_t *property_, core_property_t **property_cloned_)
{
avs_ext_property_internal_property_t *property;
avs_ext_property_internal_property_t *property_cloned;
size_t size;
core_property_result_t result;
struct property_node *node;
avs_error error;
property = (avs_ext_property_internal_property_t *) property_;
result = _avs_ext_property_size(property_, &size);
if (CORE_PROPERTY_RESULT_IS_ERROR(result)) {
return result;
}
result = _avs_ext_property_create(size, property_cloned_);
property_cloned =
(avs_ext_property_internal_property_t *) *property_cloned_;
if (CORE_PROPERTY_RESULT_IS_ERROR(result)) {
return result;
}
node = property_search(property->property, NULL, "/");
if (!node) {
error = property_get_error(property_cloned->property);
if (AVS_IS_ERROR(error)) {
_avs_ext_property_free(property_cloned_);
return CORE_PROPERTY_RESULT_ERROR_INTERNAL;
}
}
if (!property_node_clone(property_cloned->property, NULL, node, true)) {
error = property_get_error(property_cloned->property);
if (AVS_IS_ERROR(error)) {
_avs_ext_property_free(property_cloned_);
return CORE_PROPERTY_RESULT_ERROR_INTERNAL;
}
}
return CORE_PROPERTY_RESULT_SUCCESS;
}
static void _avs_ext_property_log(
const core_property_t *property_, bt_core_log_message_t log_message)
{
avs_ext_property_internal_node_t node;
core_property_node_api_t node_api;
node.property = (avs_ext_property_internal_property_t *) (property_);
node.node = property_search(node.property->property, NULL, "/");
if (node.node == NULL) {
log_message(LOG_MODULE, "<EMPTY>");
return;
}
avs_ext_property_node_core_api_get(&node_api);
node_api.v1.log((const core_property_node_t *) &node, log_message);
}
static core_property_result_t _avs_ext_property_root_node_get(
const core_property_t *property_, core_property_node_t *node_)
{
avs_ext_property_internal_property_t *property;
avs_ext_property_internal_node_t *node;
property = (avs_ext_property_internal_property_t *) property_;
node = (avs_ext_property_internal_node_t *) node_;
memset(node, 0, sizeof(avs_ext_property_internal_node_t));
node->property = property;
node->node = property_search(property->property, NULL, "/");
if (node->node == NULL) {
return CORE_PROPERTY_RESULT_NOT_FOUND;
} else {
return CORE_PROPERTY_RESULT_SUCCESS;
}
}
static core_property_result_t _avs_ext_property_other_node_insert(
core_property_t *property_, const core_property_node_t *node_)
{
avs_ext_property_internal_property_t *property;
avs_ext_property_internal_node_t *node;
property = (avs_ext_property_internal_property_t *) property_;
node = (avs_ext_property_internal_node_t *) node_;
if (!property_node_clone(property->property, NULL, node->node, true)) {
return CORE_PROPERTY_NODE_RESULT_ERROR_INTERNAL;
} else {
return CORE_PROPERTY_NODE_RESULT_SUCCESS;
}
}
static void _avs_ext_property_free(core_property_t **property_)
{
avs_ext_property_internal_property_t *property;
void *buffer;
property = (avs_ext_property_internal_property_t *) (*property_);
buffer = property_desc_to_buffer(property->property);
property_destroy(property->property);
free(buffer);
free(*property_);
*property_ = NULL;
}
static void _avs_ext_property_core_api_get(core_property_api_t *api)
{
log_assert(api);
api->version = 1;
api->v1.create = _avs_ext_property_create;
api->v1.file_load = _avs_ext_property_file_load;
api->v1.str_load = _avs_ext_property_str_load;
api->v1.size = _avs_ext_property_size;
api->v1.clone = _avs_ext_property_clone;
api->v1.log = _avs_ext_property_log;
api->v1.root_node_get = _avs_ext_property_root_node_get;
api->v1.other_node_insert = _avs_ext_property_other_node_insert;
api->v1.free = _avs_ext_property_free;
}
void avs_ext_property_core_api_set()
{
core_property_api_t api;
_avs_ext_property_core_api_get(&api);
core_property_api_set(&api);
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef AVS_EXT_PROPERTY_H
#define AVS_EXT_PROPERTY_H
#include "main/core/property.h"
void avs_ext_property_core_api_set();
#endif
+56
View File
@@ -0,0 +1,56 @@
#include "api/core/thread.h"
#include "api/core/log.h"
#include "avs-ext/thread.h"
#include "iface-core/log.h"
#include "iface-core/thread.h"
#include "imports/avs.h"
static bt_core_thread_result_t _avs_ext_thread_create(
int (*proc)(void *),
void *ctx,
uint32_t stack_sz,
unsigned int priority,
bt_core_thread_id_t *thread_id)
{
*thread_id = avs_thread_create(proc, ctx, stack_sz, priority);
return BT_CORE_THREAD_RESULT_SUCCESS;
}
static bt_core_thread_result_t
_avs_ext_thread_join(bt_core_thread_id_t thread_id, int *result)
{
avs_thread_join(thread_id, result);
return BT_CORE_THREAD_RESULT_SUCCESS;
}
static bt_core_thread_result_t
_avs_ext_thread_destroy(bt_core_thread_id_t thread_id)
{
avs_thread_destroy(thread_id);
return BT_CORE_THREAD_RESULT_SUCCESS;
}
static void _avs_ext_thread_core_api_get(bt_core_thread_api_t *api)
{
log_assert(api);
api->version = 1;
api->v1.create = _avs_ext_thread_create;
api->v1.join = _avs_ext_thread_join;
api->v1.destroy = _avs_ext_thread_destroy;
}
void avs_ext_thread_core_api_set()
{
bt_core_thread_api_t api;
_avs_ext_thread_core_api_get(&api);
bt_core_thread_api_set(&api);
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef AVS_EXT_THREAD_H
#define AVS_EXT_THREAD_H
#include "api/core/thread.h"
void avs_ext_thread_core_api_set();
#endif
-7
View File
@@ -1,7 +0,0 @@
libs += avs-util
libs_avs-util := \
src_avs-util := \
core-interop.c \
error.c \
-16
View File
@@ -1,16 +0,0 @@
#include "core/log.h"
#include "core/thread.h"
#include "imports/avs.h"
void avs_util_core_interop_log_avs_impl_set()
{
core_log_impl_set(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
}
void avs_util_core_interop_thread_avs_impl_set()
{
core_thread_impl_set(
avs_thread_create, avs_thread_join, avs_thread_destroy);
}
-7
View File
@@ -1,7 +0,0 @@
#ifndef AVS_UTIL_CORE_INTEROP_H
#define AVS_UTIL_CORE_INTEROP_H
void avs_util_core_interop_log_avs_impl_set();
void avs_util_core_interop_thread_avs_impl_set();
#endif
-10
View File
@@ -1,10 +0,0 @@
#ifndef AVS_UTIL_ERROR_H
#define AVS_UTIL_ERROR_H
#include "imports/avs.h"
const char *avs_util_error_str(avs_error error);
const char *avs_util_property_error_get_and_clear(struct property *prop);
#endif
-54
View File
@@ -1,54 +0,0 @@
#ifndef BEMANITOOLS_SDVXIO_H
#define BEMANITOOLS_SDVXIO_H
/* IO emulation provider for BeatStream */
#include <stdbool.h>
#include <stdint.h>
#include "bemanitools/glue.h"
enum bst_io_in_gpio_sys_bit {
SDVX_IO_IN_GPIO_SYS_COIN = 2,
SDVX_IO_IN_GPIO_SYS_TEST = 4,
SDVX_IO_IN_GPIO_SYS_SERVICE = 5,
};
/* The first function that will be called on your DLL. You will be supplied
with four function pointers that may be used to log messages to the game's
log file. See comments in glue.h for further information. */
void bst_io_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal);
/* Initialize your BST IO emulation DLL. Thread management functions are
provided to you; you must use these functions to create your own threads if
you want to make use of the logging functions that are provided to
eam_io_set_loggers(). You will also need to pass these thread management
functions on to geninput if you intend to make use of that library.
See glue.h and geninput.h for further details. */
bool bst_io_init(
thread_create_t thread_create,
thread_join_t thread_join,
thread_destroy_t thread_destroy);
/* Shut down your SDVX IO emulation DLL */
void bst_io_fini(void);
/* Read input state. Returns true if successful. */
bool bst_io_read_input(void);
/* Get state of coin, test, service inputs */
uint8_t bst_io_get_input(void);
// TODO: Lighting
#endif
-129
View File
@@ -1,129 +0,0 @@
#ifndef BEMANITOOLS_DDRIO_H
#define BEMANITOOLS_DDRIO_H
#include <stdbool.h>
#include <stdint.h>
#include "bemanitools/glue.h"
enum ddr_pad_bit {
DDR_TEST = 0x04,
DDR_COIN = 0x05,
DDR_SERVICE = 0x06,
DDR_P2_START = 0x08,
DDR_P2_UP = 0x09,
DDR_P2_DOWN = 0x0A,
DDR_P2_LEFT = 0x0B,
DDR_P2_RIGHT = 0x0C,
DDR_P2_MENU_LEFT = 0x0E,
DDR_P2_MENU_RIGHT = 0x0F,
DDR_P2_MENU_UP = 0x02,
DDR_P2_MENU_DOWN = 0x03,
DDR_P1_START = 0x10,
DDR_P1_UP = 0x11,
DDR_P1_DOWN = 0x12,
DDR_P1_LEFT = 0x13,
DDR_P1_RIGHT = 0x14,
DDR_P1_MENU_LEFT = 0x16,
DDR_P1_MENU_RIGHT = 0x17,
DDR_P1_MENU_UP = 0x00,
DDR_P1_MENU_DOWN = 0x01,
};
// see the functions below for more information
enum p3io_light_bit {
LIGHT_P1_MENU = 0x00,
LIGHT_P2_MENU = 0x01,
LIGHT_P2_LOWER_LAMP = 0x04,
LIGHT_P2_UPPER_LAMP = 0x05,
LIGHT_P1_LOWER_LAMP = 0x06,
LIGHT_P1_UPPER_LAMP = 0x07,
};
enum hdxs_light_bit {
LIGHT_HD_P1_START = 0x08,
LIGHT_HD_P1_UP_DOWN = 0x09,
LIGHT_HD_P1_LEFT_RIGHT = 0x0A,
LIGHT_HD_P2_START = 0x0B,
LIGHT_HD_P2_UP_DOWN = 0x0C,
LIGHT_HD_P2_LEFT_RIGHT = 0x0D,
};
// the indexing starts from 0x20 if you're looking in geninput
enum hdxs_rgb_light_idx {
LIGHT_HD_P1_SPEAKER_F_R = 0x00,
LIGHT_HD_P1_SPEAKER_F_G = 0x01,
LIGHT_HD_P1_SPEAKER_F_B = 0x02,
LIGHT_HD_P2_SPEAKER_F_R = 0x03,
LIGHT_HD_P2_SPEAKER_F_G = 0x04,
LIGHT_HD_P2_SPEAKER_F_B = 0x05,
LIGHT_HD_P1_SPEAKER_W_R = 0x06,
LIGHT_HD_P1_SPEAKER_W_G = 0x07,
LIGHT_HD_P1_SPEAKER_W_B = 0x08,
LIGHT_HD_P2_SPEAKER_W_R = 0x09,
LIGHT_HD_P2_SPEAKER_W_G = 0x0A,
LIGHT_HD_P2_SPEAKER_W_B = 0x0B,
};
enum extio_light_bit {
LIGHT_NEONS = 0x0E,
LIGHT_P2_RIGHT = 0x13,
LIGHT_P2_LEFT = 0x14,
LIGHT_P2_DOWN = 0x15,
LIGHT_P2_UP = 0x16,
LIGHT_P1_RIGHT = 0x1B,
LIGHT_P1_LEFT = 0x1C,
LIGHT_P1_DOWN = 0x1D,
LIGHT_P1_UP = 0x1E
};
/* The first function that will be called on your DLL. You will be supplied
with four function pointers that may be used to log messages to the game's
log file. See comments in glue.h for further information. */
void ddr_io_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal);
/* Initialize your DDR IO emulation DLL. Thread management functions are
provided to you; you must use these functions to create your own threads if
you want to make use of the logging functions that are provided to
eam_io_set_loggers(). You will also need to pass these thread management
functions on to geninput if you intend to make use of that library.
See glue.h and geninput.h for further details. */
bool ddr_io_init(
thread_create_t thread_create,
thread_join_t thread_join,
thread_destroy_t thread_destroy);
/* used to poll the IO for input, note that this is also where lights are
flushed to the device for geninput */
uint32_t ddr_io_read_pad(void);
/* The following are optional to implement, and allow lights to be set and
emulated as needed */
/* used to set pad lights, as well as the bass neon on SD cabs */
void ddr_io_set_lights_extio(uint32_t extio_lights);
/* used to set SD panel lights, and HD spot lights */
void ddr_io_set_lights_p3io(uint32_t p3io_lights);
/* used to set HD cab front panel lights */
void ddr_io_set_lights_hdxs_panel(uint32_t hdxs_lights);
/* used to set HD cab speaker RGB lights */
void ddr_io_set_lights_hdxs_rgb(uint8_t idx, uint8_t r, uint8_t g, uint8_t b);
void ddr_io_fini(void);
#endif
-137
View File
@@ -1,137 +0,0 @@
#ifndef BEMANITOOLS_EAM_H
#define BEMANITOOLS_EAM_H
/* Card reader emulator API. You may replace the stock EAMIO.DLL supplied by
Bemanitools with your own custom implementation, which should implement the
interface contract defined in this header file. */
#include <stdbool.h>
#include <stdint.h>
#include "bemanitools/glue.h"
/* Scan codes for the so-called "10 key" button panel on each card reader. Each
scan code corresponds to a bit position within the 16-bit bitfield that you
return from eam_io_get_keypad_state(). */
enum eam_io_keypad_scan_code {
EAM_IO_KEYPAD_0 = 0,
EAM_IO_KEYPAD_1 = 1,
EAM_IO_KEYPAD_4 = 2,
EAM_IO_KEYPAD_7 = 3,
EAM_IO_KEYPAD_00 = 4,
EAM_IO_KEYPAD_2 = 5,
EAM_IO_KEYPAD_5 = 6,
EAM_IO_KEYPAD_8 = 7,
EAM_IO_KEYPAD_DECIMAL = 8,
EAM_IO_KEYPAD_3 = 9,
EAM_IO_KEYPAD_6 = 10,
EAM_IO_KEYPAD_9 = 11,
EAM_IO_KEYPAD_COUNT = 12, /* Not an actual scan code */
};
/* Emulating the sensors of a slotted card reader. The reader has one
sensor at the front that detects if a card is getting inserted or
if the card is not fully removed. When the back sensor is triggered
the card is locked in the slot and its data is read. */
enum eam_io_sensor_state {
EAM_IO_SENSOR_FRONT = 0,
EAM_IO_SENSOR_BACK = 1,
};
/* Different commands for the (slotted) reader. The game triggers one
of these actions and the card slot as to execute it. When non-slotted
readers are emulated, these states are not used/set. */
enum eam_io_card_slot_cmd {
EAM_IO_CARD_SLOT_CMD_CLOSE = 0,
EAM_IO_CARD_SLOT_CMD_OPEN = 1,
EAM_IO_CARD_SLOT_CMD_EJECT = 2,
EAM_IO_CARD_SLOT_CMD_READ = 3,
};
/* Emulating of the card type for new readers. */
enum eam_io_read_card_result {
EAM_IO_CARD_NONE = 0,
EAM_IO_CARD_ISO15696 = 1,
EAM_IO_CARD_FELICA = 2,
};
/* A private function pointer table returned by the stock EAMIO.DLL
implementation and consumed by config.exe. The contents of this table are
undocumented and subject to change without notice. */
struct eam_io_config_api;
/* The first function that will be called on your DLL. You will be supplied
with four function pointers that may be used to log messages to the game's
log file. See comments in glue.h for further information. */
void eam_io_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal);
/* Initialize your card reader emulation DLL. Thread management functions are
provided to you; you must use these functions to create your own threads if
you want to make use of the logging functions that are provided to
eam_io_set_loggers(). You will also need to pass these thread management
functions on to geninput if you intend to make use of that library.
See glue.h and geninput.h for further details. */
bool eam_io_init(
thread_create_t thread_create,
thread_join_t thread_join,
thread_destroy_t thread_destroy);
/* Shut down your card reader emulation DLL. */
void eam_io_fini(void);
/* Return the state of the number pad on your reader. This function will be
called frequently. See enum eam_io_keypad_scan_code above for the meaning of
each bit within the return value.
This function will be called even if the running game does not actually have
a number pad on the real cabinet (e.g. Jubeat).
unit_no is either 0 or 1. Games with only a single reader (jubeat, popn,
drummania) will only use unit_no 0. */
uint16_t eam_io_get_keypad_state(uint8_t unit_no);
/* Indicate which sensors (front and back) are triggered for a slotted reader
(refer to enum). To emulate non-slotted readers, just set both sensors
to on to indicate the card is in range of the reader. This function
will be called frequently. */
uint8_t eam_io_get_sensor_state(uint8_t unit_no);
/* Read a card ID. This function is only called when the return value of
eam_io_get_sensor_state() changes from false to true, so you may take your
time and perform file I/O etc, within reason. You must return exactly eight
bytes into the buffer pointed to by card_id. */
uint8_t eam_io_read_card(uint8_t unit_no, uint8_t *card_id, uint8_t nbytes);
/* Send a command to the card slot. This is called by the game to execute
certain actions on a slotted reader (refer to enum). When emulating
wave pass readers, this is function is never called. */
bool eam_io_card_slot_cmd(uint8_t unit_no, uint8_t cmd);
/* This function is called frequently. Update your device and states in here */
bool eam_io_poll(uint8_t unit_no);
/* Return a pointer to an internal configuration API for use by config.exe.
Custom implementations should return NULL. */
const struct eam_io_config_api *eam_io_get_config_api(void);
#endif
-47
View File
@@ -1,47 +0,0 @@
#ifndef BEMANITOOLS_GLUE_H
#define BEMANITOOLS_GLUE_H
/* Common definitions for integration bindings */
#include <stdint.h>
#ifdef __GNUC__
/* Bemanitools is compiled with GCC (MinGW, specifically) as of version 5 */
#define LOG_CHECK_FMT __attribute__((format(printf, 2, 3)))
#else
/* Compile it out for MSVC plebs */
#define LOG_CHECK_FMT
#endif
/* An AVS-style logger function. Comes in four flavors: misc, info, warning,
and fatal, with increasing severity. Fatal loggers do not return, they
abort the running process after writing their message to the log.
"module" is an arbitrary short string identifying the source of the log
message. The name of the calling DLL is a good default choice for this
string, although you might want to identify a module within your DLL here
instead.
"fmt" is a printf-style format string. Depending on the context in which
your DLL is running you might end up calling a logger function exported
from libavs, which has its own printf implementation (including a number of
proprietary extensions), so don't use any overly exotic formats. */
typedef void (*log_formatter_t)(const char *module, const char *fmt, ...)
LOG_CHECK_FMT;
/* An API for spawning threads. This API is defined by libavs, although
Bemanitools itself may supply compatible implementations of these functions
to your DLL, depending on the context in which it runs.
NOTE: You may only use the logging functions from a thread where Bemanitools
calls you, or a thread that you create using this API. Failure to observe
this restriction will cause the process to crash. This is a limitation of
libavs itself, not Bemanitools. */
typedef int (*thread_create_t)(
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
typedef void (*thread_join_t)(int thread_id, int *result);
typedef void (*thread_destroy_t)(int thread_id);
#endif
-174
View File
@@ -1,174 +0,0 @@
#ifndef BEMANITOOLS_IIDXIO_H
#define BEMANITOOLS_IIDXIO_H
/* IO emulation provider for beatmania IIDX. */
#include <stdbool.h>
#include <stdint.h>
#include "bemanitools/glue.h"
/* Bit mapping for the "pad" word */
enum iidx_io_sys_bit {
IIDX_IO_SYS_TEST = 0x00,
IIDX_IO_SYS_SERVICE = 0x01,
IIDX_IO_SYS_COIN = 0x02
};
enum iidx_io_panel_bit {
IIDX_IO_PANEL_P1_START = 0x00,
IIDX_IO_PANEL_P2_START = 0x01,
IIDX_IO_PANEL_VEFX = 0x02,
IIDX_IO_PANEL_EFFECT = 0x03
};
enum iidx_io_key_bit {
IIDX_IO_KEY_P1_1 = 0x00,
IIDX_IO_KEY_P1_2 = 0x01,
IIDX_IO_KEY_P1_3 = 0x02,
IIDX_IO_KEY_P1_4 = 0x03,
IIDX_IO_KEY_P1_5 = 0x04,
IIDX_IO_KEY_P1_6 = 0x05,
IIDX_IO_KEY_P1_7 = 0x06,
IIDX_IO_KEY_P2_1 = 0x07,
IIDX_IO_KEY_P2_2 = 0x08,
IIDX_IO_KEY_P2_3 = 0x09,
IIDX_IO_KEY_P2_4 = 0x0A,
IIDX_IO_KEY_P2_5 = 0x0B,
IIDX_IO_KEY_P2_6 = 0x0C,
IIDX_IO_KEY_P2_7 = 0x0D
};
/* Bit mapping for the P1 and P2 deck lights */
enum iidx_io_deck_light {
IIDX_IO_DECK_LIGHT_P1_1 = 0,
IIDX_IO_DECK_LIGHT_P1_2 = 1,
IIDX_IO_DECK_LIGHT_P1_3 = 2,
IIDX_IO_DECK_LIGHT_P1_4 = 3,
IIDX_IO_DECK_LIGHT_P1_5 = 4,
IIDX_IO_DECK_LIGHT_P1_6 = 5,
IIDX_IO_DECK_LIGHT_P1_7 = 6,
IIDX_IO_DECK_LIGHT_P2_1 = 8,
IIDX_IO_DECK_LIGHT_P2_2 = 9,
IIDX_IO_DECK_LIGHT_P2_3 = 10,
IIDX_IO_DECK_LIGHT_P2_4 = 11,
IIDX_IO_DECK_LIGHT_P2_5 = 12,
IIDX_IO_DECK_LIGHT_P2_6 = 13,
IIDX_IO_DECK_LIGHT_P2_7 = 14,
};
/* Bit mapping for the front panel lights */
enum iidx_io_panel_light {
IIDX_IO_PANEL_LIGHT_P1_START = 0,
IIDX_IO_PANEL_LIGHT_P2_START = 1,
IIDX_IO_PANEL_LIGHT_VEFX = 2,
IIDX_IO_PANEL_LIGHT_EFFECT = 3,
};
/* Bit mapping for the top lamps from left to right when facing cabinet screen
*/
enum iidx_io_top_lamp {
IIDX_IO_TOP_LAMP_LEFT_BLUE = 0,
IIDX_IO_TOP_LAMP_LEFT_GREEN = 1,
IIDX_IO_TOP_LAMP_LEFT_YELLOW = 2,
IIDX_IO_TOP_LAMP_LEFT_RED = 3,
IIDX_IO_TOP_LAMP_RIGHT_BLUE = 4,
IIDX_IO_TOP_LAMP_RIGHT_GREEN = 5,
IIDX_IO_TOP_LAMP_RIGHT_YELLOW = 6,
IIDX_IO_TOP_LAMP_RIGHT_RED = 7,
};
/* The first function that will be called on your DLL. You will be supplied
with four function pointers that may be used to log messages to the game's
log file. See comments in glue.h for further information. */
void iidx_io_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal);
/* Initialize your IIDX IO emulation DLL. Thread management functions are
provided to you; you must use these functions to create your own threads if
you want to make use of the logging functions that are provided to
eam_io_set_loggers(). You will also need to pass these thread management
functions on to geninput if you intend to make use of that library.
See glue.h and geninput.h for further details. */
bool iidx_io_init(
thread_create_t thread_create,
thread_join_t thread_join,
thread_destroy_t thread_destroy);
/* Shut down your IIDX IO emulation DLL */
void iidx_io_fini(void);
/* Set the deck lighting state. See enum iidx_io_deck_light above. */
void iidx_io_ep1_set_deck_lights(uint16_t deck_lights);
/* Set front panel lighting state. See enum iidx_io_panel_light above. */
void iidx_io_ep1_set_panel_lights(uint8_t panel_lights);
/* Set state of the eight halogens above the marquee. */
void iidx_io_ep1_set_top_lamps(uint8_t top_lamps);
/* Switch the top neons on or off. */
void iidx_io_ep1_set_top_neons(bool top_neons);
/* Transmit the lighting state to the lighting controller. This function is
called immediately after all of the other iidx_io_ep1_set_*() functions.
Return false in the event of an IO error. This will lock the game into an
IO error screen. */
bool iidx_io_ep1_send(void);
/* Read input state from the input controller. This function is called
immediately before all of the iidx_io_ep2_get_*() functions.
Return false in the event of an IO error. This will lock the game into an
IO error screen. */
bool iidx_io_ep2_recv(void);
/* Get absolute turntable position, expressed in 1/256ths of a rotation.
player_no is either 0 or 1. */
uint8_t iidx_io_ep2_get_turntable(uint8_t player_no);
/* Get slider position, where 0 is the bottom position and 15 is the topmost
position. slider_no is a number between 0 (leftmost) and 4 (rightmost). */
uint8_t iidx_io_ep2_get_slider(uint8_t slider_no);
/* Get the state of the system buttons. See enums above. */
uint8_t iidx_io_ep2_get_sys(void);
/* Get the state of the panel buttons. See enums above. */
uint8_t iidx_io_ep2_get_panel(void);
/* Get the state of the 14 key buttons. See enums above. */
uint16_t iidx_io_ep2_get_keys(void);
/* Write a nine-character string to the 16-segment display. This happens on a
different schedule to all of the other IO operations, so you should initiate
the communication as soon as this function is called */
bool iidx_io_ep3_write_16seg(const char *text);
#endif
-92
View File
@@ -1,92 +0,0 @@
#ifndef BEMANITOOLS_INPUT_H
#define BEMANITOOLS_INPUT_H
/* Generic input API. This header file defines the public API for geninput.dll.
You may use geninput to supply generic input mapping services for controls
that your custom IO DLLs do not natively provide. For instance, you might
want to make a custom IIDXIO.DLL that interfaces with your own 16-segment
LCD marquee device while still using the stock IIDXIO.DLL input and lighting
code, which uses the generic services provided by geninput.dll.
All other exports from geninput.dll are undocumented and subject to change
without notice. */
#include <stdbool.h>
#include <stdint.h>
#include "bemanitools/glue.h"
/* Supply logging functions to geninput. You should pass on the logging
functions that are supplied to your own custom DLLs.
This is the only function that can safely be called before input_init(). */
void input_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal);
/* Initialize the generic input subsystem. You must pass on the thread
management functions that have been supplied to your DLL.
Calling any geninput functions other than input_set_loggers() before calling
input_init() will probably crash the running process.
You will also need to call mapper_config_load() with the appropriate
game_type parameter, otherwise you will not receive any input, and any
attempts to set a light output level will have no effect. */
void input_init(
thread_create_t thread_create,
thread_join_t thread_join,
thread_destroy_t thread_destroy);
/* Shut down the generic input subsystem. After calling this function, no
geninput functions other than input_set_loggers() or input_init() may be
called. */
void input_fini(void);
/* Load input mappings for a particular game, as configured from config.exe.
Currently recognized game types are:
ddr: Dance Dance Revolution
dm: Drum Mania
gf: Guitar Freaks
iidx: beatmania IIDX
pnm: pop'n music
sdvx: Sound Voltex
ju: jubeat
Returns true if a suitable config file was found and successfully loaded. */
bool mapper_config_load(const char *game_type);
/* Return the absolute position of an analog spinner, expressed in 1/256ths of
a complete rotation. */
uint8_t mapper_read_analog(uint8_t analog);
/* Map the current state of all attached input devices to a 64-bit bit field.
The exact layout of this bit field varies between game types, although we
try to approximate the contents of each emulated IO PCB's own state packet
as closely as is reasonably practical. */
uint64_t mapper_update(void);
/* Set the intensity of any light on a controller corresponding to a particular
software-controlled light on an arcade cabinet, where 0 is off and 255 is
full intensity. Consult the header files for the light identifiers used for
each game type. The mappings between these light identifiers and the actual
lights on the user's controller (if any) are configured by the user by means
of the config.exe program.
Note that any calls to this function do not take effect until the next call
to mapper_update(). */
void mapper_write_light(uint8_t light, uint8_t intensity);
#endif
-120
View File
@@ -1,120 +0,0 @@
#ifndef BEMANITOOLS_JBIO_H
#define BEMANITOOLS_JBIO_H
/* IO emulation provider for jubeat. */
#include <stdbool.h>
#include <stdint.h>
#include "bemanitools/glue.h"
/* input bit mappings. Panels on the controller are
panel 1 top left corner down to panel 16 bottom right corner */
enum jb_io_panel_bit {
JB_IO_PANEL_01 = 0x00,
JB_IO_PANEL_02 = 0x01,
JB_IO_PANEL_03 = 0x02,
JB_IO_PANEL_04 = 0x03,
JB_IO_PANEL_05 = 0x04,
JB_IO_PANEL_06 = 0x05,
JB_IO_PANEL_07 = 0x06,
JB_IO_PANEL_08 = 0x07,
JB_IO_PANEL_09 = 0x08,
JB_IO_PANEL_10 = 0x09,
JB_IO_PANEL_11 = 0x0A,
JB_IO_PANEL_12 = 0x0B,
JB_IO_PANEL_13 = 0x0C,
JB_IO_PANEL_14 = 0x0D,
JB_IO_PANEL_15 = 0x0E,
JB_IO_PANEL_16 = 0x0F,
};
/* input "single button mode" mappings. Allows you to check each corner of each
button to determine any flaky inputs
*/
enum jb_io_panel_mode {
JB_IO_PANEL_MODE_ALL = 0, // any of the four corners will trigger a panel
JB_IO_PANEL_MODE_TOP_LEFT = 1,
JB_IO_PANEL_MODE_TOP_RIGHT = 2,
JB_IO_PANEL_MODE_BOTTOM_RIGHT = 3,
JB_IO_PANEL_MODE_BOTTOM_LEFT = 4,
};
/* Bit mappings for "system" inputs */
enum jb_io_sys_bit {
JB_IO_SYS_TEST = 0x00,
JB_IO_SYS_SERVICE = 0x01,
JB_IO_SYS_COIN = 0x02,
};
/* RGB led units to address */
enum jb_io_rgb_led {
JB_IO_RGB_LED_FRONT = 0,
JB_IO_RGB_LED_TOP = 1,
JB_IO_RGB_LED_LEFT = 2,
JB_IO_RGB_LED_RIGHT = 3,
JB_IO_RGB_LED_TITLE = 4,
JB_IO_RGB_LED_WOOFER = 5
};
/* The first function that will be called on your DLL. You will be supplied
with four function pointers that may be used to log messages to the game's
log file. See comments in glue.h for further information. */
void jb_io_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal);
/* Initialize your JB IO emulation DLL. Thread management functions are
provided to you; you must use these functions to create your own threads if
you want to make use of the logging functions that are provided to
jb_io_set_loggers(). You will also need to pass these thread management
functions on to geninput if you intend to make use of that library.
See glue.h and geninput.h for further details. */
bool jb_io_init(
thread_create_t thread_create,
thread_join_t thread_join,
thread_destroy_t thread_destroy);
/* Shut down your JB IO emulation DLL */
void jb_io_fini(void);
/* Read input state */
bool jb_io_read_inputs(void);
/* Get state of coin, test, service inputs */
uint8_t jb_io_get_sys_inputs(void);
/* Get panel button state. Will return either any button being pressed, or a
particular panel corner depending on previous call to jb_io_set_panel_mode */
uint16_t jb_io_get_panel_inputs(void);
/* Set state of a PWM (dimmable) light */
void jb_io_set_rgb_led(
enum jb_io_rgb_led unit, uint8_t r, uint8_t g, uint8_t b);
/* Transmit the light state to the IOPCB */
bool jb_io_write_lights(void);
/* Select operating mode for the panel. Should be immediately sent to the IOPCB
*/
bool jb_io_set_panel_mode(enum jb_io_panel_mode mode);
/* Open or close the coin chute - true will redirect all coins to the return
slot. Required for jb_io_set_panel_mode to operate correctly on p4io.
Should be immediately sent to the IOPCB */
bool jb_io_set_coin_blocker(bool blocked);
#endif
-108
View File
@@ -1,108 +0,0 @@
#ifndef BEMANITOOLS_POPNIO_H
#define BEMANITOOLS_POPNIO_H
/* IO emulation provider for pop'n music. */
#include <stdbool.h>
#include <stdint.h>
#include "bemanitools/glue.h"
/* Bit mapping for the "buttons" word */
enum popn_io_sys_bit {
POPN_IO_SYS_SERVICE = 0x06,
POPN_IO_SYS_TEST = 0x07,
};
enum popn_io_button_bit {
POPN_IO_BUTTON_1 = 0x08,
POPN_IO_BUTTON_2 = 0x09,
POPN_IO_BUTTON_3 = 0x0a,
POPN_IO_BUTTON_4 = 0x0b,
POPN_IO_BUTTON_5 = 0x0c,
POPN_IO_BUTTON_6 = 0x0d,
POPN_IO_BUTTON_7 = 0x0e,
POPN_IO_BUTTON_8 = 0x0f,
POPN_IO_BUTTON_9 = 0x10,
};
enum popn_io_light_top_lamp_bit {
POPN_LIGHT_HI_LAMP1 = 0x00,
POPN_LIGHT_HI_LAMP2 = 0x01,
POPN_LIGHT_HI_LAMP3 = 0x02,
POPN_LIGHT_HI_LAMP4 = 0x03,
POPN_LIGHT_HI_LAMP5 = 0x04,
};
enum popn_io_light_side_lamp_bit {
POPN_LIGHT_LEFT_LAMP1 = 0x00,
POPN_LIGHT_LEFT_LAMP2 = 0x01,
POPN_LIGHT_RIGHT_LAMP1 = 0x02,
POPN_LIGHT_RIGHT_LAMP2 = 0x03,
};
enum popn_io_light_switch_lamp_bit {
POPN_LIGHT_SW_LAMP1 = 0x00, // Is actually 4 bits wide
POPN_LIGHT_SW_LAMP2 = 0x04,
POPN_LIGHT_SW_LAMP3 = 0x05,
POPN_LIGHT_SW_LAMP4 = 0x06,
POPN_LIGHT_SW_LAMP5 = 0x07,
POPN_LIGHT_SW_LAMP6 = 0x08,
POPN_LIGHT_SW_LAMP7 = 0x09,
POPN_LIGHT_SW_LAMP8 = 0x0a,
POPN_LIGHT_SW_LAMP9 = 0x0b,
};
/* The first function that will be called on your DLL. You will be supplied
with four function pointers that may be used to log messages to the game's
log file. See comments in glue.h for further information. */
void popn_io_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal);
/* Initialize your pop'n music IO emulation DLL. Thread management functions are
provided to you; you must use these functions to create your own threads if
you want to make use of the logging functions that are provided to
eam_io_set_loggers(). You will also need to pass these thread management
functions on to geninput if you intend to make use of that library.
See glue.h and geninput.h for further details. */
bool popn_io_init(
thread_create_t thread_create,
thread_join_t thread_join,
thread_destroy_t thread_destroy);
/* Shut down your pop'n music IO emulation DLL */
void popn_io_fini(void);
/* Get the state of the buttons. See enums above. */
uint32_t popn_io_get_buttons(void);
/* Set the top light state. See enum popn_io_light_top_lamp_bit above. */
void popn_io_set_top_lights(uint32_t lights);
/* Set the side light state. See enum popn_io_light_side_lamp_bit above. */
void popn_io_set_side_lights(uint32_t lights);
/* Set the button light state. See enum popn_io_light_switch_lamp_bit above. */
void popn_io_set_button_lights(uint32_t lights);
/* Set the coin blocker light state. */
void popn_io_set_coin_blocker_light(bool enabled);
/* Set the coin counter light state. */
void popn_io_set_coin_counter_light(bool enabled);
#endif
-108
View File
@@ -1,108 +0,0 @@
#ifndef BEMANITOOLS_SDVXIO_H
#define BEMANITOOLS_SDVXIO_H
/* IO emulation provider for SOUND VOLTEX */
#include <stdbool.h>
#include <stdint.h>
#include "bemanitools/glue.h"
enum sdvx_io_in_gpio_sys_bit {
SDVX_IO_IN_GPIO_SYS_COIN = 2,
SDVX_IO_IN_GPIO_SYS_SERVICE = 4,
SDVX_IO_IN_GPIO_SYS_TEST = 5,
};
enum sdvx_io_in_gpio_0_bit {
SDVX_IO_IN_GPIO_0_C = 0,
SDVX_IO_IN_GPIO_0_B = 1,
SDVX_IO_IN_GPIO_0_A = 2,
SDVX_IO_IN_GPIO_0_START = 3,
SDVX_IO_IN_GPIO_0_RECORDER = 4,
SDVX_IO_IN_GPIO_0_HEADPHONE = 5,
};
enum sdvx_io_in_gpio_1_bit {
SDVX_IO_IN_GPIO_1_FX_R = 3,
SDVX_IO_IN_GPIO_1_FX_L = 4,
SDVX_IO_IN_GPIO_1_D = 5,
};
enum sdvx_io_out_gpio_bit {
SDVX_IO_OUT_GPIO_D = 0,
SDVX_IO_OUT_GPIO_FX_L = 1,
SDVX_IO_OUT_GPIO_FX_R = 2,
SDVX_IO_OUT_GPIO_GENERATOR_B = 3,
SDVX_IO_OUT_GPIO_START = 12,
SDVX_IO_OUT_GPIO_A = 13,
SDVX_IO_OUT_GPIO_B = 14,
SDVX_IO_OUT_GPIO_C = 15,
};
/* The first function that will be called on your DLL. You will be supplied
with four function pointers that may be used to log messages to the game's
log file. See comments in glue.h for further information. */
void sdvx_io_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal);
/* Initialize your SDVX IO emulation DLL. Thread management functions are
provided to you; you must use these functions to create your own threads if
you want to make use of the logging functions that are provided to
eam_io_set_loggers(). You will also need to pass these thread management
functions on to geninput if you intend to make use of that library.
See glue.h and geninput.h for further details. */
bool sdvx_io_init(
thread_create_t thread_create,
thread_join_t thread_join,
thread_destroy_t thread_destroy);
/* Shut down your SDVX IO emulation DLL */
void sdvx_io_fini(void);
/* Set state of the GPIO (on/off) lights (see bit definitions above) */
void sdvx_io_set_gpio_lights(uint32_t gpio_lights);
/* Set state of a PWM (dimmable) light channel. These come in groups of three
(red, green, blue). There are a six group of three PWM channels, for a
total of 18 channels (0 through 17). */
void sdvx_io_set_pwm_light(uint8_t light_no, uint8_t intensity);
/* Transmit the light state to the IOPCB */
bool sdvx_io_write_output(void);
/* Read input state */
bool sdvx_io_read_input(void);
/* Get state of coin, test, service inputs */
uint8_t sdvx_io_get_input_gpio_sys(void);
/* Get gameplay button state. Parameter selects GPIO bank 0 or 1. See bit
definitions above for details. */
uint16_t sdvx_io_get_input_gpio(uint8_t gpio_bank);
/* Get a 10-bit (!) spinner position, where spinner_no is 0 or 1.
High six bits are ignored. */
uint16_t sdvx_io_get_spinner_pos(uint8_t spinner_no);
/* Sets the volume of the digital amps if possible.
Range is between 0-96, where 0 is MAX and 96 is LOW. */
bool sdvx_io_set_amp_volume(
uint8_t primary, uint8_t headphone, uint8_t subwoofer);
#endif
-61
View File
@@ -1,61 +0,0 @@
#ifndef BEMANITOOLS_VEFXIO_H
#define BEMANITOOLS_VEFXIO_H
/* IO emulation provider for beatmania IIDX Effector Panel. */
#include <stdbool.h>
#include <stdint.h>
#include "bemanitools/glue.h"
/* The first function that will be called on your DLL. You will be supplied
with four function pointers that may be used to log messages to the game's
log file. See comments in glue.h for further information. */
void vefx_io_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal);
/* Initialize your IIDX IO emulation DLL. Thread management functions are
provided to you; you must use these functions to create your own threads if
you want to make use of the logging functions that are provided to
eam_io_set_loggers(). You will also need to pass these thread management
functions on to geninput if you intend to make use of that library.
See glue.h and geninput.h for further details. */
bool vefx_io_init(
thread_create_t thread_create,
thread_join_t thread_join,
thread_destroy_t thread_destroy);
/* Shut down your IIDX IO emulation DLL */
void vefx_io_fini(void);
/* Read input state from the input controller. This function is called
immediately before the vefx_io_get_slider() function.
Return false in the event of an IO error. This will lock the game into an
IO error screen.
If making a custom driver, ppad can be used to update regular IO if needed
See iidxio.c for mappings. */
bool vefx_io_recv(uint64_t *ppad);
/* Get slider position, where 0 is the bottom position and 15 is the topmost
position. slider_no is a number between 0 (leftmost) and 4 (rightmost). */
uint8_t vefx_io_get_slider(uint8_t slider_no);
/* Write a nine-character string to the 16-segment display. This happens on a
different schedule to all of the other IO operations, so you should initiate
the communication as soon as this function is called */
bool vefx_io_write_16seg(const char *text);
#endif
+1 -1
View File
@@ -7,7 +7,7 @@
#include "aciodrv/device.h"
#include "core/log.h"
#include "iface-core/log.h"
// Must be provided on init command. Actual meaning unknown right now.
// Not providing this will not initialize the IO correctly resulting
+1 -1
View File
@@ -7,7 +7,7 @@
#include "aciodrv/device.h"
#include "core/log.h"
#include "iface-core/log.h"
static const uint8_t _BIO2DR_BI2A_SDVX_INIT_DATA = 0x3B;
+3 -3
View File
@@ -1,8 +1,8 @@
#include "bio2drv/config-bio2.h"
#include "cconfig/cconfig-util.h"
#include "core/log.h"
#include "bio2drv/config-bio2.h"
#include "iface-core/log.h"
#define BIO2DRV_CONFIG_BIO2_AUTO_KEY "bio2.autodetect"
#define BIO2DRV_CONFIG_BIO2_PORT_KEY "bio2.port"
+4 -13
View File
@@ -6,13 +6,13 @@
#include <cfgmgr32.h>
#include <setupapi.h>
#include "bio2drv/detect.h"
#include "core/log.h"
#include <stdio.h>
#include <string.h>
#include "bio2drv/detect.h"
#include "iface-core/log.h"
DEFINE_GUID(
GUID_COM_BUS_ENUMERATOR,
0x4D36E978,
@@ -136,15 +136,6 @@ static bool get_device_by_filter(
return false;
}
void bio2drv_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal)
{
core_log_impl_set(misc, warning, info, fatal);
}
bool bio2drv_detect(
enum bio2drv_detect_mode mode, size_t index, char *path, size_t length)
{
-8
View File
@@ -3,20 +3,12 @@
#include <stdbool.h>
#include "bemanitools/glue.h"
enum bio2drv_detect_mode {
DETECT_DEVICEDESC = 0x1, // look for serial devices containing BIO2(VIDEO)
DETECT_FRIENDLYNAME = 0x2, // look for serial devices containing BIO2(VIDEO)
DETECT_DEVICEID = 0x3, // look for serial devices by vid/pid
};
void bio2drv_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal);
bool bio2drv_detect(
enum bio2drv_detect_mode mode, size_t devnum, char *path, size_t length);
+42 -41
View File
@@ -10,9 +10,10 @@
#include <string.h>
#include "acioemu/emu.h"
#include "util/math.h"
#include "bemanitools/iidxio.h"
#include "iface-io/iidx.h"
#include "util/math.h"
static int get_default_slider_valid(size_t idx);
static void bio2_emu_bi2a_cmd_send_version(
@@ -178,7 +179,7 @@ static void bio2_emu_bi2a_send_status(
static int16_t tt_mult_delta(size_t tt_no)
{
int16_t current_tt = iidx_io_ep2_get_turntable(tt_no);
int16_t current_tt = bt_io_iidx_ep2_turntable_get(tt_no);
int16_t delta = get_wrapped_delta_s16(current_tt, tt_last[tt_no], 256);
tt_last[tt_no] = current_tt;
@@ -233,17 +234,17 @@ bio2_emu_bi2a_send_state(struct ac_io_emu *emu, const struct ac_io_message *req)
}
}
iidx_io_ep1_set_deck_lights(packed_lights.deck_lights);
iidx_io_ep1_set_panel_lights(packed_lights.panel_lights);
iidx_io_ep1_set_top_lamps(packed_lights.top_lamps);
iidx_io_ep1_set_top_neons(req_bi2a->NEONLAMP.l_state);
bt_io_iidx_ep1_deck_lights_set(packed_lights.deck_lights);
bt_io_iidx_ep1_panel_lights_set(packed_lights.panel_lights);
bt_io_iidx_ep1_top_lamps_set(packed_lights.top_lamps);
bt_io_iidx_ep1_top_neons_set(req_bi2a->NEONLAMP.l_state);
if (!iidx_io_ep1_send()) {
if (!bt_io_iidx_ep1_send()) {
log_warning("BIO2: iidx_io_ep1_send error");
return bio2_emu_bi2a_send_status(emu, req, 0);
}
if (!iidx_io_ep3_write_16seg((const char *) req_bi2a->SEG16)) {
if (!bt_io_iidx_ep3_16seg_send((const char *) req_bi2a->SEG16)) {
log_warning("BIO2: iidx_io_ep3_write_16seg error");
return bio2_emu_bi2a_send_status(emu, req, 0);
}
@@ -256,7 +257,7 @@ bio2_emu_bi2a_send_state(struct ac_io_emu *emu, const struct ac_io_message *req)
Sleep(1);
}
if (!iidx_io_ep2_recv()) {
if (!bt_io_iidx_ep2_recv()) {
log_warning("BIO2: iidx_io_ep2_recv error");
return bio2_emu_bi2a_send_status(emu, req, 0);
}
@@ -268,52 +269,52 @@ bio2_emu_bi2a_send_state(struct ac_io_emu *emu, const struct ac_io_message *req)
body->TURNTABLE1 = tt_accum[0];
body->TURNTABLE2 = tt_accum[1];
} else {
body->TURNTABLE1 = iidx_io_ep2_get_turntable(0);
body->TURNTABLE2 = iidx_io_ep2_get_turntable(1);
body->TURNTABLE1 = bt_io_iidx_ep2_turntable_get(0);
body->TURNTABLE2 = bt_io_iidx_ep2_turntable_get(1);
}
body->SLIDER1.s_val = get_default_slider_valid(0) ?
default_sliders[0] :
iidx_io_ep2_get_slider(0);
bt_io_iidx_ep2_slider_get(0);
body->SLIDER2.s_val = get_default_slider_valid(1) ?
default_sliders[1] :
iidx_io_ep2_get_slider(1);
bt_io_iidx_ep2_slider_get(1);
body->SLIDER3.s_val = get_default_slider_valid(2) ?
default_sliders[2] :
iidx_io_ep2_get_slider(2);
bt_io_iidx_ep2_slider_get(2);
body->SLIDER4.s_val = get_default_slider_valid(3) ?
default_sliders[3] :
iidx_io_ep2_get_slider(3);
bt_io_iidx_ep2_slider_get(3);
body->SLIDER5.s_val = get_default_slider_valid(4) ?
default_sliders[4] :
iidx_io_ep2_get_slider(4);
bt_io_iidx_ep2_slider_get(4);
input_keys = iidx_io_ep2_get_keys();
input_sys = iidx_io_ep2_get_sys();
input_panel = iidx_io_ep2_get_panel();
body->P1SW1.b_val = (input_keys >> IIDX_IO_KEY_P1_1) & 1;
body->P1SW2.b_val = (input_keys >> IIDX_IO_KEY_P1_2) & 1;
body->P1SW3.b_val = (input_keys >> IIDX_IO_KEY_P1_3) & 1;
body->P1SW4.b_val = (input_keys >> IIDX_IO_KEY_P1_4) & 1;
body->P1SW5.b_val = (input_keys >> IIDX_IO_KEY_P1_5) & 1;
body->P1SW6.b_val = (input_keys >> IIDX_IO_KEY_P1_6) & 1;
body->P1SW7.b_val = (input_keys >> IIDX_IO_KEY_P1_7) & 1;
body->P2SW1.b_val = (input_keys >> IIDX_IO_KEY_P2_1) & 1;
body->P2SW2.b_val = (input_keys >> IIDX_IO_KEY_P2_2) & 1;
body->P2SW3.b_val = (input_keys >> IIDX_IO_KEY_P2_3) & 1;
body->P2SW4.b_val = (input_keys >> IIDX_IO_KEY_P2_4) & 1;
body->P2SW5.b_val = (input_keys >> IIDX_IO_KEY_P2_5) & 1;
body->P2SW6.b_val = (input_keys >> IIDX_IO_KEY_P2_6) & 1;
body->P2SW7.b_val = (input_keys >> IIDX_IO_KEY_P2_7) & 1;
input_keys = bt_io_iidx_ep2_keys_get();
input_sys = bt_io_iidx_ep2_sys_get();
input_panel = bt_io_iidx_ep2_panel_get();
body->P1SW1.b_val = (input_keys >> BT_IO_IIDX_KEY_P1_1) & 1;
body->P1SW2.b_val = (input_keys >> BT_IO_IIDX_KEY_P1_2) & 1;
body->P1SW3.b_val = (input_keys >> BT_IO_IIDX_KEY_P1_3) & 1;
body->P1SW4.b_val = (input_keys >> BT_IO_IIDX_KEY_P1_4) & 1;
body->P1SW5.b_val = (input_keys >> BT_IO_IIDX_KEY_P1_5) & 1;
body->P1SW6.b_val = (input_keys >> BT_IO_IIDX_KEY_P1_6) & 1;
body->P1SW7.b_val = (input_keys >> BT_IO_IIDX_KEY_P1_7) & 1;
body->P2SW1.b_val = (input_keys >> BT_IO_IIDX_KEY_P2_1) & 1;
body->P2SW2.b_val = (input_keys >> BT_IO_IIDX_KEY_P2_2) & 1;
body->P2SW3.b_val = (input_keys >> BT_IO_IIDX_KEY_P2_3) & 1;
body->P2SW4.b_val = (input_keys >> BT_IO_IIDX_KEY_P2_4) & 1;
body->P2SW5.b_val = (input_keys >> BT_IO_IIDX_KEY_P2_5) & 1;
body->P2SW6.b_val = (input_keys >> BT_IO_IIDX_KEY_P2_6) & 1;
body->P2SW7.b_val = (input_keys >> BT_IO_IIDX_KEY_P2_7) & 1;
body->PANEL.y_start1 = (input_panel >> IIDX_IO_PANEL_P1_START) & 1;
body->PANEL.y_start2 = (input_panel >> IIDX_IO_PANEL_P2_START) & 1;
body->PANEL.y_vefx = (input_panel >> IIDX_IO_PANEL_VEFX) & 1;
body->PANEL.y_effect = (input_panel >> IIDX_IO_PANEL_EFFECT) & 1;
body->PANEL.y_start1 = (input_panel >> BT_IO_IIDX_PANEL_P1_START) & 1;
body->PANEL.y_start2 = (input_panel >> BT_IO_IIDX_PANEL_P2_START) & 1;
body->PANEL.y_vefx = (input_panel >> BT_IO_IIDX_PANEL_VEFX) & 1;
body->PANEL.y_effect = (input_panel >> BT_IO_IIDX_PANEL_EFFECT) & 1;
body->SYSTEM.v_test = (input_sys >> IIDX_IO_SYS_TEST) & 1;
body->SYSTEM.v_service = (input_sys >> IIDX_IO_SYS_SERVICE) & 1;
body->SYSTEM.v_coin = (input_sys >> IIDX_IO_SYS_COIN) & 1;
body->SYSTEM.v_test = (input_sys >> BT_IO_IIDX_SYS_TEST) & 1;
body->SYSTEM.v_service = (input_sys >> BT_IO_IIDX_SYS_SERVICE) & 1;
body->SYSTEM.v_coin = (input_sys >> BT_IO_IIDX_SYS_COIN) & 1;
if (body->SYSTEM.v_coin) {
if (!coin_latch) {
+2 -2
View File
@@ -14,14 +14,14 @@
#include "acioemu/addr.h"
#include "acioemu/emu.h"
#include "core/log.h"
#include "hook/iohook.h"
#include "hooklib/rs232.h"
#include "bio2emu/emu.h"
#include "bio2emu/setupapi.h"
#include "iface-core/log.h"
#include "imports/avs.h"
#include "util/array.h"
+3 -3
View File
@@ -6,12 +6,12 @@
#include <cfgmgr32.h>
#include <setupapi.h>
#include "core/log.h"
#include "bio2emu/emu.h"
#include "bio2emu/setupapi.h"
#include "hook/table.h"
#include "bio2emu/emu.h"
#include "bio2emu/setupapi.h"
#include "iface-core/log.h"
#include "util/defs.h"
#include "util/str.h"
+7 -4
View File
@@ -3,15 +3,18 @@ avsdlls += bsthook
deplibs_bsthook := \
avs \
avslibs_bsthook := \
avs-ext \
libs_bsthook := \
avs-util \
util \
core \
acioemu \
bstio \
hook \
hooklib \
util \
eamio \
iface-io \
module \
iface-core \
src_bsthook := \
acio.c \
+1 -1
View File
@@ -19,7 +19,7 @@
#include "bsthook/acio.h"
#include "bsthook/kfca.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "hook/iohook.h"
+3
View File
@@ -3,6 +3,9 @@
#include <windows.h>
#include "api/io/bst.h"
#include "api/io/eam.h"
#include "hook/iohook.h"
void ac_io_bus_init(void);
+55 -27
View File
@@ -2,13 +2,18 @@
#include <stdbool.h>
#include "avs-util/core-interop.h"
#include "avs-ext/log.h"
#include "avs-ext/thread.h"
#include "bemanitools/bstio.h"
#include "bemanitools/eamio.h"
#include "bsthook/acio.h"
#include "bsthook/gfx.h"
#include "bsthook/settings.h"
#include "core/log.h"
#include "core/thread.h"
#include "iface-core/config.h"
#include "iface-core/log.h"
#include "iface-core/thread.h"
#include "iface-io/bst.h"
#include "iface-io/eam.h"
#include "hook/iohook.h"
@@ -17,57 +22,74 @@
#include "imports/avs.h"
#include "bsthook/acio.h"
#include "bsthook/gfx.h"
#include "bsthook/settings.h"
#include "module/io-ext.h"
#include "util/cmdline.h"
#include "util/defs.h"
static module_io_t *_bsthook_module_io_bst;
static module_io_t *_bsthook_module_io_eam;
static bool my_dll_entry_init(char *sidcode, struct property_node *config);
static bool my_dll_entry_main(void);
static void _bsthook_io_bst_init(module_io_t **module)
{
bt_io_bst_api_t api;
module_io_ext_load_and_init(
"bstio.dll", "bt_module_io_bst_api_get", module);
module_io_api_get(*module, &api);
bt_io_bst_api_set(&api);
}
static void _bsthook_io_eam_init(module_io_t **module)
{
bt_io_eam_api_t api;
module_io_ext_load_and_init(
"eamio.dll", "bt_module_io_eam_api_get", module);
module_io_api_get(*module, &api);
bt_io_eam_api_set(&api);
}
static bool my_dll_entry_init(char *sidcode, struct property_node *config)
{
bool ok;
log_info("--- Begin bsthook dll_entry_init ---");
ac_io_bus_init();
log_info("Starting up BeatStream IO backend");
core_log_impl_assign(bst_io_set_loggers);
_bsthook_io_bst_init(&_bsthook_module_io_bst);
ok = bst_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
ok = bt_io_bst_init();
if (!ok) {
goto bst_io_fail;
}
core_log_impl_assign(eam_io_set_loggers);
_bsthook_io_eam_init(&_bsthook_module_io_eam);
ok = eam_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
ok = bt_io_eam_init();
if (!ok) {
goto eam_io_fail;
}
ac_io_bus_init();
log_info("--- End bsthook dll_entry_init ---");
return app_hook_invoke_init(sidcode, config);
eam_io_fail:
bst_io_fini();
bt_io_bst_fini();
bt_io_bst_api_clear();
module_io_free(&_bsthook_module_io_bst);
bst_io_fail:
ac_io_bus_fini();
return false;
}
@@ -79,10 +101,16 @@ static bool my_dll_entry_main(void)
result = app_hook_invoke_main();
log_info("Shutting down card reader backend");
eam_io_fini();
bt_io_eam_fini();
log_info("Shutting down SDVX IO backend");
bst_io_fini();
bt_io_eam_api_clear();
module_io_free(&_bsthook_module_io_eam);
log_info("Shutting down BeatStream IO backend");
bt_io_bst_fini();
bt_io_bst_api_clear();
module_io_free(&_bsthook_module_io_bst);
ac_io_bus_fini();
@@ -100,8 +128,8 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
}
// Use AVS APIs
avs_util_core_interop_thread_avs_impl_set();
avs_util_core_interop_log_avs_impl_set();
avs_ext_log_core_api_set();
avs_ext_thread_core_api_set();
args_recover(&argc, &argv);
+1 -1
View File
@@ -3,7 +3,7 @@
#include <stdbool.h>
#include "core/log.h"
#include "iface-core/log.h"
#include "hook/com-proxy.h"
#include "hook/pe.h"
+3 -3
View File
@@ -7,7 +7,7 @@
#include "acioemu/emu.h"
#include "bemanitools/bstio.h"
#include "iface-io/bst.h"
#include "util/defs.h"
@@ -122,7 +122,7 @@ static void kfca_poll(const struct ac_io_message *req)
struct ac_io_message resp;
struct ac_io_kfca_poll_in *pin;
bst_io_read_input();
bt_io_bst_input_read();
pin = &resp.cmd.kfca_poll_in;
@@ -133,7 +133,7 @@ static void kfca_poll(const struct ac_io_message *req)
memset(pin, 0, sizeof(*pin));
pin->gpio_sys = ac_io_u16(bst_io_get_input());
pin->gpio_sys = ac_io_u16(bt_io_bst_input_get());
ac_io_emu_response_push(kfca_ac_io_emu, &resp, 0);
}
+1 -1
View File
@@ -7,7 +7,7 @@
#include <stdio.h>
#include <string.h>
#include "core/log.h"
#include "iface-core/log.h"
#include "hook/table.h"
+5 -1
View File
@@ -1,7 +1,11 @@
dlls += bstio
libs_bstio := \
geninput \
module \
iface-core \
core \
iface \
util \
src_bstio := \
bstio.c \
+61 -24
View File
@@ -1,46 +1,83 @@
#define LOG_MODULE "bstio"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "bemanitools/bstio.h"
#include "bemanitools/glue.h"
#include "bemanitools/input.h"
#include "api/core/log.h"
#include "api/core/thread.h"
static uint8_t bst_io_gpio_sys;
#include "iface-core/log.h"
#include "iface-core/thread.h"
#include "iface/input.h"
void bst_io_set_loggers(
log_formatter_t misc,
log_formatter_t info,
log_formatter_t warning,
log_formatter_t fatal)
#include "module/input.h"
#include "main/module/input-ext.h"
#include "main/module/input.h"
#include "sdk/module/core/log.h"
#include "sdk/module/core/thread.h"
#include "sdk/module/input.h"
#include "sdk/module/io/bst.h"
static module_input_t *_bst_io_module_input;
static uint8_t _bst_io_gpio_sys;
bool bt_io_bst_init()
{
input_set_loggers(misc, info, warning, fatal);
bool result;
bt_input_api_t input_api;
module_input_ext_load_and_init("geninput.dll", &_bst_io_module_input);
module_input_api_get(_bst_io_module_input, &input_api);
bt_input_api_set(&input_api);
result = bt_input_init();
if (!result) {
return false;
}
return bt_input_mapper_config_load("bst");
}
bool bst_io_init(
thread_create_t thread_create,
thread_join_t thread_join,
thread_destroy_t thread_destroy)
void bt_io_bst_fini()
{
input_init(thread_create, thread_join, thread_destroy);
mapper_config_load("bst");
bt_input_fini();
bt_input_api_clear();
module_input_free(&_bst_io_module_input);
}
bool bt_io_bst_input_read()
{
_bst_io_gpio_sys = bt_input_mapper_update();
return true;
}
void bst_io_fini(void)
uint8_t bt_io_bst_input_get()
{
input_fini();
return _bst_io_gpio_sys;
}
bool bst_io_read_input(void)
void bt_module_core_log_api_set(const bt_core_log_api_t *api)
{
bst_io_gpio_sys = mapper_update();
return true;
bt_core_log_api_set(api);
}
uint8_t bst_io_get_input(void)
void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
{
return bst_io_gpio_sys;
bt_core_thread_api_set(api);
}
void bt_module_io_bst_api_get(bt_io_bst_api_t *api)
{
api->version = 1;
api->v1.init = bt_io_bst_init;
api->v1.fini = bt_io_bst_fini;
api->v1.input_read = bt_io_bst_input_read;
api->v1.input_get = bt_io_bst_input_get;
}
+10 -5
View File
@@ -1,8 +1,13 @@
LIBRARY bstio
EXPORTS
bst_io_fini
bst_io_get_input
bst_io_init
bst_io_read_input
bst_io_set_loggers
; Bemanitools 6 API
bt_module_core_log_api_set
bt_module_core_thread_api_set
bt_module_io_bst_api_get
; Direct API
bt_io_bst_init
bt_io_bst_fini
bt_io_bst_input_read
bt_io_bst_input_get
+2 -1
View File
@@ -17,8 +17,9 @@
#include "camhook/cam-detect.h"
#include "iface-core/log.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/str.h"
EXTERN_GUID(
+4 -1
View File
@@ -19,11 +19,14 @@
#include "camhook/cam.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "hook/com-proxy.h"
#include "hook/table.h"
#include "camhook/cam.h"
#include "camhook/cam-detect.h"
#include "util/defs.h"
#include "util/str.h"
+2 -2
View File
@@ -1,9 +1,9 @@
#include "cconfig/cconfig-util.h"
#include "core/log.h"
#include "camhook/config-cam.h"
#include "iface-core/log.h"
#define CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY "cam.disable_emu"
#define CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE false
+3 -3
View File
@@ -6,7 +6,7 @@
#include "cconfig/cconfig-main.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "util/cmdline.h"
@@ -85,7 +85,7 @@ bool cconfig_main_config_init(
}
log_misc("Config state after file loading:");
cconfig_util_log(config, core_log_misc_impl_get());
cconfig_util_log(config, log_misc_func);
}
log_misc("Parsing override config parameters from cmd");
@@ -97,7 +97,7 @@ bool cconfig_main_config_init(
}
log_misc("Config state after cmd parameter overrides:");
cconfig_util_log(config, core_log_misc_impl_get());
cconfig_util_log(config, log_misc_func);
goto success;
+2 -2
View File
@@ -5,7 +5,7 @@
#include "cconfig/cconfig-util.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "util/hex.h"
#include "util/mem.h"
@@ -221,7 +221,7 @@ void cconfig_util_set_data(
free(str);
}
void cconfig_util_log(struct cconfig *config, core_log_message_t log_message)
void cconfig_util_log(struct cconfig *config, bt_core_log_message_t log_message)
{
for (uint32_t i = 0; i < config->nentries; i++) {
log_message(
+3 -2
View File
@@ -7,7 +7,7 @@
#include "cconfig/cconfig.h"
#include "core/log.h"
#include "iface-core/log.h"
bool cconfig_util_get_int(
struct cconfig *config,
@@ -57,6 +57,7 @@ void cconfig_util_set_data(
size_t len,
const char *desc);
void cconfig_util_log(struct cconfig *config, core_log_message_t log_message);
void cconfig_util_log(
struct cconfig *config, bt_core_log_message_t log_message);
#endif
+1 -1
View File
@@ -2,7 +2,7 @@
#include "cconfig/cconfig.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "util/mem.h"
#include "util/str.h"
+1 -1
View File
@@ -7,7 +7,7 @@
#include "cconfig/cmd.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "util/hex.h"
#include "util/str.h"
+1 -1
View File
@@ -6,7 +6,7 @@
#include "cconfig/conf.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "util/fs.h"
#include "util/str.h"
+4
View File
@@ -4,9 +4,13 @@ cppflags_config := -DUNICODE
libs_config := \
core \
iface-io \
iface \
module \
eamio \
geninput \
util \
iface-core \
ldflags_config := \
-lcomctl32 \
+6 -4
View File
@@ -11,7 +11,8 @@
#include "config/schema.h"
#include "config/usages.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "iface/input.h"
#include "geninput/hid-mgr.h"
#include "geninput/input-config.h"
@@ -168,7 +169,7 @@ static INT_PTR analogs_ui_handle_tick(HWND hwnd)
struct analogs_ui *ui;
size_t i;
mapper_update();
bt_input_mapper_update();
ui = (struct analogs_ui *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
@@ -363,7 +364,8 @@ static void analog_ui_handle_init_invert(HWND hwnd)
ui = (struct analog_ui *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (mapper_get_analog_invert(ui->def->tag)) {
SendMessage(GetDlgItem(hwnd, IDC_ANALOG_INVERT), BM_SETCHECK, BST_CHECKED, 0);
SendMessage(
GetDlgItem(hwnd, IDC_ANALOG_INVERT), BM_SETCHECK, BST_CHECKED, 0);
}
}
@@ -566,7 +568,7 @@ static INT_PTR analog_ui_handle_tick(HWND hwnd)
ui = (struct analog_ui *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
pos_ctl = GetDlgItem(hwnd, IDC_POSITION);
ui->pos = mapper_read_analog(ui->def->tag);
ui->pos = bt_input_mapper_analog_read(ui->def->tag);
SendMessage(pos_ctl, WM_USER, 0, (LPARAM) ui->pos);
+1 -1
View File
@@ -15,7 +15,7 @@
#include "config/schema.h"
#include "config/usages.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "geninput/input-config.h"
#include "geninput/mapper.h"
+7 -5
View File
@@ -13,7 +13,9 @@
#include "config/resource.h"
#include "config/schema.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "iface-io/eam.h"
#include "iface/input.h"
#include "eamio/eam-config.h"
@@ -72,13 +74,13 @@ static INT_PTR eam_unit_ui_handle_change_device(HWND hwnd);
static INT_PTR eam_unit_ui_handle_tick(HWND hwnd);
static INT_PTR eam_unit_ui_handle_fini(HWND hwnd);
static const struct eam_io_config_api *eam_io_config_api;
static const bt_io_eam_config_api_t *eam_io_config_api;
HPROPSHEETPAGE
eam_ui_tab_create(
HINSTANCE inst,
const struct schema *schema,
const struct eam_io_config_api *api)
const bt_io_eam_config_api_t *api)
{
PROPSHEETPAGE psp;
@@ -216,7 +218,7 @@ static INT_PTR eam_ui_handle_tick(HWND hwnd)
ui = (struct eam_ui *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
mapper_update();
bt_input_mapper_update();
for (i = 0; i < ui->children.nitems; i++) {
child = *array_item(HWND, &ui->children, i);
@@ -462,7 +464,7 @@ static INT_PTR eam_unit_ui_handle_tick(HWND hwnd)
wchar_t state_str[9];
ui = (struct eam_unit_ui *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
state = eam_io_get_keypad_state(ui->def->unit_no);
state = bt_io_eam_keypad_state_get(ui->def->unit_no);
wstr_format(state_str, lengthof(state_str), L"%04x", state);
+1 -1
View File
@@ -6,7 +6,7 @@
#include "config/resource.h"
#include "config/schema.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "util/defs.h"
+66 -30
View File
@@ -14,17 +14,25 @@
#include "config/spinner.h"
#include "config/usages.h"
#include "core/boot.h"
#include "core/log-bt.h"
#include "core/log-sink-debug.h"
#include "core/log.h"
#include "core/thread-crt-ext.h"
#include "core/log-sink-std.h"
#include "core/thread-crt.h"
#include "core/thread.h"
#include "eamio/eam-config.h"
#include "geninput/input-config.h"
#include "iface-core/log.h"
#include "iface-core/thread.h"
#include "iface-io/eam.h"
#include "iface/input.h"
#include "module/input-ext.h"
#include "module/input.h"
#include "module/io-ext.h"
#include "module/io.h"
#include "util/defs.h"
#include "util/str.h"
#include "util/winres.h"
@@ -37,7 +45,7 @@ HPROPSHEETPAGE
eam_ui_tab_create(
HINSTANCE inst,
const struct schema *schema,
const struct eam_io_config_api *eam_io_config_api);
const bt_io_eam_config_api_t *eam_io_config_api);
static void my_fatal(const char *module, const char *fmt, ...)
{
@@ -54,6 +62,17 @@ static void my_fatal(const char *module, const char *fmt, ...)
ExitProcess(-1);
}
static void log_api_set()
{
bt_core_log_api_t api;
core_log_bt_core_api_get(&api);
api.v1.fatal = my_fatal;
bt_core_log_api_set(&api);
}
int main(int argc, char **argv)
{
INITCOMMONCONTROLSEX iccx;
@@ -61,27 +80,37 @@ int main(int argc, char **argv)
HPROPSHEETPAGE psp[4];
PROPSHEETHEADER psh;
intptr_t result;
const struct eam_io_config_api *eam_io_config_api;
const bt_io_eam_config_api_t *eam_io_config_api;
const struct schema *schema;
wchar_t text[1024];
int max_light;
size_t i;
struct core_log_sink sink;
core_log_sink_t sink;
bt_input_api_t input_api;
module_input_t *module_input;
bt_io_eam_api_t eam_api;
module_io_t *module_io_eam;
inst = GetModuleHandle(NULL);
// TODO turn this into optional parameters, same for log level and output to
// file
AttachConsole(ATTACH_PARENT_PROCESS);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
freopen("CONIN$", "r", stdin);
core_thread_crt_ext_impl_set();
core_boot("config");
core_log_impl_set(
core_log_bt_log_misc,
core_log_bt_log_info,
core_log_bt_log_warning,
my_fatal);
core_log_sink_debug_open(&sink);
core_log_sink_std_err_open(true, &sink);
core_log_bt_init(&sink);
core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
core_log_bt_core_api_set();
core_thread_crt_core_api_set();
log_api_set();
inst = GetModuleHandle(NULL);
usages_init(inst);
@@ -112,18 +141,16 @@ int main(int argc, char **argv)
}
}
core_log_impl_assign(input_set_loggers);
input_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
module_input_ext_load_and_init("geninput.dll", &module_input);
module_input_api_get(module_input, &input_api);
bt_input_api_set(&input_api);
core_log_impl_assign(eam_io_set_loggers);
eam_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
eam_io_config_api = eam_io_get_config_api();
module_io_ext_load_and_init(
"eamio.dll", "bt_module_io_eam_api_get", &module_io_eam);
module_io_api_get(module_io_eam, &eam_api);
bt_io_eam_api_set(&eam_api);
eam_io_config_api = bt_io_eam_config_api_get();
// calculate these and check against the loaded config
max_light = -1;
@@ -134,11 +161,14 @@ int main(int argc, char **argv)
}
}
if (!mapper_config_load(schema->name)) {
if (!bt_input_mapper_config_load(schema->name)) {
log_info("Initializing empty config for %s", schema->name);
log_info(">>>>1");
mapper_set_nlights((uint8_t) (max_light + 1));
log_info(">>>>1");
mapper_set_nanalogs((uint8_t) schema->nanalogs);
log_info(">>>>1");
} else {
// make sure that these are right
@@ -187,10 +217,16 @@ int main(int argc, char **argv)
mapper_config_save(schema->name);
}
eam_io_fini();
input_fini();
bt_io_eam_fini();
bt_input_fini();
spinner_fini(inst);
usages_fini();
bt_input_api_clear();
bt_io_eam_api_clear();
module_input_free(&module_input);
module_io_free(&module_io_eam);
return EXIT_SUCCESS;
}
+2 -2
View File
@@ -6,10 +6,10 @@
#include "config/snap.h"
#include "core/log.h"
#include "geninput/hid-mgr.h"
#include "iface-core/log.h"
#include "util/defs.h"
#include "util/mem.h"
+1 -1
View File
@@ -9,7 +9,7 @@
#include "config/resource.h"
#include "core/log.h"
#include "iface-core/log.h"
#include "util/array.h"
#include "util/str.h"
+10 -4
View File
@@ -4,6 +4,8 @@ libs_core := \
util \
src_core := \
boot.c \
config-property-node.c \
log-bt-ext.c \
log-bt.c \
log-sink-async.c \
@@ -13,8 +15,12 @@ src_core := \
log-sink-mutex.c \
log-sink-null.c \
log-sink-std.c \
log.c \
thread-crt-ext.c \
property-ext.c \
property-mxml.c \
property-mxml.c \
property-node-ext.c \
property-node-trace.c \
property-node.c \
property-trace.c \
property.c \
thread-crt.c \
thread.c \
+107
View File
@@ -0,0 +1,107 @@
#define LOG_MODULE "core-boot"
#include <debugapi.h>
#include <stdio.h>
#include "core/property-mxml.h"
#include "core/property-node-mxml.h"
#include "core/thread-crt.h"
#include "iface-core/log.h"
#include "util/str.h"
#define CORE_BOOT_LOG_MODULE_SIZE_MAX 128
/* 64k so we can log data dumps of rs232 without crashing */
#define CORE_BOOT_LOG_MSG_SIZE_MAX 65536
static void _core_boot_log_std_msg(const char *module, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
printf("[%s] ", module);
vprintf(fmt, args);
printf("\n");
va_end(args);
}
static void _core_boot_log_debug_msg(const char *module, const char *fmt, ...)
{
char module_str[CORE_BOOT_LOG_MODULE_SIZE_MAX];
char msg[CORE_BOOT_LOG_MSG_SIZE_MAX];
va_list args;
va_start(args, fmt);
str_format(module_str, sizeof(module_str), "[%s] ", module);
str_vformat(msg, sizeof(msg), fmt, args);
OutputDebugStringA(module_str);
OutputDebugStringA(msg);
OutputDebugStringA("\n");
va_end(args);
}
static void _core_boot_minimal_logging_std_env_init()
{
_core_boot_log_std_msg(
LOG_MODULE, "Init minimal logging environment (std)");
// Initialize logging directly to avoid a bootstrapping issue
// with not having any kind of logging to bootstrap the full
// featured logging system
_bt_core_log_api.version = 1;
_bt_core_log_api.v1.misc = _core_boot_log_std_msg;
_bt_core_log_api.v1.info = _core_boot_log_std_msg;
_bt_core_log_api.v1.warning = _core_boot_log_std_msg;
_bt_core_log_api.v1.fatal = _core_boot_log_std_msg;
log_info("Init minimal logging environment done");
}
static void _core_boot_minimal_logging_debug_env_init()
{
_core_boot_log_debug_msg(
LOG_MODULE, "Init minimal logging environment (debug)");
// Initialize logging directly to avoid a bootstrapping issue
// with not having any kind of logging to bootstrap the full
// featured logging system
_bt_core_log_api.version = 1;
_bt_core_log_api.v1.misc = _core_boot_log_debug_msg;
_bt_core_log_api.v1.info = _core_boot_log_debug_msg;
_bt_core_log_api.v1.warning = _core_boot_log_debug_msg;
_bt_core_log_api.v1.fatal = _core_boot_log_debug_msg;
log_info("Init minimal logging environment done");
}
void core_boot(const char *name)
{
_core_boot_log_std_msg(LOG_MODULE, "Boot: %s", name);
_core_boot_minimal_logging_std_env_init();
core_thread_crt_core_api_set();
core_property_mxml_core_api_set();
core_property_node_mxml_core_api_set();
}
void core_boot_dll(const char *name)
{
_core_boot_log_debug_msg(LOG_MODULE, "Boot: %s", name);
_core_boot_minimal_logging_debug_env_init();
core_thread_crt_core_api_set();
core_property_mxml_core_api_set();
core_property_node_mxml_core_api_set();
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef CORE_BOOT_H
#define CORE_BOOT_H
void core_boot(const char *name);
void core_boot_dll(const char *name);
#endif
+346
View File
@@ -0,0 +1,346 @@
#define LOG_MODULE "core-config-property-node"
#include "api/core/config.h"
#include "main/core/config-property-node.h"
#include "main/core/property-node.h"
#include "main/core/property.h"
#include "iface-core/log.h"
#include "util/mem.h"
typedef struct core_config_property_node {
const core_property_node_t *node;
} core_config_property_node_t;
static bt_core_config_result_t
_core_config_property_node_result_map(core_property_node_result_t result)
{
switch (result) {
case CORE_PROPERTY_NODE_RESULT_SUCCESS:
return BT_CORE_CONFIG_RESULT_SUCCESS;
case CORE_PROPERTY_NODE_RESULT_ERROR_INTERNAL:
return BT_CORE_CONFIG_RESULT_ERROR_INTERNAL;
case CORE_PROPERTY_NODE_RESULT_NODE_NOT_FOUND:
return BT_CORE_CONFIG_RESULT_VALUE_NOT_FOUND;
default:
return BT_CORE_CONFIG_RESULT_ERROR_INTERNAL;
}
}
static bt_core_config_result_t _core_config_property_node_s8_get(
const bt_core_config_t *config_, const char *path, int8_t *value)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_s8_read(&node, value);
return _core_config_property_node_result_map(result);
}
static bt_core_config_result_t _core_config_property_node_u8_get(
const bt_core_config_t *config_, const char *path, uint8_t *value)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_u8_read(&node, value);
return _core_config_property_node_result_map(result);
}
static bt_core_config_result_t _core_config_property_node_s16_get(
const bt_core_config_t *config_, const char *path, int16_t *value)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_s16_read(&node, value);
return _core_config_property_node_result_map(result);
}
static bt_core_config_result_t _core_config_property_node_u16_get(
const bt_core_config_t *config_, const char *path, uint16_t *value)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_u16_read(&node, value);
return _core_config_property_node_result_map(result);
}
static bt_core_config_result_t _core_config_property_node_s32_get(
const bt_core_config_t *config_, const char *path, int32_t *value)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_s32_read(&node, value);
return _core_config_property_node_result_map(result);
}
static bt_core_config_result_t _core_config_property_node_u32_get(
const bt_core_config_t *config_, const char *path, uint32_t *value)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_u32_read(&node, value);
return _core_config_property_node_result_map(result);
}
static bt_core_config_result_t _core_config_property_node_s64_get(
const bt_core_config_t *config_, const char *path, int64_t *value)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_s64_read(&node, value);
return _core_config_property_node_result_map(result);
}
static bt_core_config_result_t _core_config_property_node_u64_get(
const bt_core_config_t *config_, const char *path, uint64_t *value)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_u64_read(&node, value);
return _core_config_property_node_result_map(result);
}
static bt_core_config_result_t _core_config_property_node_float_get(
const bt_core_config_t *config_, const char *path, float *value)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_float_read(&node, value);
return _core_config_property_node_result_map(result);
}
static bt_core_config_result_t _core_config_property_node_double_get(
const bt_core_config_t *config_, const char *path, double *value)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_double_read(&node, value);
return _core_config_property_node_result_map(result);
}
static bt_core_config_result_t _core_config_property_node_bool_get(
const bt_core_config_t *config_, const char *path, bool *value)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_bool_read(&node, value);
return _core_config_property_node_result_map(result);
}
static bt_core_config_result_t _core_config_property_node_bin_get(
const bt_core_config_t *config_, const char *path, void *value, size_t len)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_bin_read(&node, value, len);
return _core_config_property_node_result_map(result);
}
static bt_core_config_result_t _core_config_property_node_str_get(
const bt_core_config_t *config_, const char *path, char *value, size_t len)
{
const core_config_property_node_t *config;
core_property_node_t node;
core_property_node_result_t result;
config = (const core_config_property_node_t *) config_;
result = core_property_node_search(config->node, path, &node);
if (CORE_PROPERTY_NODE_RESULT_IS_ERROR(result)) {
return _core_config_property_node_result_map(result);
}
result = core_property_node_str_read(&node, value, len);
return _core_config_property_node_result_map(result);
}
static void _core_config_property_node_core_api_get(bt_core_config_api_t *api)
{
log_assert(api);
api->version = 1;
api->v1.s8_get = _core_config_property_node_s8_get;
api->v1.u8_get = _core_config_property_node_u8_get;
api->v1.s16_get = _core_config_property_node_s16_get;
api->v1.u16_get = _core_config_property_node_u16_get;
api->v1.s32_get = _core_config_property_node_s32_get;
api->v1.u32_get = _core_config_property_node_u32_get;
api->v1.s64_get = _core_config_property_node_s64_get;
api->v1.u64_get = _core_config_property_node_u64_get;
api->v1.float_get = _core_config_property_node_float_get;
api->v1.double_get = _core_config_property_node_double_get;
api->v1.bool_get = _core_config_property_node_bool_get;
api->v1.bin_get = _core_config_property_node_bin_get;
api->v1.str_get = _core_config_property_node_str_get;
}
void core_config_property_node_core_api_set()
{
bt_core_config_api_t api;
_core_config_property_node_core_api_get(&api);
bt_core_config_api_set(&api);
}
void core_config_property_node_init(
const core_property_node_t *node, bt_core_config_t **config_)
{
core_config_property_node_t *config;
log_assert(node);
log_assert(config_);
config = xmalloc(sizeof(core_config_property_node_t));
config->node = node;
*config_ = (bt_core_config_t *) config;
}
void core_config_property_node_free(bt_core_config_t **config_)
{
core_config_property_node_t **config;
log_assert(config_);
config = (core_config_property_node_t **) config_;
free(*config);
*config = NULL;
}
+15
View File
@@ -0,0 +1,15 @@
#ifndef CORE_CONFIG_PROPERTY_NODE_H
#define CORE_CONFIG_PROPERTY_NODE_H
#include "iface-core/config.h"
#include "core/property-node.h"
void core_config_property_node_core_api_set();
void core_config_property_node_init(
const core_property_node_t *node, bt_core_config_t **config);
void core_config_property_node_free(bt_core_config_t **config);
#endif
+25 -17
View File
@@ -1,3 +1,5 @@
#define LOG_MODULE "core-log-bt-ext"
#include <stdbool.h>
#include "core/log-bt.h"
@@ -6,20 +8,10 @@
#include "core/log-sink-list.h"
#include "core/log-sink-mutex.h"
#include "core/log-sink-std.h"
#include "core/log.h"
void core_log_bt_ext_impl_set()
{
core_log_impl_set(
core_log_bt_log_misc,
core_log_bt_log_info,
core_log_bt_log_warning,
core_log_bt_log_fatal);
}
void core_log_bt_ext_init_with_stdout()
{
struct core_log_sink sink;
core_log_sink_t sink;
core_log_sink_std_out_open(true, &sink);
core_log_bt_init(&sink);
@@ -27,7 +19,7 @@ void core_log_bt_ext_init_with_stdout()
void core_log_bt_ext_init_with_stderr()
{
struct core_log_sink sink;
core_log_sink_t sink;
core_log_sink_std_err_open(true, &sink);
core_log_bt_init(&sink);
@@ -35,7 +27,7 @@ void core_log_bt_ext_init_with_stderr()
void core_log_bt_ext_init_with_debug()
{
struct core_log_sink sink;
core_log_sink_t sink;
core_log_sink_debug_open(&sink);
core_log_bt_init(&sink);
@@ -44,7 +36,7 @@ void core_log_bt_ext_init_with_debug()
void core_log_bt_ext_init_with_file(
const char *path, bool append, bool rotate, uint8_t max_rotations)
{
struct core_log_sink sink;
core_log_sink_t sink;
core_log_sink_file_open(path, append, rotate, max_rotations, &sink);
core_log_bt_init(&sink);
@@ -53,9 +45,9 @@ void core_log_bt_ext_init_with_file(
void core_log_bt_ext_init_with_stdout_and_file(
const char *path, bool append, bool rotate, uint8_t max_rotations)
{
struct core_log_sink sinks[2];
struct core_log_sink sink_composed;
struct core_log_sink sink_mutex;
core_log_sink_t sinks[2];
core_log_sink_t sink_composed;
core_log_sink_t sink_mutex;
core_log_sink_std_out_open(true, &sinks[0]);
core_log_sink_file_open(path, append, rotate, max_rotations, &sinks[1]);
@@ -63,5 +55,21 @@ void core_log_bt_ext_init_with_stdout_and_file(
core_log_sink_mutex_open(&sink_composed, &sink_mutex);
core_log_bt_init(&sink_mutex);
}
void core_log_bt_ext_init_with_stderr_and_file(
const char *path, bool append, bool rotate, uint8_t max_rotations)
{
core_log_sink_t sinks[2];
core_log_sink_t sink_composed;
core_log_sink_t sink_mutex;
core_log_sink_std_err_open(true, &sinks[0]);
core_log_sink_file_open(path, append, rotate, max_rotations, &sinks[1]);
core_log_sink_list_open(sinks, 2, &sink_composed);
core_log_sink_mutex_open(&sink_composed, &sink_mutex);
core_log_bt_init(&sink_mutex);
}
+3 -6
View File
@@ -4,12 +4,6 @@
#include <stdbool.h>
#include <stdint.h>
/**
* Set the current thread API implementation to use the bemanitools log
* implementation
*/
void core_log_bt_ext_impl_set();
/**
* Helper to setup the bemanitools log implementation with a stdout sink.
*/
@@ -56,4 +50,7 @@ void core_log_bt_ext_init_with_file(
void core_log_bt_ext_init_with_stdout_and_file(
const char *path, bool append, bool rotate, uint8_t max_rotations);
void core_log_bt_ext_init_with_stderr_and_file(
const char *path, bool append, bool rotate, uint8_t max_rotations);
#endif

Some files were not shown because too many files have changed in this diff Show More