1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-15 13:51:40 +00:00

Style: Apply clang-format on all files

Thus fixing some invalid changes that had still made it to the 2.1 branch.
This commit is contained in:
Rémi Verschelde
2017-07-30 23:00:25 +02:00
parent 6d3fea6864
commit c1f54e1a45
17 changed files with 280 additions and 296 deletions

View File

@@ -2314,12 +2314,12 @@ void Image::blend_rect(const Image &p_src, const Rect2 &p_src_rect, const Point2
BColor src = p_src._get_pixel(rrect.pos.x + j, rrect.pos.y + i, src_data_ptr, srcdsize); BColor src = p_src._get_pixel(rrect.pos.x + j, rrect.pos.y + i, src_data_ptr, srcdsize);
BColor dst = _get_pixel(p_dest.x + j, p_dest.y + i, dst_data_ptr, dst_data_size); BColor dst = _get_pixel(p_dest.x + j, p_dest.y + i, dst_data_ptr, dst_data_size);
float ba = (float) dst.a / 255.0; float ba = (float)dst.a / 255.0;
float fa = (float) src.a / 255.0; float fa = (float)src.a / 255.0;
dst.r = (uint8_t) (fa*src.r + ba*(1.0 - fa) * dst.r); dst.r = (uint8_t)(fa * src.r + ba * (1.0 - fa) * dst.r);
dst.g = (uint8_t) (fa*src.g + ba*(1.0 - fa) * dst.g); dst.g = (uint8_t)(fa * src.g + ba * (1.0 - fa) * dst.g);
dst.b = (uint8_t) (fa*src.b + ba*(1.0 - fa) * dst.b); dst.b = (uint8_t)(fa * src.b + ba * (1.0 - fa) * dst.b);
dst.a = (uint8_t) (255.0 * (fa + ba * (1.0 - fa))); dst.a = (uint8_t)(255.0 * (fa + ba * (1.0 - fa)));
_put_pixel(p_dest.x + j, p_dest.y + i, dst, dst_data_ptr); _put_pixel(p_dest.x + j, p_dest.y + i, dst, dst_data_ptr);
} }
} }
@@ -2369,12 +2369,12 @@ void Image::blend_rect_mask(const Image &p_src, const Image &p_mask, const Rect2
if (msk.a != 0) { if (msk.a != 0) {
BColor src = p_src._get_pixel(rrect.pos.x + j, rrect.pos.y + i, src_data_ptr, srcdsize); BColor src = p_src._get_pixel(rrect.pos.x + j, rrect.pos.y + i, src_data_ptr, srcdsize);
BColor dst = _get_pixel(p_dest.x + j, p_dest.y + i, dst_data_ptr, dst_data_size); BColor dst = _get_pixel(p_dest.x + j, p_dest.y + i, dst_data_ptr, dst_data_size);
float ba = (float) dst.a / 255.0; float ba = (float)dst.a / 255.0;
float fa = (float) src.a / 255.0; float fa = (float)src.a / 255.0;
dst.r = (uint8_t) (fa*src.r + ba*(1.0 - fa) * dst.r); dst.r = (uint8_t)(fa * src.r + ba * (1.0 - fa) * dst.r);
dst.g = (uint8_t) (fa*src.g + ba*(1.0 - fa) * dst.g); dst.g = (uint8_t)(fa * src.g + ba * (1.0 - fa) * dst.g);
dst.b = (uint8_t) (fa*src.b + ba*(1.0 - fa) * dst.b); dst.b = (uint8_t)(fa * src.b + ba * (1.0 - fa) * dst.b);
dst.a = (uint8_t) (255.0 * (fa + ba * (1.0 - fa))); dst.a = (uint8_t)(255.0 * (fa + ba * (1.0 - fa)));
_put_pixel(p_dest.x + j, p_dest.y + i, dst, dst_data_ptr); _put_pixel(p_dest.x + j, p_dest.y + i, dst, dst_data_ptr);
} }
} }
@@ -2388,8 +2388,8 @@ void Image::fill(const Color &p_color) {
DVector<uint8_t>::Write wp = data.write(); DVector<uint8_t>::Write wp = data.write();
unsigned char *dst_data_ptr = wp.ptr(); unsigned char *dst_data_ptr = wp.ptr();
BColor c = BColor(p_color.r*255, p_color.g*255, p_color.b*255, p_color.a*255); BColor c = BColor(p_color.r * 255, p_color.g * 255, p_color.b * 255, p_color.a * 255);
for (int i = 0; i < height; i++) { for (int i = 0; i < height; i++) {
@@ -2398,7 +2398,6 @@ void Image::fill(const Color &p_color) {
_put_pixel(j, i, c, dst_data_ptr); _put_pixel(j, i, c, dst_data_ptr);
} }
} }
} }
Image (*Image::_png_mem_loader_func)(const uint8_t *, int) = NULL; Image (*Image::_png_mem_loader_func)(const uint8_t *, int) = NULL;

View File

@@ -356,7 +356,7 @@ public:
void blend_rect_mask(const Image &p_src, const Image &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest); void blend_rect_mask(const Image &p_src, const Image &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest);
void fill(const Color &p_color); void fill(const Color &p_color);
void brush_transfer(const Image &p_src, const Image &p_brush, const Point2 &p_dest); void brush_transfer(const Image &p_src, const Image &p_brush, const Point2 &p_dest);
Image brushed(const Image &p_src, const Image &p_brush, const Point2 &p_dest) const; Image brushed(const Image &p_src, const Image &p_brush, const Point2 &p_dest) const;

View File

@@ -111,7 +111,7 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p
switch (p_mode) { switch (p_mode) {
case MODE_FASTLZ: { case MODE_FASTLZ: {
int ret_size=0; int ret_size = 0;
if (p_dst_max_size < 16) { if (p_dst_max_size < 16) {
uint8_t dst[16]; uint8_t dst[16];

View File

@@ -120,7 +120,7 @@ public:
bool is_subsequence_ofi(const String &p_string) const; bool is_subsequence_ofi(const String &p_string) const;
Vector<String> bigrams() const; Vector<String> bigrams() const;
float similarity(const String &p_string) const; float similarity(const String &p_string) const;
String format(const Variant& values, String placeholder = "{_}") const; String format(const Variant &values, String placeholder = "{_}") const;
String replace_first(String p_key, String p_with) const; String replace_first(String p_key, String p_with) const;
String replace(String p_key, String p_with) const; String replace(String p_key, String p_with) const;
String replacen(String p_key, String p_with) const; String replacen(String p_key, String p_with) const;

View File

@@ -512,7 +512,6 @@ Error EditorMeshImportPlugin::import(const String &p_path, const Ref<ResourceImp
surf_tool->add_smooth_group(true); surf_tool->add_smooth_group(true);
has_index_data = false; has_index_data = false;
} }
if (l.begins_with("o ")) //name if (l.begins_with("o ")) //name

View File

@@ -1041,8 +1041,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
v_scroll->set_val(v_scroll->get_val() + int(EditorSettings::get_singleton()->get("2d_editor/pan_speed")) / zoom * b.factor); v_scroll->set_val(v_scroll->get_val() + int(EditorSettings::get_singleton()->get("2d_editor/pan_speed")) / zoom * b.factor);
} } else {
else {
if (zoom < MIN_ZOOM) if (zoom < MIN_ZOOM)
return; return;
@@ -1055,7 +1054,6 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
h_scroll->set_val(h_scroll->get_val() + ofs.x); h_scroll->set_val(h_scroll->get_val() + ofs.x);
v_scroll->set_val(v_scroll->get_val() + ofs.y); v_scroll->set_val(v_scroll->get_val() + ofs.y);
} }
} }
_update_scroll(0); _update_scroll(0);
@@ -1069,8 +1067,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
v_scroll->set_val(v_scroll->get_val() - int(EditorSettings::get_singleton()->get("2d_editor/pan_speed")) / zoom * b.factor); v_scroll->set_val(v_scroll->get_val() - int(EditorSettings::get_singleton()->get("2d_editor/pan_speed")) / zoom * b.factor);
} } else {
else {
if (zoom > MAX_ZOOM) if (zoom > MAX_ZOOM)
return; return;
@@ -1083,7 +1080,6 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
h_scroll->set_val(h_scroll->get_val() + ofs.x); h_scroll->set_val(h_scroll->get_val() + ofs.x);
v_scroll->set_val(v_scroll->get_val() + ofs.y); v_scroll->set_val(v_scroll->get_val() + ofs.y);
} }
} }
_update_scroll(0); _update_scroll(0);
@@ -1099,9 +1095,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
_update_scroll(0); _update_scroll(0);
viewport->update(); viewport->update();
} }
} }
if (b.button_index == BUTTON_WHEEL_RIGHT) { if (b.button_index == BUTTON_WHEEL_RIGHT) {
@@ -1112,9 +1106,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
_update_scroll(0); _update_scroll(0);
viewport->update(); viewport->update();
} }
} }
if (b.button_index == BUTTON_RIGHT) { if (b.button_index == BUTTON_RIGHT) {

View File

@@ -29,11 +29,11 @@
/*************************************************************************/ /*************************************************************************/
#import "app_delegate.h" #import "app_delegate.h"
#include "audio_driver_iphone.h"
#include "core/globals.h" #include "core/globals.h"
#import "gl_view.h" #import "gl_view.h"
#include "main/main.h" #include "main/main.h"
#include "os_iphone.h" #include "os_iphone.h"
#include "audio_driver_iphone.h"
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED #ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED
#include "modules/FacebookScorer_ios/FacebookScorer.h" #include "modules/FacebookScorer_ios/FacebookScorer.h"
@@ -156,7 +156,7 @@ NSMutableDictionary *ios_joysticks = nil;
// add it to our dictionary, this will retain our controllers // add it to our dictionary, this will retain our controllers
[ios_joysticks setObject:controller [ios_joysticks setObject:controller
forKey:[NSNumber numberWithInt:joy_id]]; forKey:[NSNumber numberWithInt:joy_id]];
// set our input handler // set our input handler
[self setControllerInputHandler:controller]; [self setControllerInputHandler:controller];
@@ -210,37 +210,37 @@ NSMutableDictionary *ios_joysticks = nil;
if (element == gamepad.buttonA) { if (element == gamepad.buttonA) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_0, OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_0,
gamepad.buttonA.isPressed); gamepad.buttonA.isPressed);
} else if (element == gamepad.buttonB) { } else if (element == gamepad.buttonB) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_1, OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_1,
gamepad.buttonB.isPressed); gamepad.buttonB.isPressed);
} else if (element == gamepad.buttonX) { } else if (element == gamepad.buttonX) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_2, OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_2,
gamepad.buttonX.isPressed); gamepad.buttonX.isPressed);
} else if (element == gamepad.buttonY) { } else if (element == gamepad.buttonY) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_3, OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_3,
gamepad.buttonY.isPressed); gamepad.buttonY.isPressed);
} else if (element == gamepad.leftShoulder) { } else if (element == gamepad.leftShoulder) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_L, OSIPhone::get_singleton()->joy_button(joy_id, JOY_L,
gamepad.leftShoulder.isPressed); gamepad.leftShoulder.isPressed);
} else if (element == gamepad.rightShoulder) { } else if (element == gamepad.rightShoulder) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_R, OSIPhone::get_singleton()->joy_button(joy_id, JOY_R,
gamepad.rightShoulder.isPressed); gamepad.rightShoulder.isPressed);
} else if (element == gamepad.leftTrigger) { } else if (element == gamepad.leftTrigger) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_L2, OSIPhone::get_singleton()->joy_button(joy_id, JOY_L2,
gamepad.leftTrigger.isPressed); gamepad.leftTrigger.isPressed);
} else if (element == gamepad.rightTrigger) { } else if (element == gamepad.rightTrigger) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_R2, OSIPhone::get_singleton()->joy_button(joy_id, JOY_R2,
gamepad.rightTrigger.isPressed); gamepad.rightTrigger.isPressed);
} else if (element == gamepad.dpad) { } else if (element == gamepad.dpad) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_UP, OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_UP,
gamepad.dpad.up.isPressed); gamepad.dpad.up.isPressed);
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_DOWN, OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_DOWN,
gamepad.dpad.down.isPressed); gamepad.dpad.down.isPressed);
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_LEFT, OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_LEFT,
gamepad.dpad.left.isPressed); gamepad.dpad.left.isPressed);
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_RIGHT, OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_RIGHT,
gamepad.dpad.right.isPressed); gamepad.dpad.right.isPressed);
}; };
InputDefault::JoyAxis jx; InputDefault::JoyAxis jx;
@@ -267,36 +267,36 @@ NSMutableDictionary *ios_joysticks = nil;
// gamepad is the standard profile with 4 buttons, shoulder buttons and a // gamepad is the standard profile with 4 buttons, shoulder buttons and a
// D-pad // D-pad
controller.gamepad.valueChangedHandler = ^(GCGamepad *gamepad, controller.gamepad.valueChangedHandler = ^(GCGamepad *gamepad,
GCControllerElement *element) { GCControllerElement *element) {
int joy_id = [self getJoyIdForController:controller]; int joy_id = [self getJoyIdForController:controller];
if (element == gamepad.buttonA) { if (element == gamepad.buttonA) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_0, OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_0,
gamepad.buttonA.isPressed); gamepad.buttonA.isPressed);
} else if (element == gamepad.buttonB) { } else if (element == gamepad.buttonB) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_1, OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_1,
gamepad.buttonB.isPressed); gamepad.buttonB.isPressed);
} else if (element == gamepad.buttonX) { } else if (element == gamepad.buttonX) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_2, OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_2,
gamepad.buttonX.isPressed); gamepad.buttonX.isPressed);
} else if (element == gamepad.buttonY) { } else if (element == gamepad.buttonY) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_3, OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_3,
gamepad.buttonY.isPressed); gamepad.buttonY.isPressed);
} else if (element == gamepad.leftShoulder) { } else if (element == gamepad.leftShoulder) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_L, OSIPhone::get_singleton()->joy_button(joy_id, JOY_L,
gamepad.leftShoulder.isPressed); gamepad.leftShoulder.isPressed);
} else if (element == gamepad.rightShoulder) { } else if (element == gamepad.rightShoulder) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_R, OSIPhone::get_singleton()->joy_button(joy_id, JOY_R,
gamepad.rightShoulder.isPressed); gamepad.rightShoulder.isPressed);
} else if (element == gamepad.dpad) { } else if (element == gamepad.dpad) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_UP, OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_UP,
gamepad.dpad.up.isPressed); gamepad.dpad.up.isPressed);
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_DOWN, OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_DOWN,
gamepad.dpad.down.isPressed); gamepad.dpad.down.isPressed);
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_LEFT, OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_LEFT,
gamepad.dpad.left.isPressed); gamepad.dpad.left.isPressed);
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_RIGHT, OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_RIGHT,
gamepad.dpad.right.isPressed); gamepad.dpad.right.isPressed);
}; };
}; };
#ifdef ADD_MICRO_GAMEPAD // disabling this for now, only available on iOS 9+ and we're still compiling for iOS 7+ #ifdef ADD_MICRO_GAMEPAD // disabling this for now, only available on iOS 9+ and we're still compiling for iOS 7+
@@ -307,19 +307,19 @@ NSMutableDictionary *ios_joysticks = nil;
if (element == gamepad.buttonA) { if (element == gamepad.buttonA) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_0, OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_0,
gamepad.buttonA.isPressed); gamepad.buttonA.isPressed);
} else if (element == gamepad.buttonX) { } else if (element == gamepad.buttonX) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_2, OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_2,
gamepad.buttonX.isPressed); gamepad.buttonX.isPressed);
} else if (element == gamepad.dpad) { } else if (element == gamepad.dpad) {
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_UP, OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_UP,
gamepad.dpad.up.isPressed); gamepad.dpad.up.isPressed);
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_DOWN, OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_DOWN,
gamepad.dpad.down.isPressed); gamepad.dpad.down.isPressed);
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_LEFT, OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_LEFT,
gamepad.dpad.left.isPressed); gamepad.dpad.left.isPressed);
OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_RIGHT, OSIPhone::get_singleton()->joy_button(joy_id, JOY_DPAD_RIGHT,
gamepad.dpad.right.isPressed); gamepad.dpad.right.isPressed);
}; };
}; };
#endif #endif
@@ -337,27 +337,27 @@ NSMutableDictionary *ios_joysticks = nil;
// already connected controllers // already connected controllers
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
addObserver:self addObserver:self
selector:@selector(controllerWasConnected:) selector:@selector(controllerWasConnected:)
name:GCControllerDidConnectNotification name:GCControllerDidConnectNotification
object:nil]; object:nil];
// get told when controllers disconnect // get told when controllers disconnect
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
addObserver:self addObserver:self
selector:@selector(controllerWasDisconnected:) selector:@selector(controllerWasDisconnected:)
name:GCControllerDidDisconnectNotification name:GCControllerDidDisconnectNotification
object:nil]; object:nil];
}; };
- (void)deinitGameControllers { - (void)deinitGameControllers {
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
removeObserver:self removeObserver:self
name:GCControllerDidConnectNotification name:GCControllerDidConnectNotification
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
removeObserver:self removeObserver:self
name:GCControllerDidDisconnectNotification name:GCControllerDidDisconnectNotification
object:nil]; object:nil];
if (ios_joysticks != nil) { if (ios_joysticks != nil) {
[ios_joysticks dealloc]; [ios_joysticks dealloc];
@@ -370,195 +370,195 @@ static int frame_count = 0;
{ {
switch (frame_count) { switch (frame_count) {
case 0: { case 0: {
int backingWidth; int backingWidth;
int backingHeight; int backingHeight;
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
GL_RENDERBUFFER_WIDTH_OES, &backingWidth); GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
OS::VideoMode vm; OS::VideoMode vm;
vm.fullscreen = true; vm.fullscreen = true;
vm.width = backingWidth; vm.width = backingWidth;
vm.height = backingHeight; vm.height = backingHeight;
vm.resizable = false; vm.resizable = false;
OS::get_singleton()->set_video_mode(vm); OS::get_singleton()->set_video_mode(vm);
if (!OS::get_singleton()) { if (!OS::get_singleton()) {
exit(0); exit(0);
}; };
++frame_count; ++frame_count;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES); NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *documentsDirectory = [paths objectAtIndex:0];
// NSString *documentsDirectory = [[[NSFileManager defaultManager] // NSString *documentsDirectory = [[[NSFileManager defaultManager]
// URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] // URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]
// lastObject]; // lastObject];
OSIPhone::get_singleton()->set_data_dir( OSIPhone::get_singleton()->set_data_dir(
String::utf8([documentsDirectory UTF8String])); String::utf8([documentsDirectory UTF8String]));
NSString *locale_code = [[NSLocale currentLocale] localeIdentifier]; NSString *locale_code = [[NSLocale currentLocale] localeIdentifier];
OSIPhone::get_singleton()->set_locale( OSIPhone::get_singleton()->set_locale(
String::utf8([locale_code UTF8String])); String::utf8([locale_code UTF8String]));
NSString *uuid; NSString *uuid;
if ([[UIDevice currentDevice] if ([[UIDevice currentDevice]
respondsToSelector:@selector(identifierForVendor)]) { respondsToSelector:@selector(identifierForVendor)]) {
uuid = [UIDevice currentDevice].identifierForVendor.UUIDString; uuid = [UIDevice currentDevice].identifierForVendor.UUIDString;
} else { } else {
// before iOS 6, so just generate an identifier and store it // before iOS 6, so just generate an identifier and store it
uuid = [[NSUserDefaults standardUserDefaults] uuid = [[NSUserDefaults standardUserDefaults]
objectForKey:@"identiferForVendor"]; objectForKey:@"identiferForVendor"];
if (!uuid) { if (!uuid) {
CFUUIDRef cfuuid = CFUUIDCreate(NULL); CFUUIDRef cfuuid = CFUUIDCreate(NULL);
uuid = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, cfuuid); uuid = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, cfuuid);
CFRelease(cfuuid); CFRelease(cfuuid);
[[NSUserDefaults standardUserDefaults] [[NSUserDefaults standardUserDefaults]
setObject:uuid setObject:uuid
forKey:@"identifierForVendor"]; forKey:@"identifierForVendor"];
}
} }
}
OSIPhone::get_singleton()->set_unique_ID(String::utf8([uuid UTF8String])); OSIPhone::get_singleton()->set_unique_ID(String::utf8([uuid UTF8String]));
}; break; }; break;
/* /*
case 1: { case 1: {
++frame_count; ++frame_count;
}; break; }; break;
*/ */
case 1: { case 1: {
Main::setup2(); Main::setup2();
++frame_count; ++frame_count;
// this might be necessary before here // this might be necessary before here
NSDictionary *dict = [[NSBundle mainBundle] infoDictionary]; NSDictionary *dict = [[NSBundle mainBundle] infoDictionary];
for (NSString *key in dict) { for (NSString *key in dict) {
NSObject *value = [dict objectForKey:key]; NSObject *value = [dict objectForKey:key];
String ukey = String::utf8([key UTF8String]); String ukey = String::utf8([key UTF8String]);
// we need a NSObject to Variant conversor // we need a NSObject to Variant conversor
if ([value isKindOfClass:[NSString class]]) { if ([value isKindOfClass:[NSString class]]) {
NSString *str = (NSString *)value; NSString *str = (NSString *)value;
String uval = String::utf8([str UTF8String]); String uval = String::utf8([str UTF8String]);
Globals::get_singleton()->set("Info.plist/" + ukey, uval); Globals::get_singleton()->set("Info.plist/" + ukey, uval);
} else if ([value isKindOfClass:[NSNumber class]]) { } else if ([value isKindOfClass:[NSNumber class]]) {
NSNumber *n = (NSNumber *)value; NSNumber *n = (NSNumber *)value;
double dval = [n doubleValue]; double dval = [n doubleValue];
Globals::get_singleton()->set("Info.plist/" + ukey, dval); Globals::get_singleton()->set("Info.plist/" + ukey, dval);
}; };
// do stuff // do stuff
} }
}; break; }; break;
/* /*
case 3: { case 3: {
++frame_count; ++frame_count;
} break; } break;
*/ */
case 2: { case 2: {
Main::start(); Main::start();
++frame_count; ++frame_count;
}; break; // no fallthrough }; break; // no fallthrough
default: { default: {
if (OSIPhone::get_singleton()) { if (OSIPhone::get_singleton()) {
if (motionInitialised) { if (motionInitialised) {
// Just using polling approach for now, we can set this up so it sends // Just using polling approach for now, we can set this up so it sends
// data to us in intervals, might be better. See Apple reference pages // data to us in intervals, might be better. See Apple reference pages
// for more details: // for more details:
// https://developer.apple.com/reference/coremotion/cmmotionmanager?language=objc // https://developer.apple.com/reference/coremotion/cmmotionmanager?language=objc
// Apple splits our accelerometer date into a gravity and user movement // Apple splits our accelerometer date into a gravity and user movement
// component. We add them back together // component. We add them back together
CMAcceleration gravity = motionManager.deviceMotion.gravity; CMAcceleration gravity = motionManager.deviceMotion.gravity;
CMAcceleration acceleration = CMAcceleration acceleration =
motionManager.deviceMotion.userAcceleration; motionManager.deviceMotion.userAcceleration;
///@TODO We don't seem to be getting data here, is my device broken or ///@TODO We don't seem to be getting data here, is my device broken or
/// is this code incorrect? /// is this code incorrect?
CMMagneticField magnetic = CMMagneticField magnetic =
motionManager.deviceMotion.magneticField.field; motionManager.deviceMotion.magneticField.field;
///@TODO we can access rotationRate as a CMRotationRate variable ///@TODO we can access rotationRate as a CMRotationRate variable
///(processed date) or CMGyroData (raw data), have to see what works ///(processed date) or CMGyroData (raw data), have to see what works
/// best /// best
CMRotationRate rotation = motionManager.deviceMotion.rotationRate; CMRotationRate rotation = motionManager.deviceMotion.rotationRate;
// Adjust for screen orientation. // Adjust for screen orientation.
// [[UIDevice currentDevice] orientation] changes even if we've fixed // [[UIDevice currentDevice] orientation] changes even if we've fixed
// our orientation which is not a good thing when you're trying to get // our orientation which is not a good thing when you're trying to get
// your user to move the screen in all directions and want consistent // your user to move the screen in all directions and want consistent
// output // output
///@TODO Using [[UIApplication sharedApplication] statusBarOrientation] ///@TODO Using [[UIApplication sharedApplication] statusBarOrientation]
/// is a bit of a hack. Godot obviously knows the orientation so maybe /// is a bit of a hack. Godot obviously knows the orientation so maybe
/// we /// we
// can use that instead? (note that left and right seem swapped) // can use that instead? (note that left and right seem swapped)
switch ([[UIApplication sharedApplication] statusBarOrientation]) { switch ([[UIApplication sharedApplication] statusBarOrientation]) {
case UIDeviceOrientationLandscapeLeft: { case UIDeviceOrientationLandscapeLeft: {
OSIPhone::get_singleton()->update_gravity(-gravity.y, gravity.x, OSIPhone::get_singleton()->update_gravity(-gravity.y, gravity.x,
gravity.z); gravity.z);
OSIPhone::get_singleton()->update_accelerometer( OSIPhone::get_singleton()->update_accelerometer(
-(acceleration.y + gravity.y), (acceleration.x + gravity.x), -(acceleration.y + gravity.y), (acceleration.x + gravity.x),
acceleration.z + gravity.z); acceleration.z + gravity.z);
OSIPhone::get_singleton()->update_magnetometer( OSIPhone::get_singleton()->update_magnetometer(
-magnetic.y, magnetic.x, magnetic.z); -magnetic.y, magnetic.x, magnetic.z);
OSIPhone::get_singleton()->update_gyroscope(-rotation.y, rotation.x, OSIPhone::get_singleton()->update_gyroscope(-rotation.y, rotation.x,
rotation.z); rotation.z);
}; break; }; break;
case UIDeviceOrientationLandscapeRight: { case UIDeviceOrientationLandscapeRight: {
OSIPhone::get_singleton()->update_gravity(gravity.y, -gravity.x, OSIPhone::get_singleton()->update_gravity(gravity.y, -gravity.x,
gravity.z); gravity.z);
OSIPhone::get_singleton()->update_accelerometer( OSIPhone::get_singleton()->update_accelerometer(
(acceleration.y + gravity.y), -(acceleration.x + gravity.x), (acceleration.y + gravity.y), -(acceleration.x + gravity.x),
acceleration.z + gravity.z); acceleration.z + gravity.z);
OSIPhone::get_singleton()->update_magnetometer( OSIPhone::get_singleton()->update_magnetometer(
magnetic.y, -magnetic.x, magnetic.z); magnetic.y, -magnetic.x, magnetic.z);
OSIPhone::get_singleton()->update_gyroscope(rotation.y, -rotation.x, OSIPhone::get_singleton()->update_gyroscope(rotation.y, -rotation.x,
rotation.z); rotation.z);
}; break; }; break;
case UIDeviceOrientationPortraitUpsideDown: { case UIDeviceOrientationPortraitUpsideDown: {
OSIPhone::get_singleton()->update_gravity(-gravity.x, gravity.y, OSIPhone::get_singleton()->update_gravity(-gravity.x, gravity.y,
gravity.z); gravity.z);
OSIPhone::get_singleton()->update_accelerometer( OSIPhone::get_singleton()->update_accelerometer(
-(acceleration.x + gravity.x), (acceleration.y + gravity.y), -(acceleration.x + gravity.x), (acceleration.y + gravity.y),
acceleration.z + gravity.z); acceleration.z + gravity.z);
OSIPhone::get_singleton()->update_magnetometer( OSIPhone::get_singleton()->update_magnetometer(
-magnetic.x, magnetic.y, magnetic.z); -magnetic.x, magnetic.y, magnetic.z);
OSIPhone::get_singleton()->update_gyroscope(-rotation.x, rotation.y, OSIPhone::get_singleton()->update_gyroscope(-rotation.x, rotation.y,
rotation.z); rotation.z);
}; break; }; break;
default: { // assume portrait default: { // assume portrait
OSIPhone::get_singleton()->update_gravity(gravity.x, gravity.y, OSIPhone::get_singleton()->update_gravity(gravity.x, gravity.y,
gravity.z); gravity.z);
OSIPhone::get_singleton()->update_accelerometer( OSIPhone::get_singleton()->update_accelerometer(
acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.x + gravity.x, acceleration.y + gravity.y,
acceleration.z + gravity.z); acceleration.z + gravity.z);
OSIPhone::get_singleton()->update_magnetometer(magnetic.x, magnetic.y, OSIPhone::get_singleton()->update_magnetometer(magnetic.x, magnetic.y,
magnetic.z); magnetic.z);
OSIPhone::get_singleton()->update_gyroscope(rotation.x, rotation.y, OSIPhone::get_singleton()->update_gyroscope(rotation.x, rotation.y,
rotation.z); rotation.z);
}; break; }; break;
}; };
} }
bool quit_request = OSIPhone::get_singleton()->iterate(); bool quit_request = OSIPhone::get_singleton()->iterate();
};
}; };
}; };
};
}; };
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
@@ -595,9 +595,9 @@ static int frame_count = 0;
int backingWidth; int backingWidth;
int backingHeight; int backingHeight;
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
GL_RENDERBUFFER_WIDTH_OES, &backingWidth); GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
iphone_main(backingWidth, backingHeight, gargc, gargv); iphone_main(backingWidth, backingHeight, gargc, gargv);
@@ -605,8 +605,7 @@ static int frame_count = 0;
view_controller.view = glView; view_controller.view = glView;
window.rootViewController = view_controller; window.rootViewController = view_controller;
_set_keep_screen_on(bool(GLOBAL_DEF("display/keep_screen_on", true)) ? YES _set_keep_screen_on(bool(GLOBAL_DEF("display/keep_screen_on", true)) ? YES : NO);
: NO);
glView.useCADisplayLink = glView.useCADisplayLink =
bool(GLOBAL_DEF("display.iOS/use_cadisplaylink", true)) ? YES : NO; bool(GLOBAL_DEF("display.iOS/use_cadisplaylink", true)) ? YES : NO;
printf("cadisaplylink: %d", glView.useCADisplayLink); printf("cadisaplylink: %d", glView.useCADisplayLink);
@@ -621,7 +620,7 @@ static int frame_count = 0;
if (motionManager.deviceMotionAvailable) { if (motionManager.deviceMotionAvailable) {
motionManager.deviceMotionUpdateInterval = 1.0 / 70.0; motionManager.deviceMotionUpdateInterval = 1.0 / 70.0;
[motionManager startDeviceMotionUpdatesUsingReferenceFrame: [motionManager startDeviceMotionUpdatesUsingReferenceFrame:
CMAttitudeReferenceFrameXMagneticNorthZVertical]; CMAttitudeReferenceFrameXMagneticNorthZVertical];
motionInitialised = YES; motionInitialised = YES;
}; };
}; };
@@ -652,15 +651,15 @@ static int frame_count = 0;
// Account Configuration info - must be set // Account Configuration info - must be set
[MobileAppTracker initializeWithMATAdvertiserId:advertiser_id [MobileAppTracker initializeWithMATAdvertiserId:advertiser_id
MATConversionKey:conversion_key]; MATConversionKey:conversion_key];
// Used to pass us the IFA, enables highly accurate 1-to-1 attribution. // Used to pass us the IFA, enables highly accurate 1-to-1 attribution.
// Required for many advertising networks. // Required for many advertising networks.
[MobileAppTracker [MobileAppTracker
setAppleAdvertisingIdentifier:[[ASIdentifierManager sharedManager] setAppleAdvertisingIdentifier:[[ASIdentifierManager sharedManager]
advertisingIdentifier] advertisingIdentifier]
advertisingTrackingEnabled:[[ASIdentifierManager sharedManager] advertisingTrackingEnabled:[[ASIdentifierManager sharedManager]
isAdvertisingTrackingEnabled]]; isAdvertisingTrackingEnabled]];
#endif #endif
}; };
@@ -728,7 +727,7 @@ static int frame_count = 0;
}; };
// Fixed audio can not resume if it is interrupted cause by an incoming phone call // Fixed audio can not resume if it is interrupted cause by an incoming phone call
if(AudioDriverIphone::get_singleton() != NULL) if (AudioDriverIphone::get_singleton() != NULL)
AudioDriverIphone::get_singleton()->start(); AudioDriverIphone::get_singleton()->start();
} }
@@ -742,16 +741,16 @@ static int frame_count = 0;
// For 4.2+ support // For 4.2+ support
- (BOOL)application:(UIApplication *)application - (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation { annotation:(id)annotation {
#ifdef MODULE_PARSE_ENABLED #ifdef MODULE_PARSE_ENABLED
NSLog(@"Handling application openURL"); NSLog(@"Handling application openURL");
return return
[[FBSDKApplicationDelegate sharedInstance] application:application [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url openURL:url
sourceApplication:sourceApplication sourceApplication:sourceApplication
annotation:annotation]; annotation:annotation];
#endif #endif
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED #ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED

View File

@@ -36,7 +36,7 @@ void iOS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_rate_url", "app_id"), &iOS::get_rate_url); ObjectTypeDB::bind_method(_MD("get_rate_url", "app_id"), &iOS::get_rate_url);
}; };
void iOS::alert(const char* p_alert, const char* p_title) { void iOS::alert(const char *p_alert, const char *p_title) {
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:p_title] message:[NSString stringWithUTF8String:p_alert] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] autorelease]; UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:p_title] message:[NSString stringWithUTF8String:p_alert] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] autorelease];
[alert show]; [alert show];
} }

View File

@@ -257,7 +257,6 @@ AudioDriverOSX::AudioDriverOSX() {
samples_in = NULL; samples_in = NULL;
}; };
AudioDriverOSX::~AudioDriverOSX() { AudioDriverOSX::~AudioDriverOSX(){};
};
#endif #endif

View File

@@ -236,7 +236,7 @@ static bool mouse_down_control = false;
//Event retrieval blocks until resize is over. Call Main::iteration() directly. //Event retrieval blocks until resize is over. Call Main::iteration() directly.
Main::iteration(); Main::iteration();
} }
//_GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); //_GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
//_GodotInputWindowSize(window, contentRect.size.width, contentRect.size.height); //_GodotInputWindowSize(window, contentRect.size.width, contentRect.size.height);
//_GodotInputWindowDamage(window); //_GodotInputWindowDamage(window);
@@ -1725,7 +1725,7 @@ OS_OSX::OS_OSX() {
NSMenu *apple_menu = [[NSMenu alloc] initWithTitle:@""]; NSMenu *apple_menu = [[NSMenu alloc] initWithTitle:@""];
title = [NSString stringWithFormat:NSLocalizedString(@"About %@", nil), nsappname]; title = [NSString stringWithFormat:NSLocalizedString(@"About %@", nil), nsappname];
[apple_menu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; [apple_menu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
[apple_menu addItem:[NSMenuItem separatorItem]]; [apple_menu addItem:[NSMenuItem separatorItem]];
NSMenu *services = [[NSMenu alloc] initWithTitle:@""]; NSMenu *services = [[NSMenu alloc] initWithTitle:@""];
@@ -1740,7 +1740,7 @@ OS_OSX::OS_OSX() {
[apple_menu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"]; [apple_menu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
[menu_item setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; [menu_item setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)];
[apple_menu addItemWithTitle:NSLocalizedString(@"Show all", nil) action:@selector(unhideAllApplications:) keyEquivalent:@""]; [apple_menu addItemWithTitle:NSLocalizedString(@"Show all", nil) action:@selector(unhideAllApplications:) keyEquivalent:@""];
@@ -1752,12 +1752,12 @@ OS_OSX::OS_OSX() {
// Setup menu bar // Setup menu bar
NSMenu *main_menu = [[NSMenu alloc] initWithTitle:@""]; NSMenu *main_menu = [[NSMenu alloc] initWithTitle:@""];
menu_item = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""]; menu_item = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
[main_menu setSubmenu:apple_menu forItem:menu_item]; [main_menu setSubmenu:apple_menu forItem:menu_item];
[NSApp setMainMenu:main_menu]; [NSApp setMainMenu:main_menu];
[main_menu release]; [main_menu release];
[apple_menu release]; [apple_menu release];
[NSApp finishLaunching]; [NSApp finishLaunching];
delegate = [[GodotApplicationDelegate alloc] init]; delegate = [[GodotApplicationDelegate alloc] init];

View File

@@ -35,6 +35,9 @@
#include "GLES2/gl2.h" #include "GLES2/gl2.h"
#include "os_winrt.h" #include "os_winrt.h"
/** clang-format does not play nice with this C++/CX hybrid, needs investigation. */
/* clang-format off */
namespace GodotWinRT namespace GodotWinRT
{ {
ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView
@@ -106,3 +109,5 @@ namespace GodotWinRT
}; };
} }
/* clang-format on */

View File

@@ -37,8 +37,7 @@ using namespace Windows::Media::MediaProperties;
using namespace Windows::Media::Editing; using namespace Windows::Media::Editing;
using namespace Windows::Foundation; using namespace Windows::Foundation;
const char * AudioDriverWinRT::get_name() const const char *AudioDriverWinRT::get_name() const {
{
return "WinRT"; return "WinRT";
} }
@@ -50,7 +49,6 @@ Error AudioDriverWinRT::init() {
pcm_open = false; pcm_open = false;
samples_in = NULL; samples_in = NULL;
mix_rate = 48000; mix_rate = 48000;
output_format = OUTPUT_STEREO; output_format = OUTPUT_STEREO;
channels = 2; channels = 2;
@@ -58,11 +56,11 @@ Error AudioDriverWinRT::init() {
int latency = GLOBAL_DEF("audio/output_latency", 25); int latency = GLOBAL_DEF("audio/output_latency", 25);
buffer_size = nearest_power_of_2(latency * mix_rate / 1000); buffer_size = nearest_power_of_2(latency * mix_rate / 1000);
samples_in = memnew_arr(int32_t, buffer_size*channels); samples_in = memnew_arr(int32_t, buffer_size * channels);
for (int i = 0; i < AUDIO_BUFFERS; i++) { for (int i = 0; i < AUDIO_BUFFERS; i++) {
samples_out[i] = memnew_arr(int16_t, buffer_size*channels); samples_out[i] = memnew_arr(int16_t, buffer_size * channels);
xaudio_buffer[i].AudioBytes = buffer_size * channels * sizeof(int16_t); xaudio_buffer[i].AudioBytes = buffer_size * channels * sizeof(int16_t);
xaudio_buffer[i].pAudioData = (const BYTE*)(samples_out[i]); xaudio_buffer[i].pAudioData = (const BYTE *)(samples_out[i]);
xaudio_buffer[i].Flags = 0; xaudio_buffer[i].Flags = 0;
} }
@@ -100,15 +98,14 @@ Error AudioDriverWinRT::init() {
return OK; return OK;
}; };
void AudioDriverWinRT::thread_func(void* p_udata) { void AudioDriverWinRT::thread_func(void *p_udata) {
AudioDriverWinRT* ad = (AudioDriverWinRT*)p_udata; AudioDriverWinRT *ad = (AudioDriverWinRT *)p_udata;
uint64_t usdelay = (ad->buffer_size / float(ad->mix_rate)) * 1000000; uint64_t usdelay = (ad->buffer_size / float(ad->mix_rate)) * 1000000;
while (!ad->exit_thread) { while (!ad->exit_thread) {
if (!ad->active) { if (!ad->active) {
for (int i = 0; i < AUDIO_BUFFERS; i++) { for (int i = 0; i < AUDIO_BUFFERS; i++) {
@@ -123,30 +120,27 @@ void AudioDriverWinRT::thread_func(void* p_udata) {
ad->unlock(); ad->unlock();
for (unsigned int i = 0;i < ad->buffer_size*ad->channels;i++) { for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) {
ad->samples_out[ad->current_buffer][i] = ad->samples_in[i] >> 16; ad->samples_out[ad->current_buffer][i] = ad->samples_in[i] >> 16;
} }
ad->xaudio_buffer[ad->current_buffer].Flags = 0; ad->xaudio_buffer[ad->current_buffer].Flags = 0;
ad->xaudio_buffer[ad->current_buffer].AudioBytes = ad->buffer_size * ad->channels * sizeof(int16_t); ad->xaudio_buffer[ad->current_buffer].AudioBytes = ad->buffer_size * ad->channels * sizeof(int16_t);
ad->xaudio_buffer[ad->current_buffer].pAudioData = (const BYTE*)(ad->samples_out[ad->current_buffer]); ad->xaudio_buffer[ad->current_buffer].pAudioData = (const BYTE *)(ad->samples_out[ad->current_buffer]);
ad->xaudio_buffer[ad->current_buffer].PlayBegin = 0; ad->xaudio_buffer[ad->current_buffer].PlayBegin = 0;
ad->source_voice->SubmitSourceBuffer(&(ad->xaudio_buffer[ad->current_buffer])); ad->source_voice->SubmitSourceBuffer(&(ad->xaudio_buffer[ad->current_buffer]));
ad->current_buffer = (ad->current_buffer + 1) % AUDIO_BUFFERS; ad->current_buffer = (ad->current_buffer + 1) % AUDIO_BUFFERS;
XAUDIO2_VOICE_STATE state; XAUDIO2_VOICE_STATE state;
while (ad->source_voice->GetState(&state), state.BuffersQueued > AUDIO_BUFFERS - 1) while (ad->source_voice->GetState(&state), state.BuffersQueued > AUDIO_BUFFERS - 1) {
{
WaitForSingleObject(ad->voice_callback->buffer_end_event, INFINITE); WaitForSingleObject(ad->voice_callback->buffer_end_event, INFINITE);
} }
} }
}; };
ad->thread_exited = true; ad->thread_exited = true;
}; };
void AudioDriverWinRT::start() { void AudioDriverWinRT::start() {
@@ -236,9 +230,6 @@ AudioDriverWinRT::AudioDriverWinRT() {
current_buffer = 0; current_buffer = 0;
}; };
AudioDriverWinRT::~AudioDriverWinRT() { AudioDriverWinRT::~AudioDriverWinRT(){
}; };

View File

@@ -31,14 +31,14 @@
#include "servers/audio/audio_server_sw.h" #include "servers/audio/audio_server_sw.h"
#include "core/os/thread.h"
#include "core/os/mutex.h" #include "core/os/mutex.h"
#include "core/os/thread.h"
#include <windows.h>
#include <mmsystem.h>
#include <mmreg.h> #include <mmreg.h>
#include <xaudio2.h> #include <mmsystem.h>
#include <windows.h>
#include <wrl/client.h> #include <wrl/client.h>
#include <xaudio2.h>
class AudioDriverWinRT : public AudioDriverSW { class AudioDriverWinRT : public AudioDriverSW {
@@ -49,26 +49,28 @@ class AudioDriverWinRT : public AudioDriverSW {
struct XAudio2DriverVoiceCallback : public IXAudio2VoiceCallback { struct XAudio2DriverVoiceCallback : public IXAudio2VoiceCallback {
HANDLE buffer_end_event; HANDLE buffer_end_event;
XAudio2DriverVoiceCallback() : buffer_end_event(CreateEvent(NULL, FALSE, FALSE, NULL)) {} XAudio2DriverVoiceCallback()
void STDMETHODCALLTYPE OnBufferEnd(void* pBufferContext) { /*print_line("buffer ended");*/ SetEvent(buffer_end_event); } : buffer_end_event(CreateEvent(NULL, FALSE, FALSE, NULL)) {}
void STDMETHODCALLTYPE OnBufferEnd(void *pBufferContext) { /*print_line("buffer ended");*/
SetEvent(buffer_end_event);
}
//Unused methods are stubs //Unused methods are stubs
void STDMETHODCALLTYPE OnStreamEnd() { } void STDMETHODCALLTYPE OnStreamEnd() {}
void STDMETHODCALLTYPE OnVoiceProcessingPassEnd() { } void STDMETHODCALLTYPE OnVoiceProcessingPassEnd() {}
void STDMETHODCALLTYPE OnVoiceProcessingPassStart(UINT32 SamplesRequired) { } void STDMETHODCALLTYPE OnVoiceProcessingPassStart(UINT32 SamplesRequired) {}
void STDMETHODCALLTYPE OnBufferStart(void * pBufferContext) { } void STDMETHODCALLTYPE OnBufferStart(void *pBufferContext) {}
void STDMETHODCALLTYPE OnLoopEnd(void * pBufferContext) { } void STDMETHODCALLTYPE OnLoopEnd(void *pBufferContext) {}
void STDMETHODCALLTYPE OnVoiceError(void * pBufferContext, HRESULT Error) { } void STDMETHODCALLTYPE OnVoiceError(void *pBufferContext, HRESULT Error) {}
}; };
Thread* thread; Thread *thread;
Mutex* mutex; Mutex *mutex;
int32_t* samples_in; int32_t *samples_in;
int16_t* samples_out[AUDIO_BUFFERS]; int16_t *samples_out[AUDIO_BUFFERS];
static void thread_func(void* p_udata); static void thread_func(void *p_udata);
int buffer_size; int buffer_size;
unsigned int mix_rate; unsigned int mix_rate;
@@ -84,14 +86,13 @@ class AudioDriverWinRT : public AudioDriverSW {
WAVEFORMATEX wave_format; WAVEFORMATEX wave_format;
Microsoft::WRL::ComPtr<IXAudio2> xaudio; Microsoft::WRL::ComPtr<IXAudio2> xaudio;
int current_buffer; int current_buffer;
IXAudio2MasteringVoice* mastering_voice; IXAudio2MasteringVoice *mastering_voice;
XAUDIO2_BUFFER xaudio_buffer[AUDIO_BUFFERS]; XAUDIO2_BUFFER xaudio_buffer[AUDIO_BUFFERS];
IXAudio2SourceVoice* source_voice; IXAudio2SourceVoice *source_voice;
XAudio2DriverVoiceCallback* voice_callback; XAudio2DriverVoiceCallback *voice_callback;
public: public:
const char *get_name() const;
const char* get_name() const;
virtual Error init(); virtual Error init();
virtual void start(); virtual void start();

View File

@@ -101,8 +101,7 @@ Error ContextEGL::initialize() {
try { try {
const EGLint displayAttributes[] = const EGLint displayAttributes[] = {
{
/*EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, /*EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9, EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9,
EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3, EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3,
@@ -114,9 +113,9 @@ Error ContextEGL::initialize() {
// EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices. // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices.
// Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it. // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it.
//EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, //EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
// EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call // EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call
// the IDXGIDevice3::Trim method on behalf of the application when it gets suspended. // the IDXGIDevice3::Trim method on behalf of the application when it gets suspended.
// Calling IDXGIDevice3::Trim when an application is suspended is a Windows Store application certification requirement. // Calling IDXGIDevice3::Trim when an application is suspended is a Windows Store application certification requirement.
EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE,
EGL_NONE, EGL_NONE,

View File

@@ -53,7 +53,7 @@ uint32_t JoystickWinrt::process_controllers(uint32_t p_last_id) {
case ControllerType::GAMEPAD_CONTROLLER: { case ControllerType::GAMEPAD_CONTROLLER: {
GamepadReading reading = ((Gamepad ^) joy.controller_reference)->GetCurrentReading(); GamepadReading reading = ((Gamepad ^)joy.controller_reference)->GetCurrentReading();
int button_mask = (int)GamepadButtons::Menu; int button_mask = (int)GamepadButtons::Menu;
for (int j = 0; j < 14; j++) { for (int j = 0; j < 14; j++) {
@@ -162,7 +162,7 @@ void JoystickWinrt::joypad_vibration_start(int p_device, float p_weak_magnitude,
GamepadVibration vibration; GamepadVibration vibration;
vibration.LeftMotor = p_strong_magnitude; vibration.LeftMotor = p_strong_magnitude;
vibration.RightMotor = p_weak_magnitude; vibration.RightMotor = p_weak_magnitude;
((Gamepad ^) joy.controller_reference)->Vibration = vibration; ((Gamepad ^)joy.controller_reference)->Vibration = vibration;
joy.ff_timestamp = p_timestamp; joy.ff_timestamp = p_timestamp;
joy.ff_end_timestamp = p_duration == 0 ? 0 : p_timestamp + (uint64_t)(p_duration * 1000000.0); joy.ff_end_timestamp = p_duration == 0 ? 0 : p_timestamp + (uint64_t)(p_duration * 1000000.0);
@@ -176,7 +176,7 @@ void JoystickWinrt::joypad_vibration_stop(int p_device, uint64_t p_timestamp) {
GamepadVibration vibration; GamepadVibration vibration;
vibration.LeftMotor = 0.0; vibration.LeftMotor = 0.0;
vibration.RightMotor = 0.0; vibration.RightMotor = 0.0;
((Gamepad ^) joy.controller_reference)->Vibration = vibration; ((Gamepad ^)joy.controller_reference)->Vibration = vibration;
joy.ff_timestamp = p_timestamp; joy.ff_timestamp = p_timestamp;
joy.vibrating = false; joy.vibrating = false;

View File

@@ -33,10 +33,12 @@
ref class JoystickWinrt sealed { ref class JoystickWinrt sealed {
/** clang-format breaks this, it does not understand this token. */
/* clang-format off */
internal: internal:
void register_events(); void register_events();
uint32_t process_controllers(uint32_t p_last_id); uint32_t process_controllers(uint32_t p_last_id);
/* clang-format on */
JoystickWinrt(); JoystickWinrt();
JoystickWinrt(InputDefault *p_input); JoystickWinrt(InputDefault *p_input);

View File

@@ -520,12 +520,10 @@ void ItemList::_input_event(const InputEvent &p_event) {
if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_WHEEL_UP && p_event.mouse_button.pressed) { if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_WHEEL_UP && p_event.mouse_button.pressed) {
scroll_bar->set_val(scroll_bar->get_val() - scroll_bar->get_page() * p_event.mouse_button.factor / 8); scroll_bar->set_val(scroll_bar->get_val() - scroll_bar->get_page() * p_event.mouse_button.factor / 8);
} }
if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_WHEEL_DOWN && p_event.mouse_button.pressed) { if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_WHEEL_DOWN && p_event.mouse_button.pressed) {
scroll_bar->set_val(scroll_bar->get_val() + scroll_bar->get_page() * p_event.mouse_button.factor / 8); scroll_bar->set_val(scroll_bar->get_val() + scroll_bar->get_page() * p_event.mouse_button.factor / 8);
} }
if (p_event.is_pressed() && items.size() > 0) { if (p_event.is_pressed() && items.size() > 0) {