Author Topic: G-sensor  (Read 3673 times)

Nostalgix (OP)

  • Posts: 8
G-sensor
« on: October 29, 2014, 10:36:41 am »
Hello!

Since the accelerometer (G-sensor) should be available with the latest firmware I tried to use it.
As much as I know it should be listed as another joystick device: SDL_NumJoysticks() on GCW should read 2, but it still reads 1.

In the "firmware updates" page it is written:

G-sensor:
A driver was added that makes the g-sensor in the Zero available as a joystick. Applications that want to use this should set X-OD-NeedsGSensor=true in their OPK metadata.


But as Surkow stated here:

http://wiki.surkow.com/OPK

A minimal metadata file should contain the following fields:

 [Desktop Entry]
 
 Type=Application
 Name=Cool Game
 Comment=A super good game
 Exec=coolgame
 Icon=icon
 Categories=games;


...Only the fields listed above are supported by OpenDingux's menu,


So the line "X-OD-NeedsGSensor=true" seems not to be supported?

 
For beginners there is a really helpful SDL tutorial by Surkow about how to use the SDL library.

http://wiki.surkow.com/Tutorials:SDL


It would be great if Surkow could add the accelerometer (and the rumble motor as well?) as further examples in the SDL tutorial page.


Or maybe it is too soon (as Surkow said):
http://wiki.surkow.com/Quick_Start_Guide

Hardware Features Not Yet Supported : G-Sensor (accelerometer)    Implemented, bug fixes required.


Any suggestions??

zear

  • * Moderator
  • Posts: 2381
Re: G-sensor
« Reply #1 on: October 29, 2014, 11:27:32 am »
Since the accelerometer (G-sensor) should be available with the latest firmware I tried to use it.
As much as I know it should be listed as another joystick device: SDL_NumJoysticks() on GCW should read 2, but it still reads 1.
That's because you're missing this parameter in your OPK's .desktop file:
Code: [Select]
X-OD-NeedsGSensor=true
Quote
A minimal metadata file should contain the following fields:
(...)

So the line "X-OD-NeedsGSensor=true" seems not to be supported?
The key here is "minimal". Meaning that all these mentioned fields are mandatory and must be present in the .desktop file for GCW Zero to properly load it.
The other fields, like your X-OD-NeedsGSensor=true are optional and should be set by the OPK creator if the game is going to make use of the feature (in your case the g-sensor).

Quote
It would be great if Surkow could add the accelerometer (and the rumble motor as well?) as further examples in the SDL tutorial page.
Rumble isn't supported by SDL 1.2. Only SDL 2.0 has support for rumble devices. Note that this is a limitation of the library and not of GCW Zero. If you want to add rumble support to a non-SDL 2.0 program, you'll need to implement it yourself, by using Linux's Force Feedback: https://www.kernel.org/doc/Documentation/input/ff.txt
Additionally the current firmware has a bug in the rumble driver that makes it vibrate past the effect's run time. I have already provided a patch for this behaviour, but it has not been merged to the driver yet.

PS. The wiki is hosted in surkow.com comain, but it doesn't mean Surkow is the author of all the articles you mentioned. In fact, the SDL 1.2 tutorial was written by me and the OPK documentation by pcercuei ;)

Nostalgix (OP)

  • Posts: 8
Re: G-sensor
« Reply #2 on: November 02, 2014, 08:20:07 am »
Thanks Zear for your reply.

In the meantime I tried to investigate further. As already told I have made a small SDL application that reads SDL_NumJoysticks() and outputs the value on the console.

I can see in the GCWs "Log Viewer" that it reads nothing but 1, no matter if I add the line "X-OD-NeedsGSensor=true" to the end of the OPK meta data. The OPK file seems to be parsed correctly because I can see the changes I do for the meta file entry "Comment=..." in the gcw menu.

My kernel Version: 3.12.0-dingux+


It is a little bit annoying to be forced to create the OPK file to test, if the application together with the G-Sensor is working (I normally start tests remotely from the shell after the build so I can see at once any debug outputs on the shell). Is there a shell command to enable the G-Sensor so the OPK file is no longer needed for a more straight forward development?

It seems to me as if the G-Sensor is not implemented in the "HWTest" app on the GCW (at least I cannot see any reactions when turning the GCW0). Will it be added so I can be sure it is working in principle?

pcercuei

  • Posts: 1673
    • My devblog
Re: G-sensor
« Reply #3 on: November 02, 2014, 11:37:56 am »
There is the "gsensor" tool in the rootfs. gsensor --status should tell you if it's running or not. If it's not, double-check that you have the latest firmware installed.

Nostalgix (OP)

  • Posts: 8
Re: G-sensor
« Reply #4 on: November 03, 2014, 04:08:22 pm »
Correct firmware, correct behavior!  :-[

It works, thanks!

Nostalgix (OP)

  • Posts: 8
Re: G-sensor
« Reply #5 on: November 13, 2014, 07:43:54 pm »
G-sensor again...

I have done some simple testing using the sensor. Now that I am about to write some more "serious" software (i.e. a game  ;) ) I would like to know if there is another way to activate the g-sensor than by adding this special line in the meta data of the OPK file. At the moment it seems to me that each time I want to test I have to create the OPK file first.

To avoid this is it possible by some kind of command from the shell after login to the GCW to activate the sensor and keep it activated so I can run my program in the GCW terminal mode?

pcercuei

  • Posts: 1673
    • My devblog
Re: G-sensor
« Reply #6 on: November 13, 2014, 07:56:53 pm »
Code: [Select]
gsensor --startIt will be stopped each time gmenu2x respawns.

TimmyTopHat

  • Posts: 7
Re: G-sensor
« Reply #7 on: January 14, 2015, 06:25:16 am »
Additionally, you could add the following to your makefile to create the OPK automagically:
Code: [Select]
@chmod +x [Name of Binary]
@rm -f [Name of OPK]
mksquashfs (Files) -all-root -noappend -no-export -no-xattrs

 

Post a new topic