| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/input/input.h" |
| 34 |
#include "core/input/input_enums.h" |
| 35 |
|
| 36 |
#define Key _QKey |
| 37 |
#import <GameController/GameController.h> |
| 38 |
#undef Key |
| 39 |
|
| 40 |
@class GCController; |
| 41 |
class RumbleContext; |
| 42 |
|
| 43 |
struct GameController { |
| 44 |
int joy_id; |
| 45 |
GCController *controller; |
| 46 |
RumbleContext *rumble_context API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) = nil; |
| 47 |
NSInteger ff_effect_timestamp = 0; |
| 48 |
bool force_feedback = false; |
| 49 |
bool double_nintendo_joycon_layout = false; |
| 50 |
bool single_nintendo_joycon_layout = false; |
| 51 |
|
| 52 |
uint32_t axis_changed_mask = 0; |
| 53 |
static_assert(static_cast<uint32_t>(JoyAxis::MAX) < 32, "JoyAxis::MAX must be less than 32"); |
| 54 |
double axis_value[(int)JoyAxis::MAX]; |
| 55 |
|
| 56 |
GameController(int p_joy_id, GCController *p_controller); |
| 57 |
~GameController(); |
| 58 |
}; |
| 59 |
|
| 60 |
class JoypadApple { |
| 61 |
private: |
| 62 |
id<NSObject> connect_observer = nil; |
| 63 |
id<NSObject> disconnect_observer = nil; |
| 64 |
HashMap<int, GameController *> joypads; |
| 65 |
HashMap<GCController *, int> controller_to_joy_id; |
| 66 |
|
| 67 |
GCControllerPlayerIndex get_free_player_index(); |
| 68 |
|
| 69 |
void add_joypad(GCController *p_controller); |
| 70 |
void remove_joypad(GCController *p_controller); |
| 71 |
|
| 72 |
public: |
| 73 |
JoypadApple(); |
| 74 |
~JoypadApple(); |
| 75 |
|
| 76 |
void joypad_vibration_start(GameController &p_joypad, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); |
| 77 |
void joypad_vibration_stop(GameController &p_joypad, uint64_t p_timestamp) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); |
| 78 |
|
| 79 |
void process_joypads(); |
| 80 |
}; |