Refactored input mapping state

This commit is contained in:
Mr-Wiseguy 2024-01-14 22:49:04 -05:00
parent 8f3acd3623
commit 457bc878e9
6 changed files with 107 additions and 371 deletions

View File

@ -1,212 +0,0 @@
The RmlUi samples include fonts that are separately licensed. They are listed
below along with their licenses.
-----------------------------------------------------------
-----------------------------------------------------------
--- Lato ---
--- http://www.latofonts.com/ ---
--- ---
--- LatoLatin-Bold.ttf ---
--- LatoLatin-BoldItalic.ttf ---
--- LatoLatin-Italic.ttf ---
--- LatoLatin-Regular.ttf ---
-----------------------------------------------------------
-----------------------------------------------------------
Copyright (c) 2010-2015, Łukasz Dziedzic (dziedzic@typoland.com),
with Reserved Font Name Lato.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
-----------------------------------------------------------
-----------------------------------------------------------
--- Noto Emoji ---
--- https://www.google.com/get/noto/ ---
--- ---
--- NotoEmoji-Regular.ttf ---
-----------------------------------------------------------
-----------------------------------------------------------
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to
provide a free and open framework in which fonts may be shared and
improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software
components as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to,
deleting, or substituting -- in part or in whole -- any of the
components of the Original Version, by changing formats or by porting
the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed,
modify, redistribute, and sell modified and unmodified copies of the
Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in
Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created using
the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@ -46,6 +46,9 @@ namespace recomp {
extern const DefaultN64Mappings default_n64_keyboard_mappings;
extern const DefaultN64Mappings default_n64_controller_mappings;
// Loads the user's saved controller mapping if one exists, loads the default mappings if no saved mapping exists.
void init_control_mappings();
void get_n64_input(uint16_t* buttons_out, float* x_out, float* y_out);
void handle_events();

View File

@ -26,25 +26,6 @@ extern "C" {
void name(uint8_t* rdram, recomp_context* ctx);
#endif
enum RecompDigitalInput {
RECOMP_DIGITAL_INPUT_ITEM1,
RECOMP_DIGITAL_INPUT_ITEM2,
RECOMP_DIGITAL_INPUT_ITEM3,
RECOMP_DIGITAL_INPUT_MAX
};
enum RecompAnalogInput {
RECOMP_ANALOG_INPUT_MOVEMENT_X,
RECOMP_ANALOG_INPUT_MOVEMENT_Y,
RECOMP_ANALOG_INPUT_CAMERA_X,
RECOMP_ANALOG_INPUT_CAMERA_Y,
RECOMP_ANALOG_INPUT_MAX,
};
DECLARE_FUNC(u32, recomp_get_digital_input, u32 which);
DECLARE_FUNC(float, recomp_get_analog_input, u32 which);
DECLARE_FUNC(void, recomp_get_item_inputs, u32* buttons);
DECLARE_FUNC(void, recomp_get_camera_inputs, float* x_out, float* y_out);
// TODO move these
DECLARE_FUNC(void, recomp_puts, const char* data, u32 size);
DECLARE_FUNC(void, recomp_exit);

View File

@ -1,11 +1,9 @@
__start = 0x80000000;
/* Dummy addresses that get recompiled into function calls */
recomp_get_item_inputs = 0x81000000;
recomp_puts = 0x81000004;
recomp_get_camera_inputs = 0x81000008;
recomp_exit = 0x8100000C;
recomp_handle_quicksave_actions = 0x81000010;
recomp_handle_quicksave_actions_main = 0x81000014;
osRecvMesg_recomp = 0x81000018;
osSendMesg_recomp = 0x8100001C;
recomp_puts = 0x81000000;
recomp_exit = 0x81000004;
recomp_handle_quicksave_actions = 0x81000008;
recomp_handle_quicksave_actions_main = 0x8100000C;
osRecvMesg_recomp = 0x81000010;
osSendMesg_recomp = 0x81000014;

View File

@ -1,159 +1,124 @@
#include <array>
#include "recomp_helpers.h"
#include "recomp_input.h"
#include "../ultramodern/ultramodern.hpp"
#include "../patches/input.h"
namespace N64Inputs {
enum Input : uint16_t {
A = 0x8000,
B = 0x4000,
Z = 0x2000,
START = 0x1000,
DPAD_UP = 0x0800,
DPAD_DOWN = 0x0400,
DPAD_LEFT = 0x0200,
DPAD_RIGHT = 0x0100,
L = 0x0020,
R = 0x0010,
C_UP = 0x0008,
C_DOWN = 0x0004,
C_LEFT = 0x0002,
C_RIGHT = 0x0001,
// x-macros to build input enums and arrays. First parameter is the name, second parameter is the bit field for the input (or 0 if there is no associated one)
#define DEFINE_N64_BUTTON_INPUTS() \
DEFINE_INPUT(A, 0x8000) \
DEFINE_INPUT(B, 0x4000) \
DEFINE_INPUT(Z, 0x2000) \
DEFINE_INPUT(START, 0x1000) \
DEFINE_INPUT(DPAD_UP, 0x0800) \
DEFINE_INPUT(DPAD_DOWN, 0x0400) \
DEFINE_INPUT(DPAD_LEFT, 0x0200) \
DEFINE_INPUT(DPAD_RIGHT, 0x0100) \
DEFINE_INPUT(L, 0x0020) \
DEFINE_INPUT(R, 0x0010) \
DEFINE_INPUT(C_UP, 0x0008) \
DEFINE_INPUT(C_DOWN, 0x0004) \
DEFINE_INPUT(C_LEFT, 0x0002) \
DEFINE_INPUT(C_RIGHT, 0x0001)
#define DEFINE_N64_AXIS_INPUTS() \
DEFINE_INPUT(X_AXIS_NEG, 0) \
DEFINE_INPUT(X_AXIS_POS, 0) \
DEFINE_INPUT(Y_AXIS_NEG, 0) \
DEFINE_INPUT(Y_AXIS_POS, 0) \
// Make the input enum.
#define DEFINE_INPUT(name, value) name,
enum class GameInput {
DEFINE_N64_BUTTON_INPUTS()
DEFINE_N64_AXIS_INPUTS()
COUNT,
N64_BUTTON_START = A,
N64_BUTTON_COUNT = C_RIGHT - N64_BUTTON_START + 1,
N64_AXIS_START = X_AXIS_NEG,
N64_AXIS_COUNT = Y_AXIS_POS - N64_AXIS_START + 1,
};
#undef DEFINE_INPUT
// Arrays that hold the mappings for every input for keyboard and controller respectively.
using input_mapping_array = std::array<std::vector<recomp::InputField>, (size_t)GameInput::COUNT>;
static std::array<std::vector<recomp::InputField>, (size_t)GameInput::COUNT> keyboard_input_mappings{};
static std::array<std::vector<recomp::InputField>, (size_t)GameInput::COUNT> controller_input_mappings{};
// Make the button value array, which maps a button index to its bit field.
#define DEFINE_INPUT(name, value) uint16_t(value##u),
static const std::array n64_button_values = {
DEFINE_N64_BUTTON_INPUTS()
};
#undef DEFINE_INPUT
void recomp::init_control_mappings() {
// TODO load from a file if one exists.
auto assign_mapping = [](input_mapping_array& mapping, GameInput input, const std::vector<recomp::InputField>& value) {
mapping[(size_t)input] = value;
};
auto assign_all_mappings = [&](input_mapping_array& mapping, const recomp::DefaultN64Mappings& values) {
assign_mapping(mapping, GameInput::A, values.a);
assign_mapping(mapping, GameInput::A, values.a);
assign_mapping(mapping, GameInput::B, values.b);
assign_mapping(mapping, GameInput::Z, values.z);
assign_mapping(mapping, GameInput::START, values.start);
assign_mapping(mapping, GameInput::DPAD_UP, values.dpad_up);
assign_mapping(mapping, GameInput::DPAD_DOWN, values.dpad_down);
assign_mapping(mapping, GameInput::DPAD_LEFT, values.dpad_left);
assign_mapping(mapping, GameInput::DPAD_RIGHT, values.dpad_right);
assign_mapping(mapping, GameInput::L, values.l);
assign_mapping(mapping, GameInput::R, values.r);
assign_mapping(mapping, GameInput::C_UP, values.c_up);
assign_mapping(mapping, GameInput::C_DOWN, values.c_down);
assign_mapping(mapping, GameInput::C_LEFT, values.c_left);
assign_mapping(mapping, GameInput::C_RIGHT, values.c_right);
assign_mapping(mapping, GameInput::X_AXIS_NEG, values.analog_left);
assign_mapping(mapping, GameInput::X_AXIS_POS, values.analog_right);
assign_mapping(mapping, GameInput::Y_AXIS_NEG, values.analog_down);
assign_mapping(mapping, GameInput::Y_AXIS_POS, values.analog_up);
};
assign_all_mappings(keyboard_input_mappings, recomp::default_n64_keyboard_mappings);
assign_all_mappings(controller_input_mappings, recomp::default_n64_controller_mappings);
}
constexpr float controller_default_threshold = 0.7f;
struct GameControllerAxisMapping {
int32_t axis;
float threshold; // Positive or negative to indicate direction
uint32_t output_mask;
};
using axis_map_t = std::vector<GameControllerAxisMapping>;
struct GameControllerButtonMapping {
uint32_t button;
uint32_t output_mask;
};
using button_map_t = std::vector<GameControllerButtonMapping>;
void recomp::get_n64_input(uint16_t* buttons_out, float* x_out, float* y_out) {
uint16_t cur_buttons = 0;
float cur_x = 0.0f;
float cur_y = 0.0f;
if (!recomp::game_input_disabled()) {
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.a) ? N64Inputs::A : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.b) ? N64Inputs::B : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.l) ? N64Inputs::L : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.r) ? N64Inputs::R : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.z) ? N64Inputs::Z : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.start) ? N64Inputs::START : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.c_left) ? N64Inputs::C_LEFT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.c_right) ? N64Inputs::C_RIGHT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.c_up) ? N64Inputs::C_UP : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.c_down) ? N64Inputs::C_DOWN : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.dpad_left) ? N64Inputs::DPAD_LEFT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.dpad_right) ? N64Inputs::DPAD_RIGHT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.dpad_up) ? N64Inputs::DPAD_UP : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.dpad_down) ? N64Inputs::DPAD_DOWN : 0;
for (size_t i = 0; i < n64_button_values.size(); i++) {
size_t input_index = (size_t)GameInput::N64_BUTTON_START + i;
cur_buttons |= recomp::get_input_digital(keyboard_input_mappings[input_index]) ? n64_button_values[i] : 0;
cur_buttons |= recomp::get_input_digital(controller_input_mappings[input_index]) ? n64_button_values[i] : 0;
}
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.a) ? N64Inputs::A : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.b) ? N64Inputs::B : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.l) ? N64Inputs::L : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.r) ? N64Inputs::R : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.z) ? N64Inputs::Z : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.start) ? N64Inputs::START : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.c_left) ? N64Inputs::C_LEFT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.c_right) ? N64Inputs::C_RIGHT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.c_up) ? N64Inputs::C_UP : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.c_down) ? N64Inputs::C_DOWN : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.dpad_left) ? N64Inputs::DPAD_LEFT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.dpad_right) ? N64Inputs::DPAD_RIGHT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.dpad_up) ? N64Inputs::DPAD_UP : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.dpad_down) ? N64Inputs::DPAD_DOWN : 0;
cur_x = recomp::get_input_analog(recomp::default_n64_keyboard_mappings.analog_right) - recomp::get_input_analog(recomp::default_n64_keyboard_mappings.analog_left);
cur_y = recomp::get_input_analog(recomp::default_n64_keyboard_mappings.analog_up) - recomp::get_input_analog(recomp::default_n64_keyboard_mappings.analog_down);
cur_x += recomp::get_input_analog(recomp::default_n64_controller_mappings.analog_right) - recomp::get_input_analog(recomp::default_n64_controller_mappings.analog_left);
cur_y += recomp::get_input_analog(recomp::default_n64_controller_mappings.analog_up) - recomp::get_input_analog(recomp::default_n64_controller_mappings.analog_down);
cur_x = recomp::get_input_analog(keyboard_input_mappings[(size_t)GameInput::X_AXIS_POS])
- recomp::get_input_analog(keyboard_input_mappings[(size_t)GameInput::X_AXIS_NEG])
+ recomp::get_input_analog(controller_input_mappings[(size_t)GameInput::X_AXIS_POS])
- recomp::get_input_analog(controller_input_mappings[(size_t)GameInput::X_AXIS_NEG]);
cur_y = recomp::get_input_analog(keyboard_input_mappings[(size_t)GameInput::Y_AXIS_POS])
- recomp::get_input_analog(keyboard_input_mappings[(size_t)GameInput::Y_AXIS_NEG])
+ recomp::get_input_analog(controller_input_mappings[(size_t)GameInput::Y_AXIS_POS])
- recomp::get_input_analog(controller_input_mappings[(size_t)GameInput::Y_AXIS_NEG]);
}
*buttons_out = cur_buttons;
*x_out = cur_x;
*y_out = cur_y;
*x_out = std::clamp(cur_x, -1.0f, 1.0f);
*y_out = std::clamp(cur_y, -1.0f, 1.0f);
}
extern "C" void recomp_get_item_inputs(uint8_t* rdram, recomp_context* ctx) {
u32* buttons_out = _arg<0, u32*>(rdram, ctx);
uint32_t cur_buttons = 0;
if (!recomp::game_input_disabled()) {
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.b) ? N64Inputs::B : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.c_left) ? N64Inputs::C_LEFT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.c_right) ? N64Inputs::C_RIGHT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.c_down) ? N64Inputs::C_DOWN : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.dpad_left) ? N64Inputs::DPAD_LEFT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.dpad_right) ? N64Inputs::DPAD_RIGHT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.dpad_up) ? N64Inputs::DPAD_UP : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_keyboard_mappings.dpad_down) ? N64Inputs::DPAD_DOWN : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.b) ? N64Inputs::B : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.c_left) ? N64Inputs::C_LEFT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.c_right) ? N64Inputs::C_RIGHT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.c_down) ? N64Inputs::C_DOWN : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.dpad_left) ? N64Inputs::DPAD_LEFT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.dpad_right) ? N64Inputs::DPAD_RIGHT : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.dpad_up) ? N64Inputs::DPAD_UP : 0;
cur_buttons |= recomp::get_input_digital(recomp::default_n64_controller_mappings.dpad_down) ? N64Inputs::DPAD_DOWN : 0;
}
*buttons_out = cur_buttons;
}
bool recomp_digital_input_state[RECOMP_DIGITAL_INPUT_MAX];
float recomp_analog_input_state[RECOMP_ANALOG_INPUT_MAX];
extern "C" void recomp_update_inputs(uint8_t* rdram, recomp_context* ctx) {
recomp::poll_inputs();
}
extern "C" void recomp_get_digital_input(uint8_t* rdram, recomp_context* ctx) {
u32 input_slot = _arg<0, u32>(rdram, ctx);
// TODO implement this
_return<u32>(ctx, 0);
}
extern "C" void recomp_get_analog_input(uint8_t* rdram, recomp_context* ctx) {
u32 input_slot = _arg<0, u32>(rdram, ctx);
// TODO implement this
_return<float>(ctx, 0);
}
extern "C" void recomp_get_camera_inputs(uint8_t* rdram, recomp_context* ctx) {
float* x_out = _arg<0, float*>(rdram, ctx);
float* y_out = _arg<1, float*>(rdram, ctx);
float x_val = 0;
float y_val = 0;
if (!recomp::game_input_disabled()) {
x_val += recomp::get_input_analog(recomp::default_n64_keyboard_mappings.c_right) - recomp::get_input_analog(recomp::default_n64_keyboard_mappings.c_left);
y_val += recomp::get_input_analog(recomp::default_n64_keyboard_mappings.c_up) - recomp::get_input_analog(recomp::default_n64_keyboard_mappings.c_down);
x_val += recomp::get_input_analog(recomp::default_n64_controller_mappings.c_right) - recomp::get_input_analog(recomp::default_n64_controller_mappings.c_left);
y_val += recomp::get_input_analog(recomp::default_n64_controller_mappings.c_up) - recomp::get_input_analog(recomp::default_n64_controller_mappings.c_down);
}
*x_out = x_val;
*y_out = y_val;
}
// TODO move these
extern "C" void recomp_puts(uint8_t* rdram, recomp_context* ctx) {
PTR(char) cur_str = _arg<0, PTR(char)>(rdram, ctx);

View File

@ -234,6 +234,7 @@ int main(int argc, char** argv) {
reset_audio(48000);
init();
recomp::init_control_mappings();
ultramodern::gfx_callbacks_t gfx_callbacks{
.create_gfx = create_gfx,