 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
AvsDecode
Joined: 15 Mar 2009 Posts: 2
|
Posted: Sat Mar 21, 2009 12:38 am Post subject: how to get power from psp? |
|
|
As you know, Psp'camera use the two sheet metals beside the usb interface to supply power,and now i want to use them to supply power for
my own deivce,but i don't know if there is a function to control the power on or off, and what function i can call.
Sorry for my english. |
|
| Back to top |
|
 |
Ooblik
Joined: 10 Apr 2008 Posts: 38
|
Posted: Sat Mar 21, 2009 9:55 am Post subject: |
|
|
It's a bit old but I got someone to make a PRX Plugin to enable the power using L+R in the XMB way back.
Not sure if it works with current firmwares...
https://lan.st/showpost.php?p=5815&postcount=18 |
|
| Back to top |
|
 |
Dariusc123456
Joined: 12 Aug 2008 Posts: 394
|
Posted: Sat Mar 21, 2009 12:40 pm Post subject: |
|
|
| He asking for a command to activate his device power. |
|
| Back to top |
|
 |
AvsDecode
Joined: 15 Mar 2009 Posts: 2
|
Posted: Sat Mar 21, 2009 1:43 pm Post subject: |
|
|
Thank you for your reply, and it must be useful.
It seems there still some problem when set usb power on as the author said.
If there is a system call such as 'sceSetUsbPower()' , it would be an easy way to set usb power with my own software.
Thanks for you help! |
|
| Back to top |
|
 |
Ooblik
Joined: 10 Apr 2008 Posts: 38
|
Posted: Mon Mar 23, 2009 2:07 pm Post subject: |
|
|
| Dariusc123456 wrote: | | He asking for a command to activate his device power. |
No really..? *rolls eyes* l beleive it's one click from the link I posted. The full source for the PRX. So don't be so quick to flame the help you idiot..
| Code: |
#include <pspsdk.h>
#include <pspdisplay.h>
#include <pspuser.h>
#include <pspctrl.h>
#include <string.h>
#include <pspusb.h>
#include <stdio.h>
#include <sys/unistd.h>
#define PSP_USBGPS_PID 0x283
#define printf pspDebugScreenPrintf
#define PSP_USBGPS_DRIVERNAME "USBGps_Driver"
#define PSP_CTRL_COMBO PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER
PSP_MODULE_INFO("SoftSwitch", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
u32 usbState = 0;
SceCtrlData newInput;
int err, kill_threads = 0;
/* Helper function for input_thread. */
int checkInput(int PSP_CTRL_BUTTON) {
return ((newInput.Buttons & (PSP_CTRL_COMBO | PSP_CTRL_BUTTON)) == (PSP_CTRL_COMBO | PSP_CTRL_BUTTON));
}
void input_thread(SceSize args, void *argp) {
u32 oldInput = 0;
while (!kill_threads) {
sceCtrlPeekBufferPositive(&newInput, 1);
if (newInput.Buttons != oldInput) {
if (checkInput(PSP_CTRL_TRIANGLE)) kill_threads = 1;
if (checkInput(PSP_CTRL_SQUARE)) {
if (usbState & PSP_USB_ACTIVATED) sceUsbDeactivate(PSP_USBGPS_PID); else sceUsbActivate(PSP_USBGPS_PID);
usbState = sceUsbGetState();
}
}
oldInput = newInput.Buttons;
sceKernelDelayThread(1000);
}
sceKernelExitDeleteThread(0);
}
u32 moduleLoadStart (const char *path) {
SceUID loadResult, startResult;
int status;
loadResult = sceKernelLoadModule(path, 0, NULL);
if (loadResult & 0x80000000) return 1;
startResult = sceKernelStartModule(loadResult, 0, NULL, &status, NULL);
if (loadResult != startResult) return 2;
return 0;
}
void initialize() {
err = moduleLoadStart("ms0:/prx/usbacc.prx");
if (err) printf("Error loading USB Accessory Module (0x%08X)/n", err);
err = moduleLoadStart("ms0:/prx/usbgps.prx");
if (err) printf("Error loading GPS Accessory Module (0x%08X)/n", err);
err = sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
if (err) printf("Error starting USB BUS Driver (0x%08X)/n", err);
err = sceUsbStart("USBAccBaseDriver", 0, 0);
if (err) printf("Error starting USB Accessory Driver (0x%08X)/n", err);
err = sceUsbStart(PSP_USBGPS_DRIVERNAME,0,0);
if (err) printf("Error starting USB GPS Driver (0x%08X)/n", err);
err = sceUsbActivate(PSP_USBGPS_PID);
if (err) printf("Error activating USB GPS (0x%08X)/n", err);
usbState = sceUsbGetState();
printf("USB: %s/n", (usbState & PSP_USB_ACTIVATED) ? "On" : "Off");
}
void exit_thread(SceSize args, void *argp) {
while (!kill_threads) { sceKernelDelayThread(10000); }
while (kill_threads) {
sceUsbDeactivate(PSP_USBGPS_PID);
err = sceUsbStop(PSP_USBGPS_DRIVERNAME,0,0);
if (err) printf("Error stopping USB Gps driver (0x%08X)/n", err);
err = sceUsbStop("USBAccBaseDriver",0,0);
if (err) printf("Error stopping USB Acc driver (0x%08X)/n", err);
err = sceUsbStop(PSP_USBBUS_DRIVERNAME,0,0);
if (err) printf("Error stopping USB BUS driver (0x%08X)/n", err);
}
sceKernelExitDeleteThread(0);
}
int main_thread (SceSize args, void *argp) {
SceUID input_thid, exit_thid;
initialize();
// Start input_thread to detect input conditions.
input_thid = sceKernelCreateThread("input_thread", (SceKernelThreadEntry)input_thread, 0x20, 0x10000, 0, NULL);
if (input_thid >= 0) sceKernelStartThread(input_thid, 0, NULL);
sceKernelDelayThread(1000);
// Start exit_thread to manage exit.
exit_thid = sceKernelCreateThread("exit_thread", (SceKernelThreadEntry)exit_thread, 0x21, 0x10000, 0, NULL);
if (exit_thid >= 0) sceKernelStartThread(exit_thid, 0, NULL);
sceKernelDelayThread(1000);
return 0;
}
int module_start (SceSize args, void *argp) {
SceUID main_thid;
main_thid = sceKernelCreateThread("main_thread", main_thread, 0x20, 0x10000, 0, NULL);
if (main_thid >= 0) sceKernelStartThread(main_thid, args, argp);
return 0;
}
|
Code By: califrag [lan.st] |
|
| Back to top |
|
 |
Ooblik
Joined: 10 Apr 2008 Posts: 38
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|