2024-05-22 09:18:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
2024-05-22 10:11:51 +00:00
|
|
|
#include <map>
|
2024-06-05 21:27:03 +00:00
|
|
|
#include <string_view>
|
2024-05-22 10:11:51 +00:00
|
|
|
|
2024-05-22 09:18:03 +00:00
|
|
|
#import <GameController/GameController.h>
|
2024-06-04 09:51:09 +00:00
|
|
|
#import <CoreMotion/CoreMotion.h>
|
|
|
|
|
2024-05-22 10:11:51 +00:00
|
|
|
#include "iCade/iCadeState.h"
|
|
|
|
#include "Common/Input/InputState.h"
|
2024-05-22 09:18:03 +00:00
|
|
|
|
2024-05-22 08:38:40 +00:00
|
|
|
// Code extracted from ViewController.mm, in order to modularize
|
|
|
|
// and share it between multiple view controllers.
|
|
|
|
|
2024-06-05 13:01:02 +00:00
|
|
|
bool InitController(GCController *controller);
|
|
|
|
void ShutdownController(GCController *controller);
|
2024-05-22 09:59:26 +00:00
|
|
|
|
|
|
|
struct TouchTracker {
|
2024-05-22 10:11:51 +00:00
|
|
|
public:
|
2024-05-22 09:59:26 +00:00
|
|
|
void Began(NSSet *touches, UIView *view);
|
|
|
|
void Moved(NSSet *touches, UIView *view);
|
|
|
|
void Ended(NSSet *touches, UIView *view);
|
|
|
|
void Cancelled(NSSet *touches, UIView *view);
|
|
|
|
private:
|
|
|
|
void SendTouchEvent(float x, float y, int code, int pointerId);
|
|
|
|
int ToTouchID(UITouch *uiTouch, bool allowAllocate);
|
|
|
|
UITouch *touches_[10]{};
|
2024-05-22 10:11:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Can probably get rid of this, but let's keep it for now.
|
|
|
|
struct ICadeTracker {
|
|
|
|
public:
|
|
|
|
void ButtonDown(iCadeState button);
|
|
|
|
void ButtonUp(iCadeState button);
|
|
|
|
void InitKeyMap();
|
|
|
|
private:
|
|
|
|
bool simulateAnalog = false;
|
|
|
|
bool iCadeConnectNotified = false;
|
|
|
|
|
|
|
|
std::map<uint16_t, InputKeyCode> iCadeToKeyMap;
|
|
|
|
|
|
|
|
double lastSelectPress = 0.0f;
|
|
|
|
double lastStartPress = 0.0f;
|
|
|
|
};
|
2024-06-04 09:51:09 +00:00
|
|
|
|
2024-06-05 21:27:03 +00:00
|
|
|
void ProcessAccelerometerData(CMAccelerometerData *accData);
|
|
|
|
InputKeyCode HIDUsageToInputKeyCode(UIKeyboardHIDUsage usage);
|
|
|
|
|
|
|
|
void KeyboardPressesBegan(NSSet<UIPress *> *presses, UIPressesEvent *event);
|
|
|
|
void KeyboardPressesEnded(NSSet<UIPress *> *presses, UIPressesEvent *event);
|
|
|
|
void SendKeyboardChars(std::string_view str);
|