Implement base DSi camera handling

This commit is contained in:
Rafael Caetano 2023-02-01 19:11:28 +00:00
parent 60cf5bfa50
commit 4dce6ceec0
4 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,17 @@
#ifndef ANDROIDCAMERAHANDLER_H
#define ANDROIDCAMERAHANDLER_H
#include "../types.h"
namespace MelonDSAndroid
{
class AndroidCameraHandler {
public:
virtual void startCamera(int camera) = 0;
virtual void stopCamera(int camera) = 0;
virtual void captureFrame(int camera, u32* frameBuffer, int width, int height, bool isYuv) = 0;
virtual ~AndroidCameraHandler() {};
};
}
#endif //ANDROIDCAMERAHANDLER_H

View File

@ -19,6 +19,7 @@
#include "FrontendUtil.h"
#include "RewindManager.h"
#include "ROMManager.h"
#include "AndroidCameraHandler.h"
#include "LocalMultiplayer.h"
#include <android/asset_manager.h>
#include <cstring>
@ -39,6 +40,7 @@ namespace MelonDSAndroid
int actualMicSource = 0;
AAssetManager* assetManager;
AndroidFileHandler* fileHandler;
AndroidCameraHandler* cameraHandler;
std::string internalFilesDir;
EmulatorConfiguration currentConfiguration;
@ -120,7 +122,8 @@ namespace MelonDSAndroid
RewindManager::SetRewindBufferSizes(1024 * 1024 * 20, 256 * 384 * 4);
}
void setup(AAssetManager* androidAssetManager, u32* textureBufferPointer, bool isMasterInstance) {
void setup(AAssetManager* androidAssetManager, AndroidCameraHandler* androidCameraHandler, u32* textureBufferPointer, bool isMasterInstance) {
cameraHandler = androidCameraHandler;
assetManager = androidAssetManager;
textureBuffer = textureBufferPointer;
LocalMultiplayer::SetIsMasterInstance(isMasterInstance);

View File

@ -3,6 +3,7 @@
#include <list>
#include "AndroidFileHandler.h"
#include "AndroidCameraHandler.h"
#include "RewindManager.h"
#include "../types.h"
#include "../GPU.h"
@ -64,10 +65,11 @@ namespace MelonDSAndroid {
extern AAssetManager* assetManager;
extern AndroidFileHandler* fileHandler;
extern AndroidCameraHandler* cameraHandler;
extern std::string internalFilesDir;
extern void setConfiguration(EmulatorConfiguration emulatorConfiguration);
extern void setup(AAssetManager* androidAssetManager, u32* textureBufferPointer, bool isMasterInstance);
extern void setup(AAssetManager* androidAssetManager, AndroidCameraHandler* androidCameraHandler, u32* textureBufferPointer, bool isMasterInstance);
extern void setCodeList(std::list<Cheat> cheats);
extern void updateEmulatorConfiguration(EmulatorConfiguration emulatorConfiguration);

View File

@ -442,13 +442,16 @@ namespace Platform
void Camera_Start(int num)
{
MelonDSAndroid::cameraHandler->startCamera(num);
}
void Camera_Stop(int num)
{
MelonDSAndroid::cameraHandler->stopCamera(num);
}
void Camera_CaptureFrame(int num, u32* frame, int width, int height, bool yuv)
{
MelonDSAndroid::cameraHandler->captureFrame(num, frame, width, height, yuv);
}
}