PsychHID: Support for event buffers for KbQueues.

At least the core and OS/X implementation so far.

Keyboard queue event buffers buffer all key events of
a given keyboard queue. Events can be fetched later via
the new function PsychHID('KbQueueGetEvent'). Each event
contains timestamp, if it was a button press- or release event,
which raw keycode was affected, and the translated character
for that key. Translation of keys into characters is not yet
implemented, it returns -1 for any key.

Tested and shown to work on OSX, PsychHID for Matlab on
OSX Intel rebuilt.

Compile and test on Windows / Linux pending.
Demos, tests, key -> character translation pending.



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2541 f5efbe48-b203-0410-9429-fc5e098e5a54
PsychHID: Eventbuffer - Fix use of ^ instead of ~ for negation.

git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2542 f5efbe48-b203-0410-9429-fc5e098e5a54
Windows: Fix PsychWaitCondition() and PsychTimedWaitCondition() to conform to Posix semantic.

The routines didn't behave like their Poxix counterparts on
OS/X and Linux. Now they should do.



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2543 f5efbe48-b203-0410-9429-fc5e098e5a54
PsychHID: Improve KbEvent-Buffer support. Implement Windows part.

* PsychHID('GetKbQueueEvent') can now wait for new events with a
  timeout, instead of just polling.

* Small fixes here and there.

* Help text updates.

Windows version tested & works. Can now map keycodes + shift
modifier state to ASCII character codes for yet another way
to implement GetChar().

-> PsychHID for OS/X Intel+Matlab rebuilt and tested.
-> PsychHID for Windows Matlab R2007a and Octave rebuilt and tested.



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2544 f5efbe48-b203-0410-9429-fc5e098e5a54
PsychHID/Linux: Add support for KbEventBuffers and new GetChar mode.

- Same fixes as on Windows.
- Add translation of keycodes to ASCII characters for (ab)use as yet
  another GetChar() implementation.

=> Screen mex file for 32-Bit Octave & Matlab rebuilt and tested.

git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2545 f5efbe48-b203-0410-9429-fc5e098e5a54
Windows: Fix PsychWaitCondition and PsychTimedWaitCondition hopefully for good.

There was still a potential race, where a thread could SetEvent()
the condition variable in a PsychSignalCondition() call, while
Psych(Timed)WaitCondition() would just decide to ResetEvent() the
condition variable after unlocking the associated mutex, so a
signal could get lost:

OLD:

Signaller:        Receiver:
WaitonLock        Holdlock
---               Unlock
Lock              ---
SetEvent          ---
---               ResetEvent(!)
---               WaitEvent !! Forever !!
Unlock

Now we ResetEvent() while still under lock protection,
so signaller can only lock -> SetEvent after we've
done ResetEvent -> unlock, ie., our reset can't undo
the almost simultaneous SetEvent() of the signaller and
the signal can't get lost.

Similar logic applies to resetting the "auto-reset" event
after we've regained the lock, for increased determinism.

Hilariously: Auto-Reset events on Windows only auto-reset if
they released at least one waiting thread, but they don't
auto-reset if no thread was waiting at SetEvent() time.
(Really?!? WTF!)

This should make signalling more Posix like, ie., more like
pthread_cond_signal() / pthread_cond_(timed)wait() on OS/X
and Linux.

For best results(tm) we will reorder all PsychSignalCondition()
calls in client code to first signal, then unlock.



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2546 f5efbe48-b203-0410-9429-fc5e098e5a54
Place all PsychSignalCondition() calls before PsychUnlockMutex()

Signal condition variables while still holding the mutex lock
associated with them during Psych(Timed)WaitCondition().

This is supposed to improve determinism of scheduling a tiny
bit and possibly help the most broken OS in existence.

Posix (== Linux & OS/X) do not need this, but Posix recommends it
for deterministic scheduling:

Quote: "The pthread_cond_signal() or pthread_cond_broadcast()
functions may be called by a thread whether or not it currently
owns the mutex that threads calling pthread_cond_wait() or
pthread_cond_timedwait() have associated with the condition
variable during their waits; however, if predictable scheduling
behaviour is required, then that mutex is locked by the thread
calling pthread_cond_signal() or pthread_cond_broadcast()."

MS-Windows otoh is sufficiently f$#@$# to probably need this
much more urgently so it can better limp along with the real operating
systems.

-> Needs rebuild of Screen, PsychHID, PsychPortAudio to take effect.



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2547 f5efbe48-b203-0410-9429-fc5e098e5a54
PortAudio: Replace pa_dither.[ch] with 64-Bit clean version from upstream Rev. 1418

Revision 1418 of upstream...

<http://www.assembla.com/code/portaudio/subversion/changesets/1418>

... fixes the audio dithering functions to work correctly on
64-Bit systems. This (so far untested) should fix the
loud white-noise heard in BasicSoundOutputDemo on 64-Bit
Ubuntu 12.04-LTS. BasicSoundOutputDemo is our only demo
which uses reqlatencyclass == 0, ie., no low-latency mode,
ie., dithering enabled --> White noise on 64-Bit Linux.

Let's see how this works out. Maybe this was related to the
static noise  bug on CentOS from Psychtoolbox forum message #13331?



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2548 f5efbe48-b203-0410-9429-fc5e098e5a54
Fix so that it runs.  A bit more testing wouldn't hurt.  DHB

git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2549 f5efbe48-b203-0410-9429-fc5e098e5a54
Add test of irradiance to troland conversion. DHB

git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2550 f5efbe48-b203-0410-9429-fc5e098e5a54
moglmorpher: Add stricter parameter validation for 'addMesh'

Makes sure nobody passes in vertices, normals, texcoords or
vertex colors of wrong component count.



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2551 f5efbe48-b203-0410-9429-fc5e098e5a54
PsychHID/OSX: Fixes and start of a GetChar mapping mode.

- Some important fixes.
- Half-Done HID code -> ASCII code remapping. This is just
  such a pain on the Apple OS, i couldn't stand it anymore!
  Will be finished another time.



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2552 f5efbe48-b203-0410-9429-fc5e098e5a54
Screen, PsychPortAudio, PsychHID for OSX Intel Octave & Matlab rebuilt.



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2553 f5efbe48-b203-0410-9429-fc5e098e5a54
Screen, PsychHID, PsychPortAudio for Windows Matlab R2007a & Octave rebuilt.
Screen, PsychHID, PsychPortAudio for Linux 64-Bit Matlab & Octave rebuilt.

-> PsychPortAudio contains Portaudio dithering fixes for 64-Bit Linux.



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2554 f5efbe48-b203-0410-9429-fc5e098e5a54
Linux: Screen, PsychPortAudio, PsychHID for 32-Bit Octave & Matlab rebuilt.

git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2555 f5efbe48-b203-0410-9429-fc5e098e5a54
Screen, PsychPortAudio for Matlab R11 on Windows rebuilt.



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2556 f5efbe48-b203-0410-9429-fc5e098e5a54
Screen, PsychPortAudio, PsychHID for OSX on PowerPC and Matlab rebuilt.



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2557 f5efbe48-b203-0410-9429-fc5e098e5a54
- Fixed a bug in SaveCalFile, which was introduced in the last change.  The internal call to LoadCalFile omitted the 'whichCal' parameter.

     -Chris-

git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2558 f5efbe48-b203-0410-9429-fc5e098e5a54
PsychHID/Linux: Exclude anything with "Bus" in its name as default keyboard.

"Video Bus" - is not a good choice for a default keyboard
in the KbQueueXXX functions on Linux...



git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2559 f5efbe48-b203-0410-9429-fc5e098e5a54
Added CIE 2 and 10 degree 'physiologically relevant' luminosity functions.

git-svn-id: http://psychtoolbox-3.googlecode.com/svn/trunk@2560 f5efbe48-b203-0410-9429-fc5e098e5a54