Skip to content

Commit b03a797

Browse files
committed
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.
1 parent 2260df1 commit b03a797

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Diff for: src/cm108.c

+11-9
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ int main (void)
138138
#if __WIN32__
139139
#include <wchar.h>
140140
#include "hidapi.h"
141+
#elif __APPLE__
142+
#include "hidapi.h"
141143
#else
142144
#include <libudev.h>
143145
#include <sys/types.h>
@@ -240,7 +242,7 @@ static int cm108_write (char *name, int iomask, int iodata);
240242

241243
// Used to process regular expression matching results.
242244

243-
#ifndef __WIN32__
245+
#if !defined(__WIN32__) && !defined(__APPLE__)
244246

245247
static void substr_se (char *dest, const char *src, int start, int endp1)
246248
{
@@ -317,7 +319,7 @@ static void usage(void)
317319
dw_printf ("Usage: cm108 [ device-path [ gpio-num ] ]\n");
318320
dw_printf ("\n");
319321
dw_printf ("With no command line arguments, this will produce a list of\n");
320-
#if __WIN32__
322+
#if __WIN32__ || __APPLE__
321323
dw_printf ("Human Interface Devices (HID) and indicate which ones can be\n");
322324
dw_printf ("used for GPIO PTT.\n");
323325
#else
@@ -375,11 +377,11 @@ int main (int argc, char **argv)
375377

376378
num_things = cm108_inventory (things, MAXX_THINGS);
377379

378-
#if __WIN32__
380+
#if __WIN32__ || __APPLE__
379381

380-
/////////////////////////////////////////////////////
381-
// Windows - Remove the sound related columns for now.
382-
/////////////////////////////////////////////////////
382+
////////////////////////////////////////////////////////////
383+
// Windows & Mac - Remove the sound related columns for now.
384+
////////////////////////////////////////////////////////////
383385

384386
dw_printf (" VID PID %-*s %-*s"
385387
"\n", (int)sizeof(things[0].product), "Product",
@@ -539,7 +541,7 @@ int cm108_inventory (struct thing_s *things, int max_things)
539541
int num_things = 0;
540542
memset (things, 0, sizeof(struct thing_s) * max_things);
541543

542-
#if __WIN32__
544+
#if __WIN32__ || __APPLE__
543545

544546
struct hid_device_info *devs, *cur_dev;
545547

@@ -779,7 +781,7 @@ void cm108_find_ptt (char *output_audio_device, char *ptt_device, int ptt_devic
779781
// Possible improvement: Skip if inventory already taken.
780782
num_things = cm108_inventory (things, MAXX_THINGS);
781783

782-
#if __WIN32__
784+
#if __WIN32__ || __APPLE__
783785
// FIXME - This is just a half baked implementation.
784786
// I have not been able to figure out how to find the connection
785787
// 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)
934936
static int cm108_write (char *name, int iomask, int iodata)
935937
{
936938

937-
#if __WIN32__
939+
#if __WIN32__ || __APPLE__
938940

939941
//text_color_set(DW_COLOR_DEBUG);
940942
//dw_printf ("TEMP DEBUG cm108_write: %s %d %d\n", name, iomask, iodata);

0 commit comments

Comments
 (0)