Inconsistent joystick operation in application

Hi,
I've got a MatLab application (i.e. Matlab source code not a model) and want to use an X-Box controller to control various features. I open the connection using vrjoystick and then use read on a regular basis to get the values. The strange bit is that it only works reliably when I put a breakpoint somewhere in the loop.
I have a number of tabs to display different items and only one tab is using the joystick data. If I put a breakpoint in and then remove it the display updates fine as I move the joysticks. If I change to a different tab and then change back to the original tab the joystick doesn't provide any inputs until I add/remove a breakpoint.
I've tried closing and opening vrjoystick each time but that makes things worse. I get no values in my program, but I do get values when doing a read from the console.
The joystick is in it's own class and updates data in the MVC way, so is only indirectly connected to the tabs.
Any ideas would be gratefully appreciated.
Thanks in advance
Adrian
I've got sample code that shows the problem. Running this just shows 0 even when moving the left joystick horizontally. Adding a breakpoint and then re-running then shows the value changing with the stick movement.
fig = uifigure;
steer = uieditfield(fig, "numeric");
controller = vrjoystick(1);
while true
[ca, cb, cp] = read(controller);
steer.Value = double(ca(1));
pause(0.2);
end % while

 채택된 답변

Adrian
Adrian 2023년 6월 14일

0 개 추천

I reported this to Matlab, and they supplied me with a patch. This issue should be fixed in a later version of Matlab (after 2023a)

댓글 수: 1

I am facing the similar issue. Can you please share the patch here and the instructions ?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2022b

태그

질문:

2023년 4월 18일

댓글:

2023년 10월 2일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by