Module | Joyau::Usb |
In: |
Drawable.cpp
|
This class allows to start the USB connexion through a Ruby script.
Establishes the USB connection.
/* Establishes the USB connection. */ VALUE usbConnect(VALUE self) { sceUsbActivate(0x1c8); return Qnil; }
Returns whether the cable is connected.
/* Returns whether the cable is connected. */ VALUE Usb_connected(VALUE self) { u32 state = sceUsbGetState(); return state & PSP_USB_CABLE_CONNECTED ? Qtrue : Qfalse; }
Disconnects from the USB connection.
/* Disconnects from the USB connection. */ VALUE usbDisconnect(VALUE self) { sceUsbDeactivate(0x1c8); sceIoDevctl("fatms0:", 0x0240D81E, NULL, 0, NULL, 0 ); return Qnil; }
Returns whether the connection has been established.
/* Returns whether the connection has been established. */ VALUE USb_established(VALUE self) { u32 state = sceUsbGetState(); return state & PSP_USB_CONNECTION_ESTABLISHED ? Qtrue : Qfalse; }
Inits the module used for the USB connection.
/* Inits the module used for the USB connection. */ VALUE initUsb(VALUE self) { if (!loadStartModule("flash0:/kd/chkreg.prx") || !loadStartModule("flash0:/kd/npdrm.prx") || !loadStartModule("flash0:/kd/semawm.prx") || !loadStartModule("flash0:/kd/usbstor.prx") || !loadStartModule("flash0:/kd/usbstormgr.prx") || !loadStartModule("flash0:/kd/usbstorms.prx") || !loadStartModule("flash0:/kd/usbstorboot.prx")) return Qfalse; if (sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0) != 0) return Qfalse; if (sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0) != 0) return Qfalse; if (sceUsbstorBootSetCapacity(0x800000) != 0) return Qfalse; return Qtrue; }
Returns a hash where the different connections states are saved, at the following keys: “activated”, “connected”, and “established”.
/* Returns a hash where the different connections states are saved, at the following keys: "activated", "connected", and "established". */ VALUE usbState(VALUE self) { VALUE ret = rb_hash_new(); u32 state = sceUsbGetState(); rb_hash_aset(ret, rb_str_new2("activated"), state & PSP_USB_ACTIVATED ? Qtrue : Qfalse); rb_hash_aset(ret, rb_str_new2("connected"), state & PSP_USB_CABLE_CONNECTED ? Qtrue : Qfalse); rb_hash_aset(ret, rb_str_new2("established"), state & PSP_USB_CONNECTION_ESTABLISHED ? Qtrue : Qfalse); return ret; }