diff options
Diffstat (limited to 'platform/bb10')
| -rw-r--r-- | platform/bb10/audio_driver_bb10.cpp | 37 | ||||
| -rw-r--r-- | platform/bb10/audio_driver_bb10.h | 20 | ||||
| -rw-r--r-- | platform/bb10/export/export.cpp | 12 | ||||
| -rw-r--r-- | platform/bb10/godot_bb10.cpp | 7 | ||||
| -rw-r--r-- | platform/bb10/os_bb10.cpp | 301 | ||||
| -rw-r--r-- | platform/bb10/os_bb10.h | 47 | ||||
| -rw-r--r-- | platform/bb10/payment_service.cpp | 36 | ||||
| -rw-r--r-- | platform/bb10/payment_service.h | 8 | ||||
| -rw-r--r-- | platform/bb10/power_bb10.cpp | 15 | ||||
| -rw-r--r-- | platform/bb10/power_bb10.h | 1 |
10 files changed, 224 insertions, 260 deletions
diff --git a/platform/bb10/audio_driver_bb10.cpp b/platform/bb10/audio_driver_bb10.cpp index b6ea0bc26..5416fc5f0 100644 --- a/platform/bb10/audio_driver_bb10.cpp +++ b/platform/bb10/audio_driver_bb10.cpp @@ -34,11 +34,11 @@ Error AudioDriverBB10::init() { return init(NULL); }; -Error AudioDriverBB10::init(const char* p_name) { +Error AudioDriverBB10::init(const char *p_name) { - active=false; - thread_exited=false; - exit_thread=false; + active = false; + thread_exited = false; + exit_thread = false; pcm_open = false; samples_in = NULL; samples_out = NULL; @@ -46,11 +46,11 @@ Error AudioDriverBB10::init(const char* p_name) { mix_rate = 44100; speaker_mode = SPEAKER_MODE_STEREO; - char* dev_name; + char *dev_name; if (p_name == NULL) { dev_name = "pcmPreferred"; } else { - dev_name = (char *) p_name; + dev_name = (char *)p_name; } printf("******** reconnecting to device %s\n", dev_name); int ret = snd_pcm_open_name(&pcm_handle, dev_name, SND_PCM_OPEN_PLAYBACK); @@ -58,7 +58,7 @@ Error AudioDriverBB10::init(const char* p_name) { pcm_open = true; snd_pcm_channel_info_t cinfo; - zeromem(&cinfo, sizeof (cinfo)); + zeromem(&cinfo, sizeof(cinfo)); cinfo.channel = SND_PCM_CHANNEL_PLAYBACK; snd_pcm_plugin_info(pcm_handle, &cinfo); @@ -117,9 +117,9 @@ Error AudioDriverBB10::init(const char* p_name) { return OK; }; -void AudioDriverBB10::thread_func(void* p_udata) { +void AudioDriverBB10::thread_func(void *p_udata) { - AudioDriverBB10* ad = (AudioDriverBB10*)p_udata; + AudioDriverBB10 *ad = (AudioDriverBB10 *)p_udata; int channels = speaker_mode; int frame_count = ad->sample_buf_count / channels; @@ -127,10 +127,9 @@ void AudioDriverBB10::thread_func(void* p_udata) { while (!ad->exit_thread) { - if (!ad->active) { - for (int i=0; i < ad->sample_buf_count; i++) { + for (int i = 0; i < ad->sample_buf_count; i++) { ad->samples_out[i] = 0; }; @@ -142,20 +141,19 @@ void AudioDriverBB10::thread_func(void* p_udata) { ad->unlock(); - for(int i=0;i<frame_count*channels;i++) { + for (int i = 0; i < frame_count * channels; i++) { - ad->samples_out[i]=ad->samples_in[i]>>16; + ad->samples_out[i] = ad->samples_in[i] >> 16; } }; - int todo = bytes_out; int total = 0; while (todo) { - uint8_t* src = (uint8_t*)ad->samples_out; - int wrote = snd_pcm_plugin_write(ad->pcm_handle, (void*)(src + total), todo); + uint8_t *src = (uint8_t *)ad->samples_out; + int wrote = snd_pcm_plugin_write(ad->pcm_handle, (void *)(src + total), todo); if (wrote < 0) { // error? break; @@ -179,7 +177,7 @@ void AudioDriverBB10::thread_func(void* p_udata) { break; }; if (status.status == SND_PCM_STATUS_READY || - status.status == SND_PCM_STATUS_UNDERRUN) { + status.status == SND_PCM_STATUS_UNDERRUN) { snd_pcm_plugin_prepare(ad->pcm_handle, SND_PCM_CHANNEL_PLAYBACK); } else { break; @@ -188,9 +186,9 @@ void AudioDriverBB10::thread_func(void* p_udata) { }; }; - snd_pcm_plugin_flush (ad->pcm_handle, SND_PCM_CHANNEL_PLAYBACK); + snd_pcm_plugin_flush(ad->pcm_handle, SND_PCM_CHANNEL_PLAYBACK); - ad->thread_exited=true; + ad->thread_exited = true; printf("**************** audio thread exit\n"); }; @@ -253,4 +251,3 @@ AudioDriverBB10::~AudioDriverBB10() { memdelete(mutex); mutex = NULL; }; - diff --git a/platform/bb10/audio_driver_bb10.h b/platform/bb10/audio_driver_bb10.h index efb98b1b9..2a0ed9c54 100644 --- a/platform/bb10/audio_driver_bb10.h +++ b/platform/bb10/audio_driver_bb10.h @@ -28,23 +28,23 @@ /*************************************************************************/ #include "servers/audio_server.h" -#include "core/os/thread.h" #include "core/os/mutex.h" +#include "core/os/thread.h" #include <sys/asoundlib.h> class AudioDriverBB10 : public AudioDriver { - Thread* thread; - Mutex* mutex; + Thread *thread; + Mutex *mutex; - snd_pcm_t* pcm_handle; + snd_pcm_t *pcm_handle; - int32_t* samples_in; - int16_t* samples_out; + int32_t *samples_in; + int16_t *samples_out; int sample_buf_count; - static void thread_func(void* p_udata); + static void thread_func(void *p_udata); int mix_rate; SpeakerMode speaker_mode; @@ -58,13 +58,12 @@ class AudioDriverBB10 : public AudioDriver { bool pcm_open; public: - - const char* get_name() const { + const char *get_name() const { return "BB10"; }; virtual Error init(); - virtual Error init(const char* p_name); + virtual Error init(const char *p_name); virtual void start(); virtual int get_mix_rate() const; virtual SpeakerMode get_speaker_mode() const; @@ -75,4 +74,3 @@ public: AudioDriverBB10(); ~AudioDriverBB10(); }; - diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp index cf8e2fcc0..c958bf7ff 100644 --- a/platform/bb10/export/export.cpp +++ b/platform/bb10/export/export.cpp @@ -26,18 +26,18 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "export.h" -#include "editor/editor_settings.h" #include "editor/editor_export.h" #include "editor/editor_node.h" -#include "io/zip_io.h" -#include "io/marshalls.h" +#include "editor/editor_settings.h" #include "global_config.h" +#include "io/marshalls.h" +#include "io/xml_parser.h" +#include "io/zip_io.h" #include "os/file_access.h" #include "os/os.h" #include "platform/bb10/logo.h" -#include "io/xml_parser.h" +#include "version.h" #define MAX_DEVICES 5 #if 0 @@ -826,5 +826,3 @@ void register_bb10_exporter() { #endif } - - diff --git a/platform/bb10/godot_bb10.cpp b/platform/bb10/godot_bb10.cpp index 4b8270b49..e1826450a 100644 --- a/platform/bb10/godot_bb10.cpp +++ b/platform/bb10/godot_bb10.cpp @@ -31,12 +31,12 @@ #include <unistd.h> -int main(int argc, char* argv[]) { +int main(int argc, char *argv[]) { OSBB10 os; - Error err = Main::setup(argv[0],argc-1,&argv[1]); - if (err!=OK) + Error err = Main::setup(argv[0], argc - 1, &argv[1]); + if (err != OK) return 255; if (Main::start()) @@ -45,4 +45,3 @@ int main(int argc, char* argv[]) { return os.get_exit_code(); } - diff --git a/platform/bb10/os_bb10.cpp b/platform/bb10/os_bb10.cpp index bf7bfb690..80e846d3c 100644 --- a/platform/bb10/os_bb10.cpp +++ b/platform/bb10/os_bb10.cpp @@ -28,37 +28,37 @@ /*************************************************************************/ #include "os_bb10.h" -#include "drivers/gles2/rasterizer_gles2.h" -#include "servers/visual/visual_server_raster.h" -#include "core/os/dir_access.h" -#include "core/global_config.h" -#include "main/main.h" #include "bbutil.h" +#include "core/global_config.h" +#include "core/os/dir_access.h" #include "core/os/keyboard.h" +#include "drivers/gles2/rasterizer_gles2.h" +#include "main/main.h" +#include "servers/visual/visual_server_raster.h" -#include <stdlib.h> -#include <stdbool.h> #include <assert.h> +#include <bps/accelerometer.h> +#include <bps/audiodevice.h> #include <bps/bps.h> -#include <bps/screen.h> #include <bps/navigator.h> -#include <bps/accelerometer.h> #include <bps/orientation.h> +#include <bps/screen.h> #include <bps/virtualkeyboard.h> -#include <bps/audiodevice.h> +#include <stdbool.h> +#include <stdlib.h> #ifdef BB10_SCORELOOP_ENABLED #include "modules/scoreloop/scoreloop_bb10.h" #endif static char launch_dir[512]; -char* launch_dir_ptr; +char *launch_dir_ptr; int OSBB10::get_video_driver_count() const { return 1; } -const char * OSBB10::get_video_driver_name(int p_driver) const { +const char *OSBB10::get_video_driver_name(int p_driver) const { return "GLES2"; } @@ -72,26 +72,26 @@ int OSBB10::get_audio_driver_count() const { return 1; } -const char * OSBB10::get_audio_driver_name(int p_driver) const { +const char *OSBB10::get_audio_driver_name(int p_driver) const { return "BB10"; } -void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) { +void OSBB10::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { data_dir = getenv("HOME"); //Create a screen context that will be used to create an EGL surface to to receive libscreen events - screen_create_context(&screen_cxt,0); + screen_create_context(&screen_cxt, 0); //Initialize BPS library bps_initialize(); //Use utility code to initialize EGL for 2D rendering with GL ES 1.1 enum RENDERING_API api = GL_ES_2; - #ifdef BB10_LGLES_OVERRIDE +#ifdef BB10_LGLES_OVERRIDE api = GL_ES_1; - #endif +#endif if (EXIT_SUCCESS != bbutil_init(screen_cxt, api)) { bbutil_terminate(); screen_destroy_context(screen_cxt); @@ -116,9 +116,9 @@ void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi virtualkeyboard_request_events(0); audiodevice_request_events(0); - #ifdef DEBUG_ENABLED +#ifdef DEBUG_ENABLED bps_set_verbosity(3); - #endif +#endif accel_supported = accelerometer_is_supported(); if (accel_supported) @@ -126,13 +126,13 @@ void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi pitch = 0; roll = 0; - #ifdef BB10_LGLES_OVERRIDE - rasterizer = memnew( RasterizerGLES1(false) ); - #else - rasterizer = memnew( RasterizerGLES2(false, false) ); - #endif +#ifdef BB10_LGLES_OVERRIDE + rasterizer = memnew(RasterizerGLES1(false)); +#else + rasterizer = memnew(RasterizerGLES2(false, false)); +#endif - visual_server = memnew( VisualServerRaster(rasterizer) ); + visual_server = memnew(VisualServerRaster(rasterizer)); visual_server->init(); visual_server->cursor_set_visible(false, 0); @@ -140,39 +140,38 @@ void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi audio_driver->set_singleton(); audio_driver->init(NULL); - physics_server = memnew( PhysicsServerSW ); + physics_server = memnew(PhysicsServerSW); physics_server->init(); - physics_2d_server = memnew( Physics2DServerSW ); + physics_2d_server = memnew(Physics2DServerSW); physics_2d_server->init(); - input = memnew( InputDefault ); - - power_manager = memnew( PowerBB10 ); + input = memnew(InputDefault); + + power_manager = memnew(PowerBB10); - #ifdef PAYMENT_SERVICE_ENABLED +#ifdef PAYMENT_SERVICE_ENABLED payment_service = memnew(PaymentService); Globals::get_singleton()->add_singleton(Globals::Singleton("InAppStore", payment_service)); - #endif - +#endif } -void OSBB10::set_main_loop( MainLoop * p_main_loop ) { +void OSBB10::set_main_loop(MainLoop *p_main_loop) { input->set_main_loop(p_main_loop); - main_loop=p_main_loop; + main_loop = p_main_loop; } void OSBB10::delete_main_loop() { - memdelete( main_loop ); + memdelete(main_loop); main_loop = NULL; } void OSBB10::finalize() { - if(main_loop) + if (main_loop) memdelete(main_loop); - main_loop=NULL; + main_loop = NULL; /* if (debugger_connection_console) { @@ -190,9 +189,9 @@ void OSBB10::finalize() { physics_2d_server->finish(); memdelete(physics_2d_server); - #ifdef PAYMENT_SERVICE_ENABLED +#ifdef PAYMENT_SERVICE_ENABLED memdelete(payment_service); - #endif +#endif memdelete(input); @@ -225,16 +224,14 @@ int OSBB10::get_mouse_button_state() const { return 0; } -void OSBB10::set_window_title(const String& p_title) { - - +void OSBB10::set_window_title(const String &p_title) { } //interesting byt not yet //void set_clipboard(const String& p_text); //String get_clipboard() const; -void OSBB10::set_video_mode(const VideoMode& p_video_mode,int p_screen) { +void OSBB10::set_video_mode(const VideoMode &p_video_mode, int p_screen) { default_videomode = p_video_mode; } @@ -243,7 +240,7 @@ OS::VideoMode OSBB10::get_video_mode(int p_screen) const { return default_videomode; } -void OSBB10::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { +void OSBB10::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const { p_list->push_back(default_videomode); } @@ -278,128 +275,125 @@ void OSBB10::handle_screen_event(bps_event_t *event) { int pos[2]; switch (screen_val) { - case SCREEN_EVENT_MTOUCH_TOUCH: - case SCREEN_EVENT_MTOUCH_RELEASE: { + case SCREEN_EVENT_MTOUCH_TOUCH: + case SCREEN_EVENT_MTOUCH_RELEASE: { - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_POSITION, pos); + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_POSITION, pos); - InputEvent ievent; - ievent.type = InputEvent::SCREEN_TOUCH; - ievent.ID = ++last_id; - ievent.device = 0; - ievent.screen_touch.pressed = (screen_val == SCREEN_EVENT_MTOUCH_TOUCH); - ievent.screen_touch.x = pos[0]; - ievent.screen_touch.y = pos[1]; - Point2 mpos(ievent.screen_touch.x, ievent.screen_touch.y); - - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TOUCH_ID, &pos[0]); - ievent.screen_touch.index = pos[0]; + InputEvent ievent; + ievent.type = InputEvent::SCREEN_TOUCH; + ievent.ID = ++last_id; + ievent.device = 0; + ievent.screen_touch.pressed = (screen_val == SCREEN_EVENT_MTOUCH_TOUCH); + ievent.screen_touch.x = pos[0]; + ievent.screen_touch.y = pos[1]; + Point2 mpos(ievent.screen_touch.x, ievent.screen_touch.y); - last_touch_x[pos[0]] = ievent.screen_touch.x; - last_touch_y[pos[0]] = ievent.screen_touch.y; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TOUCH_ID, &pos[0]); + ievent.screen_touch.index = pos[0]; - input->parse_input_event( ievent ); + last_touch_x[pos[0]] = ievent.screen_touch.x; + last_touch_y[pos[0]] = ievent.screen_touch.y; - if (ievent.screen_touch.index == 0) { + input->parse_input_event(ievent); - InputEvent ievent; - ievent.type = InputEvent::MOUSE_BUTTON; - ievent.ID = ++last_id; - ievent.device = 0; - ievent.mouse_button.pressed = (screen_val == SCREEN_EVENT_MTOUCH_TOUCH); - ievent.mouse_button.button_index = BUTTON_LEFT; - ievent.mouse_button.doubleclick = 0; - ievent.mouse_button.x = ievent.mouse_button.global_x = mpos.x; - ievent.mouse_button.y = ievent.mouse_button.global_y = mpos.y; - input->parse_input_event( ievent ); - }; + if (ievent.screen_touch.index == 0) { + InputEvent ievent; + ievent.type = InputEvent::MOUSE_BUTTON; + ievent.ID = ++last_id; + ievent.device = 0; + ievent.mouse_button.pressed = (screen_val == SCREEN_EVENT_MTOUCH_TOUCH); + ievent.mouse_button.button_index = BUTTON_LEFT; + ievent.mouse_button.doubleclick = 0; + ievent.mouse_button.x = ievent.mouse_button.global_x = mpos.x; + ievent.mouse_button.y = ievent.mouse_button.global_y = mpos.y; + input->parse_input_event(ievent); + }; - } break; - case SCREEN_EVENT_MTOUCH_MOVE: { + } break; + case SCREEN_EVENT_MTOUCH_MOVE: { - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_POSITION, pos); + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_POSITION, pos); - InputEvent ievent; - ievent.type = InputEvent::SCREEN_DRAG; - ievent.ID = ++last_id; - ievent.device = 0; - ievent.screen_drag.x = pos[0]; - ievent.screen_drag.y = pos[1]; + InputEvent ievent; + ievent.type = InputEvent::SCREEN_DRAG; + ievent.ID = ++last_id; + ievent.device = 0; + ievent.screen_drag.x = pos[0]; + ievent.screen_drag.y = pos[1]; - /* + /* screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_SOURCE_POSITION, pos); ievent.screen_drag.relative_x = ievent.screen_drag.x - pos[0]; ievent.screen_drag.relative_y = ievent.screen_drag.y - pos[1]; */ - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TOUCH_ID, &pos[0]); - ievent.screen_drag.index = pos[0]; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TOUCH_ID, &pos[0]); + ievent.screen_drag.index = pos[0]; + ievent.screen_drag.relative_x = ievent.screen_drag.x - last_touch_x[ievent.screen_drag.index]; + ievent.screen_drag.relative_y = ievent.screen_drag.y - last_touch_y[ievent.screen_drag.index]; - ievent.screen_drag.relative_x = ievent.screen_drag.x - last_touch_x[ievent.screen_drag.index]; - ievent.screen_drag.relative_y = ievent.screen_drag.y - last_touch_y[ievent.screen_drag.index]; + last_touch_x[ievent.screen_drag.index] = ievent.screen_drag.x; + last_touch_y[ievent.screen_drag.index] = ievent.screen_drag.y; - last_touch_x[ievent.screen_drag.index] = ievent.screen_drag.x; - last_touch_y[ievent.screen_drag.index] = ievent.screen_drag.y; + Point2 mpos(ievent.screen_drag.x, ievent.screen_drag.y); + Point2 mrel(ievent.screen_drag.relative_x, ievent.screen_drag.relative_y); - Point2 mpos(ievent.screen_drag.x, ievent.screen_drag.y); - Point2 mrel(ievent.screen_drag.relative_x, ievent.screen_drag.relative_y); + input->parse_input_event(ievent); - input->parse_input_event( ievent ); + if (ievent.screen_touch.index == 0) { - if (ievent.screen_touch.index == 0) { + InputEvent ievent; + ievent.type = InputEvent::MOUSE_MOTION; + ievent.ID = ++last_id; + ievent.device = 0; + ievent.mouse_motion.x = ievent.mouse_motion.global_x = mpos.x; + ievent.mouse_motion.y = ievent.mouse_motion.global_y = mpos.y; + input->set_mouse_pos(Point2(ievent.mouse_motion.x, ievent.mouse_motion.y)); + ievent.mouse_motion.speed_x = input->get_last_mouse_speed().x; + ievent.mouse_motion.speed_y = input->get_last_mouse_speed().y; + ievent.mouse_motion.relative_x = mrel.x; + ievent.mouse_motion.relative_y = mrel.y; + ievent.mouse_motion.button_mask = 1; // pressed + + input->parse_input_event(ievent); + }; + } break; + + case SCREEN_EVENT_KEYBOARD: { InputEvent ievent; - ievent.type = InputEvent::MOUSE_MOTION; + ievent.type = InputEvent::KEY; ievent.ID = ++last_id; ievent.device = 0; - ievent.mouse_motion.x = ievent.mouse_motion.global_x = mpos.x; - ievent.mouse_motion.y = ievent.mouse_motion.global_y = mpos.y; - input->set_mouse_pos(Point2(ievent.mouse_motion.x,ievent.mouse_motion.y)); - ievent.mouse_motion.speed_x=input->get_last_mouse_speed().x; - ievent.mouse_motion.speed_y=input->get_last_mouse_speed().y; - ievent.mouse_motion.relative_x = mrel.x; - ievent.mouse_motion.relative_y = mrel.y; - ievent.mouse_motion.button_mask = 1; // pressed - - input->parse_input_event( ievent ); - }; - } break; - - case SCREEN_EVENT_KEYBOARD: { - - InputEvent ievent; - ievent.type = InputEvent::KEY; - ievent.ID = ++last_id; - ievent.device = 0; - int val = 0; - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SCAN, &val); - ievent.key.scancode = val; - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SYM, &val); - ievent.key.unicode = val; - if (val == 61448) { - ievent.key.scancode = KEY_BACKSPACE; - ievent.key.unicode = KEY_BACKSPACE; - }; - if (val == 61453) { - ievent.key.scancode = KEY_ENTER; - ievent.key.unicode = KEY_ENTER; - }; - - int flags; - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_FLAGS, &flags); - ievent.key.pressed = flags & 1; // bit 1 is pressed apparently + int val = 0; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SCAN, &val); + ievent.key.scancode = val; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SYM, &val); + ievent.key.unicode = val; + if (val == 61448) { + ievent.key.scancode = KEY_BACKSPACE; + ievent.key.unicode = KEY_BACKSPACE; + }; + if (val == 61453) { + ievent.key.scancode = KEY_ENTER; + ievent.key.unicode = KEY_ENTER; + }; - int mod; - screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_MODIFIERS, &mod); + int flags; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_FLAGS, &flags); + ievent.key.pressed = flags & 1; // bit 1 is pressed apparently - input->parse_input_event( ievent ); - } break; + int mod; + screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_MODIFIERS, &mod); - default: - break; + input->parse_input_event(ievent); + } break; + default: + break; } }; @@ -419,8 +413,7 @@ void OSBB10::handle_accelerometer() { //input->set_accelerometer(Vector3(force_y, flip_accelerometer?force_x:(-force_x), force_z)); }; - -void OSBB10::_resize(bps_event_t* event) { +void OSBB10::_resize(bps_event_t *event) { int angle = navigator_event_get_orientation_angle(event); bbutil_rotate_screen_surface(angle); @@ -449,16 +442,16 @@ void OSBB10::process_events() { if (!event) break; - #ifdef BB10_SCORELOOP_ENABLED - ScoreloopBB10* sc = Globals::get_singleton()->get_singleton_object("Scoreloop")->cast_to<ScoreloopBB10>(); +#ifdef BB10_SCORELOOP_ENABLED + ScoreloopBB10 *sc = Globals::get_singleton()->get_singleton_object("Scoreloop")->cast_to<ScoreloopBB10>(); if (sc->handle_event(event)) continue; - #endif +#endif - #ifdef PAYMENT_SERVICE_ENABLED +#ifdef PAYMENT_SERVICE_ENABLED if (payment_service->handle_event(event)) continue; - #endif +#endif int domain = bps_event_get_domain(event); if (domain == screen_get_domain()) { @@ -473,7 +466,7 @@ void OSBB10::process_events() { bps_event_destroy(event); exit(0); return; - /* + /* } else if (bps_event_get_code(event) == NAVIGATOR_ORIENTATION_CHECK) { int angle = navigator_event_get_orientation_angle(event); @@ -504,7 +497,7 @@ void OSBB10::process_events() { }; } else if (domain == audiodevice_get_domain()) { - const char * audiodevice_path = audiodevice_event_get_path(event); + const char *audiodevice_path = audiodevice_event_get_path(event); printf("************* got audiodevice event, path %s\n", audiodevice_path); audio_driver->finish(); audio_driver->init(audiodevice_path); @@ -520,7 +513,7 @@ bool OSBB10::has_virtual_keyboard() const { return true; }; -void OSBB10::show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect) { +void OSBB10::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect) { virtualkeyboard_show(); }; @@ -551,11 +544,10 @@ void OSBB10::run() { }; */ - while (true) { process_events(); // get rid of pending events - if (Main::iteration()==true) + if (Main::iteration() == true) break; bbutil_swap(); //#ifdef DEBUG_ENABLED @@ -564,7 +556,6 @@ void OSBB10::run() { }; main_loop->finish(); - }; bool OSBB10::has_touchscreen_ui_hint() const { @@ -574,7 +565,7 @@ bool OSBB10::has_touchscreen_ui_hint() const { Error OSBB10::shell_open(String p_uri) { - char* msg = NULL; + char *msg = NULL; int ret = navigator_invoke(p_uri.utf8().get_data(), &msg); return ret == BPS_SUCCESS ? OK : FAILED; @@ -603,15 +594,14 @@ int OSBB10::get_power_percent_left() { OSBB10::OSBB10() { - main_loop=NULL; - last_id=1; + main_loop = NULL; + last_id = 1; minimized = false; fullscreen = true; flip_accelerometer = true; fullscreen_mixer_volume = 1; fullscreen_stream_volume = 1; - printf("godot bb10!\n"); getcwd(launch_dir, sizeof(launch_dir)); printf("launch dir %s\n", launch_dir); @@ -620,7 +610,4 @@ OSBB10::OSBB10() { } OSBB10::~OSBB10() { - - } - diff --git a/platform/bb10/os_bb10.h b/platform/bb10/os_bb10.h index 678b8c9fc..313f9c9e6 100644 --- a/platform/bb10/os_bb10.h +++ b/platform/bb10/os_bb10.h @@ -29,22 +29,22 @@ #ifndef OS_BB10_H #define OS_BB10_H -#include "os/input.h" +#include "audio_driver_bb10.h" #include "drivers/unix/os_unix.h" -#include "os/main_loop.h" #include "main/input_default.h" -#include "servers/physics/physics_server_sw.h" +#include "os/input.h" +#include "os/main_loop.h" +#include "payment_service.h" +#include "power_bb10.h" #include "servers/audio_server.h" +#include "servers/physics/physics_server_sw.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/visual/rasterizer.h" -#include "audio_driver_bb10.h" -#include "payment_service.h" -#include "power_bb10.h" -#include <screen/screen.h> -#include <sys/platform.h> #include <bps/event.h> +#include <screen/screen.h> #include <stdint.h> +#include <sys/platform.h> class OSBB10 : public OS_Unix { @@ -58,15 +58,15 @@ class OSBB10 : public OS_Unix { VisualServer *visual_server; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; - AudioDriverBB10* audio_driver; + AudioDriverBB10 *audio_driver; PowerBB10 *power_manager; #ifdef PAYMENT_SERVICE_ENABLED - PaymentService* payment_service; + PaymentService *payment_service; #endif VideoMode default_videomode; - MainLoop * main_loop; + MainLoop *main_loop; void process_events(); @@ -87,48 +87,47 @@ class OSBB10 : public OS_Unix { String data_dir; InputDefault *input; -public: +public: // functions used by main to initialize/deintialize the OS virtual int get_video_driver_count() const; - virtual const char * get_video_driver_name(int p_driver) const; + virtual const char *get_video_driver_name(int p_driver) const; virtual VideoMode get_default_video_mode() const; virtual String get_data_dir() const; virtual int get_audio_driver_count() const; - virtual const char * get_audio_driver_name(int p_driver) const; + virtual const char *get_audio_driver_name(int p_driver) const; - virtual void initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver); + virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); - virtual void set_main_loop( MainLoop * p_main_loop ); + virtual void set_main_loop(MainLoop *p_main_loop); virtual void delete_main_loop(); virtual void finalize(); typedef int64_t ProcessID; - static OS* get_singleton(); + static OS *get_singleton(); virtual void set_mouse_show(bool p_show); virtual void set_mouse_grab(bool p_grab); virtual bool is_mouse_grab_enabled() const; virtual Point2 get_mouse_pos() const; virtual int get_mouse_button_state() const; - virtual void set_window_title(const String& p_title); + virtual void set_window_title(const String &p_title); //virtual void set_clipboard(const String& p_text); //virtual String get_clipboard() const; - virtual bool has_virtual_keyboard() const; - virtual void show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect); + virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect); virtual void hide_virtual_keyboard(); - virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0); - virtual VideoMode get_video_mode(int p_screen=0) const; - virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const; + virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0); + virtual VideoMode get_video_mode(int p_screen = 0) const; + virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const; virtual Size2 get_window_size() const; virtual String get_name(); @@ -150,8 +149,6 @@ public: OSBB10(); ~OSBB10(); - }; #endif - diff --git a/platform/bb10/payment_service.cpp b/platform/bb10/payment_service.cpp index 131c9712a..e78326e8b 100644 --- a/platform/bb10/payment_service.cpp +++ b/platform/bb10/payment_service.cpp @@ -31,18 +31,18 @@ #include "payment_service.h" #include "bbutil.h" -#include <string.h> #include <errno.h> +#include <string.h> #include <unistd.h> -extern char* launch_dir_ptr; +extern char *launch_dir_ptr; void PaymentService::_bind_methods() { - ClassDB::bind_method(D_METHOD("request_product_info"),&PaymentService::request_product_info); - ClassDB::bind_method(D_METHOD("purchase"),&PaymentService::purchase); + ClassDB::bind_method(D_METHOD("request_product_info"), &PaymentService::request_product_info); + ClassDB::bind_method(D_METHOD("purchase"), &PaymentService::purchase); - ClassDB::bind_method(D_METHOD("get_pending_event_count"),&PaymentService::get_pending_event_count); - ClassDB::bind_method(D_METHOD("pop_pending_event"),&PaymentService::pop_pending_event); + ClassDB::bind_method(D_METHOD("get_pending_event_count"), &PaymentService::get_pending_event_count); + ClassDB::bind_method(D_METHOD("pop_pending_event"), &PaymentService::pop_pending_event); }; Error PaymentService::request_product_info(Variant p_params) { @@ -55,16 +55,16 @@ Error PaymentService::purchase(Variant p_params) { Dictionary params = p_params; ERR_FAIL_COND_V((!params.has("product_id")) && (!params.has("product_sku")), ERR_INVALID_PARAMETER); - char* id = NULL; - char* sku = NULL; + char *id = NULL; + char *sku = NULL; - CharString p_id = params.has("product_id")?String(params["product_id"]).ascii():CharString(); - CharString p_sku = params.has("product_sku")?String(params["product_sku"]).ascii():CharString(); + CharString p_id = params.has("product_id") ? String(params["product_id"]).ascii() : CharString(); + CharString p_sku = params.has("product_sku") ? String(params["product_sku"]).ascii() : CharString(); unsigned int request_id; chdir(launch_dir_ptr); int ret = paymentservice_purchase_request(params.has("product_sku") ? NULL : p_id.get_data(), - params.has("product_sku") ? p_sku.get_data() : NULL, - NULL, NULL, NULL, NULL, get_window_group_id(), &request_id); + params.has("product_sku") ? p_sku.get_data() : NULL, + NULL, NULL, NULL, NULL, get_window_group_id(), &request_id); chdir("app/native"); if (ret != BPS_SUCCESS) { @@ -76,8 +76,7 @@ Error PaymentService::purchase(Variant p_params) { return OK; }; - -bool PaymentService::handle_event(bps_event_t* p_event) { +bool PaymentService::handle_event(bps_event_t *p_event) { if (bps_event_get_domain(p_event) != paymentservice_get_domain()) { return false; @@ -91,12 +90,12 @@ bool PaymentService::handle_event(bps_event_t* p_event) { res = bps_event_get_code(p_event); if (res == PURCHASE_RESPONSE) { dict["type"] = "purchase"; - const char* pid = paymentservice_event_get_digital_good_id(p_event, 0); - dict["product_id"] = String(pid?pid:""); + const char *pid = paymentservice_event_get_digital_good_id(p_event, 0); + dict["product_id"] = String(pid ? pid : ""); }; } else { - const char* desc = paymentservice_event_get_error_text(p_event); + const char *desc = paymentservice_event_get_error_text(p_event); if (strcmp(desc, "alreadyPurchased") == 0) { dict["result"] = "ok"; } else { @@ -142,9 +141,8 @@ PaymentService::PaymentService() { #endif }; -PaymentService::~PaymentService() { +PaymentService::~PaymentService(){ }; - #endif diff --git a/platform/bb10/payment_service.h b/platform/bb10/payment_service.h index b31a954ef..d5b4cc3d6 100644 --- a/platform/bb10/payment_service.h +++ b/platform/bb10/payment_service.h @@ -46,24 +46,18 @@ class PaymentService : public Object { List<Variant> pending_events; public: - Error request_product_info(Variant p_params); Error purchase(Variant p_params); int get_pending_event_count(); Variant pop_pending_event(); - bool handle_event(bps_event_t* p_event); + bool handle_event(bps_event_t *p_event); PaymentService(); ~PaymentService(); }; - - #endif - #endif - - diff --git a/platform/bb10/power_bb10.cpp b/platform/bb10/power_bb10.cpp index 5cd84d624..29c1fe370 100644 --- a/platform/bb10/power_bb10.cpp +++ b/platform/bb10/power_bb10.cpp @@ -31,7 +31,6 @@ #include "core/error_macros.h" - bool PowerBB10::UpdatePowerInfo() { return false; @@ -40,8 +39,7 @@ bool PowerBB10::UpdatePowerInfo() { PowerState PowerBB10::get_power_state() { if (UpdatePowerInfo()) { return power_state; - } - else { + } else { WARN_PRINT("Power management is not implemented on this platform, defaulting to POWERSTATE_UNKNOWN"); return POWERSTATE_UNKNOWN; } @@ -50,8 +48,7 @@ PowerState PowerBB10::get_power_state() { int PowerBB10::get_power_seconds_left() { if (UpdatePowerInfo()) { return nsecs_left; - } - else { + } else { WARN_PRINT("Power management is not implemented on this platform, defaulting to -1"); return -1; } @@ -60,17 +57,15 @@ int PowerBB10::get_power_seconds_left() { int PowerBB10::get_power_percent_left() { if (UpdatePowerInfo()) { return percent_left; - } - else { + } else { WARN_PRINT("Power management is not implemented on this platform, defaulting to -1"); return -1; } } -PowerBB10::PowerBB10() : nsecs_left(-1), percent_left(-1), power_state(POWERSTATE_UNKNOWN) { - +PowerBB10::PowerBB10() + : nsecs_left(-1), percent_left(-1), power_state(POWERSTATE_UNKNOWN) { } PowerBB10::~PowerBB10() { } - diff --git a/platform/bb10/power_bb10.h b/platform/bb10/power_bb10.h index 0e6eb53d0..6c13f6e99 100644 --- a/platform/bb10/power_bb10.h +++ b/platform/bb10/power_bb10.h @@ -37,6 +37,7 @@ private: PowerState power_state; bool UpdatePowerInfo(); + public: PowerBB10(); virtual ~PowerBB10(); |
