Permalink
Browse files

Integrate sceUsbGps and sceUsbCam with Android

  • Loading branch information...
Florin9doi committed Aug 20, 2017
1 parent 4938ab7 commit 892bc8617df71fc332a0757136bd6b7a50f8716e
View
@@ -1500,6 +1500,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/HLE/sceUmd.h
Core/HLE/sceUsb.cpp
Core/HLE/sceUsb.h
Core/HLE/sceUsbCam.cpp
Core/HLE/sceUsbCam.h
Core/HLE/sceUsbGps.cpp
Core/HLE/sceUsbGps.h
Core/HLE/sceUtility.cpp
View
@@ -186,6 +186,7 @@
<ClCompile Include="AVIDump.cpp" />
<ClCompile Include="FileSystems\BlobFileSystem.cpp" />
<ClCompile Include="HLE\KUBridge.cpp" />
<ClCompile Include="HLE\sceUsbCam.cpp" />
<ClCompile Include="MIPS\IR\IRAsm.cpp" />
<ClCompile Include="MIPS\IR\IRCompALU.cpp" />
<ClCompile Include="MIPS\IR\IRCompBranch.cpp" />
@@ -528,6 +529,7 @@
<ClInclude Include="AVIDump.h" />
<ClInclude Include="FileSystems\BlobFileSystem.h" />
<ClInclude Include="HLE\KUBridge.h" />
<ClInclude Include="HLE\sceUsbCam.h" />
<ClInclude Include="MIPS\IR\IRFrontend.h" />
<ClInclude Include="MIPS\IR\IRInst.h" />
<ClInclude Include="MIPS\IR\IRInterpreter.h" />
@@ -683,6 +683,9 @@
<ClCompile Include="FileSystems\BlobFileSystem.cpp">
<Filter>FileSystems</Filter>
</ClCompile>
<ClCompile Include="HLE\sceUsbCam.cpp">
<Filter>HLE\Libraries</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ELF\ElfReader.h">
@@ -1256,6 +1259,9 @@
<ClInclude Include="FileSystems\BlobFileSystem.h">
<Filter>FileSystems</Filter>
</ClInclude>
<ClInclude Include="HLE\sceUsbCam.h">
<Filter>HLE\Libraries</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
View
@@ -66,10 +66,11 @@
#include "sceSsl.h"
#include "sceUmd.h"
#include "sceUsb.h"
#include "sceUsbCam.h"
#include "sceUsbGps.h"
#include "sceUtility.h"
#include "sceVaudio.h"
#include "sceMt19937.h"
#include "sceUsbGps.h"
#include "sceSha256.h"
#include "sceAdler.h"
#include "sceSfmt19937.h"
View
@@ -75,6 +75,7 @@
#include "scePsmf.h"
#include "sceImpose.h"
#include "sceUsb.h"
#include "sceUsbGps.h"
#include "scePspNpDrm_user.h"
#include "sceVaudio.h"
#include "sceHeap.h"
@@ -132,6 +133,7 @@ void __KernelInit()
__SslInit();
__ImposeInit();
__UsbInit();
__UsbGpsInit();
__FontInit();
__NetInit();
__NetAdhocInit();
@@ -261,6 +263,7 @@ void __KernelDoState(PointerWrap &p)
__UmdDoState(p);
__UtilityDoState(p);
__UsbDoState(p);
__UsbGpsDoState(p);
__VaudioDoState(p);
__HeapDoState(p);
View
@@ -15,6 +15,7 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "base/NativeApp.h"
#include "Core/HLE/HLE.h"
#include "Core/HLE/FunctionWrappers.h"
#include "Core/MIPS/MIPS.h"
@@ -74,10 +75,15 @@ static int sceUsbStop(const char* driverName, u32 argsSize, u32 argsPtr) {
}
static int sceUsbGetState() {
ERROR_LOG(HLE, "UNIMPL sceUsbGetState");
int state = (usbStarted ? USB_STATUS_STARTED : USB_STATUS_STOPPED)
| (usbConnected ? USB_STATUS_CONNECTED : USB_STATUS_DISCONNECTED)
| (usbActivated ? USB_STATUS_ACTIVATED : USB_STATUS_DEACTIVATED);
int state = 0;
if (!usbStarted) {
state = 0x80243007;
} else {
state = USB_STATUS_STARTED
| (usbConnected ? USB_STATUS_CONNECTED : USB_STATUS_DISCONNECTED)
| (usbActivated ? USB_STATUS_ACTIVATED : USB_STATUS_DEACTIVATED);
}
ERROR_LOG(HLE, "UNIMPL sceUsbGetState: 0x%x", state);
return state;
}
@@ -122,68 +128,9 @@ const HLEFunction sceUsbstorBoot[] =
{0XA55C9E16, nullptr, "sceUsbstorBootUnregisterNotify", '?', "" },
};
const HLEFunction sceUsbCam[] =
{
{0X17F7B2FB, nullptr, "sceUsbCamSetupVideo", '?', "" },
{0XF93C4669, nullptr, "sceUsbCamAutoImageReverseSW", '?', "" },
{0X574A8C3F, nullptr, "sceUsbCamStartVideo", '?', "" },
{0X6CF32CB9, nullptr, "sceUsbCamStopVideo", '?', "" },
{0X03ED7A82, nullptr, "sceUsbCamSetupMic", '?', "" },
{0X82A64030, nullptr, "sceUsbCamStartMic", '?', "" },
{0X7DAC0C71, nullptr, "sceUsbCamReadVideoFrameBlocking", '?', "" },
{0X99D86281, nullptr, "sceUsbCamReadVideoFrame", '?', "" },
{0X41E73E95, nullptr, "sceUsbCamPollReadVideoFrameEnd", '?', "" },
{0XF90B2293, nullptr, "sceUsbCamWaitReadVideoFrameEnd", '?', "" },
{0X4C34F553, nullptr, "sceUsbCamGetLensDirection", '?', "" },
{0X3F0CF289, nullptr, "sceUsbCamSetupStill", '?', "" },
{0X0A41A298, nullptr, "sceUsbCamSetupStillEx", '?', "" },
{0X61BE5CAC, nullptr, "sceUsbCamStillInputBlocking", '?', "" },
{0XFB0A6C5D, nullptr, "sceUsbCamStillInput", '?', "" },
{0X7563AFA1, nullptr, "sceUsbCamStillWaitInputEnd", '?', "" },
{0X1A46CFE7, nullptr, "sceUsbCamStillPollInputEnd", '?', "" },
{0XA720937C, nullptr, "sceUsbCamStillCancelInput", '?', "" },
{0XE5959C36, nullptr, "sceUsbCamStillGetInputLength", '?', "" },
{0XCFE9E999, nullptr, "sceUsbCamSetupVideoEx", '?', "" },
{0XDF9D0C92, nullptr, "sceUsbCamGetReadVideoFrameSize", '?', "" },
{0X6E205974, nullptr, "sceUsbCamSetSaturation", '?', "" },
{0X4F3D84D5, nullptr, "sceUsbCamSetBrightness", '?', "" },
{0X09C26C7E, nullptr, "sceUsbCamSetContrast", '?', "" },
{0X622F83CC, nullptr, "sceUsbCamSetSharpness", '?', "" },
{0XD4876173, nullptr, "sceUsbCamSetImageEffectMode", '?', "" },
{0X1D686870, nullptr, "sceUsbCamSetEvLevel", '?', "" },
{0X951BEDF5, nullptr, "sceUsbCamSetReverseMode", '?', "" },
{0XC484901F, nullptr, "sceUsbCamSetZoom", '?', "" },
{0X383E9FA8, nullptr, "sceUsbCamGetSaturation", '?', "" },
{0X70F522C5, nullptr, "sceUsbCamGetBrightness", '?', "" },
{0XA063A957, nullptr, "sceUsbCamGetContrast", '?', "" },
{0XFDB68C23, nullptr, "sceUsbCamGetSharpness", '?', "" },
{0X994471E0, nullptr, "sceUsbCamGetImageEffectMode", '?', "" },
{0X2BCD50C0, nullptr, "sceUsbCamGetEvLevel", '?', "" },
{0XD5279339, nullptr, "sceUsbCamGetReverseMode", '?', "" },
{0X9E8AAF8D, nullptr, "sceUsbCamGetZoom", '?', "" },
{0X11A1F128, nullptr, "sceUsbCamGetAutoImageReverseState", '?', "" },
{0X08AEE98A, nullptr, "sceUsbCamSetMicGain", '?', "" },
{0X2E930264, nullptr, "sceUsbCamSetupMicEx", '?', "" },
{0X36636925, nullptr, "sceUsbCamReadMicBlocking", '?', "" },
{0X3DC0088E, nullptr, "sceUsbCamReadMic", '?', "" },
{0X41EE8797, nullptr, "sceUsbCamUnregisterLensRotationCallback", '?', "" },
{0X5145868A, nullptr, "sceUsbCamStopMic", '?', "" },
{0X5778B452, nullptr, "sceUsbCamGetMicDataLength", '?', "" },
{0X6784E6A8, nullptr, "sceUsbCamSetAntiFlicker", '?', "" },
{0XAA7D94BA, nullptr, "sceUsbCamGetAntiFlicker", '?', "" },
{0XB048A67D, nullptr, "sceUsbCamWaitReadMicEnd", '?', "" },
{0XD293A100, nullptr, "sceUsbCamRegisterLensRotationCallback", '?', "" },
{0XF8847F60, nullptr, "sceUsbCamPollReadMicEnd", '?', "" },
};
void Register_sceUsb()
{
RegisterModule("sceUsbstor", ARRAY_SIZE(sceUsbstor), sceUsbstor);
RegisterModule("sceUsbstorBoot", ARRAY_SIZE(sceUsbstorBoot), sceUsbstorBoot);
RegisterModule("sceUsb", ARRAY_SIZE(sceUsb), sceUsb);
}
void Register_sceUsbCam()
{
RegisterModule("sceUsbCam", ARRAY_SIZE(sceUsbCam), sceUsbCam);
}
View
@@ -22,4 +22,3 @@ void Register_sceUsb();
void __UsbInit();
void __UsbDoState(PointerWrap &p);
void Register_sceUsbCam();
View
@@ -0,0 +1,181 @@
// Copyright (c) 2012- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <mutex>
#include "base/NativeApp.h"
#include "Common/ChunkFile.h"
#include "Core/HLE/HLE.h"
#include "Core/HLE/FunctionWrappers.h"
#include "Core/HLE/sceUsbCam.h"
#include "Core/MemMapHelpers.h"
PspUsbCamSetupMicParam micParam;
PspUsbCamSetupVideoParam videoParam;
unsigned int videoBufferLength = 0;
unsigned int nextVideoFrame = 0;
unsigned char videoBuffer[40 * 1000];
std::mutex videoBufferMutex;
static int sceUsbCamSetupMic(u32 paramAddr, u32 workareaAddr, int wasize) {
INFO_LOG(HLE, "UNIMPL sceUsbCamSetupMic");
if (Memory::IsValidRange(paramAddr, sizeof(micParam))) {
Memory::ReadStruct(paramAddr, &micParam);
}
return 0;
}
static int sceUsbCamStartMic() {
INFO_LOG(HLE, "UNIMPL sceUsbCamStartMic");
return 0;
}
static int sceUsbCamStopMic() {
INFO_LOG(HLE, "UNIMPL sceUsbCamStopMic");
return 0;
}
static int sceUsbCamSetupVideo(u32 paramAddr, u32 workareaAddr, int wasize) {
INFO_LOG(HLE, "UNIMPL sceUsbCamSetupVideo");
if (Memory::IsValidRange(paramAddr, sizeof(videoParam))) {
Memory::ReadStruct(paramAddr, &videoParam);
}
std::lock_guard<std::mutex> lock(videoBufferMutex);
videoBufferLength = sizeof(sceUsbCamDummyImage);
memset(videoBuffer, 0, sizeof(videoBuffer));
memcpy(videoBuffer, sceUsbCamDummyImage, sizeof(sceUsbCamDummyImage));
INFO_LOG(HLE, "UNIMPL sceUsbCamSetupVideo - size: %d", videoParam.size);
INFO_LOG(HLE, "UNIMPL sceUsbCamSetupVideo - resolution: %d", videoParam.resolution);
return 0;
}
static int sceUsbCamStartVideo() {
INFO_LOG(HLE, "UNIMPL sceUsbCamStartVideo");
System_SendMessage("camera_command", "startVideo");
return 0;
}
static int sceUsbCamStopVideo() {
INFO_LOG(HLE, "UNIMPL sceUsbCamStopVideo");
System_SendMessage("camera_command", "stopVideo");
return 0;
}
static int sceUsbCamAutoImageReverseSW(int rev) {
INFO_LOG(HLE, "UNIMPL sceUsbCamAutoImageReverseSW");
return 0;
}
static int sceUsbCamReadVideoFrameBlocking(u32 bufAddr, u32 size) {
std::lock_guard<std::mutex> lock(videoBufferMutex);
for (unsigned int i = 0; i < videoBufferLength && i < size; i++) {
if (Memory::IsValidAddress(bufAddr + i)) {
Memory::Write_U8(videoBuffer[i], bufAddr + i);
}
}
return videoBufferLength;
}
static int sceUsbCamReadVideoFrame(u32 bufAddr, u32 size) {
std::lock_guard<std::mutex> lock(videoBufferMutex);
for (unsigned int i = 0; i < videoBufferLength && i < size; i++) {
if (Memory::IsValidAddress(bufAddr + i)) {
Memory::Write_U8(videoBuffer[i], bufAddr + i);
}
}
nextVideoFrame = videoBufferLength;
return 0;
}
static int sceUsbCamPollReadVideoFrameEnd() {
INFO_LOG(HLE, "UNIMPL sceUsbCamPollReadVideoFrameEnd: %d", nextVideoFrame);
return nextVideoFrame;
}
const HLEFunction sceUsbCam[] =
{
{ 0X03ED7A82, &WrapI_UUI<sceUsbCamSetupMic>, "sceUsbCamSetupMic", 'i', "xxi" },
{ 0X2E930264, nullptr, "sceUsbCamSetupMicEx", '?', "" },
{ 0X82A64030, &WrapI_V<sceUsbCamStartMic>, "sceUsbCamStartMic", 'i', "" },
{ 0X5145868A, &WrapI_V<sceUsbCamStopMic>, "sceUsbCamStopMic", 'i', "" },
{ 0X36636925, nullptr, "sceUsbCamReadMicBlocking", '?', "" },
{ 0X3DC0088E, nullptr, "sceUsbCamReadMic", '?', "" },
{ 0XB048A67D, nullptr, "sceUsbCamWaitReadMicEnd", '?', "" },
{ 0XF8847F60, nullptr, "sceUsbCamPollReadMicEnd", '?', "" },
{ 0X5778B452, nullptr, "sceUsbCamGetMicDataLength", '?', "" },
{ 0X08AEE98A, nullptr, "sceUsbCamSetMicGain", '?', "" },
{ 0X17F7B2FB, &WrapI_UUI<sceUsbCamSetupVideo>, "sceUsbCamSetupVideo", 'i', "xxi" },
{ 0XCFE9E999, nullptr, "sceUsbCamSetupVideoEx", '?', "" },
{ 0X574A8C3F, &WrapI_V<sceUsbCamStartVideo>, "sceUsbCamStartVideo", 'i', "" },
{ 0X6CF32CB9, &WrapI_V<sceUsbCamStopVideo>, "sceUsbCamStopVideo", 'i', "" },
{ 0X7DAC0C71, &WrapI_UU<sceUsbCamReadVideoFrameBlocking>, "sceUsbCamReadVideoFrameBlocking", 'i', "xx" },
{ 0X99D86281, &WrapI_UU<sceUsbCamReadVideoFrame>, "sceUsbCamReadVideoFrame", 'i', "xx" },
{ 0XF90B2293, nullptr, "sceUsbCamWaitReadVideoFrameEnd", '?', "" },
{ 0X41E73E95, &WrapI_V<sceUsbCamPollReadVideoFrameEnd>, "sceUsbCamPollReadVideoFrameEnd", 'i', "" },
{ 0XDF9D0C92, nullptr, "sceUsbCamGetReadVideoFrameSize", '?', "" },
{ 0X3F0CF289, nullptr, "sceUsbCamSetupStill", '?', "" },
{ 0X0A41A298, nullptr, "sceUsbCamSetupStillEx", '?', "" },
{ 0X61BE5CAC, nullptr, "sceUsbCamStillInputBlocking", '?', "" },
{ 0XFB0A6C5D, nullptr, "sceUsbCamStillInput", '?', "" },
{ 0X7563AFA1, nullptr, "sceUsbCamStillWaitInputEnd", '?', "" },
{ 0X1A46CFE7, nullptr, "sceUsbCamStillPollInputEnd", '?', "" },
{ 0XA720937C, nullptr, "sceUsbCamStillCancelInput", '?', "" },
{ 0XE5959C36, nullptr, "sceUsbCamStillGetInputLength", '?', "" },
{ 0XF93C4669, &WrapI_I<sceUsbCamAutoImageReverseSW>, "sceUsbCamAutoImageReverseSW", 'i', "i" },
{ 0X11A1F128, nullptr, "sceUsbCamGetAutoImageReverseState", '?', "" },
{ 0X4C34F553, nullptr, "sceUsbCamGetLensDirection", '?', "" },
{ 0X383E9FA8, nullptr, "sceUsbCamGetSaturation", '?', "" },
{ 0X6E205974, nullptr, "sceUsbCamSetSaturation", '?', "" },
{ 0X70F522C5, nullptr, "sceUsbCamGetBrightness", '?', "" },
{ 0X4F3D84D5, nullptr, "sceUsbCamSetBrightness", '?', "" },
{ 0XA063A957, nullptr, "sceUsbCamGetContrast", '?', "" },
{ 0X09C26C7E, nullptr, "sceUsbCamSetContrast", '?', "" },
{ 0XFDB68C23, nullptr, "sceUsbCamGetSharpness", '?', "" },
{ 0X622F83CC, nullptr, "sceUsbCamSetSharpness", '?', "" },
{ 0X994471E0, nullptr, "sceUsbCamGetImageEffectMode", '?', "" },
{ 0XD4876173, nullptr, "sceUsbCamSetImageEffectMode", '?', "" },
{ 0X2BCD50C0, nullptr, "sceUsbCamGetEvLevel", '?', "" },
{ 0X1D686870, nullptr, "sceUsbCamSetEvLevel", '?', "" },
{ 0XD5279339, nullptr, "sceUsbCamGetReverseMode", '?', "" },
{ 0X951BEDF5, nullptr, "sceUsbCamSetReverseMode", '?', "" },
{ 0X9E8AAF8D, nullptr, "sceUsbCamGetZoom", '?', "" },
{ 0XC484901F, nullptr, "sceUsbCamSetZoom", '?', "" },
{ 0XAA7D94BA, nullptr, "sceUsbCamGetAntiFlicker", '?', "" },
{ 0X6784E6A8, nullptr, "sceUsbCamSetAntiFlicker", '?', "" },
{ 0XD293A100, nullptr, "sceUsbCamRegisterLensRotationCallback", '?', "" },
{ 0X41EE8797, nullptr, "sceUsbCamUnregisterLensRotationCallback", '?', "" },
};
void Register_sceUsbCam()
{
RegisterModule("sceUsbCam", ARRAY_SIZE(sceUsbCam), sceUsbCam);
}
void Camera::pushCameraImage(long long length, unsigned char* image) {
std::lock_guard<std::mutex> lock(videoBufferMutex);
videoBufferLength = length;
memset (videoBuffer, 0, sizeof(videoBuffer));
memcpy (videoBuffer, image, length);
}
Oops, something went wrong.

0 comments on commit 892bc86

Please sign in to comment.