macos_system.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. - (BOOL)acceptsFirstResponder;
  28. - (BOOL)becomeFirstResponder;
  29. - (BOOL)resignFirstResponder;
  30. - (id)initWithFrame:(NSRect)frameRect;
  31. - (void)resize:(NSSize)size;
  32. @end
  33. #ifdef WITH_GAMEPAD
  34. struct HIDGamepad {
  35. int padIndex;
  36. IOHIDDeviceRef hidDeviceRef;
  37. IOHIDQueueRef hidQueueRef;
  38. int hidDeviceVendorID;
  39. int hidDeviceProductID;
  40. char hidDeviceVendor[64];
  41. char hidDeviceProduct[64];
  42. IOHIDElementCookie axis[6];
  43. IOHIDElementCookie buttons[15];
  44. };
  45. void HIDGamepad_init(struct HIDGamepad *gamepad);
  46. void HIDGamepad_destroy(struct HIDGamepad *gamepad);
  47. void HIDGamepad_bind(struct HIDGamepad *gamepad, IOHIDDeviceRef deviceRef, int padIndex);
  48. void HIDGamepad_unbind(struct HIDGamepad *gamepad);
  49. static const int IRON_MAX_HID_DEVICES = 8;
  50. // Slots to hold details on connected devices
  51. struct HIDManagerDeviceRecord {
  52. bool connected; // = false;
  53. IOHIDDeviceRef device; // = NULL;
  54. struct HIDGamepad pad;
  55. };
  56. struct HIDManager {
  57. IOHIDManagerRef managerRef;
  58. struct HIDManagerDeviceRecord devices[IRON_MAX_HID_DEVICES];
  59. };
  60. void HIDManager_init(struct HIDManager *manager);
  61. void HIDManager_destroy(struct HIDManager *manager);
  62. #endif