Files
armorpaint/base/sources/backends/macos_system.h
T

76 lines
2.0 KiB
C
Raw Normal View History

2025-02-26 18:46:36 +01:00
#import <MetalKit/MTKView.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#include <IOKit/hid/IOHIDManager.h>
#include <iron_global.h>
2025-07-31 22:13:40 +02:00
@interface BasicMTKView : MTKView {
2025-02-26 18:46:36 +01:00
@private
id<MTLDevice> device;
id<MTLCommandQueue> commandQueue;
id<MTLLibrary> library;
}
- (CAMetalLayer *)metalLayer;
- (id<MTLDevice>)metalDevice;
- (id<MTLCommandQueue>)metalQueue;
- (void)keyDown:(NSEvent *)theEvent;
- (void)keyUp:(NSEvent *)theEvent;
- (void)mouseDown:(NSEvent *)theEvent;
- (void)mouseUp:(NSEvent *)theEvent;
- (void)mouseMoved:(NSEvent *)theEvent;
- (void)mouseDragged:(NSEvent *)theEvent;
- (void)rightMouseDown:(NSEvent *)theEvent;
- (void)rightMouseUp:(NSEvent *)theEvent;
- (void)rightMouseDragged:(NSEvent *)theEvent;
- (void)scrollWheel:(NSEvent *)theEvent;
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender;
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender;
- (BOOL)acceptsFirstResponder;
- (BOOL)becomeFirstResponder;
- (BOOL)resignFirstResponder;
- (id)initWithFrame:(NSRect)frameRect;
- (void)resize:(NSSize)size;
@end
2025-08-03 13:23:42 +02:00
#ifdef WITH_GAMEPAD
2025-02-26 18:46:36 +01:00
struct HIDGamepad {
int padIndex;
IOHIDDeviceRef hidDeviceRef;
IOHIDQueueRef hidQueueRef;
int hidDeviceVendorID;
int hidDeviceProductID;
char hidDeviceVendor[64];
char hidDeviceProduct[64];
IOHIDElementCookie axis[6];
IOHIDElementCookie buttons[15];
};
void HIDGamepad_init(struct HIDGamepad *gamepad);
void HIDGamepad_destroy(struct HIDGamepad *gamepad);
void HIDGamepad_bind(struct HIDGamepad *gamepad, IOHIDDeviceRef deviceRef, int padIndex);
void HIDGamepad_unbind(struct HIDGamepad *gamepad);
2025-08-03 13:23:42 +02:00
static const int IRON_MAX_HID_DEVICES = 8;
2025-02-26 18:46:36 +01:00
// Slots to hold details on connected devices
struct HIDManagerDeviceRecord {
bool connected; // = false;
IOHIDDeviceRef device; // = NULL;
struct HIDGamepad pad;
};
struct HIDManager {
IOHIDManagerRef managerRef;
2025-03-09 17:02:12 +01:00
struct HIDManagerDeviceRecord devices[IRON_MAX_HID_DEVICES];
2025-02-26 18:46:36 +01:00
};
void HIDManager_init(struct HIDManager *manager);
void HIDManager_destroy(struct HIDManager *manager);
2025-08-03 13:23:42 +02:00
#endif