1
// Copyright (c) 2012- PPSSPP Project.
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
18
#include "Core/HLE/HLE.h"
19
#include "Core/HLE/FunctionWrappers.h"
20
#include "Core/MIPS/MIPS.h"
21
#include "Core/CoreTiming.h"
22
#include "Common/ChunkFile.h"
23
#include "Core/HLE/sceUsb.h"
25
// TODO: Map by driver name
26
bool usbStarted = false;
27
// TODO: Check actual status
28
bool usbConnected = true;
29
// TODO: Activation by product id
30
bool usbActivated = false;
33
USB_STATUS_STOPPED = 0x001,
34
USB_STATUS_STARTED = 0x002,
35
USB_STATUS_DISCONNECTED = 0x010,
36
USB_STATUS_CONNECTED = 0x020,
37
USB_STATUS_DEACTIVATED = 0x100,
38
USB_STATUS_ACTIVATED = 0x200,
48
void __UsbDoState(PointerWrap &p)
50
auto s = p.Section("sceUsb", 1, 2);
64
static int sceUsbStart(const char* driverName, u32 argsSize, u32 argsPtr) {
65
ERROR_LOG(HLE, "UNIMPL sceUsbStart(%s, %i, %08x)", driverName, argsSize, argsPtr);
70
static int sceUsbStop(const char* driverName, u32 argsSize, u32 argsPtr) {
71
ERROR_LOG(HLE, "UNIMPL sceUsbStop(%s, %i, %08x)", driverName, argsSize, argsPtr);
76
static int sceUsbGetState() {
77
ERROR_LOG(HLE, "UNIMPL sceUsbGetState");
78
int state = (usbStarted ? USB_STATUS_STARTED : USB_STATUS_STOPPED)
79
| (usbConnected ? USB_STATUS_CONNECTED : USB_STATUS_DISCONNECTED)
80
| (usbActivated ? USB_STATUS_ACTIVATED : USB_STATUS_DEACTIVATED);
84
static int sceUsbActivate(u32 pid) {
85
ERROR_LOG(HLE, "UNIMPL sceUsbActivate(%i)", pid);
90
static int sceUsbDeactivate(u32 pid) {
91
ERROR_LOG(HLE, "UNIMPL sceUsbDeactivate(%i)", pid);
96
const HLEFunction sceUsb[] =
98
{0XAE5DE6AF, &WrapI_CUU<sceUsbStart>, "sceUsbStart", 'i', "sxx"},
99
{0XC2464FA0, &WrapI_CUU<sceUsbStop>, "sceUsbStop", 'i', "sxx"},
100
{0XC21645A4, &WrapI_V<sceUsbGetState>, "sceUsbGetState", 'i', "" },
101
{0X4E537366, nullptr, "sceUsbGetDrvList", '?', "" },
102
{0X112CC951, nullptr, "sceUsbGetDrvState", '?', "" },
103
{0X586DB82C, &WrapI_U<sceUsbActivate>, "sceUsbActivate", 'i', "x" },
104
{0XC572A9C8, &WrapI_U<sceUsbDeactivate>, "sceUsbDeactivate", 'i', "x" },
105
{0X5BE0E002, nullptr, "sceUsbWaitState", '?', "" },
106
{0X616F2B61, nullptr, "sceUsbWaitStateCB", '?', "" },
107
{0X1C360735, nullptr, "sceUsbWaitCancel", '?', "" },
110
const HLEFunction sceUsbstor[] =
112
{0X60066CFE, nullptr, "sceUsbstorGetStatus", '?', "" },
115
const HLEFunction sceUsbstorBoot[] =
117
{0XE58818A8, nullptr, "sceUsbstorBootSetCapacity", '?', "" },
118
{0X594BBF95, nullptr, "sceUsbstorBootSetLoadAddr", '?', "" },
119
{0X6D865ECD, nullptr, "sceUsbstorBootGetDataSize", '?', "" },
120
{0XA1119F0D, nullptr, "sceUsbstorBootSetStatus", '?', "" },
121
{0X1F080078, nullptr, "sceUsbstorBootRegisterNotify", '?', "" },
122
{0XA55C9E16, nullptr, "sceUsbstorBootUnregisterNotify", '?', "" },
125
const HLEFunction sceUsbCam[] =
127
{0X17F7B2FB, nullptr, "sceUsbCamSetupVideo", '?', "" },
128
{0XF93C4669, nullptr, "sceUsbCamAutoImageReverseSW", '?', "" },
129
{0X574A8C3F, nullptr, "sceUsbCamStartVideo", '?', "" },
130
{0X6CF32CB9, nullptr, "sceUsbCamStopVideo", '?', "" },
131
{0X03ED7A82, nullptr, "sceUsbCamSetupMic", '?', "" },
132
{0X82A64030, nullptr, "sceUsbCamStartMic", '?', "" },
133
{0X7DAC0C71, nullptr, "sceUsbCamReadVideoFrameBlocking", '?', "" },
134
{0X99D86281, nullptr, "sceUsbCamReadVideoFrame", '?', "" },
135
{0X41E73E95, nullptr, "sceUsbCamPollReadVideoFrameEnd", '?', "" },
136
{0XF90B2293, nullptr, "sceUsbCamWaitReadVideoFrameEnd", '?', "" },
137
{0X4C34F553, nullptr, "sceUsbCamGetLensDirection", '?', "" },
138
{0X3F0CF289, nullptr, "sceUsbCamSetupStill", '?', "" },
139
{0X0A41A298, nullptr, "sceUsbCamSetupStillEx", '?', "" },
140
{0X61BE5CAC, nullptr, "sceUsbCamStillInputBlocking", '?', "" },
141
{0XFB0A6C5D, nullptr, "sceUsbCamStillInput", '?', "" },
142
{0X7563AFA1, nullptr, "sceUsbCamStillWaitInputEnd", '?', "" },
143
{0X1A46CFE7, nullptr, "sceUsbCamStillPollInputEnd", '?', "" },
144
{0XA720937C, nullptr, "sceUsbCamStillCancelInput", '?', "" },
145
{0XE5959C36, nullptr, "sceUsbCamStillGetInputLength", '?', "" },
146
{0XCFE9E999, nullptr, "sceUsbCamSetupVideoEx", '?', "" },
147
{0XDF9D0C92, nullptr, "sceUsbCamGetReadVideoFrameSize", '?', "" },
148
{0X6E205974, nullptr, "sceUsbCamSetSaturation", '?', "" },
149
{0X4F3D84D5, nullptr, "sceUsbCamSetBrightness", '?', "" },
150
{0X09C26C7E, nullptr, "sceUsbCamSetContrast", '?', "" },
151
{0X622F83CC, nullptr, "sceUsbCamSetSharpness", '?', "" },
152
{0XD4876173, nullptr, "sceUsbCamSetImageEffectMode", '?', "" },
153
{0X1D686870, nullptr, "sceUsbCamSetEvLevel", '?', "" },
154
{0X951BEDF5, nullptr, "sceUsbCamSetReverseMode", '?', "" },
155
{0XC484901F, nullptr, "sceUsbCamSetZoom", '?', "" },
156
{0X383E9FA8, nullptr, "sceUsbCamGetSaturation", '?', "" },
157
{0X70F522C5, nullptr, "sceUsbCamGetBrightness", '?', "" },
158
{0XA063A957, nullptr, "sceUsbCamGetContrast", '?', "" },
159
{0XFDB68C23, nullptr, "sceUsbCamGetSharpness", '?', "" },
160
{0X994471E0, nullptr, "sceUsbCamGetImageEffectMode", '?', "" },
161
{0X2BCD50C0, nullptr, "sceUsbCamGetEvLevel", '?', "" },
162
{0XD5279339, nullptr, "sceUsbCamGetReverseMode", '?', "" },
163
{0X9E8AAF8D, nullptr, "sceUsbCamGetZoom", '?', "" },
164
{0X11A1F128, nullptr, "sceUsbCamGetAutoImageReverseState", '?', "" },
165
{0X08AEE98A, nullptr, "sceUsbCamSetMicGain", '?', "" },
166
{0X2E930264, nullptr, "sceUsbCamSetupMicEx", '?', "" },
167
{0X36636925, nullptr, "sceUsbCamReadMicBlocking", '?', "" },
168
{0X3DC0088E, nullptr, "sceUsbCamReadMic", '?', "" },
169
{0X41EE8797, nullptr, "sceUsbCamUnregisterLensRotationCallback", '?', "" },
170
{0X5145868A, nullptr, "sceUsbCamStopMic", '?', "" },
171
{0X5778B452, nullptr, "sceUsbCamGetMicDataLength", '?', "" },
172
{0X6784E6A8, nullptr, "sceUsbCamSetAntiFlicker", '?', "" },
173
{0XAA7D94BA, nullptr, "sceUsbCamGetAntiFlicker", '?', "" },
174
{0XB048A67D, nullptr, "sceUsbCamWaitReadMicEnd", '?', "" },
175
{0XD293A100, nullptr, "sceUsbCamRegisterLensRotationCallback", '?', "" },
176
{0XF8847F60, nullptr, "sceUsbCamPollReadMicEnd", '?', "" },
179
void Register_sceUsb()
181
RegisterModule("sceUsbstor", ARRAY_SIZE(sceUsbstor), sceUsbstor);
182
RegisterModule("sceUsbstorBoot", ARRAY_SIZE(sceUsbstorBoot), sceUsbstorBoot);
183
RegisterModule("sceUsb", ARRAY_SIZE(sceUsb), sceUsb);
186
void Register_sceUsbCam()
188
RegisterModule("sceUsbCam", ARRAY_SIZE(sceUsbCam), sceUsbCam);