Another day, another Android question.
Is there functionality in place (or easily implemented) to listen for Android events? I know the Android "Back" button is bound to the Orx KEY_ESCAPE input (well, "know"...I mean I've tried it and it works); are there any others, for instance the Menu button or volume rocker/buttons?
More generally, I was going to look through the Orx SVN code myself, and see if I could find where the "Back"->KEY_ESCAPE mapping took place, and extrapolate from there; but I realised I had no idea where in the SVN folders that might be. trunk/code/include and trunk/code/src are for the vanilla Orx library; where are the Android-specific implementations?
Thanks for any clarification!
You're completly right. Orx manage his different plateform using plugins, so you can find all of them under code/plugins/. And you give us the good path for the android keyboard.
Now, as I said, the android port used an external library, made by NVidia. This external library is in externNvEvent.
I just search NV_KEYCODE_MENU in this folder, and I found the place where this is used, and as I can see, the volume isn't managed actually by the NVEvent part. I found on the android developper website that sound event can be managed by KEYCODE_VOLUME_DOWN/UP.
But, you can add this to nvevent/orx, exactly like other event. It's something like doing some copy/replace/paste.
The actual version of the NVEvent isn't the orginal. I made some change inside for multitouch purpose, and lydesik too I think.
If you want to add some support for this event, I suggest you to modify the nvevent framework, modify the android part under code/plugins/, compile the nvevent library (I think you have to do a "make" in the extern/nvevent/build/ folder), compile orx (run make in the code/build/android folder or something like that) and commit your change when it's working.
If you aren't be able to do that, maybe Iarwain can give you access on the svn ? And if you don't know what I said, I can do that for you, but you will have to wait, I don't really have the time actually ... Maybe next week, don't know.
It's ok ?
Only issues now:
- Since Orx doesn't have explicit "Volume Up/Down" keyboard inputs of its own, I've mapped them to Page Up/Down for the time being. Strikes me as a bit of a hack though, so I don't want to commit the change before discussing with you folks.
- With those keybindings, I can receive volume up/down events just fine. When I get volume up, for instance, I just call orxSoundSystem_SetGlobalVolume() to increment the volume, and vice versa. Only thing is, I'm not sure what values to use: is 0.0f mute and 1.0f full volume, for instance? Or is the range something other than that?
Thanks for the help!
And yes, 0.0 is mute, 1.0 is the actual volume of the sample/stream, and anything above will be louder but is also more likely to produce saturated results.
in general on Android, it's a bad idea to trap volume up/down event...
you should let android handle it by itself.
So the question is why are you doing that, or why do you need to call orxSoundSystem_SetGlobalVolume()?
In my game, i'm not binding vol+/vol- in orx, still using thoses key while the game is running change the volume of the music and the SFX...
I'm about to put my game on the Android Market, so I'd sent copies out to a few of my friends with Android devices. All of them seem to have it running okay, except one guy. He has a few recurring and bizarre bugs that keep cropping up, and I have no idea why. Like, they fall into the realm of "this is technically impossible, but it's happening anyway": game states transitioning when there is literally no actual call to do so, and so on. Weird stuff.
Anyway, he was also asking why my game is so loud, and actually playing it on his phone, I can see he's right...it's intense! And his volume rocker doesn't seem to work while he's playing the game.
He does have a jailbroken phone with a few other mods installed besides. I'm sort of hoping that's the issue. In any case, don't worry about the volume controls; I'll leave things as-is and let the device do the modifications.
I found this site, where a solution is offered. In the game's Java Activity, import the Android audio manager:
...and then call the following in your overridden onCreate() function:
This will ensure that using the volume rocker will apply to Media Volume (which includes all audio coming from your game. You can also call the following in onDestroy() to return to the default audio setting:
Should this be called by default in orx's java activity then?
But I imagine it may clear up some problems for other coders in the future.
Shamefully I have yet to try the Android version myself.
will look at this when i can find some free time
Until now, orxSoundSystem_SetGlobalVolume() (and Get) for android was not implemented.
It's done now in the actual svn version.
This global volume is apply on the sound at the last time, when the volume is passed to the Java part.
This function doesn't set the phone's volume, it's apply to the orxSOUND object. So when orxSoundSystem_SetGlobalVolume is set to 1.0, sounds are played at the phone's volume.
I use this function to create a "mute" button.
Since few day, there's 2 new types of fx : volume and pitch. So you can easily create some fade in / fade out effect for example.
Hope this can help !
A small question though, just to be sure the Android plugin is behaving like all others: when you set a global volume, does it override the local sound volume or is it used as a multiplier?
The way it's supposed to work is that global volume is actually a multiplier, hence if SoundA.Volume = 0.5 and SoundB.Volume = 1.0, when having a GlobalVolume of 0.5, it's equivalent of having SoundA.Volume = 0.25 and SoundB.Volume = 0.5.
If it already behaves that way it's great, otherwise do you think you could change it for consistency sake?
For the 2 fx types, you're welcome ^^ It was not really hard to do, just a bunch of copy/paste tricks
For the global volume, actually behaviour is exactly whats you said in your example, so it's perfect