/
antim
/
LuaPlayer-by-YuliaTeam
Обзор
Документация
Войти
/
antim
/
LuaPlayer-by-YuliaTeam
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
lua/usb.c
204 строки
8 KB
antim0118
Заменил заголовки файлов
25 фев 2026, 22:25
25 фев 2026, 22:25
842b6c8
Код
Авторство
О чём код?
/*-----------------------------------------------------------------------------------------------------------------------# #------------- This file is part of: ------------------------------------------------------------------------------------# #---█████----------------------------███████████--████------------------------------------------█████-█████-███████████--# #--░░███----------------------------░░███░░░░░███░░███-----------------------------------------░░███-░░███-░█░░░███░░░█--# #---░███--------█████-████--██████---░███----░███-░███---██████---█████-████--██████--████████--░░███-███--░---░███--░---# #---░███-------░░███-░███--░░░░░███--░██████████--░███--░░░░░███-░░███-░███--███░░███░░███░░███--░░█████-------░███------# #---░███--------░███-░███---███████--░███░░░░░░---░███---███████--░███-░███-░███████--░███-░░░----░░███--------░███------# #---░███------█-░███-░███--███░░███--░███---------░███--███░░███--░███-░███-░███░░░---░███---------░███--------░███------# #---███████████-░░████████░░████████-█████--------█████░░████████-░░███████-░░██████--█████--------█████-------█████-----# #--░░░░░░░░░░░---░░░░░░░░--░░░░░░░░-░░░░░--------░░░░░--░░░░░░░░---░░░░░███--░░░░░░--░░░░░--------░░░░░-------░░░░░------# #------------------------------------------------------------------███-░███----------------------------------------------# #-----------------------------------------------------------------░░██████-----------------------------------------------# #------------------------------------------------------------------░░░░░░------------------------------------------------# #------------------------------------------------------------------------------------ Made by Kodilo --------------------# #- Special Thanks to: ---------------------------------------------------------------------------------------------------# #------------------------------------------------------------------------------------------------------------------------# #- BenHur for intraFont -------------------------------------------------------------------------------------------------# #- Geecko for gLib2D ----------------------------------------------------------------------------------------------------# #- Arshia001 for PSPAALIB -----------------------------------------------------------------------------------------------# #- jonny & Raphael for PMP Mod ------------------------------------------------------------------------------------------# #- InsertWittyName & MK2k for PGE source code ---------------------------------------------------------------------------# #- Rinnegatamante & Nanni for example of awesome Lua Player -------------------------------------------------------------# #-----------------------------------------------------------------------------------------------------------------------*/ #include "usb.h" static int usbStarted = 0; static SceUID LPYT_USB[7]; SceUID StartModule(const char *filename) { SceUID r = kuKernelLoadModule(filename, 0, 0); if (r <= 0) return 0; int status; int res = sceKernelStartModule(r, 0, 0, &status, 0); if (res < 0) { return 0; } return (r); } static int UnloadModule(SceUID modid) { int status; int res = sceKernelStopModule(modid, 0, 0, &status, 0); if (res < 0) { return 0; } res = sceKernelUnloadModule(modid); return (res); } static int USB_kernelInit() { LPYT_USB[0] = StartModule("flash0:/kd/semawm.prx"); if (LPYT_USB[0] < 0) return -1; LPYT_USB[1] = StartModule("flash0:/kd/usbstor.prx"); if (LPYT_USB[1] < 0) { UnloadModule(LPYT_USB[0]); return -1; } LPYT_USB[2] = StartModule("flash0:/kd/usbstormgr.prx"); if (LPYT_USB[2] < 0) { UnloadModule(LPYT_USB[0]); UnloadModule(LPYT_USB[1]); return -1; } LPYT_USB[3] = StartModule("flash0:/kd/usbstorms.prx"); if (LPYT_USB[3] < 0) { UnloadModule(LPYT_USB[0]); UnloadModule(LPYT_USB[1]); UnloadModule(LPYT_USB[2]); return -1; } LPYT_USB[4] = StartModule("flash0:/kd/usbstorboot.prx"); if (LPYT_USB[4] < 0) { UnloadModule(LPYT_USB[0]); UnloadModule(LPYT_USB[1]); UnloadModule(LPYT_USB[2]); UnloadModule(LPYT_USB[3]); return -1; } LPYT_USB[5] = StartModule("flash0:/kd/chkreg.prx"); if (LPYT_USB[5] < 0) { UnloadModule(LPYT_USB[0]); UnloadModule(LPYT_USB[1]); UnloadModule(LPYT_USB[2]); UnloadModule(LPYT_USB[3]); UnloadModule(LPYT_USB[4]); return -1; } LPYT_USB[6] = StartModule("flash0:/kd/npdrm.prx"); if (LPYT_USB[6] < 0) { UnloadModule(LPYT_USB[0]); UnloadModule(LPYT_USB[1]); UnloadModule(LPYT_USB[2]); UnloadModule(LPYT_USB[3]); UnloadModule(LPYT_USB[4]); UnloadModule(LPYT_USB[5]); return -1; } return 0; } int USB_activate() { if (usbStarted) return 1; //if (USB_kernelInit() < 0) // return -1; sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0); sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0); sceUsbstorBootSetCapacity(0x800000); sceUsbActivate(0x1c8); usbStarted = 1; return 0; } int USB_deactivate() { if (!usbStarted) return -1; sceUsbDeactivate(0x1c8); sceUsbStop(PSP_USBSTOR_DRIVERNAME, 0, 0); sceUsbStop(PSP_USBBUS_DRIVERNAME, 0, 0); usbStarted = 0; //UnloadModule(LPYT_USB[0]); //UnloadModule(LPYT_USB[1]); //UnloadModule(LPYT_USB[2]); //UnloadModule(LPYT_USB[3]); //UnloadModule(LPYT_USB[4]); //UnloadModule(LPYT_USB[5]); //UnloadModule(LPYT_USB[6]); return 0; } int USB_getState() { return sceUsbGetState(); } static int luaUSB_activate(lua_State *L) { if (lua_gettop(L) != 0) return luaL_error(L, "USB.activate() takes no arguments"); lua_pushnumber(L, USB_activate()); return 1; } static int luaUSB_deactivate(lua_State *L) { if (lua_gettop(L) != 0) return luaL_error(L, "USB.deactivate() takes no arguments"); lua_pushnumber(L, USB_deactivate()); return 1; } static int luaUSB_getState(lua_State *L) { if (lua_gettop(L) != 0) return luaL_error(L, "USB.getState() takes no arguments"); lua_pushnumber(L, USB_getState()); return 1; } static const luaL_Reg USB_methods[] = { {"activate", luaUSB_activate}, {"deactivate", luaUSB_deactivate}, {"getState", luaUSB_getState}, {0, 0} }; int USB_init(lua_State *L) { lua_getglobal(L, "System"); lua_newtable(L); luaL_register(L, 0, USB_methods); lua_setfield(L, -2, "USB"); lua_pop(L, 1); if (USB_kernelInit() < 0) return -1; return 1; }