From b03a797ec4b1bd320586ebd98474adabe634be4c Mon Sep 17 00:00:00 2001 From: Martin Cooper Date: Wed, 15 Nov 2023 17:00:53 -0800 Subject: [PATCH] Add support for the use of CM108 for PTT on Mac Support for CM108-based PTT on Mac is provided using the hidapi library in the same way as on Windows. As such, the code changes are limited almost entirely to updated #if conditions, treating Windows and Mac in the same way. --- src/cm108.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cm108.c b/src/cm108.c index ff3ff79..27e5887 100644 --- a/src/cm108.c +++ b/src/cm108.c @@ -138,6 +138,8 @@ int main (void) #if __WIN32__ #include #include "hidapi.h" +#elif __APPLE__ +#include "hidapi.h" #else #include #include @@ -240,7 +242,7 @@ static int cm108_write (char *name, int iomask, int iodata); // Used to process regular expression matching results. -#ifndef __WIN32__ +#if !defined(__WIN32__) && !defined(__APPLE__) static void substr_se (char *dest, const char *src, int start, int endp1) { @@ -317,7 +319,7 @@ static void usage(void) dw_printf ("Usage: cm108 [ device-path [ gpio-num ] ]\n"); dw_printf ("\n"); dw_printf ("With no command line arguments, this will produce a list of\n"); -#if __WIN32__ +#if __WIN32__ || __APPLE__ dw_printf ("Human Interface Devices (HID) and indicate which ones can be\n"); dw_printf ("used for GPIO PTT.\n"); #else @@ -375,11 +377,11 @@ int main (int argc, char **argv) num_things = cm108_inventory (things, MAXX_THINGS); -#if __WIN32__ +#if __WIN32__ || __APPLE__ -///////////////////////////////////////////////////// -// Windows - Remove the sound related columns for now. -///////////////////////////////////////////////////// +//////////////////////////////////////////////////////////// +// Windows & Mac - Remove the sound related columns for now. +//////////////////////////////////////////////////////////// dw_printf (" VID PID %-*s %-*s" "\n", (int)sizeof(things[0].product), "Product", @@ -539,7 +541,7 @@ int cm108_inventory (struct thing_s *things, int max_things) int num_things = 0; memset (things, 0, sizeof(struct thing_s) * max_things); -#if __WIN32__ +#if __WIN32__ || __APPLE__ struct hid_device_info *devs, *cur_dev; @@ -779,7 +781,7 @@ void cm108_find_ptt (char *output_audio_device, char *ptt_device, int ptt_devic // Possible improvement: Skip if inventory already taken. num_things = cm108_inventory (things, MAXX_THINGS); -#if __WIN32__ +#if __WIN32__ || __APPLE__ // FIXME - This is just a half baked implementation. // I have not been able to figure out how to find the connection // between the audio device and HID in the same package. @@ -934,7 +936,7 @@ int cm108_set_gpio_pin (char *name, int num, int state) static int cm108_write (char *name, int iomask, int iodata) { -#if __WIN32__ +#if __WIN32__ || __APPLE__ //text_color_set(DW_COLOR_DEBUG); //dw_printf ("TEMP DEBUG cm108_write: %s %d %d\n", name, iomask, iodata);