Active Topics

 



Notices


Reply
Thread Tools
Posts: 482 | Thanked: 550 times | Joined on Oct 2010
#1
I don't know whether anybody has done this yet, but I got inspired by the mouse in my friend's Wii and decided to write a program to allow me to do the same with my N900. Currently I only have a OSX version of the script, because I won't have access to a Linux or Windows computer until this evening and there doesn't seem to be any cross-platform way to move the mouse pointer.

Note that this will only work if you connect your N900 to the same Wifi network as your computer!

To Use:
  1. Download the .zip archive and extract it. You should have two files, client.py and server.py.
  2. In this case, the N900 is the client and the computer is the server. Move client.py onto the N900 and put it somewhere where you know where it is. (I made a folder named Python and put it in there.)
  3. Find out what your computer's local IP address is. Go to System Preferences > Network and it should tell you your IP address.
  4. Open up Terminal on your computer. If you haven't used it before, it is under Applications/Utilities.
  5. Type this into Terminal:
    Code:
    cd Downloads/MouseControl
  6. Now type
    Code:
    python server.py 2000
    (the 2000 is the port it opens, use a different one if neccessary).
  7. The server script is now waiting for input. On the N900, open up Xterm, and type
    Code:
    cd MyDocs/Python
  8. Now to start the service: Type
    Code:
    python client.py abc.def.ghi.jkl 2000
    where abc.def.ghi.jkl is the IP address you found earlier.
  9. Wave the N900 around and watch the mouse move. Flat on the table should put the cursor in the center of the screen. I have it set up so that you point with the USB port end.
  10. To stop the script, press control+c on the computer and both scripts should stop.

Please tell me what you think! I know I really should make it threaded to smooth the movement but I hate threading, I will work on that though.
Attached Files
File Type: zip MouseControl.zip (2.1 KB, 119 views)
 

The Following 17 Users Say Thank You to skykooler For This Useful Post:
Posts: 482 | Thanked: 550 times | Joined on Oct 2010
#2
Update: Now with threading. Mouse moves much more smoothly. However, I get some errors in terminal about a pool not released which I don't understand. It says it may be leaking memory but I don't see that - I let it run and the memory consumption didn't go up. And does anybody know how to stop a threaded program? Control+c doesn't work reliably, I sometimes have to kill it by closing the window. Use threaded version at your own risk.
Attached Files
File Type: zip MouseControlThreaded.zip (2.2 KB, 83 views)
 

The Following User Says Thank You to skykooler For This Useful Post:
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#3
Originally Posted by skykooler View Post
there doesn't seem to be any cross-platform way to move the mouse pointer.
There is pymouse. I have only used it in Linux, but it should also work in mac and windows.

Best way imho would be to emulate mouse device like bluemaemo.
__________________
Couple of my applications:
ConnLock - Advanced phone lock
Sanakirja.org - A Sanakirja.org dictionary client
Wlan Driver Selector Applet - Switch easily between stock and bleeding edge drivers
 

The Following 4 Users Say Thank You to laasonen For This Useful Post:
Posts: 482 | Thanked: 550 times | Joined on Oct 2010
#4
I looked over the pymouse code, and rather than making users have to install it first I simply integrated it into my app. Here is the new version: it is threaded, hopefully cross-platform, and mouse movement is now very smooth. Unfortunately, it is still rather hard to kill, I don't know why. I will look into that.
Attached Files
File Type: zip MouseControlThreaded.zip (3.3 KB, 90 views)
 

The Following User Says Thank You to skykooler For This Useful Post:
Posts: 482 | Thanked: 550 times | Joined on Oct 2010
#5
The system is now very usable, I have been using it instead of my mouse for the last 15 minutes. I still need to implement clicking though. I now have the ability to stop it however: to terminate it at any time, press control+D.
Attached Files
File Type: zip MouseControlThreaded.zip (3.4 KB, 77 views)
 

The Following User Says Thank You to skykooler For This Useful Post:
Posts: 482 | Thanked: 550 times | Joined on Oct 2010
#6
Could anybody tell me whether this works on Linux or Windows?
 
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#7
You need python2 and python-xlib packages to run it under linux. The cursor seems to go up when I want it to go down and down when I want it to go up, otherwise it seems to work.
__________________
Couple of my applications:
ConnLock - Advanced phone lock
Sanakirja.org - A Sanakirja.org dictionary client
Wlan Driver Selector Applet - Switch easily between stock and bleeding edge drivers
 

The Following 2 Users Say Thank You to laasonen For This Useful Post:
Posts: 482 | Thanked: 550 times | Joined on Oct 2010
#8
Originally Posted by laasonen View Post
The cursor seems to go up when I want it to go down and down when I want it to go up, otherwise it seems to work.
Hmm...I wonder why that is. Anyway, you can change that by changing the line
Code:
x = (lx*8+(average(l3x)/800.0+0.5)*height)/9
to
Code:
x = (lx*8+(average(l3x)/(-800.0)+0.5)*height)/9
in server.py.

I should add a command line flag for that.
 

The Following User Says Thank You to skykooler For This Useful Post:
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#9
Originally Posted by skykooler View Post
Hmm...I wonder why that is. Anyway, you can change that by changing the line
Code:
x = (lx*8+(average(l3x)/800.0+0.5)*height)/9
to
Code:
x = (lx*8+(average(l3x)/(-800.0)+0.5)*height)/9
in server.py.

I should add a command line flag for that.
That fixed it. Its still almost impossible to control the cursor properly, maybe in some games
__________________
Couple of my applications:
ConnLock - Advanced phone lock
Sanakirja.org - A Sanakirja.org dictionary client
Wlan Driver Selector Applet - Switch easily between stock and bleeding edge drivers
 

The Following User Says Thank You to laasonen For This Useful Post:
Posts: 482 | Thanked: 550 times | Joined on Oct 2010
#10
I added the command line flags --fx and --fy to flip the x and y axes, respectively. Using both is equivalent to turning the phone around.

That fixed it. Its still almost impossible to control the cursor properly, maybe in some games
I hadn't thought about using it in games...I wonder how well it would work as a joystick in a flight simulator? I will try this evening!

Meanwhile, I will try and add some buttons so that you can click and scroll.
Attached Files
File Type: zip MouseControlThreaded.zip (3.5 KB, 102 views)
 

The Following User Says Thank You to skykooler For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 00:17.