Implement & link m_vibctl.c

This commit is contained in:
Cuyler36
2023-06-17 23:52:03 -04:00
parent 214069927d
commit 1f7c355a5e
5 changed files with 583 additions and 7 deletions
+4
View File
@@ -7,6 +7,10 @@
extern "C" {
#endif
#define PAD_MOTOR_STOP 0
#define PAD_MOTOR_RUMBLE 1
#define PAD_MOTOR_STOP_HARD 2
#define PAD_BUTTON_LEFT 0x0001
#define PAD_BUTTON_RIGHT 0x0002
#define PAD_BUTTON_DOWN 0x0004
+76 -1
View File
@@ -7,9 +7,84 @@
extern "C" {
#endif
#define mVibctl_FLAG_FORCE_STOP_NONE 0
#define mVibctl_FLAG_FORCE_STOP0 (1 << 0) // 1
#define mVibctl_FLAG_FORCE_STOP1 (1 << 1) // 2
#define mVibctl_FLAG_FORCE_STOP2 (1 << 2) // 4
#define mVibctl_FLAG_FORCE_STOP3 (1 << 3) // 8
#define mVibctl_FLAG_FORCE_STOP_ALL (mVibctl_FLAG_FORCE_STOP0 | mVibctl_FLAG_FORCE_STOP1 | mVibctl_FLAG_FORCE_STOP2 | mVibctl_FLAG_FORCE_STOP3) // 15
enum {
mVibctl_ELEM_ENTRY_ATTACK, // fade-in program
mVibctl_ELEM_ENTRY_SUSTAIN, // sustain program
mVibctl_ELEM_ENTRY_RELEASE, // fade-out program
mVibctl_ELEM_ENTRY_END, // program has finished
mVibctl_ELEM_ENTRY_NUM = mVibctl_ELEM_ENTRY_END
};
enum {
mVibctl_VIB_PROG_NON, // rumble config attack, shake tree attack
mVibctl_VIB_PROG_FFF, // fish touch bobber, fishing rod cast, rumble config sustain, Mouth of Truth furniture interaction attack & sustain, shovel hits soft object, net swing, axe cut attack & release, trip attack, pick weed sustain & release
mVibctl_VIB_PROG_F, // unused?
mVibctl_VIB_PROG_MF, // unused?
mVibctl_VIB_PROG_MP, // unused?
mVibctl_VIB_PROG_P, // rumble config release, shake tree release
mVibctl_VIB_PROG_FUNBARI, // unused?
mVibctl_VIB_PROG_ANAHORI, // digging with shovel
mVibctl_VIB_PROG_ANAUME, // filling hole with shovel
mVibctl_VIB_PROG_IMPACT, // fish bite bobber, shovel hits hard object
mVibctl_VIB_PROG_KI_GA_TAORERU, // axe cut sustain
mVibctl_VIB_PROG_KI_WO_YUSURU, // shake tree sustain
mVibctl_VIB_PROG_KORONODA, // trip sustain
mVibctl_VIB_PROG_SURPRISE, // Mouth of Truth furniture interaction release
mVibctl_VIB_PROG_DUMMY_B, // unused?
mVibctl_VIB_PROG_SAMPLE, // unused?
mVibctl_VIB_PROG_NUM
};
#define mVibctl_ELEM_NUM 4
typedef struct vibration_element_entry_s {
int type;
int frames;
f32 step;
} mVibInfo_elem_entry_c;
typedef struct vibration_element_s {
mVibInfo_elem_entry_c entries[mVibctl_ELEM_ENTRY_NUM];
f32 step0;
f32 step1;
int now_entry;
int state_idx;
f32 frame_intensity;
int entry_frame;
f32 now_intensity;
int command; // for padmgr, PAD_MOTOR_*
} mVibElem_c;
typedef struct vibration_info_s {
mVibElem_c* target_elem;
mVibElem_c elements[mVibctl_ELEM_NUM];
int num_elements;
int force_stop;
int last_force_stop;
} mVibInfo_c;
typedef struct vibration_work_data_S {
const u8* data;
int count;
} mVibWorkData_c;
extern void mVibctl_ct();
extern void mVibctl_reset();
extern void mVibctl_init0();
extern void mVibctl_init();
extern void mVibctl_reset();
extern void mVibctl_entry(int total_frames, int attack_type, int sustain_type, int release_type, int attack_frames, int sustain_frames, int release_frames, f32 step);
extern void mVibctl_simple_entry(int total_frames, int type, int attack_frames, int sustain_frames, int release_frames, f32 step);
extern void mVibctl_set_force_stop(int force_stop);
extern void mVibctl_clr_force_stop(int force_stop);
#ifdef __cplusplus
}
+9 -6
View File
@@ -22,8 +22,8 @@ enum pads {
};
typedef struct {
u8 last_intensity;
u8 now_intensity;
u8 last_command; // PAD_MOTOR_*
u8 now_command; // PAD_MOTOR_*
u8 frames;
u8 _pad;
} Motor_t;
@@ -64,18 +64,21 @@ typedef struct {
extern padmgr padmgr_class;
extern int padmgr_isConnectedController(int pad);
extern void padmgr_force_stop_ON();
extern void padmgr_force_stop_OFF();
extern void padmgr_RumbleSet(int pad, int intensity);
#define padmgr_setClient(callback, param) \
#define padmgr_setClient(callback_proc, param) \
do { \
padmgr* mgr = &padmgr_class; \
mgr->callback = callback; \
mgr->callback = callback_proc; \
mgr->callback_param = param; \
} while (0)
#define padmgr_removeClient(callback, param) \
#define padmgr_removeClient(callback_proc, param) \
do { \
padmgr* mgr = &padmgr_class; \
if (mgr->callback == (callback) && mgr->callback_param == (param)) { \
if (mgr->callback == (callback_proc) && mgr->callback_param == (param)) { \
mgr->callback = NULL; \
mgr->callback_param = NULL; \
} \