~ubuntu-branches/ubuntu/trusty/psychtoolbox-3/trusty-proposed

« back to all changes in this revision

Viewing changes to Psychtoolbox/PsychBasic/KbName.m

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-11-19 23:34:50 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20131119233450-f7nf92vb8qavjmk8
Tags: 3.0.11.20131017.dfsg1-3
Upload to unsable since fresh glew has arrived to sid!

Show diffs side-by-side

added added

removed removed

Lines of Context:
657
657
    WaitSecs(1);
658
658
    keyPressed = 0;
659
659
    while (~keyPressed)
660
 
        [keyPressed, secs, keyCodes] = KbCheck(-1);
 
660
        [keyPressed, secs, keyCodes] = KbCheck(-1); %#ok<*ASGLU>
661
661
    end
662
662
    kbNameResult= KbName(logical(keyCodes));  %note that keyCodes should be of type logical here.
663
663
 
670
670
%recur on the result. 
671
671
%Note that this case must come before the test for double below.  In Matlab 5 logicals are also
672
672
%doubles but in Matlab 6.5 logicals are not doubles.  
673
 
elseif islogical(arg) | (isa(arg,'double') & length(arg)==256) | (isa(arg,'uint8') & length(arg)==256)
 
673
elseif islogical(arg) || (isa(arg,'double') && length(arg)==256) || (isa(arg,'uint8') && length(arg)==256)
674
674
    kbNameResult=KbName(find(arg));
675
675
 
676
676
%if the argument is a single double or a list of doubles (list of keycodes)
677
677
%or a single uint8 or list of uint8's (list of keycodes).
678
 
elseif isa(arg,'double') | isa(arg,'uint8')
 
678
elseif isa(arg,'double') || isa(arg,'uint8')
679
679
    %single element, the base case, we look up the name.
680
680
    if length(arg) == 1
681
 
        if(arg < 1 | arg > 65535)
 
681
        if(arg < 1 || arg > 65535)
682
682
            error('Argument exceeded allowable range of 1-65536');
683
683
        elseif arg > 255 
684
684
            kbNameResult='Undefined';
861
861
        
862
862
        % End of keyname unification code.
863
863
    else
864
 
        if IsOctave & IsWin
 
864
        if IsOctave && IsWin
865
865
            % GNU/Octave on Windows does not yet support index mode for strcmpi, need to do it manually...
866
866
            for i=1:length(kk)
867
867
                if strcmpi(char(kk(i)), arg)
884
884
    for i = 1:length(arg)
885
885
                codes = KbName(arg{i});
886
886
                ncodes = numel(codes);
887
 
                kbNameResult(cnt) = codes(1);
 
887
                kbNameResult(cnt) = codes(1); %#ok<*AGROW>
888
888
                if ncodes>1
889
889
                        kbNameResult(cnt+1:cnt+ncodes-1) = codes(2:ncodes);
890
890
                end