/ CoreGraphics / CGEventSource.m
CGEventSource.m
1 /* 2 This file is part of Darling. 3 4 Copyright (C) 2020 Lubos Dolezel 5 6 Darling is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 Darling is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #include "CGEventObjC.h" 20 #include <CoreGraphics/CGEventSource.h> 21 22 static CGEventFlags g_sourceStates[3]; 23 24 CFTypeID CGEventSourceGetTypeID(void) { 25 return (CFTypeID)[CGEventSource self]; 26 } 27 28 CGEventSourceRef CGEventSourceCreate(CGEventSourceStateID stateID) { 29 return (CGEventSourceRef) [[CGEventSource alloc] initWithState: stateID]; 30 } 31 32 CGEventSourceKeyboardType CGEventSourceGetKeyboardType(CGEventSourceRef source) 33 { 34 CGEventSource *src = (CGEventSource *) source; 35 return src.keyboardType; 36 } 37 38 void CGEventSourceSetKeyboardType(CGEventSourceRef source, 39 CGEventSourceKeyboardType keyboardType) 40 { 41 CGEventSource *src = (CGEventSource *) source; 42 src.keyboardType = keyboardType; 43 } 44 45 CGEventSourceStateID CGEventSourceGetSourceStateID(CGEventSourceRef source) { 46 CGEventSource *src = (CGEventSource *) source; 47 return src.stateID; 48 } 49 50 int64_t CGEventSourceGetUserData(CGEventSourceRef source) { 51 CGEventSource *src = (CGEventSource *) source; 52 return src.userData; 53 } 54 55 void CGEventSourceSetUserData(CGEventSourceRef source, int64_t userData) { 56 CGEventSource *src = (CGEventSource *) source; 57 src.userData = userData; 58 } 59 60 double CGEventSourceGetPixelsPerLine(CGEventSourceRef source) { 61 CGEventSource *src = (CGEventSource *) source; 62 return src.pixelsPerLine; 63 } 64 65 void CGEventSourceSetPixelsPerLine(CGEventSourceRef source, 66 double pixelsPerLine) 67 { 68 CGEventSource *src = (CGEventSource *) source; 69 src.pixelsPerLine = pixelsPerLine; 70 } 71 72 CGEventFlags CGEventSourceFlagsState(CGEventSourceStateID stateID) { 73 return g_sourceStates[stateID + 1]; 74 }