macos_system.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #import <MetalKit/MTKView.h>
  2. #include <IOKit/IOKitLib.h>
  3. #include <IOKit/hid/IOHIDKeys.h>
  4. #include <IOKit/hid/IOHIDManager.h>
  5. #include <iron_global.h>
  6. @interface BasicMTKView : MTKView {
  7. @private
  8. id<MTLDevice> device;
  9. id<MTLCommandQueue> commandQueue;
  10. id<MTLLibrary> library;
  11. }
  12. - (CAMetalLayer *)metalLayer;
  13. - (id<MTLDevice>)metalDevice;
  14. - (id<MTLCommandQueue>)metalQueue;
  15. - (void)keyDown:(NSEvent *)theEvent;
  16. - (void)keyUp:(NSEvent *)theEvent;
  17. - (void)mouseDown:(NSEvent *)theEvent;
  18. - (void)mouseUp:(NSEvent *)theEvent;
  19. - (void)mouseMoved:(NSEvent *)theEvent;
  20. - (void)mouseDragged:(NSEvent *)theEvent;
  21. - (void)rightMouseDown:(NSEvent *)theEvent;
  22. - (void)rightMouseUp:(NSEvent *)theEvent;
  23. - (void)rightMouseDragged:(NSEvent *)theEvent;
  24. - (void)scrollWheel:(NSEvent *)theEvent;
  25. - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender;
  26. - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender;
  27. - (void)update;
  28. - (BOOL)acceptsFirstResponder;
  29. - (BOOL)becomeFirstResponder;
  30. - (BOOL)resignFirstResponder;
  31. - (id)initWithFrame:(NSRect)frameRect;
  32. - (void)resize:(NSSize)size;
  33. @end
  34. #ifdef WITH_GAMEPAD
  35. struct HIDGamepad {
  36. int padIndex;
  37. IOHIDDeviceRef hidDeviceRef;
  38. IOHIDQueueRef hidQueueRef;
  39. int hidDeviceVendorID;
  40. int hidDeviceProductID;
  41. char hidDeviceVendor[64];
  42. char hidDeviceProduct[64];
  43. IOHIDElementCookie axis[6];
  44. IOHIDElementCookie buttons[15];
  45. };
  46. void HIDGamepad_init(struct HIDGamepad *gamepad);
  47. void HIDGamepad_destroy(struct HIDGamepad *gamepad);
  48. void HIDGamepad_bind(struct HIDGamepad *gamepad, IOHIDDeviceRef deviceRef, int padIndex);
  49. void HIDGamepad_unbind(struct HIDGamepad *gamepad);
  50. static const int IRON_MAX_HID_DEVICES = 8;
  51. // Slots to hold details on connected devices
  52. struct HIDManagerDeviceRecord {
  53. bool connected; // = false;
  54. IOHIDDeviceRef device; // = NULL;
  55. struct HIDGamepad pad;
  56. };
  57. struct HIDManager {
  58. IOHIDManagerRef managerRef;
  59. struct HIDManagerDeviceRecord devices[IRON_MAX_HID_DEVICES];
  60. };
  61. void HIDManager_init(struct HIDManager *manager);
  62. void HIDManager_destroy(struct HIDManager *manager);
  63. #endif