aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ambient_light_sensor.c6
-rw-r--r--keyboard_light.c6
-rw-r--r--smc.c6
-rw-r--r--sudden_motion_sensor.c6
4 files changed, 20 insertions, 4 deletions
diff --git a/ambient_light_sensor.c b/ambient_light_sensor.c
index 4e7df0a..26c18db 100644
--- a/ambient_light_sensor.c
+++ b/ambient_light_sensor.c
@@ -26,6 +26,7 @@
#include <mach/mach.h>
#include <IOKit/IOKitLib.h>
#include <CoreFoundation/CoreFoundation.h>
+#include <CoreServices/CoreServices.h>
#include <m_pd.h>
#define DEBUG(x)
@@ -76,9 +77,11 @@ static void ambient_light_sensor_output(t_ambient_light_sensor* x)
#if !defined(__LP64__)
// Check if Mac OS X 10.5 API is available...
- if (IOConnectCallScalarMethod != NULL) {
+ SInt32 MacVersion;
+ if ((Gestalt(gestaltSystemVersion, &MacVersion) == noErr) && (MacVersion >= 0x1050)) {
// ...and use it if it is.
#endif
+#ifdef AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
uint64_t inputValues[0];
uint32_t inputCount = 0;
uint64_t outputValues[2];
@@ -91,6 +94,7 @@ static void ambient_light_sensor_output(t_ambient_light_sensor* x)
&outputCount);
left = (t_float) (outputValues[0] / 2000.0);
right = (t_float) (outputValues[1] / 2000.0);
+#endif
#if !defined(__LP64__)
}
else {
diff --git a/keyboard_light.c b/keyboard_light.c
index b7c0b96..042d7c7 100644
--- a/keyboard_light.c
+++ b/keyboard_light.c
@@ -26,6 +26,7 @@
#include <mach/mach.h>
#include <IOKit/IOKitLib.h>
#include <CoreFoundation/CoreFoundation.h>
+#include <CoreServices/CoreServices.h>
#include <m_pd.h>
#define DEBUG(x)
@@ -133,9 +134,11 @@ static void keyboard_light_float(t_keyboard_light* x, t_float f)
#if !defined(__LP64__)
// Check if Mac OS X 10.5 API is available...
- if (IOConnectCallScalarMethod != NULL) {
+ SInt32 MacVersion;
+ if ((Gestalt(gestaltSystemVersion, &MacVersion) == noErr) && (MacVersion >= 0x1050)) {
// ...and use it if it is.
#endif
+#ifdef AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
uint64_t inputValues[3];
uint32_t inputCount = 3;
uint64_t outputValues[1];
@@ -149,6 +152,7 @@ static void keyboard_light_float(t_keyboard_light* x, t_float f)
inputCount,
outputValues,
&outputCount);
+#endif
#if !defined(__LP64__)
}
else {
diff --git a/smc.c b/smc.c
index e1b60a2..0403baf 100644
--- a/smc.c
+++ b/smc.c
@@ -31,6 +31,7 @@
#include <string.h>
#include <ctype.h>
#include <IOKit/IOKitLib.h>
+#include <CoreServices/CoreServices.h>
#include "m_pd.h"
#include "smc.h"
@@ -167,9 +168,11 @@ kern_return_t SMCCall(int index, SMCKeyData_t *inputStructure, SMCKeyData_t *out
structureOutputSize = sizeof(SMCKeyData_t);
#if !defined(__LP64__)
// Check if Mac OS X 10.5 API is available...
- if (IOConnectCallStructMethod != NULL) {
+ SInt32 MacVersion;
+ if ((Gestalt(gestaltSystemVersion, &MacVersion) == noErr) && (MacVersion >= 0x1050)) {
// ...and use it if it is.
#endif
+#ifdef AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
return IOConnectCallStructMethod(
conn, // an io_connect_t returned from IOServiceOpen().
index, // selector of the function to be called via the user client.
@@ -178,6 +181,7 @@ kern_return_t SMCCall(int index, SMCKeyData_t *inputStructure, SMCKeyData_t *out
outputStructure, // pointer to the output struct parameter.
&structureOutputSize// pointer to the size of the output structure parameter.
);
+#endif
#if !defined(__LP64__)
}
else {
diff --git a/sudden_motion_sensor.c b/sudden_motion_sensor.c
index a9daa89..71f170a 100644
--- a/sudden_motion_sensor.c
+++ b/sudden_motion_sensor.c
@@ -26,6 +26,7 @@
#include <mach/mach.h>
#include <IOKit/IOKitLib.h>
#include <CoreFoundation/CoreFoundation.h>
+#include <CoreServices/CoreServices.h>
#include <m_pd.h>
#define DEBUG(x)
@@ -144,9 +145,11 @@ FOUND_SENSOR:
#if !defined(__LP64__)
// Check if Mac OS X 10.5 API is available...
- if (IOConnectCallStructMethod != NULL) {
+ SInt32 MacVersion;
+ if ((Gestalt(gestaltSystemVersion, &MacVersion) == noErr) && (MacVersion >= 0x1050)) {
// ...and use it if it is.
#endif
+#ifdef AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
kern_return = IOConnectCallStructMethod(
io_connect, // an io_connect_t returned from IOServiceOpen().
kernel_function, // selector of the function to be called via the user client.
@@ -155,6 +158,7 @@ FOUND_SENSOR:
&outputStructure, // pointer to the output struct parameter.
&structureOutputSize// pointer to the size of the output structure parameter.
);
+#endif
#if !defined(__LP64__)
}
else {