Jump to content
  • Advertisement
Sign in to follow this  
Pooya65

checking Mouse Click in the Linux without events

This topic is 2839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi

how can i check mouse clicks in the Linux without using events?

my windows code for doing it is:

bool Mouse::isKeyDown(int key) const
{
return ((GetKeyState(key) & 0x80) > 0);
}

Share this post


Link to post
Share on other sites
Advertisement
Something like this in Xlib (although, avoiding events is hardly the proper "X" way):

Display *display;
Window window;

bool Mouse::isKeyDown(int key) const
{
const unsigned int masks[5] = { Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask };
Window root, child;
int root_x, root_y, child_x, child_y;
unsigned int mask;

if(key < 0 || key >= sizeof(masks)/sizeof(masks[0]))
return false;

XQueryPointer(display, window, &root, &child, &root_x, &root_y, &child_x, &child_y, &mask);

return ((mask & masks[key]) > 0);
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!