Fix HideCursor() / ShowCursor() on some MS-Windows setups.

HideCursor() wasn't hiding the cursor anymore on some Matlab + Windows
combos for no conceivable reason. On others it worked fine. Apparently
ShowCursor(FALSE/TRUE), while still dec/incrementing the cursor
reference counter, had no effect anymore on the actual cursor.

Various workarounds are implemented in this commit, almost all utterly
ineffective, contrary to what Internet technical forums and Microsoft
MSDN docu says.

The one thing that works (at least on R2012a 32/64-Bit + Windows-7 in a
VirtualBox VM -- my only test system which was broken wrt.
HideCursor()), is defining our own cursor image via CreateCursor(),
which simply contains a 32-by-32 pixels invisible cursor and then
assigning that via SetCursor() during Hidecursor calls, restoring the
backed up original cursor on ShowCursor calls.

This seems to work well enough, as does changing the cursor shape.

I also tried AttachThreadInput() which should have helped, and should
have made GetChar() on WinVista+ working again by sharing all input
queues of our threads/windows with Matlabs queues, but it hasn't any
positive effect on either cursor or GetChar, also does not seem to do
damage to KbCheck or KbQueueXXX, so we leave it in for now.

Screen for 32-Bit and 64-Bit Matlab on Windows rebuilt and tested. What
a nightmare of a system.
Screen GStreamer vidcap: Fix qtkitvideosrc, prepare for camerabin2

Some small fixes to make qtkitvideosrc plugin work on OSX with
GStreamer.
The plugin is less flexible than miovideosrc, can't probe its sources,
doesn't provide meaningful capture timestamps, so no big win. We still
prioritize miovideosrc for this reason. However, h264 video recording
worked with qtkitvideosrc, but created a deadlock-hang with
miovideosrc. At least one thing works better with qtkitvideosrc…

This also starts a camerabin2 implementation. This is half-finished, as
i can't test with the GStreamer-SDK, due to a bug in the SDK. Therefore
camerabin is still the only viable choice, which is fine on 32-Bit
Windows and all versions of Linux, but requires GStreamer from HomeBrew
on OSX.

VideoRecordingDemo cleaned up a bit.
PsychTweak: Improve VM handling and allow choice of GPU to use.

Add PsychTweak('UseGPUIndex') to select the target GPU to use for
low-level ops. Sets the relevant env var on behalf of user code.

PsychTweak('PrepareForVirtualMachine') - also disables sync tests and
calibrations on all systems, to make this more pain-free. Sets marker
env var PSYCH_IN_VM to signal to all components PTB is running inside a
VM. This is used by Priority() to no-op, as rt-scheduling and
memory-locking can wreak havoc in VMs.
Screen OSX: Add suppor for GPU selection for low-level ops.

Now also accepts the same environment variable from PsychTweak() as on
Linux. Screen not yet recompiled, this is not important enough for now.
Screen/Linux: Improve 'Framerate' detection further.

Our last hack to make Screen('Framerate') work inside VirtualBox VM's
by accepting a slightly weird modeline from RandR unfortunately broke
some specialized real setup with NVidia binary blob, which on that
setup also returns a invalid/weird modeline via RandR. That mode should
have been rejected and instead the XF86VidMode fallback used for proper
results, but our more lenient mode checking didn't reject the mode.

-> Failure on real setups, even exotic ones, is worse than failure in a
VM, so fix the real setup and return a zero "unknown" value in the VM,
where it doesn't hurt much on top of all other VM inflicted limitations.

Screen mex files for Linux rebuilt.
pnet.mexw64: Bugfix for 64-Bit bug on Windows.

Use of size_t instead of mwSize for matrix dimensions and lack of
-largeArrayDims switch caused a miscompile, where mwSize was 32-Bit due
to lack of -largeArrayDims switch, but size_t was 64-Bit due to compile
for 64-Bit Matlab. Hilarity ensures when trying to receive any data
type other than uint8 / char, e.g., double. Fixed. Fixes forum bug
#14500.

pnet.mexw64 for 64-Bit Matlab on Windows rebuilt and tested.
Fixes to udp_plotter_demo.m and udp_send_demo.m
Screen/Linux: Fix INTEL_swap_event support.

Use of the extension couldn't get enabled anymore, because our
extension query code failed to detect presence of the extension. This
used to work, then broke. Apparently something was fixed in the
extension query mechanism, which broke our code, or something was
broken in the mechanism which broke our code. Anyway, add additional
checks so we detect support on systems with old style query and new
style query path.

Also allow to force use of extension for ptb low-level debugging if env
variable PSYCH_FORCE_INTEL_swap_event is defined to any value.
Additionally fix some "missing return value" compiler warning.
Screen/Linux: Error detection and workaround for broken Intel ddx.

Add check to make sure that swap scheduling works correctly and never
executes a swap at a 'msc' before the requested 'targetMSC'. If this
fails, switch to swap scheduling fallback path with wait +
glXSwapBuffers and warn user about broken driver. Check is performed
after each swap and during window open startup tests.

This to catch and handle a horrifying bug in all Intel ddx drivers
shipped between June 2011 and at least October 2012. Of course people
who check their Flip timestamps will have noticed this bug, but good to
protect the other ones and to automatically handle the problem.

Screen.mex for 32-Bit Octave from previous commit rebuilt and tested so
far against broken Intel driver. More tests pending.
Screen/Linux: Improve robustness and diagnostic of Screen('Resolution');

Make it more robust against drivers which claim RandR-1.2 support, but
do weird things in mode enumeration, e.g., don't return any modes. Make
it more robust against drivers without RandR-1.2 support at all.

Improve debug diagnostic output to simplfiy debugging of problems with
the function - add more detailed optional debug output about mode
enumeration and matching.
Screen/Linux: Improve interop with apitrace.

Optional env-variable "PSYCH_ALLOW_APITRACE" if defined should make
Linux ptb compatible with apitrace. So far it does disable GLX-1.3
support, as that seems to be one point of pain for apitrace. However,
this is just a start, apitrace still dies when trying to trace.
Screen/Linux: Improve diagnostic messages for Intel ddx bug detection.

Slight cleanup and readability improvements.
Screen/Linux: Make sure new swap scheduling tests only execute for vsynced swaps.

For non-vsynced swaps, skip them, to avoid false positives.
Need to place initial vsync enable before
PsychDetectAndAssignGfxCaps(), as that code triggers the
OML_sync_control correctness tests, which depend on vsync being enabled.
Screen/Linux: Another paranoia check for possible oml-timestamping bugs.

This one has some potential to detect potential future driver bugs in
pageflip completion timestamping on the DRI2/KMS graphics drivers. No
such bug exists yet, but given the amount of work that currently goes
into improving the drivers timestamping/scheduling, this may serve as
an additional correctness check for the graphics stack -- and as a
protection of users against such problems, should they go unnoticed
pre-release.
Screen/Linux: Add additional safety checks via use of INTEL_swap_event ext.

The INTEL_swap_event extension provides one additional bit of
information after each swap: If the swap was performed via pageflip
(good), or via copyswap/blit, or buffer exchange - which would be bad
for timing and timestamping, but can happen on misconfigured systems or
very suboptimal setups.

By default, we now enable event delivery by the extension if the
extension is supported, and check events for this condition: If a
vsync'ed swap on a regular (non-composited) fullscreen window was
performed, it should be a page-flipped swap, otherwise something is
seriously wrong and we output warning messages to the user, telling
that the system is misconfigured or malfunctioning and in need of
attention. On non-vsynced, composited, or non-fullscreen swaps, we
don't check for trouble, as such configs are by definition not
reliable/trustworthy wrt. timing or timestamping in any way, and users
know this -- at least if they read our help ;).

The Screen('GetFlipInfo') function now no longer enables/disables use
of the extension and event delivery, instead it only logically
enables/disables it. The extension is always enabled if supported, the
usercode switch just decides if usercode gets exclusive access to flip
events, or if they are instead directed to our internal trouble
checking code.

Detection of the extension was also improved, to make it robust against
some changes in the extension enumeration mechanism on recent Linux
systems.
Screen: Silence some warnings about beampos queries if OML_sync_control in use.

If we can and do use OML_sync_control timestamping for flip timestamps
and correctness checks, then beamposition queries for beampos
timestamping are redundant/not needed, except for extended debugging or
some special applications.

Therefore silence many of the warnings related to beamposition trouble
in such a case. No need to clutter the console with pretty irrelevant
warnings in such a case. Avoid displaying the warning triangle in such
a case.
Screen: Fix use of OpenML status flags.

Due to wrong use of status flags, disabling the OpenML swap scheduling
accidentally also disabled the use of OpenML timestamping. Fixed.
Screen/Linux: Add some missing lines for INTEL_swap_events checks.

Got lost in previous commit...
Screen: Avoid ugly corrupted startup screen on triple-buffered OpenGL setups.

The Intel graphics drivers on Linux support and enable OpenGL
triple-buffering by default. The existence of a 2nd backbuffer in this
config broke some assumptions of our startup-logo display code, warning
triangle display code, and the initial clearing of the window to
background clear color. This caused the 3rd buffer to get swapped int
uninitialized, containing random pixel trash, which looked really ugly.
Perform 3 init + swapbuffers calls instead of 2 init + swapbuffers call
in logo display, warning display, and initial background color clear in
'OpenWindow' to make startup beautiful again.
Screen for 32-Bit Octave on Linux rebuilt for testing.

For testing of all previously committed changes:

This version can correctly detect and workaround broken Intel-DDX swap
scheduling on Linux. It can properly handle Intel triple-buffering for
artifact free nice startup screens and session startup. All additional
cross-checks work as expected.
Speech(): Add support for Linux and Windows, improve OSX support.

Add Linux and MS-Windows support, and support for some optional
parameters, as well as speaking multiple text strings in succession.

MS-Windows support contributed by Vishal Shah, NYU.