narrow dependencies on Carbon
(reduced Carbon footprint?)
This commit is contained in:
parent
4dc47ef413
commit
31231a6a8d
|
@ -8,28 +8,26 @@
|
||||||
(require ffi/unsafe
|
(require ffi/unsafe
|
||||||
ffi/unsafe/objc
|
ffi/unsafe/objc
|
||||||
ffi/unsafe/define
|
ffi/unsafe/define
|
||||||
mred/private/wx/cocoa/types) ; _NSString
|
"types.rkt"
|
||||||
|
"utils.rkt")
|
||||||
|
|
||||||
;;; Bit operations
|
;;; Bit operations
|
||||||
(define (<< x y) (arithmetic-shift x y))
|
(define (<< x y) (arithmetic-shift x y))
|
||||||
(define (>> x y) (arithmetic-shift x (- y)))
|
(define (>> x y) (arithmetic-shift x (- y)))
|
||||||
|
|
||||||
;;; Libraries used
|
;;; Libraries used
|
||||||
(define quartz-lib (ffi-lib "/System/Library/Frameworks/Quartz.framework/Versions/Current/Quartz"))
|
(define carboncore-lib
|
||||||
(define carbon-lib (ffi-lib "/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon"))
|
(ffi-lib (string-append "/System/Library/Frameworks/CoreServices.framework/Versions/Current/"
|
||||||
(define carbon-core-lib
|
|
||||||
(ffi-lib (string-append "/System/Library/Frameworks/CoreServices.framework/"
|
|
||||||
"Frameworks/CarbonCore.framework/Versions/Current/CarbonCore")))
|
"Frameworks/CarbonCore.framework/Versions/Current/CarbonCore")))
|
||||||
(define cf-lib (ffi-lib "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation"))
|
(define hitoolbox-lib
|
||||||
|
(ffi-lib (string-append "/System/Library/Frameworks/Carbon.framework/Versions/Current/"
|
||||||
|
"Frameworks/HIToolbox.framework/Versions/Current/HIToolbox")))
|
||||||
|
|
||||||
(define-ffi-definer define-quartz quartz-lib)
|
(define-ffi-definer define-carboncore carboncore-lib)
|
||||||
(define-ffi-definer define-carbon-core carbon-core-lib)
|
(define-ffi-definer define-hitoolbox hitoolbox-lib)
|
||||||
(define-ffi-definer define-carbon carbon-lib)
|
|
||||||
(define-ffi-definer define-cf cf-lib #:default-make-fail make-not-available)
|
|
||||||
|
|
||||||
;;; CORE FOUNDATION
|
;;; CORE FOUNDATION
|
||||||
|
|
||||||
(import-class NSString)
|
|
||||||
(define _CFStringRef _NSString)
|
(define _CFStringRef _NSString)
|
||||||
|
|
||||||
; (define _OSStatus _sint32) ; already imported
|
; (define _OSStatus _sint32) ; already imported
|
||||||
|
@ -56,15 +54,15 @@
|
||||||
; A keyboard layout determines which character corresponds to a physical key.
|
; A keyboard layout determines which character corresponds to a physical key.
|
||||||
|
|
||||||
; To get a layout, one must first get a reference to the input source:
|
; To get a layout, one must first get a reference to the input source:
|
||||||
(define-carbon TISCopyCurrentKeyboardLayoutInputSource (_fun -> _TISInputSourceRef))
|
(define-hitoolbox TISCopyCurrentKeyboardLayoutInputSource (_fun -> _TISInputSourceRef))
|
||||||
(define-carbon TISCopyCurrentASCIICapableKeyboardLayoutInputSource (_fun -> _TISInputSourceRef))
|
(define-hitoolbox TISCopyCurrentASCIICapableKeyboardLayoutInputSource (_fun -> _TISInputSourceRef))
|
||||||
; Note: These days TISCopyCurrentKeyboardLayoutInputSource ought to work for all keyboards.
|
; Note: These days TISCopyCurrentKeyboardLayoutInputSource ought to work for all keyboards.
|
||||||
|
|
||||||
; The input source has several properties, one of is:
|
; The input source has several properties, one of is:
|
||||||
(define-carbon kTISPropertyUnicodeKeyLayoutData _NSString)
|
(define-hitoolbox kTISPropertyUnicodeKeyLayoutData _NSString)
|
||||||
|
|
||||||
; Getting the property is done by:
|
; Getting the property is done by:
|
||||||
(define-carbon TISGetInputSourceProperty
|
(define-hitoolbox TISGetInputSourceProperty
|
||||||
(_fun (_inputSource : _TISInputSourceRef)
|
(_fun (_inputSource : _TISInputSourceRef)
|
||||||
(_propertyKey : _CFStringRef)
|
(_propertyKey : _CFStringRef)
|
||||||
-> (_or-null _CFDataRef)))
|
-> (_or-null _CFDataRef)))
|
||||||
|
@ -78,12 +76,12 @@
|
||||||
|
|
||||||
; Before translating key codes to characters, one must option
|
; Before translating key codes to characters, one must option
|
||||||
; the physical type of keyboard.
|
; the physical type of keyboard.
|
||||||
(define-carbon LMGetKbdType (_fun -> _uint8))
|
(define-hitoolbox LMGetKbdType (_fun -> _uint8))
|
||||||
|
|
||||||
; Given a layout and a keyboard type, one can translate
|
; Given a layout and a keyboard type, one can translate
|
||||||
; keycodes to characters using UCKeyTranslate.
|
; keycodes to characters using UCKeyTranslate.
|
||||||
|
|
||||||
(define-carbon UCKeyTranslate
|
(define-carboncore UCKeyTranslate
|
||||||
(_fun (keyboardLayoutPtr : _UCKeyboardLayout)
|
(_fun (keyboardLayoutPtr : _UCKeyboardLayout)
|
||||||
(virtualKeyCode : _uint16)
|
(virtualKeyCode : _uint16)
|
||||||
(keyAction : _uint16)
|
(keyAction : _uint16)
|
||||||
|
@ -92,7 +90,6 @@
|
||||||
(keyTranslateOptions : _OptionBits) ; uint32
|
(keyTranslateOptions : _OptionBits) ; uint32
|
||||||
(deadKeyState : (_box _uint32))
|
(deadKeyState : (_box _uint32))
|
||||||
(maxStringLength : _UniCharCount)
|
(maxStringLength : _UniCharCount)
|
||||||
; (actualStringLength : _UniCharCountPointer)
|
|
||||||
(actualStringLength : (_box _UniCharCount))
|
(actualStringLength : (_box _UniCharCount))
|
||||||
(unicodeString : _pointer)
|
(unicodeString : _pointer)
|
||||||
-> _OSStatus))
|
-> _OSStatus))
|
||||||
|
@ -576,7 +573,3 @@
|
||||||
(define mods (if (list? k+ms) (cadddr k+ms) #f))
|
(define mods (if (list? k+ms) (cadddr k+ms) #f))
|
||||||
(values mck mods))
|
(values mck mods))
|
||||||
(values #f #f)))
|
(values #f #f)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user