# Creating MWorks plugin

**URL:** https://mworks.discourse.group/t/creating-mworks-plugin/499
**Category:** Support
**Created:** [August 17, 2015, 2:09pm UTC](https://mworks.discourse.group/t/creating-mworks-plugin/499 "2015-08-17T14:09:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [August 17, 2015, 2:09pm UTC](https://mworks.discourse.group/t/creating-mworks-plugin/499/1 "2015-08-17T14:09:19Z")

</div>

Hello Chris,

I’m currently a rotation student with the Movshon lab at NYU and have been working with Najib on developing a plug-in for MWorks. We’d like to be able set the monitor’s gamma values, run a calibration in case gamma values are not known, and set monitor resolution and refresh rate.

The short story is that I have been unable to figure out how the client (grabbing data from the user via some graphical interface) sends variable updates to the server so that the server can take specific actions for each updated variable.

The more detailed story is that I’ve looked around the code a fair amount and have run into some issues:

The variables window plug-in works in the same way that we envision for our display plugin. I found in the code (file MWVariablesDataSource.m in plugins–\>client–\>VariablesWindow) where the “branches” of variables (e.g. system variables, experiment variables) are loaded, where each variable is loaded into the display and where user modification of the variable is handled. I’m not sure how this file, though, interacts with the GUI found in Main.xib of the same project.

Putting aside that approach, I created my own GUI but was unable to establish a link between the GUI and acting on the values in the GUI.

What’s the approach that you recommend? Any advice is greatly appreciated!

Thanks,

Paul

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [August 17, 2015, 4:49pm UTC](https://mworks.discourse.group/t/creating-mworks-plugin/499/2 "2015-08-17T16:49:45Z")

</div>

Hi Paul,

I’d recommend having a look at Apple’s [introductory Mac development tutorial](https://developer.apple.com/library/mac/referencelibrary/GettingStarted/RoadMapOSX/books/RM_YourFirstApp_Mac/Articles/Introduction.html), which covers the basics of implementing a graphical UI and associated back end.

Cheers,  
Chris

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [August 17, 2015, 11:53pm UTC](https://mworks.discourse.group/t/creating-mworks-plugin/499/3 "2015-08-17T23:53:07Z")

</div>

Hi Chris,

Since I’m partially responsible for Paul’s inquiry, I though maybe I’d try to re-explain the issue.

We’d like to add some additional parameters to the MWorks Server’s preference window. We’re stuck on knowing where these parameters are saved and how to access them from other routines. After looking through some code, I think they’re mostly saved in (and accessed by) the global variable “mainDisplayInfo”. We just want to confirm and make sure whatever we edit won’t break things in the long run (i.e. in which files we should make our edits so as not to break future builds). Would you be available tomorrow (Tues, Aug 18) at 3 pm for a chat (via phone/skype/etc)? It would be with myself, Najib Majaj and Paul (all of us in Tony Movshon’s Lab at NYU). If not, can you suggest a good time?

- Romesh

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [August 18, 2015, 2:25pm UTC](https://mworks.discourse.group/t/creating-mworks-plugin/499/4 "2015-08-18T14:25:00Z")

</div>

Hi Romesh,

MWorks configuration is handled via a [handful of system variables](https://mworks.discourse.group/kb/installation/configuring-mworks#editing-the-configuration-file). For the purpose Paul described, I think you’re correct that `#mainScreenInfo` is the right variable for storing your settings. Its value is a dictionary, so you can just add new keys for the settings you want to store.

MWServer’s preferences window reads and writes the relevant system variable for each setting. However, the window itself isn’t designed to be extended by plugins. If you want a GUI for your settings, then you should create a MWClient plugin. The [Eye Calibrator Window](https://github.com/dicarlolab-mworks/dicarlolab_mwclient_plugins/tree/master/CalibratorWindow) is similar to what you’d need, in that it provides a client-side GUI that reads and writes server-side variables. It’s also smaller and easier to understand than the variables window.

Of course, once you’ve set variables on the server side, the server needs to _do_ something with them. To that end, you’ll also need a core plugin. This would probably implement a new `IODevice` subclass, which could use `OpenGLContextManager::getMainDisplayID` to get the `CGDirectDisplayID` for the stimulus display. Once it had that, it could employ the appropriate functions from [Quartz Display Services](https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/index.html) to configure the display.

> Would you be available tomorrow (Tues, Aug 18) at 3 pm for a chat (via phone/skype/etc)?

Yes, I’m available then, if you think a chat would be helpful.

Cheers,  
Chris

---

<div class="post-metadata">

### Author: ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)
#### Post date: [July 19, 2022, 10:25pm UTC](https://mworks.discourse.group/t/creating-mworks-plugin/499/5 "2022-07-19T22:25:09Z")

</div>


