xerpi / vita-udcd-uvc

PSVita UDCD USB Video Class plugin
468 stars 23 forks source link

Any chances on making a combo for turning off the screen? #5

Open Varon9 opened 5 years ago

Varon9 commented 5 years ago

Basically os that, the plugin it's amazing un addition of DS3 vita but It Would be so nice to can turn off the screen while playing. Thanks so much!

xerpi commented 5 years ago

If you have VITASDK installed you can try this patch: https://pastebin.com/raw/wK8fent0

Varon9 commented 5 years ago

Is It ready to compile ir do i need todo copypaste un one of the files?

xerpi commented 5 years ago

It's a patch file, but since it's a bit old I doubt it still applies so you have to apply the changes to each file manually.

Varon9 commented 5 years ago

Oh i see, i'll try It tomorrow if i manage yo patchwork It properly, thanks so much!

Varon9 commented 5 years ago

I managed to patch It manually and works like a charm! Thanks so much xerpi!!

xerpi commented 5 years ago

Nice, I'm glad it works.

Maybe using ksceOledDisplayOn / ksceOledDisplayOff instead of the brightness functions would also work, and if it does, it will save more power.

Varon9 commented 5 years ago

I'll check if i can do It, because i'm actually suprised that It worked in the first try since i haven't any idea on programming but, there's allways a first time 😅

xerpi commented 5 years ago

Oh haha then it's quite a feat if you managed to apply the patch and get it working without knowing how to program :stuck_out_tongue:

Varon9 commented 5 years ago

I'll unlock a trophy if i manage to implement those two "instructions?" Haha 😅

Varon9 commented 5 years ago

it almost worked, i mean with ksceOledDisplayOn/Off, but it turns off the oled then turns on inmediatly, don't know why. static int uvc_udcd_attach(int usb_version, void *user_data) { LOG("uvc_udcd_attach %d\n", usb_version);

ksceOledDisplayOff();

ksceUdcdClearFIFO(&endpoints[2]);

return 0;

}

static void uvc_udcd_detach(void *user_data) { LOG("uvc_udcd_detach\n"); ksceOledDisplayOn(); uvc_handle_video_abort(); } this is what i did

Varon9 commented 5 years ago

forget about it, it was an stupid mistake of mine, it turned off then on because no capturing program was runing, i started potplayer then opened vita and voilá, screen is off permanently till usb disconects

Emiougus commented 5 years ago

What version are you running on? I attempted this with my Vita 2000 on 3.65 added ksceLcdDisplayOff(); to uvc-udcd-attach and ksceLcdDisplayOn(); to uvc-udcd-detach. Display turned off fine and functioned as it should've but when I unplugged the cord the display stayed off, I tried multiple things and noticed that if I put ksceLcdDisplayOff(); under uvc-udcd-detach and remove it from uvc-udcd-attach the display still turns off, this leads me to believe that uvc_udcd_detach is called when the cable is plugged in therefore causing it to bug and just stay off? I'm new to this kinda stuff sorry if I'm using the wrong terminology.

Edit: after a bit more tinkering, I'm fairly certain that ksceLcdDisplayOn doesn't work either on 3.65 or just entirely. Doesn't make sense though as ksceLcdDisplayOff works perfectly fine.

Update: Found a fix(for anyone who's looking for it),

SceUID uvc_frame_req_evflag;

int ksceLcdDisplayOff();
int ksceLcdDisplayOn();

int ksceLcdGetBrightness();
int ksceLcdSetBrightness(unsigned int brightness);
static unsigned int initial_brightness = 1;

and

static int uvc_udcd_attach(int usb_version, void *user_data)
{
    LOG("uvc_udcd_attach %d\n", usb_version);

    initial_brightness = ksceLcdGetBrightness();
    ksceLcdDisplayOff();

    ksceUdcdClearFIFO(&endpoints[2]);

    return 0;
}

static void uvc_udcd_detach(void *user_data)
{
    LOG("uvc_udcd_detach\n");

    ksceLcdSetBrightness(initial_brightness);

    /* ksceLcdDisplayOn(); Not Working*/  

    uvc_handle_video_abort();
}

I guess setting the brightness wakes the screen up and the DisplayOff function works so it's all good :)

xerpi commented 5 years ago

Implemented 3 different versions: https://github.com/xerpi/vita-udcd-uvc/releases