Files
djhackersdev_bemanitools/src/main/iface/input.c
T
icex2 57e68f928a 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:
2024-08-15 11:34:31 +02:00

128 lines
2.8 KiB
C

#define LOG_MODULE "bt-input"
#include <string.h>
#include "api/input.h"
#include "iface-core/log.h"
#define BT_INPUT_ASSERT_IMPLEMENTED(func, name) \
if (!func) { \
log_fatal("Function %s not implemented", STRINGIFY(name)); \
}
static bt_input_api_t _bt_input_api;
static bool _bt_input_api_is_valid()
{
return _bt_input_api.version > 0;
}
void bt_input_api_set(const bt_input_api_t *api)
{
log_assert(api);
if (_bt_input_api_is_valid()) {
log_warning("Re-initialize");
}
if (api->version == 1) {
BT_INPUT_ASSERT_IMPLEMENTED(api->v1.init, "bt_input_init");
BT_INPUT_ASSERT_IMPLEMENTED(api->v1.fini, "bt_input_fini");
BT_INPUT_ASSERT_IMPLEMENTED(
api->v1.mapper_config_load, "bt_input_mapper_config_load");
BT_INPUT_ASSERT_IMPLEMENTED(
api->v1.mapper_analog_read, "bt_input_mapper_analog_read");
BT_INPUT_ASSERT_IMPLEMENTED(
api->v1.mapper_update, "bt_input_mapper_update");
BT_INPUT_ASSERT_IMPLEMENTED(
api->v1.mapper_light_write, "bt_input_mapper_light_write");
memcpy(&_bt_input_api, api, sizeof(bt_input_api_t));
log_misc("api v1 set");
} else {
log_fatal("Unsupported API version: %d", api->version);
}
}
void bt_input_api_get(bt_input_api_t *api)
{
log_assert(api);
log_assert(_bt_input_api_is_valid());
memcpy(api, &_bt_input_api, sizeof(bt_input_api_t));
}
void bt_input_api_clear()
{
log_assert(_bt_input_api_is_valid());
memset(&_bt_input_api, 0, sizeof(bt_input_api_t));
log_misc("api cleared");
}
bool bt_input_init()
{
bool result;
log_assert(_bt_input_api_is_valid());
log_misc(">>> init");
result = _bt_input_api.v1.init();
log_misc("<<< init: %d", result);
return result;
}
void bt_input_fini()
{
log_assert(_bt_input_api_is_valid());
log_misc(">>> fini");
_bt_input_api.v1.fini();
log_misc("<<< fini");
}
bool bt_input_mapper_config_load(const char *game_type)
{
bool result;
log_assert(_bt_input_api_is_valid());
log_misc(">>> mapper_config_load: %s", game_type);
result = _bt_input_api.v1.mapper_config_load(game_type);
log_misc("<<< mapper_config_load: %d", result);
return result;
}
uint8_t bt_input_mapper_analog_read(uint8_t analog)
{
log_assert(_bt_input_api_is_valid());
return _bt_input_api.v1.mapper_analog_read(analog);
}
uint64_t bt_input_mapper_update()
{
log_assert(_bt_input_api_is_valid());
return _bt_input_api.v1.mapper_update();
}
void bt_input_mapper_light_write(uint8_t light, uint8_t intensity)
{
log_assert(_bt_input_api_is_valid());
return _bt_input_api.v1.mapper_light_write(light, intensity);
}