# GetClicks and GetMouse behave awkwardly under Linux

**URL:** <https://psychtoolbox.discourse.group/t/getclicks-and-getmouse-behave-awkwardly-under-linux/846>\
**Category:** Uncategorized\
**Created:** [August 31, 2010, 2:18pm UTC](https://psychtoolbox.discourse.group/t/getclicks-and-getmouse-behave-awkwardly-under-linux/846 "2010-08-31T14:18:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [August 31, 2010, 2:18pm UTC](https://psychtoolbox.discourse.group/t/getclicks-and-getmouse-behave-awkwardly-under-linux/846/1 "2010-08-31T14:18:42Z")

</div>

Hi,  
  
I have just started using Psychtoolbox 3 and have difficulties with using the mouse as a response device.  
  
I am running Ubuntu 10.04 (lucid lynx) using a logitech mx518 mouse.  
  
When I run the code attached below the function will inevitably get stuck once it executes GetClicks. I tried running in full screen vs. window mode, using longer times for the click interval and also---getting desperate---collecting the results of GetClicks. Always the same, no matter how often the mouse is clicked, GetClicks never returns.  
  
I also tried GetMouse. Interestingly, GetMouse returns a 32-element vector in buttons and, although no mouse button has been clicked one of these 32 values is always 1. So far, I "fixed" the problem by restricting the test for mouse buttons to the first three entries. I assume there is a better way to do this? Any suggestions would be very welcome!  
  
My apologies, if this question has been raised and answered before. I could not find any hint to a solution in the online documentation, the PTB3-slides or this forum.  
  
Code follows:  
  
function MouseTest()  
fixW = 2;  
fixL = 60;  
posOW = 3;  
posOL = 100;  
targetDist = 100;  
fixOff = 20;  
  
KbName('UnifyKeyNames');  
KbCheck;  
olddebuglevel=Screen('Preference', 'VisualDebuglevel', 3);  
screenNumber=max(Screen('Screens'));  
  
% open window  
expWin = Screen('OpenWindow',screenNumber,[128, 128, 128],[250 50 1530 1074]);  
  
[mx, my] = WindowCenter(expWin);  
Priority(MaxPriority(expWin));  
  
% create first texture  
fixM = repmat(ones(1,1,3)\*128,fixL,fixL);  
fixM([30:31],:,:) = zeros(fixW,fixL,3);  
fixM(:,[30:31],:) = zeros(fixL,fixW,3);  
fix = Screen('MakeTexture',expWin,fixM);  
  
% create second texture  
posOM = repmat(zeros(1,1,3), posOL, posOW);  
posO = Screen('MakeTexture',expWin,posOM);  
  
% draw textures  
Screen('DrawTexture',expWin, posO, [], [mx-targetDist-posOW my-round(posOL/2) mx-targetDist my+round(posOL/2)]);  
Screen('DrawTexture',expWin, fix, [], [fixOff my-round(fixL/2) fixOff+fixL my+round(fixL/2)]);  
Screen('Flip', expWin);  
  
% wait for mouse (nothing ever happens even if mouse is clicked a thousand times)  
GetClicks(expWin,0);  
Screen('Flip', expWin);  
  
Priority(0);  
Screen('Preference', 'VisualDebuglevel', olddebuglevel);  
sca
