Unrecognized function or variable 'moglcore'

Hi Mario, thanks so much for all your help developing and maintaining PsychToolBox.

I updated the OS of my mac to 10.15.5 (Catalina), which appeared to require installing an updated version of Matlab (2020b, vs. 2019b previously), and reinstalling PsychToolBox (3.0.16.8, vs. Beta-2019-04-01_V3.0.15 previously). There is now a problem calling the script InitializeMatlabOpenGL in my code which previously worked. I get the following error message:

"Unrecognized function or variable ‘moglcore’.

Error in InitializeMatlabOpenGL (line 186)
moglcore(‘DEBUGLEVEL’, debuglevel);"

I can’t find a moglcore.m file in the current version of psychtoolbox, but then there didn’t seem to be one in previous versions.

Thanks so much,

Paul

Hi Paul,

Can you find a file moglcore.mexmaci64? Thats what should get called.

Cheers,
Dee

Thanks so much Dee, I really appreciate it!

Yes, you’re right, moglcore.mexmaci64 was missing even though in original download.

Mac prompts me to send to the bin because unrecognised developer, but I always say no, go to Control Panel -> Security and Privacy, then manually allow blocked file. Then re-run, and press open in pop-up when prompted. And moglcore.mexmaci64 in bin, so don’t know where it went! Same issue with PsychHID.mexmaci64 (is missing).

So started completely afresh (new psychtoolbox download). moglcore.mexmaci64 and PsychHID.mexmaci64 both blocked, but I approved them in the control panel, and so should now be ok (and checked they were not deleted). However, when I run the following script as a test:

OpenGL working fine (thanks so much!), but still an issue with PsychHID.mexmaci64:

"Operands to the || and && operators must be convertible to logical scalar values.

Error in KbCheck (line 226)
if allowPsychHID && (~IsWin || (IsWin && ~isempty(deviceNumber)))

Error in KbWait (line 129)
[isDown, secs, keyCode, deltaSecs] = KbCheck(deviceNumber);"

Thanks so much again Dee!

Paul

Sorry, should say And NO moglcore.mexmaci64 in bin, so don’t know where it went!

I found this helpful in ensuring downloaded mexmaci64 files are not blocked from a trusted source.

KbCheck issue still persists. Thanks so much, again, for all your help,

Paul

Looking at the code of KbCheck, that is a very strange error. Have you tried restarting matlab so that all state is clean?

Thanks Dee, really appreciate it.

Just restarted. Prompted to give matlab access to keystrokes, which did. Restarted, now no error when running Scarfe demo, but now key presses have no effect, as if not registered, even though at KBWait.

Only other thing is that command window opens with warning:
“Warning: Name is nonexistent or not a directory: /private/var/folders/qv/qnjm6xwd0fv7bmwqrxpbspp00000gn/T/Editor_ezcuc”

Thanks so much, and sorry this has gotten more complicated than expected.

Paul

Hi Paul,

Glad you’re moving forward. There have been other posts on the forum recently about macosx keyboard access. I’m not a mac user and didn’t follow them closely. Could you have a look at those and see if they contain solutions and if those solutions work for you?

Cheers,
Dee

I guess the most simple solution for Apples trainwreck getting in the way would be to “Allow apps from anywhere”:

Strangely i don’t see this problem on my Catalina 10.15.7 setup, although it is set to allow apps from “AppStore and identified developers”, and so far this question has never come up on this machine.

Are all other mex files also authorized to run? Does typing “PsychHID Version” and “Screen Version” work?

Wrt. KbCheck not working despite Matlab being added to the “Security & Privacy” -> “Privacy” -> “Input monitoring” category, that is just puzzling. But i think we had at least one post if you search for it, where the user had to remove it, quit Matlab, restart Matlab, quit Matlab, restart Matlab, then readd it, or whatever. Some absurd user hostile dance in the way one would only have to do if one buys from the iToys company.

-mario

Thanks so much Dee and Mario, I really appreciate your advice.

Yes, the other mex files working ok. And I tried the workarounds that gabrielino00 and gholland suggested in the previous thread but they didn’t work for me:

[See also KbDemo not working on Catalina, allowing input monitoring does not help - #2 by mariokleiner ]

It turned out to be the same issue that Han was having before:

KbDemo is picking up the escape key ok (and therefore the touchbar) but not the keyboard. Setting KbWait() to KbWait(-1) fixes this, but the workaround in psychtoolbox doesn’t seem to be working for me with Catalina.

Thanks so much for you both for all your help on this, I really appreciate it,

Paul

So you are saying that KbWait() doesn’t work, but KbWait(-1) does? With the most recent PTB beta release?

In that case the iToys company must have broken keyboard and touchbar enumeration in new ways for your machine. My MacBookPro 2017 with the Catalina 10.15.7 trainwreck doesn’t have problems, although it is a model with the useless touchbar gimmick.

So what is the output of PsychHID('Devices'), and [a,b,c] = GetKeyboardIndices()? Screen('Computer');, MacModelName?

What exact macOS version and model of computer is this?
-mario

Thanks so much Mario,

Yes, KbWait() doesn’t work for me, but KbWait(-1) does. This is with Psychtoolbox-3-3.0.16.8, and Matlab version R2020b.

PsychHID(‘Devices’) gives the following:



[a,b,c] = GetKeyboardIndices() gives the following:

With c expanded:

Screen(‘Computer’) gives the following (I’ve removed a few details):

MacModelName fails for me:

But cutting and pasting from “About This Mac”:
8

Thanks so much Mario (and Dee), I really appreciate all your help on this!

Paul

Does KbWait(GetKeyboardIndices()) work?

Thanks so much Mario,

Yes KbWait(GetKeyboardIndices()) works, just like KbWait(-1)

Paul

Ok, what’s the output of PsychHID('Devices', -1) ?

Thanks Mario! I get ans = 2

And two other values also appear in the workspace:
ptb_ConfigPath = /Users/paul/Library/Preferences/Psychtoolbox/
ptb_RootPath = /Users/paul/Dropbox/PaulDropbox/Psychtoolbox/

Ok, that result doesn’t make any sense. GetKeyboardIndices and PsychHID('Devices', -1) use the same logic to filter out the touchbar gimmick to avoid detecting it as a keyboard, despite macOS lying to us and claiming the touchbar being a regular keyboard (thanks dear geniuses at Apple!). But PsychHID fails to do so, using exactly the same information to decide on this that it returns to GetKeyboardIndices to decide on it.

Do which PsychHID and which KbCheck which GetKeyboardIndices actually point to the same Psychtoolbox installation on your Matlab path?

After clear all or maybe better a Matlab restart or even machine restart, do PsychHID('Devices', -1) and GetKeyboardIndices still disagree?

Thanks so much Mario for explaining this all, it’s super helpful!

These are the results I got after clear all and restarting computer:

The value for GetKeyboardIndices seems to be changing. Here it is 3, earlier in the thread it was 4 ( Unrecognized function or variable 'moglcore' ), and when I tested it before restarting my computer it was 5.

Thanks, again, for all your help,

Paul

Thanks again Mario,

I’ve just done 10 consecutive restarts of Matlab to test GetKeyboardIndices (and on the last 6 also tested PsychHID(‘Devices’, -1)):

  1. GetKeyboardIndices = 5

  2. GetKeyboardIndices = 3

  3. GetKeyboardIndices = 5

  4. GetKeyboardIndices = 7

  5. GetKeyboardIndices = 3, PsychHID(‘Devices’, -1) = 1

  6. GetKeyboardIndices = 5, PsychHID(‘Devices’, -1) = 2

  7. GetKeyboardIndices = 6, PsychHID(‘Devices’, -1) = 2

  8. GetKeyboardIndices = 7, PsychHID(‘Devices’, -1) = 2

  9. GetKeyboardIndices = 4, PsychHID(‘Devices’, -1) = 1

  10. GetKeyboardIndices = 4, PsychHID(‘Devices’, -1) = 2

So neither value appears to be especially stable.

That the numbers are not stable even between reboots is “normal” on Apples operating system. What is completely baffling is that both GetKeyboardIndices and PsychHID(‘Devices’,-1) execute exactly the same very trivial method, using exactly the same information to filter out the touchbar, just one is implemented in C, the other in a M-File.

Both will classify a device as keyboard if (in the output of PsychHID(‘Devices’)) its usagePage is 1, usage is 6 - this means “keyboard” and locationId is non-zero - because the touchbar has id 0 whereas real keyboards don’t. This code was originally written for the MBP 2016, so obviously should work on one. That’s why it is completely unclear how happens what happens on your system.