1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| function joystick_connection(hObject, eventdata, handles)
%Create joysticks object and get the number of joysticks connected
handles = guidata(gcf);
%Exception on josticks connection
try
%VRJOYSTICK Create a joystick object.
% JOY = VRJOYSTICK(ID) creates a joystick object capable of interfacing
% a joystick device. The ID parameter is one-based joystick ID.
handles.joystick1 = vrjoystick(1);
handles.joy_connected = 1;
catch exception
handles.joy_connected = 0;
end
if handles.joy_connected == 1
try
handles.joystick2 = vrjoystick(2);
handles.joy_connected = 2;
catch exception
handles.joy_connected = 1;
end
end
if handles.joy_connected == 0
set(handles.text_joystick_number,'String','0');
elseif handles.joy_connected == 1
set(handles.text_joystick_number,'String','1');
else
set(handles.text_joystick_number,'String','2');
end
% Update handles structure
guidata(gcf, handles);
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%TIMERS%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
function Timer_config(hObject, eventdata, handles)
handles = guidata(gcf);
handles.t = timer;
set(handles.t,'ExecutionMode','fixedRate','Period',1,'TimerFcn',{@Timer,handles});%Timer
start(handles.t);
% Update handles structure
guidata(gcf, handles);
function Timer(hObject, eventdata, handles)
handles = guidata(gcf); %surement pas utilise car déclaré avant : {@Timer,handles}
joystick_connection(hObject, eventdata, handles)
% Update handles structure
guidata(gcf, handles); |
Partager