Add more darwin bindings

This commit is contained in:
Lucas Perlind
2023-08-31 17:35:05 +10:00
parent 46e7fa52b3
commit 747116aeb0
3 changed files with 199 additions and 3 deletions

View File

@@ -0,0 +1,43 @@
package CoreVideo
DisplayLinkRef :: distinct rawptr
Return :: i32
TimeStamp :: struct {
version: u32,
videoTimeScale: i32,
videoTime: i64,
hostTime: u64,
rateScalar: f64,
videoRefreshPeriod: i64,
smpteTime: CVSMPTETime,
flags: u64,
reserved: u64,
}
CVSMPTETime :: struct {
sbuframes: i16,
subframeDivisor: i16,
count: u32,
type: u32,
flags: u32,
hours: i16,
minutes: i16,
seconds: i16,
frames: i16,
}
OptionFlags :: u64
DisplayLinkOutputCallback :: #type proc "c" (displayLink: DisplayLinkRef, #by_ptr inNow: TimeStamp, #by_ptr inOutputTime: TimeStamp, flagsIn: OptionFlags, flagsOut: ^OptionFlags, displayLinkContext: rawptr) -> Return
foreign import CoreVideo "system:CoreVideo.framework"
@(link_prefix="CV")
foreign CoreVideo {
DisplayLinkCreateWithActiveCGDisplays :: proc "c" (displayLinkOut: ^DisplayLinkRef) -> Return ---
DisplayLinkStart :: proc "c" (displayLink: DisplayLinkRef) -> Return ---
DisplayLinkStop :: proc "c" (displayLink: DisplayLinkRef) -> Return ---
DisplayLinkSetOutputCallback :: proc "c" (displayLink: DisplayLinkRef, callback: DisplayLinkOutputCallback, userInfo: rawptr) -> Return ---
DisplayLinkRelease :: proc "c" (displayLink: DisplayLinkRef) ---
DisplayLinkRetain :: proc "c" (displayLink: DisplayLinkRef) -> DisplayLinkRef ---
}

View File

@@ -105,6 +105,130 @@ PointingDeviceType :: enum UInteger {
Eraser = 3,
}
// Defined in Carbon.framework Events.h
kVK :: enum {
ANSI_A = 0x00,
ANSI_S = 0x01,
ANSI_D = 0x02,
ANSI_F = 0x03,
ANSI_H = 0x04,
ANSI_G = 0x05,
ANSI_Z = 0x06,
ANSI_X = 0x07,
ANSI_C = 0x08,
ANSI_V = 0x09,
ANSI_B = 0x0B,
ANSI_Q = 0x0C,
ANSI_W = 0x0D,
ANSI_E = 0x0E,
ANSI_R = 0x0F,
ANSI_Y = 0x10,
ANSI_T = 0x11,
ANSI_1 = 0x12,
ANSI_2 = 0x13,
ANSI_3 = 0x14,
ANSI_4 = 0x15,
ANSI_6 = 0x16,
ANSI_5 = 0x17,
ANSI_Equal = 0x18,
ANSI_9 = 0x19,
ANSI_7 = 0x1A,
ANSI_Minus = 0x1B,
ANSI_8 = 0x1C,
ANSI_0 = 0x1D,
ANSI_RightBracket = 0x1E,
ANSI_O = 0x1F,
ANSI_U = 0x20,
ANSI_LeftBracket = 0x21,
ANSI_I = 0x22,
ANSI_P = 0x23,
ANSI_L = 0x25,
ANSI_J = 0x26,
ANSI_Quote = 0x27,
ANSI_K = 0x28,
ANSI_Semicolon = 0x29,
ANSI_Backslash = 0x2A,
ANSI_Comma = 0x2B,
ANSI_Slash = 0x2C,
ANSI_N = 0x2D,
ANSI_M = 0x2E,
ANSI_Period = 0x2F,
ANSI_Grave = 0x32,
ANSI_KeypadDecimal = 0x41,
ANSI_KeypadMultiply = 0x43,
ANSI_KeypadPlus = 0x45,
ANSI_KeypadClear = 0x47,
ANSI_KeypadDivide = 0x4B,
ANSI_KeypadEnter = 0x4C,
ANSI_KeypadMinus = 0x4E,
ANSI_KeypadEquals = 0x51,
ANSI_Keypad0 = 0x52,
ANSI_Keypad1 = 0x53,
ANSI_Keypad2 = 0x54,
ANSI_Keypad3 = 0x55,
ANSI_Keypad4 = 0x56,
ANSI_Keypad5 = 0x57,
ANSI_Keypad6 = 0x58,
ANSI_Keypad7 = 0x59,
ANSI_Keypad8 = 0x5B,
ANSI_Keypad9 = 0x5C,
Return = 0x24,
Tab = 0x30,
Space = 0x31,
Delete = 0x33,
Escape = 0x35,
Command = 0x37,
Shift = 0x38,
CapsLock = 0x39,
Option = 0x3A,
Control = 0x3B,
RightCommand = 0x36,
RightShift = 0x3C,
RightOption = 0x3D,
RightControl = 0x3E,
Function = 0x3F,
F17 = 0x40,
VolumeUp = 0x48,
VolumeDown = 0x49,
Mute = 0x4A,
F18 = 0x4F,
F19 = 0x50,
F20 = 0x5A,
F5 = 0x60,
F6 = 0x61,
F7 = 0x62,
F3 = 0x63,
F8 = 0x64,
F9 = 0x65,
F11 = 0x67,
F13 = 0x69,
F16 = 0x6A,
F14 = 0x6B,
F10 = 0x6D,
F12 = 0x6F,
F15 = 0x71,
Help = 0x72,
Home = 0x73,
PageUp = 0x74,
ForwardDelete = 0x75,
F4 = 0x76,
End = 0x77,
F2 = 0x78,
PageDown = 0x79,
F1 = 0x7A,
LeftArrow = 0x7B,
RightArrow = 0x7C,
DownArrow = 0x7D,
UpArrow = 0x7E,
JIS_Yen = 0x5D,
JIS_Underscore = 0x5E,
JIS_KeypadComma = 0x5F,
JIS_Eisu = 0x66,
JIS_Kana = 0x68,
ISO_Section = 0x0A,
}
/* these messages are valid for all events */
@(objc_type=Event, objc_name="type")

View File

@@ -55,7 +55,14 @@ MetalLayer_framebufferOnly :: proc "c" (self: ^MetalLayer) -> NS.BOOL {
MetalLayer_setFramebufferOnly :: proc "c" (self: ^MetalLayer, ok: NS.BOOL) {
msgSend(nil, self, "setFramebufferOnly:", ok)
}
@(objc_type=MetalLayer, objc_name="maximumDrawableCount")
MetalLayer_maximumDrawableCount :: proc "c" (self: ^MetalLayer) -> NS.UInteger {
return msgSend(NS.UInteger, self, "maximumDrawableCount")
}
@(objc_type=MetalLayer, objc_name="setMaximumDrawableCount")
MetalLayer_setMaximumDrawableCount :: proc "c" (self: ^MetalLayer, count: NS.UInteger) {
msgSend(nil, self, "setMaximumDrawableCount:", count)
}
@(objc_type=MetalLayer, objc_name="drawableSize")
MetalLayer_drawableSize :: proc "c" (self: ^MetalLayer) -> NS.Size {
@@ -65,7 +72,22 @@ MetalLayer_drawableSize :: proc "c" (self: ^MetalLayer) -> NS.Size {
MetalLayer_setDrawableSize :: proc "c" (self: ^MetalLayer, drawableSize: NS.Size) {
msgSend(nil, self, "setDrawableSize:", drawableSize)
}
@(objc_type=MetalLayer, objc_name="displaySyncEnabled")
MetalLayer_displaySyncEnabled :: proc "c" (self: ^MetalLayer) -> NS.BOOL {
return msgSend(NS.BOOL, self, "displaySyncEnabled")
}
@(objc_type=MetalLayer, objc_name="setDisplaySyncEnabled")
MetalLayer_setDisplaySyncEnabled :: proc "c" (self: ^MetalLayer, enabled: NS.BOOL) {
msgSend(nil, self, "setDisplaySyncEnabled:", enabled)
}
@(objc_type=MetalLayer, objc_name="presentsWithTransaction")
MetalLayer_presentsWithTransaction :: proc "c" (self: ^MetalLayer) -> NS.BOOL {
return msgSend(NS.BOOL, self, "presentsWithTransaction")
}
@(objc_type=MetalLayer, objc_name="setPresentsWithTransaction")
MetalLayer_setPresentsWithTransaction :: proc "c" (self: ^MetalLayer, enabled: NS.BOOL) {
msgSend(nil, self, "setPresentsWithTransaction:", enabled)
}
@(objc_type=MetalLayer, objc_name="frame")
MetalLayer_frame :: proc "c" (self: ^MetalLayer) -> NS.Rect {
@@ -95,4 +117,11 @@ MetalDrawable_layer :: proc "c" (self: ^MetalDrawable) -> ^MetalLayer {
@(objc_type=MetalDrawable, objc_name="texture")
MetalDrawable_texture :: proc "c" (self: ^MetalDrawable) -> ^MTL.Texture {
return msgSend(^MTL.Texture, self, "texture")
}
}
DrawablePresentedHandler :: ^NS.Block
@(objc_type=MetalDrawable, objc_name="addPresentedHandler")
MetalDrawable_addPresentedHandler :: proc "c" (self: ^MetalDrawable, block: DrawablePresentedHandler) {
msgSend(nil, self, "addPresentedHandler:", block)
}