mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-08-21 21:40:36 -04:00
Implement & link padmgr
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#define OS_CONT_PAD
|
||||
|
||||
#include "types.h"
|
||||
#include "libultra/os_pfs.h"
|
||||
#include "dolphin/os/OSMessage.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -11,20 +13,63 @@ extern "C" {
|
||||
|
||||
#define MAXCONTROLLERS 4
|
||||
|
||||
/* controller errors */
|
||||
#define CONT_NO_ERROR 0
|
||||
#define CONT_NO_RESPONSE_ERROR 0x8
|
||||
#define CONT_OVERRUN_ERROR 0x4
|
||||
#define CONT_RANGE_ERROR -1
|
||||
|
||||
/* Controller type */
|
||||
#define CONT_NONE 0x0000
|
||||
#define CONT_ABSOLUTE 0x0001
|
||||
#define CONT_RELATIVE 0x0002
|
||||
#define CONT_JOYPORT 0x0004
|
||||
#define CONT_EEPROM 0x8000
|
||||
#define CONT_EEP16K 0x4000
|
||||
#define CONT_TYPE_MASK 0x1f07
|
||||
#define CONT_TYPE_NORMAL 0x0005
|
||||
#define CONT_TYPE_MOUSE 0x0002
|
||||
#define CONT_TYPE_VOICE 0x0100
|
||||
|
||||
/* Controller status */
|
||||
|
||||
#define CONT_CARD_ON 0x01
|
||||
#define CONT_CARD_PULL 0x02
|
||||
#define CONT_ADDR_CRC_ER 0x04
|
||||
#define CONT_EEPROM_BUSY 0x80
|
||||
|
||||
/* Controller error number */
|
||||
|
||||
#define CONT_ERR_NO_CONTROLLER PFS_ERR_NOPACK /* 1 */
|
||||
#define CONT_ERR_CONTRFAIL CONT_OVERRUN_ERROR /* 4 */
|
||||
#define CONT_ERR_INVALID PFS_ERR_INVALID /* 5 */
|
||||
#define CONT_ERR_DEVICE PFS_ERR_DEVICE /* 11 */
|
||||
#define CONT_ERR_NOT_READY 12
|
||||
#define CONT_ERR_VOICE_MEMORY 13
|
||||
#define CONT_ERR_VOICE_WORD 14
|
||||
#define CONT_ERR_VOICE_NO_RESPONSE 15
|
||||
|
||||
typedef struct {
|
||||
u16 type;
|
||||
u8 status;
|
||||
u8 errno;
|
||||
u16 type;
|
||||
u8 status;
|
||||
u8 errno;
|
||||
} OSContStatus;
|
||||
|
||||
/* sizeof(OSContPad) == 6 */
|
||||
typedef struct {
|
||||
/* 0x00 */ u16 button;
|
||||
/* 0x02 */ s8 stick_x;
|
||||
/* 0x03 */ s8 stick_y;
|
||||
/* 0x04 */ u8 errno;
|
||||
/* 0x00 */ u16 button;
|
||||
/* 0x02 */ s8 stick_x;
|
||||
/* 0x03 */ s8 stick_y;
|
||||
/* 0x04 */ u8 errno;
|
||||
} OSContPad;
|
||||
|
||||
extern s32 osContInit(OSMessageQueue* mq, u8* pattern_p, OSContStatus* status);
|
||||
extern s32 osContStartQuery(OSMessageQueue* mq);
|
||||
extern s32 osContStartReadData(OSMessageQueue* mq);
|
||||
extern void osContGetQuery(OSContStatus* status);
|
||||
extern s32 osContSetCh(u8 num_controllers);
|
||||
extern void osContGetReadData(OSContPad* pad);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef OS_PFS_H
|
||||
#define OS_PFS_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* File System error number */
|
||||
|
||||
#define PFS_ERR_NOPACK 1 /* no memory card is plugged or */
|
||||
#define PFS_ERR_NEW_PACK 2 /* ram pack has been changed to a different one */
|
||||
#define PFS_ERR_INCONSISTENT 3 /* need to run Pfschecker*/
|
||||
#define PFS_ERR_CONTRFAIL CONT_OVERRUN_ERROR
|
||||
#define PFS_ERR_INVALID 5 /* invalid parameter or file not exist*/
|
||||
#define PFS_ERR_BAD_DATA 6 /* the data read from pack are bad*/
|
||||
#define PFS_DATA_FULL 7 /* no free pages on ram pack*/
|
||||
#define PFS_DIR_FULL 8 /* no free directories on ram pack*/
|
||||
#define PFS_ERR_EXIST 9 /* file exists*/
|
||||
#define PFS_ERR_ID_FATAL 10 /* dead ram pack */
|
||||
#define PFS_ERR_DEVICE 11 /* wrong device type*/
|
||||
#define PFS_ERR_NO_GBCART 12 /* no gb cartridge (64GB-PAK) */
|
||||
#define PFS_ERR_NEW_GBCART 13 /* gb cartridge may be changed */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+31
-7
@@ -6,6 +6,7 @@
|
||||
#include "libu64/pad.h"
|
||||
#include "dolphin/os/OSMessage.h"
|
||||
#include "libultra/osThread.h"
|
||||
#include "libu64/pad.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -13,6 +14,10 @@ extern "C" {
|
||||
|
||||
#define PADMSGBUFCNT 8
|
||||
|
||||
#define PADMGR_FLAG_HANDLE_RETRACE (1 << 0)
|
||||
#define PADMGR_FLAG_HANDLE_PRENMI (1 << 1)
|
||||
#define PADMGR_FLAG_DONE (1 << 2)
|
||||
|
||||
enum pads {
|
||||
PAD0,
|
||||
PAD1,
|
||||
@@ -22,6 +27,26 @@ enum pads {
|
||||
PAD_NUM
|
||||
};
|
||||
|
||||
enum {
|
||||
PADMGR_PAK_NONE,
|
||||
PADMGR_PAK_RUMBLE,
|
||||
PADMGR_PAK_CONTROLLER,
|
||||
PADMGR_PAK_UNK,
|
||||
|
||||
PADMGR_PAK_NUM
|
||||
};
|
||||
|
||||
enum {
|
||||
PADMGR_TYPE_NONE,
|
||||
PADMGR_TYPE_CONTROLLER,
|
||||
PADMGR_TYPE_2,
|
||||
PADMGR_TYPE_MOUSE,
|
||||
PADMGR_TYPE_VOICE_UNINTIALIZED,
|
||||
PADMGR_TYPE_VOICE_INITIALIZED,
|
||||
|
||||
PADMGR_TYPE_UNK = 255
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u8 last_command; // PAD_MOTOR_*
|
||||
u8 now_command; // PAD_MOTOR_*
|
||||
@@ -43,22 +68,21 @@ typedef struct {
|
||||
/* 0x0008 */ void* callback_param;
|
||||
/* 0x000C */ void (*callback2)(void*);
|
||||
/* 0x0010 */ void* callback2_param;
|
||||
|
||||
/* 0x0014 */ OSContStatus pad_status[MAXCONTROLLERS];
|
||||
/* 0x0024 */ OSMessage _msg24;
|
||||
/* 0x0028 */ OSMessage _msg28;
|
||||
/* 0x002C */ OSMessage _msgBuf2C[PADMSGBUFCNT];
|
||||
/* 0x004C */ OSMessageQueue _msgQueue4C;
|
||||
/* 0x006C */ OSMessageQueue _msgQueue6C;
|
||||
/* 0x004C */ OSMessageQueue serial_mq;
|
||||
/* 0x006C */ OSMessageQueue controller_lock_mq;
|
||||
/* 0x008C */ OSMessageQueue _msgQueue8C;
|
||||
/* 0x00AC */ irqmgr_client_t irqclient;
|
||||
/* 0x00B4 */ u32 _unk0; /* maybe additional value in irqmgr_client_t? */
|
||||
/* 0x00B8 */ OSThread thread;
|
||||
/* 0x03C8 */ u8 _tmp[0x60]; // pad_t pads[MAXCONTROLLERS]; // TODO: figure out what's going on here.
|
||||
/* 0x0428 */ OSContPad n64_pads[MAXCONTROLLERS]; /* Converted from PADStatus via JUTGamePad */
|
||||
/* 0x03C8 */ pad_t pads[MAXCONTROLLERS];
|
||||
/* 0x0428 */ OSContPad cur_pads[MAXCONTROLLERS]; /* Converted from PADStatus via JUTGamePad */
|
||||
/* 0x0440 */ u8 num_controllers;
|
||||
/* 0x0441 */ u8 device_type[4];
|
||||
/* 0x0445 */ u8 pak_type[4];
|
||||
/* 0x0441 */ u8 device_type[MAXCONTROLLERS];
|
||||
/* 0x0445 */ u8 pak_type[MAXCONTROLLERS];
|
||||
/* 0x044A */ Rumble_t rumble;
|
||||
} padmgr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user