Fix osContGetReadData

This commit is contained in:
angie 2024-06-06 19:42:37 -04:00
parent b57f0f995c
commit c6afd5c811
3 changed files with 16 additions and 10 deletions

View file

@ -2,6 +2,8 @@
#include "helpers.hpp"
#define MAXCONTROLLERS 4
extern "C" void recomp_set_current_frame_poll_id(uint8_t* rdram, recomp_context* ctx) {
// TODO reimplement the system for tagging polls with IDs to handle games with multithreaded input polling.
}
@ -40,7 +42,16 @@ extern "C" void osContStartReadData_recomp(uint8_t* rdram, recomp_context* ctx)
extern "C" void osContGetReadData_recomp(uint8_t* rdram, recomp_context* ctx) {
PTR(OSContPad) data = _arg<0, PTR(OSContPad)>(rdram, ctx);
osContGetReadData(PASS_RDRAM data);
OSContPad dummy_data[MAXCONTROLLERS];
osContGetReadData(dummy_data);
for (int controller = 0; controller < MAXCONTROLLERS; controller++) {
MEM_H(6 * controller + 0, data) = dummy_data[controller].button;
MEM_B(6 * controller + 2, data) = dummy_data[controller].stick_x;
MEM_B(6 * controller + 3, data) = dummy_data[controller].stick_y;
MEM_B(6 * controller + 4, data) = dummy_data[controller].err_no;
}
}
extern "C" void osContStartQuery_recomp(uint8_t * rdram, recomp_context * ctx) {

View file

@ -246,12 +246,9 @@ typedef struct {
} OSContStatus;
typedef struct {
// These three members reversed due to endianness
s8 stick_y; /* -80 <= stick_y <= 80 */
s8 stick_x; /* -80 <= stick_x <= 80 */
u16 button;
// Padding due to endianness
u8 padding[3];
s8 stick_x; /* -80 <= stick_x <= 80 */
s8 stick_y; /* -80 <= stick_y <= 80 */
u8 err_no;
} OSContPad;
@ -305,7 +302,7 @@ s32 osContStartQuery(RDRAM_ARG PTR(OSMesgQueue));
s32 osContStartReadData(RDRAM_ARG PTR(OSMesgQueue));
s32 osContSetCh(RDRAM_ARG u8);
void osContGetQuery(RDRAM_ARG PTR(OSContStatus));
void osContGetReadData(RDRAM_ARG PTR(OSContPad));
void osContGetReadData(OSContPad *);
/* Rumble PAK interface */

View file

@ -128,9 +128,7 @@ extern "C" void osContGetQuery(RDRAM_ARG PTR(OSContStatus) data_) {
__osContGetInitData(&pattern, data);
}
extern "C" void osContGetReadData(RDRAM_ARG PTR(OSContPad) data_) {
OSContPad *data = TO_PTR(OSContPad, data_);
extern "C" void osContGetReadData(OSContPad *data) {
for (int controller = 0; controller < max_controllers; controller++) {
uint16_t buttons = 0;
float x = 0.0f;