ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Really what I want is a finger-point in the right direction for this. I have a burning desire to implement a new feature that did not come native to TrackIR.. and that feature is moving mouse cursor position to that of the current position indicated by the TrackIR.
I want to take the current X, Y coordinates from the TrackIR and make them the new mouse coordinates.
Never heard of TrackIR, but I've used the following (Perl) code to move the cursor via the keyboard:
Code:
sub on_keypress {
if ($add_bfe_flag) {
# only respond to these keys
my $up = 65362;
my $down = 65364;
my $left = 65361;
my $right = 65363;
my $enter = 65293; # emulates mouse button-1
my $keypad_enter = 65421; # emulates mouse button-3
# determine which key was pressed
my $w = shift;
my $e = shift;
my $keyval = $e->keyval;
# get current cursor position (screen coordinates)
my $d = Gtk2::Gdk::Display->get_default;
my $s = $d->get_default_screen;
my @p = $d->get_pointer; # $p[1] is x, $p[2] is y
my @screen_point = ($p[1],$p[2]);
# get current cursor position (window coordinates)
# because function on_press() uses window coordinates
@point = @last_point;
# if the first two parameters are 0 (or FALSE),
# on_press() will use the third parameter as the
# button pressed
given ($keyval) {
when ($up) {$screen_point[1]--;}
when ($down) {$screen_point[1]++;}
when ($left) {$screen_point[0]--;}
when ($right) {$screen_point[0]++;}
when ($enter) {on_press(0,0,1);}
when ($keypad_enter) {on_press(0,0,3);}
default { }
}
# move cursor to proper position (uses screen coordinates)
$d->warp_pointer($s,@screen_point);
}
}
This task is apparently not going to be as easy as I want...
What I'm trying to do currently is find out how a fullscreen 3d program captures mouse output. I can move the cursor in Python now, and set it to specific positions on the desktop, but when running the program with the 3d program going as well, my program still moves the mouse cursor on the desktop while leaving the program unaffected.
So it is apparent to me that:
A.) The desktop gets output from the mouse in a separate way than 3d programs
B.) I will have to analyze the game to find out where the mouse values are
C.) Maybe the aren't actually separate, but that the game is capturing a different call I'm using the move the mouse.
Update -
Aha, so the framework used to build the 3d application will contain exclusive use of the mouse, and a separate style of capturing mouse input (relative as opposed to absolute). So, if I can move it on the desktop even though code is in place to actually detect and move the cursor...
perhaps I can move it in the 3d instance as well, even though it shares similar characteristics.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.