You can use IsOSX() or IsPC() in your programs to create if statements that run different commands depending on the platform.
On Macs, each keyboard/keypad has it's own device number (assigned only when Matlab starts up) and you specify a device to query when using KbCheck(device_number). You can use KbCheck(-1), which queries all devices at once. I haven't used this much, but you won't be able to see which device had which key pressed.
On PCs, devices are not assigned distinct device numbers and KbCheck (regardless of what argument is passed: KbCheck(), KbCheck(1), KbCheck(100000)) will check all devices simultaneously. Note, you can plug keypads into PCs after Matlab has started, and once they are recognized by Windows as new keyboards, Matlab will be able to read them with KbCheck without having to restart.
Therefore, on a Mac you are either hard coding your device numbers or preferably using the input_device_...() functions (part of claffey_matlab) to dynamically find them. These don't work and should be skipped on PCs, so you have something like:
if IsOSX()
% mac version
my_left_keypad_index = input_device_by_prompt('Hit a button on the left keypad ', 'keypad');
my_right_keypad_index = input_device_by_prompt('Hit a button on the left keypad ', 'keypad');
else
% pc version
my_left_keypad_index = [];
my_right_keypad_index = [];
end
On Macs, the order of the screen_id argument and command argument to most Screen commands seem interchangable. In other words, Screen(w, 'Flip') is the same as Screen('Flip', w).
On PCs, it has to be command first: Screen('Flip', w). In general, it looks like we should always use this format for easy compatibility.
I've encounted a few times when GetSecs() on a PC will produce negative numbers. This requires a restart of Matlab.
On Mac, the file separater is /
On PC, the file separater is \
If you hard code this into your program, it appears to be able to
handle the other system's character, but it may produce occassional
problems. You can use the filesep() function to dynamically build paths.
For example: dir_str = ['myExperiments' filesep() 'data' filesep()
'subject_1'] will produce 'myExperiment\data\subject_1' on a PC and
'myExperiment/data/subject_1' on a Mac.
Copyright 2013 Mike Claffey