mirror of
https://github.com/N64Recomp/N64ModernRuntime.git
synced 2026-04-28 04:51:44 +00:00
Add check for controller device info in rumble functions (#132)
Some checks are pending
validate / ubuntu (arm64, Release) (push) Waiting to run
validate / ubuntu (x64, Debug) (push) Waiting to run
validate / ubuntu (x64, Release) (push) Waiting to run
validate / ubuntu (arm64, Debug) (push) Waiting to run
validate / windows (x64, Debug) (push) Waiting to run
validate / windows (x64, Release) (push) Waiting to run
validate / macos (arm64, Debug) (push) Waiting to run
validate / macos (arm64, Release) (push) Waiting to run
validate / macos (x64, Debug) (push) Waiting to run
validate / macos (x64, Release) (push) Waiting to run
Some checks are pending
validate / ubuntu (arm64, Release) (push) Waiting to run
validate / ubuntu (x64, Debug) (push) Waiting to run
validate / ubuntu (x64, Release) (push) Waiting to run
validate / ubuntu (arm64, Debug) (push) Waiting to run
validate / windows (x64, Debug) (push) Waiting to run
validate / windows (x64, Release) (push) Waiting to run
validate / macos (arm64, Debug) (push) Waiting to run
validate / macos (arm64, Release) (push) Waiting to run
validate / macos (x64, Debug) (push) Waiting to run
validate / macos (x64, Release) (push) Waiting to run
This commit is contained in:
parent
575c8f22a0
commit
9ae9dbbe41
1 changed files with 36 additions and 1 deletions
|
|
@ -4,6 +4,17 @@
|
||||||
#include "ultramodern/ultra64.h"
|
#include "ultramodern/ultra64.h"
|
||||||
#include "ultramodern/ultramodern.hpp"
|
#include "ultramodern/ultramodern.hpp"
|
||||||
|
|
||||||
|
#define PFS_ERR_NOPACK 1 // no device inserted
|
||||||
|
#define PFS_ERR_CONTRFAIL 4 // data transmission failure
|
||||||
|
#define PFS_ERR_INVALID 5 // invalid parameter or invalid file
|
||||||
|
#define PFS_ERR_DEVICE 11 // different type of device inserted
|
||||||
|
|
||||||
|
#define PFS_INITIALIZED 1
|
||||||
|
#define PFS_CORRUPTED 2
|
||||||
|
#define PFS_ID_BROKEN 4
|
||||||
|
#define PFS_MOTOR_INITIALIZED 8
|
||||||
|
#define PFS_GBPAK_INITIALIZED 16
|
||||||
|
|
||||||
static ultramodern::input::callbacks_t input_callbacks {};
|
static ultramodern::input::callbacks_t input_callbacks {};
|
||||||
|
|
||||||
void ultramodern::input::set_callbacks(const callbacks_t& callbacks) {
|
void ultramodern::input::set_callbacks(const callbacks_t& callbacks) {
|
||||||
|
|
@ -154,8 +165,28 @@ extern "C" void osContGetReadData(OSContPad *data) {
|
||||||
s32 osMotorInit(RDRAM_ARG PTR(OSMesgQueue) mq, PTR(OSPfs) pfs_, int channel) {
|
s32 osMotorInit(RDRAM_ARG PTR(OSMesgQueue) mq, PTR(OSPfs) pfs_, int channel) {
|
||||||
OSPfs *pfs = TO_PTR(OSPfs, pfs_);
|
OSPfs *pfs = TO_PTR(OSPfs, pfs_);
|
||||||
|
|
||||||
|
// basic initialization performed regardless of connected/disconnected status
|
||||||
|
pfs->queue = mq;
|
||||||
pfs->channel = channel;
|
pfs->channel = channel;
|
||||||
|
pfs->activebank = 0xFF;
|
||||||
|
pfs->status = 0;
|
||||||
|
|
||||||
|
ultramodern::input::connected_device_info_t device_info{};
|
||||||
|
if (input_callbacks.get_connected_device_info != nullptr) {
|
||||||
|
device_info = input_callbacks.get_connected_device_info(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device_info.connected_device != ultramodern::input::Device::Controller) {
|
||||||
|
return PFS_ERR_CONTRFAIL;
|
||||||
|
}
|
||||||
|
if (device_info.connected_pak == ultramodern::input::Pak::None) {
|
||||||
|
return PFS_ERR_NOPACK;
|
||||||
|
}
|
||||||
|
if (device_info.connected_pak != ultramodern::input::Pak::RumblePak) {
|
||||||
|
return PFS_ERR_DEVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pfs->status = PFS_MOTOR_INITIALIZED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,10 +201,14 @@ s32 osMotorStart(RDRAM_ARG PTR(OSPfs) pfs) {
|
||||||
s32 __osMotorAccess(RDRAM_ARG PTR(OSPfs) pfs_, s32 flag) {
|
s32 __osMotorAccess(RDRAM_ARG PTR(OSPfs) pfs_, s32 flag) {
|
||||||
OSPfs *pfs = TO_PTR(OSPfs, pfs_);
|
OSPfs *pfs = TO_PTR(OSPfs, pfs_);
|
||||||
|
|
||||||
|
if (!(pfs->status & PFS_MOTOR_INITIALIZED)) {
|
||||||
|
return PFS_ERR_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
if (input_callbacks.set_rumble != nullptr) {
|
if (input_callbacks.set_rumble != nullptr) {
|
||||||
// TODO: Should we check if the Rumble Pak is connected? Or just rumble regardless of the connected Pak?
|
|
||||||
input_callbacks.set_rumble(pfs->channel, flag);
|
input_callbacks.set_rumble(pfs->channel, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue