Implemented love.system.vibrate on iOS. Unfortunately due to API limitations the duration argument is ignored, and it always vibrates for roughly 0.5 seconds.

This commit is contained in:
Alex Szpakowski
2015-08-14 21:30:07 -03:00
parent 2ab69094e1
commit 9be2581e6f
4 changed files with 21 additions and 1 deletions
+5
View File
@@ -59,6 +59,11 @@ bool openURL(const std::string &url);
**/
std::string getExecutablePath();
/**
* Causes devices with vibration support to vibrate for about 0.5 seconds.
**/
void vibrate();
} // ios
} // love
+13
View File
@@ -25,6 +25,8 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioServices.h>
#include <vector>
#include <SDL_events.h>
@@ -321,6 +323,17 @@ std::string getExecutablePath()
}
}
static dispatch_queue_t queue = nil;
static dispatch_source_t timer = nil;
void vibrate()
{
@autoreleasepool
{
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
}
} // ios
} // love