maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Games (https://talk.maemo.org/forumdisplay.php?f=12)
-   -   [Maemo 5] Accelemymote: making your accelerometer more joy-ful (https://talk.maemo.org/showthread.php?t=45482)

Flandry 2010-02-22 21:10

[Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Accelemymote
making your accelerometer more joy-ful

Accelemymote takes input from the accelerometers in the N900 and converts it into joystick events. This makes any game that supports a generic joystick interface tilt compatible.

Games and emulators that support tilt control using Accelemymote:
  • The Ur-Quan Masters
  • PrBoom (edit cfg file for best results--see comments there
  • MAME
  • Descent
  • Mupen64plus

Status: Default profile (analog 2 axis; proximity sensor as button A) and debug implemented. As installed, works reasonably well with quite a few MAME ROMs and is okay in uqm. PrBoom works well, but requires some changes to the default config due to its poor joystick support (a separate issue that will hopefully be dealt with at some point).

With some key mapping and config tweaks (this is where you come in...), a lot of other games and MAME ROMs should work well. Please report.

Package pages:
GUI -- Found in the "System" category. Will automatically install the other package:
CLI daemon -- for those who want to invoke via scripts or xterm. You'll have to use apt to grab this by itself.

Instructions:
  1. Install accelemymote-gui package.
  2. Click icon to start app.
  3. Start game.
  4. When done playing, exit gui app to shutdown joystick driver.
You can change the settings in ~/.accelemymote/main.cfg

How to Edit Settings (for Dummies :))
  1. Install leafpad from app manager
  2. Open xterm
  3. Type
    Code:

    leafpad .accelemymote/main.cfg
    . Don't miss the dot in front of accelemymote. You should get an edit window full of config file--if not, you did something wrong.
  4. Edit the values of the parameters. Possibly useful ones to edit are max_roll and max_pitch (which control the sensitivity), and deadzone, which determines what fraction of the max angles from neutral is required before joystick motion begins.
  5. Save
The values in brackets [ ] are the defaults if you want to return it to original behavior. The code below should match the contents of the file if you need to copy-paste a fix.

Zeroing the axis:
To change the baseline tilt (the neutral position) from the default of 30 degrees, click the button in the GUI and hold it at the desired neutral tilt until a banner informs you it has been calibrated (about 5 s).

Triggering that automatic calibration can also be done by changing the value of the offset_pitch in the config file to 900 and then saving. Alternatively, you can change the value to whatever angle you hold the N900 at by default (0 would be flat on a table, 90 vertical).

Config Options (main.cfg)

Code:

; Accelemymote configuration file
[Format]
version =        1
[Sampling]
samples =        2        ; Samples to average for each frame        (1-5)                [2]
frame_rate =        10        ; Number of event-generating timesteps per second (1-30)[10]
;
; At default settings, accelemymote consumes about 1% CPU cycles at baseline frequency mode
;
[Control]
flip_pitch =        -1        ; -1=> tilt forward is up; 1=> tilt forward is down        [-1]
offset_pitch =        30        ; degrees tilt backwards to the neutral position        [30]
; Calibration: Setting offset_pitch to 900 will cause accelemymote to
; update it with the current pitch after 4 seconds
;
; Most games that take digital joystick inputs use some intermediate
; value as the "on" position.
; PrBoom is a bit stupid in that it doesn't consider a direction "on"
; until the max is reached, so set these to a small value for PrBoom (~7).
max_roll =        20        ; degrees plus/minus from neutral to max out the x axis        [20]
max_pitch =        18        ; degrees plus/minus from neutral to max out the y axis        [18]
;
deadzone =        0.10        ; fraction of max angle from neutral to start joystick [0.10]
;
; Set these to 0 for PrBoom (it requires spamming of events to work well)
threshold_roll =2        ; degrees of tilt change between new x axis events [2]
threshold_pitch=2        ; degrees of tilt change between new y axis events [2]
;
profile =        analog        ; control mode. Options=hat, analog, debug.        [analog]
;
; **Not currently supported/used**
; debug: prints out messages about the events being generated. Very noisy!
; hat: a digital joystick (just on or off in each direction, a dpad or hatswitch). Not currently supported.
; analog: well, an analog joystick... the default

; Turtle makes the driver sleep when upside-down (frame_rate = .5).
; Also, flipping the phone on its face activates/deactivates joystick events.
; 1 is enabled
; 0 is disabled
; -1 is active (start in turtle mode)

turtle =        1        ; Toggle joystick by turning the N900 upside down. [1]
proximity =        2        ; Enables/configures effect of proximity sensor. [2]
; Proximity 1 makes it act like inverting the phone in turtle mode.
; Proximity 2 makes it act like a joystick button A press.

autofire0 =        0        ; Enables per-frame automatic spamming of button press. [0]
; **Not currently used.**

Currently a WIP. Stay tuned.

Bratag 2010-02-22 21:26

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Let me be the first to say - HUZZAH!

Flandry 2010-02-23 10:17

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Initial proof-of-concept package uploaded. It seems to set up the driver correctly and was tested to work with PrBoom (you need to enable the joystick in the PrBoom menu.)

The way it works right now is through a toggle, implemented as a startup script and a file called ~/accelemymote/live-trigger, that gets the daemon running. It will continue to run, consuming about 0.8% CPU cycles, until you restart or delete the trigger file.

You can delete the trigger file by clicking the app icon again. If in doubt whether it is running, you can run top and see if the process shows up.

It's probably more sensible to run it from the command line for now:
/opt/maemo/usr/bin/accelemymote.sh

Let me know if it works for you. There is a lot left to do before it's ready for mainstream, but i want to be sure the module and driver installation is working.

Edit: i tried it with uqm and it's way too spammy with events to work well there right now.

johnel 2010-02-23 10:23

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Great work all we need now is a flight simulator...or a port of Descent!

tangs 2010-02-23 14:02

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
i just tried it with prboom and it's working, so good job for this :)
But the problem is that is nearly impossible to play with it because of the settings of the accelerometer :(
Would it be possible to config accelemymote without going to ~/.accelemymote/main.cfg ? I'm really a end user and if config woul be possible from the application it would be much more friendly :)
anyway, it's just the 0.1 so we can expectgood things for the 0.2 ;)

F2thaK 2010-02-23 14:10

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
actually it installs mostlly but i get an error during install, icon is in menu........I run app, it closes and I dont see it in top

Flandry 2010-02-23 16:09

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Thanks for testing.

Quote:

Originally Posted by f2thak (Post 542681)
actually it installs mostlly but i get an error during install, icon is in menu........I run app, it closes and I dont see it in top

What kind of error did it give you?

tangs: The config file is a first step. Version 0.0.0 didn't have any options at all. ;) What is it about the accelerometer setup that you find hard to control?

Bundyo 2010-02-23 21:50

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Someone tried to port Descent 1 to OpenGL ES, couldn't get it running though.

Flandry 2010-02-23 22:36

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
I looked at Descent 1 and 2 but they suffer from the same problem as other commercial games with open engine and closed data: you can't distribute the content via the repos so it can never be end-user friendly. That was enough to discourage me from putting more time into it. It seems like the shareware version might be ok to distribute, though, so maybe there was something else to it. I really should keep notes. :p

Descent 1 in its original incarnation could certainly have run on the N900 without GLES acceleration--in fact, there was a descent port for an earlier version of maemo iirc.

So far i have one report of success and one of failure at getting this package to work. Anyone else?

Lobi_Earl 2010-02-24 01:30

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
I'm a bit scared because a friend of mine installed some joydev kernel and after rebooting phone it was totally bricked so he needed to flash it... so any more reports of some brave people in here??

Flandry 2010-02-24 01:38

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
This doesn't install a custom kernel, just a kernel module. While the chances of something bad happening aren't zero, i think you'd have to try really hard to brick an N900 by installing a tested, packaged kernel module.

Lobi_Earl 2010-02-24 01:38

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
ok ive tried now installation went well and icon got shown. Followed your instructions app closed after pressing but no accelero use in prboom for me, still default key config.

hope you'll get it working, sounds amazing

Flandry 2010-02-24 01:39

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Quote:

Originally Posted by Lobi_Earl (Post 543617)
ok ive tried now installation went well and icon got shown. Followed your instructions app losed after pressing but no accelero use in prboom for me, still default key config.

hope you'll get it working, sounds amazing

Thanks for trying.

Did you enable joystick in the prboom menu?

Lobi_Earl 2010-02-24 01:41

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Ha no thanks that was my fault gonna try again and report asap

Lobi_Earl 2010-02-24 01:47

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
ehm....cant find any enable joystick option in prboom menu..? is it in general?

Flandry 2010-02-24 02:06

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Options->General->Next->Enable Joystick

I'm especially interested in feedback from people who have played a lot of accelerometer-controlled games (say, on the iPhone...) and therefore have a good idea what is possible and insight into what could be improved for the control itself.

Lobi_Earl 2010-02-24 02:33

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
AWESOME! it works very flawless! one option to add would be to shake the phone for making a jump, like in openarena.

I also couldnt find the shoot button, does it change when applying joystick??

thanks for your work, this is bomb!


EDIT: ok shoot button found, its getting pretty late :) gorgeous

F2thaK 2010-02-24 02:41

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
for me it downloads but says "unable to install" part way thru install.........

it seems install cant overwrite joydev.ko as ive installed another kernel thats updated that file (sixaxis support)

Flandry 2010-02-24 04:04

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Yes, i was going to ask if you had installed one of the hacks going around. The joydev kernel module is available as a package now, so hopefully there won't be too many taking the hard route to installing it.

Well good, it seems this install works for stock N900s.

Quote:

Originally Posted by Lobi_Earl (Post 543655)
AWESOME! it works very flawless! one option to add would be to shake the phone for making a jump, like in openarena.

Glad to hear it. There is actually no jumping in Doom. :) I do plan on making gestures mappable, though. Unfortunately i have more plans than time. :(

Quote:

I also couldnt find the shoot button, does it change when applying joystick??
Nope. I hope to eventually make the camera button an optional joystick button.

F2thaK 2010-02-24 04:21

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
so theres a compatibility issue then with sixaxis joydev kernel?? thx

im unable to install joydev kernel thru app manager also, i get the same error :(

Flandry 2010-02-24 04:47

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
I haven't looked at the sixaxis setup in detail but from what you describe, i suspect that they are providing the same file in their package, so the package manager sees that another package would collide and refuses to let you install it. All it requires is for the sixaxis maintainer to either depend on the joydev package instead of installing the module, or to mark the package as "Provides" joydev. If his package advertises itself as providing the virtual package "joydev", the accelemymote package that depends on "joydev" will happily install and use that module. The first option is better because there are obviously cases where someone would want to uninstall the sixaxis package and not the accelemymote package, and that wouldn't be possible with the latter option.

Maybe you can point him to this post so he's aware of the problem?

Edit: of course individual users can "force" the install, which should work fine, but that's not a solution.

F2thaK 2010-02-24 05:26

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Quote:

Originally Posted by Flandry (Post 543734)
Edit: of course individual users can "force" the install, which should work fine, but that's not a solution.

are you able to elaborate how to do this?? thanks! i think i may have tried this?? apt-get -f install???

Flandry 2010-02-24 06:50

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Quote:

Originally Posted by f2thak (Post 543774)
are you able to elaborate how to do this?? thanks! i think i may have tried this?? apt-get -f install???

http://linux.die.net/man/8/apt-get

--ignore-missing might do it. I've never had to do it for a package i didn't have as a .deb file, so i use dpkg. See dpkg --force-help for more information.

F2thaK 2010-02-24 09:31

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
downloaded *.deb, did dpkg --force-all -i accelemymote.deb....... installed i think... thanks HEAPS

EDIT: okay found config file.. but I get this error when running app from xterm.

trigger file /home/user/.accelemymote/live-trigger specified; file not found... shutting down.

EDIT: dont know what i did but i ran thru menu shortcut, checked in top and it was there and works!! but in doom, if i want to config 'actions' is that possible?? i.e. make left/right strafe instead of turn??? tHANKS :D

actually im guessing thats not posible if this acts as a joystick, not keyboard

IMHO i think the name Accelemote would be much better for this app..! :D

Flandry 2010-02-24 14:08

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Quote:

Originally Posted by f2thak (Post 543959)
downloaded *.deb, did dpkg --force-all -i accelemymote.deb....... installed i think... thanks HEAPS

Probably best not to make a habit of that, which i'm sure you know. ;)

Quote:

EDIT: okay found config file.. but I get this error when running app from xterm.

trigger file /home/user/.accelemymote/live-trigger specified; file not found... shutting down.
It wasn't an error, it was simply letting you know that it didn't have any reason to live... tragic.

Seriously, though, you were probably running the binary executable instead of the script.

/opt/maemo/usr/bin/accelemymote.sh is the toggle script. Run it with an "&" at the end to start it up, and then run it again when you are done.

Quote:

EDIT: dont know what i did but i ran thru menu shortcut, checked in top and it was there and works!! but in doom, if i want to config 'actions' is that possible?? i.e. make left/right strafe instead of turn??? tHANKS :D

actually im guessing thats not posible if this acts as a joystick, not keyboard
Limited to the controls the app gives to joystick. PrBoom maps four joystick buttons to actions, so that's one way to approach it for future versions. There's also potential for keyboard mode.

Quote:

IMHO i think the name Accelemote would be much better for this app..! :D
Less of a mouthful but less shades of "maemo".

F2thaK 2010-02-24 14:15

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
i did run
/opt/maemo/usr/bin/accelemymote.sh
in xterm! ??

it works fine, just doesnt install properly for me.. keeps saying it has an update..

tangs 2010-02-24 14:20

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Quote:

Originally Posted by Flandry (Post 542878)

tangs: The config file is a first step. Version 0.0.0 didn't have any options at all. ;) What is it about the accelerometer setup that you find hard to control?

Yes, it's quiet hard to control. When you turn left or right, it's moving to fast. To move foward you need to keep the device parallel to the groud that is not confortable, it would be more easy to play if it was moving forward when the device is 45 degres from the ground, could it be possible ?

Sorry for my bad english, just trying to hell p ;)

Flandry 2010-02-24 14:44

Quote:

Originally Posted by tangs (Post 544361)
Yes, it's quiet hard to control. When you turn left or right, it's moving to fast. To move foward you need to keep the device parallel to the groud that is not confortable, it would be more easy to play if it was moving forward when the device is 45 degres from the ground, could it be possible ?

Sorry for my bad english, just trying to hell p ;)

There's a setting for that in the main.cfg file:
Quote:

offset_pitch = 20 ; degrees tilt backwards to the neutral position
I realize that's not user friendly yet, but you would set it to "45" in your case.

As for the speed of side movement... are you saying it should actually go slower than when you push "left" and "right" on the keyboard?

I guess what you're asking is analog control. Right now it only works as a "hat" (up/down/left/right) rather than an analog stick, so that might be fixed when i finish the analog profile... if prboom supports that.

Quote:

Originally Posted by f2thak (Post 544354)
i did run
/opt/maemo/usr/bin/accelemymote.sh
in xterm! ??

it works fine, just doesnt install properly for me.. keeps saying it has an update..

An update? oO It's a simple script... you run it once, it starts the daemon and creates the live-trigger; you run it again, it deletes the live-trigger, shutting down the daemon. Run it with an "&" at the end so it doesn't block.

tangs 2010-02-24 14:54

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Ok, i'll try to change it to 45.
where do i find the .accelemymote/main.cfg please ?

Flandry 2010-02-24 15:41

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Quote:

Originally Posted by tangs (Post 544419)
Ok, i'll try to change it to 45.
where do i find the .accelemymote/main.cfg please ?

It would be easier in your case to use sed. Copy and paste this line into xterm:
sed -i 's/\(offset_pitch *= *\)[0-9]*\(.*\)/\145\2/' ~/.accelemymote/main.cfg
Change the part that says 45 to something like 30 if it ends up being too much.

tangs 2010-02-24 19:35

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
so i sudo gainrooted, copyed your line but nothing happened... i tried the game and this is still the same :(
I asked where i can find .accelemymote/main.cfg because like this i could maybe also change the speed of how it's turn right and left.

trying to do it, trying to do it :)

Flandry 2010-02-24 20:18

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Quote:

Originally Posted by tangs (Post 544799)
so i sudo gainrooted, copyed your line but nothing happened... i tried the game and this is still the same :(
I asked where i can find .accelemymote/main.cfg because like this i could maybe also change the speed of how it's turn right and left.

trying to do it, trying to do it :)

Don't be sudo gainrooting on a whim: it's asking for trouble. For example, you've now made the config file belong to root, so that the app can't alter it. Sudo gainroot and type:
chown user ~/.accelemymote/main.cfg
and then type exit and don't sudo again unless you know why you are doing it. :D

The tilde (~) represents your home directory to the shell, so ~/.accelemymote/main.cfg is the full location of the file. It's in your home directory under a hidden subdirectory (begins with '.') called .accelemymote.

You are right though that it doesn't do anything (besides change the value in the config file). Apparently it's not using that option properly yet. Next version... ;)

You can try changing the poll_rate parameter in the file to something lower, but in Doom you are either moving, running, or not moving. I'm not sure there is a "slower". If there is, it will be via analog joystick support which is not implemented yet.

tangs 2010-02-25 14:25

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
"Sudo gainroot and type:
chown user ~/.accelemymote/main.cfg
and then type exit "
I did it, nothing happened after this, i suppose this is the way it should be ?

As you see, i'm ready to risk my life to try it ;)

Bratag 2010-02-25 15:25

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Quote:

Originally Posted by tangs (Post 545875)
"Sudo gainroot and type:
chown user ~/.accelemymote/main.cfg
and then type exit "
I did it, nothing happened after this, i suppose this is the way it should be ?

As you see, i'm ready to risk my life to try it ;)

All that does is reset the permissions on the config file. It wouldn't actually "do" anything after running the command (IE no output if successful). This is why kiddies shouldn't play with root in the first place :)

LordNelson 2010-03-01 18:13

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Nice, that's what I was searching for, already wanted to write it myself :D

But the offset_pitch doesn't seem to work here... Changed it to 35, 60, even 350, and the zero position is always nearly horizontal (about 5-10 degrees maybe). Is this a bug or am I just too stupid? :P

Descent is running pretty good with it though (Ignoring the fact that I have to play it in strange positions because the offset_pitch isn't recognized :D). But it got some framerate-problems with the software-renderer, especially in the energy-charging areas. There seems to be a OpenGL ES port in work, but it's not complete and the source isn't released to the public up to now so I couldn't try it out yet :/

Flandry 2010-03-01 19:19

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Quote:

Originally Posted by LordNelson (Post 551348)
Nice, that's what I was searching for, already wanted to write it myself :D

But the offset_pitch doesn't seem to work here... Changed it to 35, 60, even 350, and the zero position is always nearly horizontal (about 5-10 degrees maybe). Is this a bug or am I just too stupid? :P

Thanks for trying it out. And yeah, as i noted a few posts back, offset seems to not work as intended. I threw it in at the last minute before the first release because i was running out of time. It will be fixed next release.

LordNelson 2010-03-01 19:48

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Quote:

Originally Posted by Flandry (Post 551446)
Thanks for trying it out. And yeah, as i noted a few posts back, offset seems to not work as intended. I threw it in at the last minute before the first release because i was running out of time. It will be fixed next release.

Okay, will wait for the next release then.
Beside this bug it's really a great application, thanks a lot for it :)

Flandry 2010-03-02 07:00

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
Version 0.0.2 just went through the autobuilder and should be available momentarily.

Changelog:
accelemymote (0.0.2) unstable; urgency=low

* Fixed ini config file parser (offset_pitch now works).
* Abstracted polling for a frame into a function (enables samples option).

-- Flandry <davidfalkayn@gmail.cmo> Mon, 1 Mar 2010 16:52:17 -0500

Valid options (~/.accelemymote/main.cfg):
[Sampling]
samples = 2 ; Samples to average for each frame (1-5) [2]
frame_rate = 24 ; Number of event-generating timesteps per second (1-30)[24]
[Control]
flip_pitch = -1 ; -1=> tilt forward is up; 1=> tilt forward is down [-1]
offset_pitch = 30 ; degrees tilt backwards to the neutral position [30]
max_roll = 9 ; degrees plus/minus from neutral to max out the axis [9]
max_pitch = 7 ; degrees plus/minus from neutral to max out the axis [7]


It will clobber your existing main.cfg file. Just FYI.

Edit: Works pretty well with PrBoom with default settings. Still too spammy for uqm. Gauntlet is "interesting" but not really enjoyable; Rampage middling; someone with mad Centipede skills might find that entertaining (really, really fast movement...:D ); Joust is not too bad; ghosts 'n goblins has a weird ladder climbing issue. Some tweaks to config might make a big difference for some of these.

F2thaK 2010-03-02 09:25

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
1 Attachment(s)
just so you know this app is compatible with sixaxis daemon!


i have made an app icon, if you like it.....feel free to use it.

EDIT: updated icon

http://f2thak.com/N900/Screenshot-20100302-213239.png

Flandry 2010-03-02 21:10

Re: [Maemo 5] Accelemymote: making your accelerometer more joy-ful
 
PrBoom turns out to be a really bad test case. While it actually needs redundant joystick events to be spammed to work properly, most apps don't really appreciate that.

Version 0.0.3 brings better defaults for everything (except prboom). To use it with prboom, edit the main.cfg and reduce the maximum pitch and roll to around 8 and the thresholds to 0. Alternatively, edit and copy the file to prboom.cfg and pass that as the only parameter to the accelemymote binary. I.e.
/opt/maemo/usr/bin/accelemymote ~/.accelemymote/prboom.cfg

accelemymote (0.0.3) unstable; urgency=low

* Enabled threshold angle change between events (fixes many control issues).
* Better universal default settings (PrBoom has special needs).


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

vBulletin® Version 3.8.8