Keyboard inactive / does not respond during script in MATLAB R2018b running on Ubuntu 18.04

Hi,
I'm running a script for an experiment using a function (from a different, experiment controller, ExpControl.m file), which waits for a 'space' to continue or a 'q' to quit (script is here below). However, Matlab does not respond, as if the keyboard were not functioning. If I use the mouse, I can click into the command window, where I can type, but it is not recognized as a command (screenshots below). At this point I can quit with ctrl + c, but I have no idea what could be reason for it. The script worked perfectly well on a MacBook Pro OSX 10.11. I've just moved to Linux Ubuntu 18.04.2 LTS, running on a Dell G3 with Nvidia GeForce GTX 1050 Ti. Do you have any suggestions?
Thank you!
%Script from the script of the specifi experiment
if ExpControl_ELTE('WaitSpace')
%the experimenter QUIT
stopexp=1;
%FINISHING UP
PsychPortAudio('Close');
ExpControl_ELTE('FinishExp');
break
end
%Experiment controller file
function state=ExpControl_ELTE(command,varargin)
state=false;
switch lower(command)
case 'iskey'
% Checks whether a given key is pressed
if nargin<2
key=0;
else
key=varargin{1};
end
state=IsKey(key);
return
case 'waitspace'
% Waits for Space or Q
state=WaitSpace();
return
otherwise
error('Invalid command. Call "help ExpControl" to find out the available commands.');
return;
end
return
function ctrl=IsKey(key)
global KEYBOARD;
[keyIsDown,secs,keyCode]=PsychHID('KbCheck', KEYBOARD);
if ~isnumeric(key)
kc = KbName(key);
else
kc = key;
end
ctrl=keyCode(kc);
return
function state=WaitSpace()
QKEY=KbName('q');
SPACEKEY=KbName('space');
while 1
if IsKey(QKEY)
state=true;
% while IsKey(QKEY)
% end
return;
end
if IsKey(SPACEKEY)
state=false;
return;
end
end
return

Answers (0)

Categories

Products

Release

R2018b

Asked:

on 18 Jul 2019

Edited:

on 19 Jul 2019

Community Treasure Hunt

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

Start Hunting!