Accelerometer in OpenFL/Lime Next

Is the accelerometer implemented yet in the current version of Lime / OpenFL? If so how do I get to it?

by the looks of it, SDL2 appears to use the accelerometer as a joystick. I wonder if it registers under the gamepad API or not. It’s possible that it’s appearing as a gamepad axis right now. It would be worth someone checking if this is the case (in which case we should just redirect them to dispatch as new accelerometer events) or if we need to do something else

Has anyone looked into this yet? I’ve just tried overriding onGamepadAxisMove in my Lime Application but the accelerometer doesn’t seem to be registering anything…

I’ve just had a quick look and it seems that SDL registers the events as Joystick events which are currently being ignored by Lime in favour of Controller events. I’m not sure I like the joystick interface as it could easily get confusing if mixed with actual joysticks (in the rare test case that will eventually happen ;)).

I’m going to look into adding Accelerometer support into my project as a native extension.

Yeah, we’re going to have to try and track the accelerometer differently. We don’t want it to appear as a gamepad, we want it to register as an accelerometer on a Lime level

Any idea if the Accelerometer code is implemented yet? I want to detect if the user tilts/moves the device around in different rotations.

Couldn’t make the accelerometer to work with latest version of openfl (3.3.3) and lime (2.6.2). So I guess no. It is not implemented yet :frowning:

Argh, that sucks. I would’ve thought it would be sorted out by now. Did you test on Android or iOS?

But I doubt it would be implemented for iOS yet.
For now, if you want to use the accolerometer it looks like you have to stick with openfl legacy

Oh, I am currently using OpenFL legacy (because of issues with Away3D that i’m experiencing) so it should work right? I haven’t attempted to use it yet.

<set name="openfl-legacy" /> <–

well yes. If you use openfl legacy, sure, the accelerometer is fully supported.

I added it to Lime just tonight, support in OpenFL will come tomorrow

1 Like

Done :smile:

Nice one!!!

Next question … How easy is it to add other common sensors :slight_smile:

I think that SDL2 starts and ends at accelerometer. I think we’ll need to go custom Java/Objective-C to get the rest, but if we kept it to a minimum it shouldn’t be a big deal, although we may need to work out a permissions model, so we don’t ask for compass permission for every Lime project released? (that sort of thing)