mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user