# Unrecognized function or variable 'moglcore'

**URL:** <https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453>\
**Category:** Bugs & Features\
**Tags:** macos\
**Created:** [October 19, 2020, 11:16am UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453 "2020-10-19T11:16:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulLinton](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/paullinton/32/518_2.png) [@PaulLinton](https://psychtoolbox.discourse.group/u/PaulLinton)\
**Post date:** [October 19, 2020, 11:16am UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/1 "2020-10-19T11:16:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dcnieho](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@dcnieho](https://psychtoolbox.discourse.group/u/dcnieho)\
**Post date:** [October 19, 2020, 12:37pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/2 "2020-10-19T12:37:33Z")

</div>

Hi Paul,

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

Cheers,  
Dee

---

<div class="post-metadata">

**Author:** ![PaulLinton](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/paullinton/32/518_2.png) [@PaulLinton](https://psychtoolbox.discourse.group/u/PaulLinton)\
**Post date:** [October 19, 2020, 1:06pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/3 "2020-10-19T13:06:33Z")

</div>

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:

> **[CubesDemo](http://peterscarfe.com/cubesdemo.html)**

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

---

<div class="post-metadata">

**Author:** ![PaulLinton](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/paullinton/32/518_2.png) [@PaulLinton](https://psychtoolbox.discourse.group/u/PaulLinton)\
**Post date:** [October 19, 2020, 1:07pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/4 "2020-10-19T13:07:21Z")

</div>

> [@PaulLinton](#):
>
> And moglcore.mexmaci64 in bin, so don’t know where it went!

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

---

<div class="post-metadata">

**Author:** ![PaulLinton](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/paullinton/32/518_2.png) [@PaulLinton](https://psychtoolbox.discourse.group/u/PaulLinton)\
**Post date:** [October 19, 2020, 1:32pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/5 "2020-10-19T13:32:33Z")

</div>

> **[MATLAB complains that mexmaci64 cannot be opened because the developer cannot...](https://www.fieldtriptoolbox.org/faq/mexmaci64_cannot_be_opened_because_the_developer_cannot_be_verified/)**

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

---

<div class="post-metadata">

**Author:** ![dcnieho](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@dcnieho](https://psychtoolbox.discourse.group/u/dcnieho)\
**Post date:** [October 19, 2020, 1:45pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/6 "2020-10-19T13:45:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PaulLinton](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/paullinton/32/518_2.png) [@PaulLinton](https://psychtoolbox.discourse.group/u/PaulLinton)\
**Post date:** [October 19, 2020, 2:34pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/7 "2020-10-19T14:34:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dcnieho](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@dcnieho](https://psychtoolbox.discourse.group/u/dcnieho)\
**Post date:** [October 19, 2020, 3:34pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/8 "2020-10-19T15:34:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [October 19, 2020, 5:39pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/9 "2020-10-19T17:39:56Z")

</div>

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

> **[How to Allow Apps from Anywhere in macOS Gatekeeper (Catalina, Mojave,...](https://osxdaily.com/2016/09/27/allow-apps-from-anywhere-macos-gatekeeper/)**
>
> Gatekeeper in MacOS is now stricter than ever, defaulting to only allow options for apps downloaded from either the App Store or the App Store and identified developers. Advanced Mac users may wish…

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

---

<div class="post-metadata">

**Author:** ![PaulLinton](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/paullinton/32/518_2.png) [@PaulLinton](https://psychtoolbox.discourse.group/u/PaulLinton)\
**Post date:** [October 20, 2020, 11:21am UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/10 "2020-10-20T11:21:50Z")

</div>

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:

> [@KbDemo not working, Mac OSX Catalina](https://psychtoolbox.discourse.group/t/kbdemo-not-working-mac-osx-catalina/3042):
>
> Mac OSX Catalina 10.15.3, MacBook Pro (15-inch, 2017), Matlab 2019b I searched the forum for a thread on the topic, but didn’t find one … apologies if I overlooked something. And I’m aware that using the toolbox with Catalina is not a good idea … sorry. When running KbDemo and I press a key, there’s no response (except the key being printed in the Matlab command window). I can only exit by Ctrl-C. Output looks as follows (I pressed fghj): 1 of 4. Testing KbCheck and KbName: press a key …

[See also [KbDemo not working on Catalina, allowing input monitoring does not help - #2 by mariokleiner](https://psychtoolbox.discourse.group/t/kbdemo-not-working-on-catalina-allowing-input-monitoring-does-not-help/3169/2) ]

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

> [@KbDemo not working, Mac OSX Catalina](https://psychtoolbox.discourse.group/t/kbdemo-not-working-mac-osx-catalina/3042/12):
>
> So basically a totally broken security UI workflow in Apples latest macOS Vista trainwreck. That’s not a Matlab bug for sure. It’s a sign of poor operating system engineering that a piece of standard userspace application software that is not close to system level would need to frequently adjust to a new OS version. From the category “Only in the magic world of Apple”. I’m pretty sure the only way to be sure your camera can’t spy on you on any OS + hw combo is to put a sticker over it. And dis…

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

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [October 20, 2020, 5:41pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/11 "2020-10-20T17:41:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PaulLinton](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/paullinton/32/518_2.png) [@PaulLinton](https://psychtoolbox.discourse.group/u/PaulLinton)\
**Post date:** [October 20, 2020, 7:14pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/12 "2020-10-20T19:14:57Z")

</div>

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:

 ![1](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/218685d912a2ded6a284613b3bee5239588495b2.png)  
 ![2](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/1d4b7221a304e2ce2d7e67d779f03aeb9339ebd4.png)  
 ![3](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/be5b4a86cdcd0caf193364f70f4cef139f17425d.png)

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

 ![4](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/48fe8091f88f646c18544aea601464cf7e1ec499.png)

With c expanded:

 ![5](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/4c61dcc09850c80996ee927e8883f2014b648729.png)

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

 ![6](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/8bf6eb87d6b02c1b054167134c88c326847c8b3d.png)

MacModelName fails for me:

 ![7](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/89d8d9a7ea09f5a3f7c05f70f69d4c3a7ef6ceda.png)

But cutting and pasting from “About This Mac”:  
 ![8](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/a82f3ce38896e60dbac3566a0bc7237e9a93fd3f.png)

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

Paul

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [October 21, 2020, 3:31am UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/13 "2020-10-21T03:31:50Z")

</div>

Does KbWait(GetKeyboardIndices()) work?

---

<div class="post-metadata">

**Author:** ![PaulLinton](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/paullinton/32/518_2.png) [@PaulLinton](https://psychtoolbox.discourse.group/u/PaulLinton)\
**Post date:** [October 21, 2020, 8:49am UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/14 "2020-10-21T08:49:00Z")

</div>

Thanks so much Mario,

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

Paul

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [October 22, 2020, 1:29pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/15 "2020-10-22T13:29:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PaulLinton](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/paullinton/32/518_2.png) [@PaulLinton](https://psychtoolbox.discourse.group/u/PaulLinton)\
**Post date:** [October 22, 2020, 3:27pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/16 "2020-10-22T15:27:22Z")

</div>

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/

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [October 22, 2020, 5:00pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/17 "2020-10-22T17:00:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![PaulLinton](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/paullinton/32/518_2.png) [@PaulLinton](https://psychtoolbox.discourse.group/u/PaulLinton)\
**Post date:** [October 22, 2020, 6:03pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/18 "2020-10-22T18:03:23Z")

</div>

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

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

 ![Screenshot 2020-10-22 at 19.01.15](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/ab3b7bd910247b2a2a32ade417f83a42ae4cffba.png)

The value for GetKeyboardIndices seems to be changing. Here it is 3, earlier in the thread it was 4 ( [Unrecognized function or variable 'moglcore'](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/12) ), and when I tested it before restarting my computer it was 5.

Thanks, again, for all your help,

Paul

---

<div class="post-metadata">

**Author:** ![PaulLinton](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/paullinton/32/518_2.png) [@PaulLinton](https://psychtoolbox.discourse.group/u/PaulLinton)\
**Post date:** [October 22, 2020, 6:29pm UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/19 "2020-10-22T18:29:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [October 23, 2020, 2:55am UTC](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453/20 "2020-10-23T02:55:19Z")

</div>

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.

[Next page](https://psychtoolbox.discourse.group/t/unrecognized-function-or-variable-moglcore/3453.md?page=2)
