Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the use of CM108 for PTT on Mac #500

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
mfncooper committed Nov 16, 2023
commit b03a797ec4b1bd320586ebd98474adabe634be4c
20 changes: 11 additions & 9 deletions src/cm108.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ int main (void)
#if __WIN32__
#include <wchar.h>
#include "hidapi.h"
#elif __APPLE__
#include "hidapi.h"
#else
#include <libudev.h>
#include <sys/types.h>
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down