gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS Motion Sensor > 'Mouse' on GBA

#135755 - Ant6n - Thu Jul 26, 2007 2:24 am

I've spend some time the last couple of days trying to devise a way to get a sort of mouse working on the gba using the gbaccelerometer. Here is what i have come up with so far. I created some sort of library called gbamouse.
It reads the values from the gbaccelerometer and provides these as acceleration on the axis, rotation around the axis, angle between rotated xy,yz,zy planes and the corresponding untransformed planes.
Unlike a sort of joystick, a tilting of the gba from the original position doesn't represent movement of the mouse, but an absolution position that is relative to the original position (i.e. calibration)

I provided a little example to show the settings. One can browse through them with the dpad. It also shows the values the mouse object reads. One can turn that off to see the mouse running at 'normal' speed. So far everything is programmed using floats (and pretty fugly), because this is a proof of concept.

I hope that people test this and give feedback, and their favorite settings.
I hope that eventually people will port some old dos game or so (that is if they havent all moved to the DS yet).
source/binary:
http://www.cs.mcgill.ca/~adubra/gba/mouse/gbaMouse.zip
Anton


(ps:)The settings are:
source of mouse x and y values - either axis angle, plane angle or values directly from accelerometer
x/y sensitivity - the higher the value, the farther the mouse will go on tilt
x/y mouse lag - its a sort of filter to avoid small jumps; it represents how much the difference between old mouse position and new measured mouse position is to be multiplied by to get the new actual mouse position
one can associate a button (or more) with the mouse, for movement and calibration (in the example i used both shoulders and select)
calibration - calibration on pressing mouse, releasing mouse, no calibration
center on calibration - either center the mouse on calibration, or keep it where it is
when to move - move or not on button press, move or not on not button press

#135800 - KeithE - Thu Jul 26, 2007 1:49 pm

Cool. I like it. Here are the settings that I liked best (with the showing of values off)

mouse x: plane
xsensit: 524
x-lag: .08
mouse y: plane
ysensit: 655
y-lag: .08
calibrt: on press
ccenter: no move-calibrate
whenmov: on key press

Something strange that I noticed - when I hold it upside down, like when lying in bed, the directions are reversed from what I would expect. To see what I mean, hold it face up and rotate to the right - cursor moves to the right. Now, hold it face down and rotate to the right - cursor moves to the left.

Another thing you might want to try - use a running average of a few samples of the accelerometer readings instead of the raw values to reduce bouncing.

#135828 - Ant6n - Thu Jul 26, 2007 6:46 pm

Thank you for trying!
EDIT
i wrote some bs.
the angles do wrap around when upside down... have to think about that
/EDIT


as for running average, i hoped that the 'mouselag' would be enough. The mouse position uses a sort of running average, i find new values by:
mousex += (newx - mousex)*mouselag
Maybe i should try a real running average over a couple of accelerator readings as well.