LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-18-2011, 11:35 PM   #1
Dogs
Member
 
Registered: Aug 2009
Location: Houston
Distribution: Slackware 13.37 x64
Posts: 105

Rep: Reputation: 25
I want to move my mouse cursor with my program.


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.

Anyone have experience with such a thing?
 
Old 02-19-2011, 06:43 AM   #2
RockDoctor
Senior Member
 
Registered: Nov 2003
Location: Minnesota, US
Distribution: Fedora, Ubuntu, Manjaro
Posts: 1,791

Rep: Reputation: 427Reputation: 427Reputation: 427Reputation: 427Reputation: 427
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);
    }
}
 
Old 02-20-2011, 01:33 PM   #3
Dogs
Member
 
Registered: Aug 2009
Location: Houston
Distribution: Slackware 13.37 x64
Posts: 105

Original Poster
Rep: Reputation: 25
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.

Last edited by Dogs; 02-20-2011 at 01:50 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide mouse cursor/change cursor location? mrjamin Linux - Software 4 09-27-2010 10:09 AM
Mouse cursor move sluggish, slow and erratically foojoy Linux - Hardware 4 03-25-2008 06:50 PM
i'm using xandros 3.0.2, my mouse(logitech) is not being sensed(cursor doesnt move) rocky_sk0c Linux - Hardware 0 09-13-2005 10:51 AM
startx on Debian gives grey background - cannot move mouse cursor or type fdac Linux - Newbie 7 05-04-2005 03:11 PM
mouse cursor doesn't move in X/Debian LovelyJunna Linux - Newbie 7 03-26-2004 05:12 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration