-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reducing the clock/current apparently makes it not work on USB 3.0 #43
Comments
I'm trying to compile the project but I receive this error on the linking step:
I can run I'm trying to compile the project as is before trying to compile my proposed changes on the issue.
I can successfully compile the hello_world sample and run it on my PSVita. @xerpi @rafaelsamenezes @nkrapivin |
Try building the |
Thank you for your reply, and sorry to direct mention you. TL;DR: I don't know why it doesn't work, but sometimes it does...
That's correct, building the I also noticed that I had to copy the
I wasn't expecting that, considering that I didn't changed anything inside the Anyways, after learning those two lessons, I managed to compile my version of the vpk and run it. As you can see it successfully detected the Vita and I could map the buttons. It also worked on a Steam application (Blasphemous). (Interesting that the applications detect different buttons, Square is Button 0 for the Emulator, but it's Button 1 for Blasphemous) Now, as I've said, it "kinda" worked. I've implemented two routines for increasing and decreasing the clock inside the application. I noticed that if I reboot the PSVita, if vitastick is the first application I open after rebooting, it have more chances to work. // reload app
if ((pad.buttons & reload_vitastick_mask) == reload_vitastick_mask)
{
printf("\nrestarting vitastick...\n");
vitastick_stop();
ret = vitastick_start();
if (ret >= 0) printf("vitastick restarted successfully!\n");
}
Sometimes I have to reboot multiple times using VitaShell for it to work again. For a moment I thought that maybe my USB cable was broken or something, but the idea was exactly to What happens is that, every time I say it "doesn't work" it do shows the "PS Vita" as input, but trying to map the buttons on emulator or game doesn't work. Only once I did a "select+triangle" and the controller started working. So it's completely random. |
@jacksonbenete Nice experimentation you've been doing here! |
Regarding the current (mA), can you try playing with the
The
More info here: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/usbspec/ns-usbspec-_usb_configuration_descriptor |
hi guys, hope you're doing well. I've been experimenting to find a solution to the "controller being recognized but not sending inputs" problem, that normally occurs after the first run of vitastick. I've made vitakeyboard based on hidmouse and vitastick, and like hidmouse, it doesn't have that problem for some reason, so I'm trying to replicate a few things from vitakeyboard to see what is causing it. when using
anyway, gonna keep trying... If you have any ideas I can try them out also, for some reason I can't get LOG to work, even though it was working when I copied it for vitakeyboard 🤔 |
I'm short of time until Friday but I'll later, or this weekend, try to compile an older versions of vitastick. From 2017 to 2021 vitastick received some commits and pull requests, maybe in the way something might have been removed by mistake? If the 2017 version of vitastick works as expected, we can then backtrack by the commit's diffs to understand what's missing and in what point it stopped sending inputs. |
Hey I think I figured it out! When sending reports, both vitastick and hidmouse account for only sending HID reports (the data) when the previous report was sent. vitastick does this with EventFlags (sends a sort of "report sent" event when report is sent and waits for this event before sending a new one) and hidmouse does it with a field of the report structure as a flag that is polled every iteration of the USB thread loop. But there's other places in the code in which data is sent, that vitastick is not accounting for only sending the next report when the previous one was already sent. That would be:
I've tested modifying these using the hidmouse solution and it seems to work and never be in that state of "connected but not sending inputs". I'll try implementing it in a simpler way using global variables and make a PR so you guys can test it. I don't think using EventFlag here makes sense since we aren't expected to continuously send this data nor have multiple events that affect a loop, like the main reports do. |
Okay so global variables don't seem to be working for some reason... Maybe the hidmouse solution of using the unused attribute of the request makes more sense since the on_complete will for sure have access to the pointer to the request (which will contain the unused attribute) I'll stop working on this for today but here's the branch with the hidmouse solution I'm talking about: https://github.com/mswlandi/vitastick/tree/hidmouse-solution @jacksonbenete can you try building and testing it to confirm it fixes the bug? |
I've tried both master branch and origin/hidmouse-solution. It works sometimes when vitastick is the first app I open, then if I close vitastick (select+start) and open it again, it doens't work for me. Does it works for you? Have you tried closing vitastick app and opening it again, it keeps working? |
The master branch has no changes in relation to xerpi/vitastick
Huh, yeah it was working for me, no matter how many times I closed the app and reopened again... I'll test it again later. Maybe it was some small change I made in the vpk that I didn't commit |
That's nice. Let me know if there was some commit pending so I'll try it again! If it's not the case, maybe it's just a bad luck about my device, or might be something between OS, since you're on Linux and I'm on macOS. |
I tested with the original vpk and it indeed wasn't working - it seems that commenting out the clock-changing functions was necessary. If you want to test that'd be appreciated (hidmouse-solution branch). If it works I'll continue trying to make a simpler version of the fix that uses global variables or similar. |
So the clock reduction issue did made some difference after all? Anyway I tested it and it did worked. Before, it took me multiple reboots to make it to work, and when it finally worked, if I closed the app or disconnected the USB it was all gone and I had to reboot multiple times again for another lucky moment. Your branch, although sometimes I'll reboot and it'll not work, it does work more often. But again, sometimes I'll reboot the device and it'll not work, and sometimes it will work but after one or two times closing the app and opening it again, it'll not work anymore. We don't have a
I'll successfully receive the descriptor doesn't matter if the controller is working or not though, unless I put the Vita to sleep, if I do that the pid will not be found as the device will change for the non-vitastick usb connection. When I have the time I'll try the suggestion xerpi made about the delay. In fact I was thinking that we should put the "connection" (vitastick_start) inside the loop (wait_key_press). That's because apparently it might be losing something from the I don't know if it's possible to make it this way as I don't understand the Vita OS and kernel, but it's something that have occurred to me, that we have a "main loop" that don't check the application state, only the controller state reading the buttons (sceCtrlReadBufferPositive), we could have more control and power over the application after it started running. I was just thinking about something else non-related to this issue, I think we can make it to transmit the buttons differently later. |
I tested closing and opening up to 10 times (before pushing the commit I think it was 7 times) and it didn't stop working.
Huh. Yeah, it might be a difference in the drivers of linux and macOS... I can test in windows later and see what happens.
Yeah, that makes sense, it would be smart to check if it is connected every iteration of the loop. That is assuming of course that it is possible, but we can try finding out how
Yeah it makes sense... In fact it makes me think if the problem is that for some reason peaking the controls at the kernel plugin USB loop stops working after a reset... Maybe I could try making it like vitakeyboard: exporting a function to userland so the app can call it to press the buttons
That's probably because vitastick was made to emulate a generic gamepad device, and so its descriptors make the computer think it's just that, with generic buttons. To make the computer receive triangle and cross for example, we'd probably have to emulate a Dualshock... |
I guess I'll report my findings... EDIT: Neither using a USB3 nor USB2 port made any difference. So using this in conjunction with a plugin that stops the screen turning off after inactivity is recommend. |
So, there are a couple of issues apparently describing the same problem.
I only have USB 3.0 ports available (M1 Air), so I can't test it on USB 2.0.
Considering another issue #30 suggests it work on 2.0 but not on 3.0, I think this might be the case for me as well.
Issues like #41 #34 and maybe #29 , all describe something about the controller getting recognised, but not accepting any inputs as a dead controller or something.
I've spotted that, when I open the apk, and connect the usb, it recognises the "controller" in the system as "PS Vita", this one will appear on softwares as a valid usb controller.
After some seconds, it will lose the connection and the controller is not "connected" anymore.
Then, the operational system will recognise the usb input with a different name "PS Vita Type B", this one doesn't show on software as a valid usb controller.
Even if I unblock the screen, it's still Type B.
(Should unblocking the screen increases the clock and current? This might invalidate my assumptions about the problem)
The difference the OS shows between the two is that:
PS Vita, as a valid input usb have
PS Vita Type B, not a valid input usb:
So, maybe that's because USB 3.0 needs more current to work?
I never modded PSVita and my C programming is rust (if it was any good ever), but I would like to try to change something and make it work. I don't know though if I can compile Vita SDK on M1, but I'll try that later.
Any tips about it? Does it sounds reasonable that this might be the problem (current) on USB 3.0?
Maybe the fix is not reduce the clock?
(In the images it shows USB2.0 Hub but it's in fact a hub of USB 3)
The text was updated successfully, but these errors were encountered: