Cursor Global Position
Hello all,
How can i get the global position of the cursor? (i'm using c language, and suse 10.1 linux) Thanks. |
You can do that with a simple X11 application.
Have a look at xeyes for example to see how it can be done. |
Thanks for your reply,
but this method use X11, i need another method. i'm using the framebuffer to draw something on the screen(desktop), and i want to get the position of the cursor. Can you help me? Thanks. |
Quote:
|
Ok, Thank you.
Could you please give me an example on how to do that in X11 ? or the name of the API? I'v searched for that in the xeyes, but i didn't find the API. |
man XQueryPointer
|
Thanks, and here is the code:
Code:
#include <stdio.h> |
I need to that without using xlib, any help?
|
Perhaps looking at code for directFB would give a clue...
|
Modift / Set (x, y) coordinates
Hi
I also used X11 to get x and y coordinates through XQueryPointer() in the same way as in above mentioned code. Is there any way to work in lower level of XServer using HID (Hardware Interface Device). As I am intrested to control my joystick to move in my mentioned coordinates on display screen. Thanks alot madni madni[AT]kth[DOT]se |
Hi
Here is another way to get x and y axis and other events of devices (dev/usb/hiddevX) for kernel 2.6.X This is by using HID (Hardware Interface Device) events at hardware interface level. /* * Madni * gcc -Wall -W events.c * sudo ./a.out /dev/usb/hiddev0 */ #include <stdlib.h> #include <stdio.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <asm/types.h> #include <fcntl.h> #include <unistd.h> #include <stdint.h> #include <linux/input.h> #include <linux/hiddev.h> #define EV_NUM 5 int main (int argc, char **argv) { int fd = -1; char name[256]= "Unknown"; /* ioctl() requires a file descriptor, so we check we got one, and then open it */ if (argc != 2) { fprintf(stderr, "usage: %s event-device - probably /dev/input/evdev0\n", argv[0]); exit(1); } if ((fd = open(argv[1], O_RDONLY)) < 0) { perror("evdev open"); exit(1); } //------------- Device Name --------------------------- char name[100]; if (ioctl(fd, HIDIOCGNAME(99), name) < 0) perror("HIDIOCGNAME"); else { name[99] = 0; printf("Device Name: %s\n", name); } //-------------- Read Events------------------------------- struct hiddev_event ev[EV_NUM]; int i; while (1) { read(fd, ev, sizeof(struct hiddev_event) * EV_NUM); for (i = 0; i < EV_NUM; i++) { printf("%d : EVENT: PARAM %x : %d\n", i,ev[i].hid, ev[i].value); } } close(fd); exit(0); } |
All times are GMT -5. The time now is 12:17 AM. |