Skip to content

Commit

Permalink
Initial boilerplate for the Applesauce.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgiven committed Sep 28, 2024
1 parent a4a83c6 commit 2840831
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/usb/applesauce.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#define APPLESAUCE_VID 0x16c0
#define APPLESAUCE_PID 0x0483

#define APPLESAUCE_ID ((APPLESAUCE_VID << 16) | APPLESAUCE_PID)
9 changes: 9 additions & 0 deletions lib/usb/usb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "lib/proto.h"
#include "usbfinder.h"
#include "lib/logger.h"
#include "applesauce.h"
#include "greaseweazle.h"

static USB* usb = NULL;
Expand Down Expand Up @@ -54,6 +55,11 @@ static std::shared_ptr<CandidateDevice> selectDevice()
std::cerr << fmt::format(
"Greaseweazle: {} on {}\n", c->serial, c->serialPort);
break;

case APPLESAUCE_ID:
std::cerr << fmt::format(
"Applesauce: {} on {}\n", c->serial, c->serialPort);
break;
}
}
exit(1);
Expand Down Expand Up @@ -87,6 +93,9 @@ USB* get_usb_impl()
return createGreaseweazleUsb(
candidate->serialPort, globalConfig()->usb().greaseweazle());

case APPLESAUCE_ID:
error("Applesauce not supported yet");

default:
error("internal");
}
Expand Down
6 changes: 5 additions & 1 deletion lib/usb/usbfinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
#include "usb.h"
#include "lib/bytes.h"
#include "usbfinder.h"
#include "applesauce.h"
#include "greaseweazle.h"
#include "protocol.h"
#include "libusbp.hpp"

static const std::set<uint32_t> VALID_DEVICES = {
GREASEWEAZLE_ID, FLUXENGINE_ID};
GREASEWEAZLE_ID, FLUXENGINE_ID, APPLESAUCE_ID};

static const std::string get_serial_number(const libusbp::device& device)
{
Expand Down Expand Up @@ -71,6 +72,9 @@ std::string getDeviceName(DeviceType type)
case DEVICE_FLUXENGINE:
return "FluxEngine";

case DEVICE_APPLESAUCE:
return "Applesauce";

default:
return "unknown";
}
Expand Down
3 changes: 2 additions & 1 deletion lib/usb/usbfinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
enum DeviceType
{
DEVICE_FLUXENGINE,
DEVICE_GREASEWEAZLE
DEVICE_GREASEWEAZLE,
DEVICE_APPLESAUCE,
};

extern std::string getDeviceName(DeviceType type);
Expand Down

0 comments on commit 2840831

Please sign in to comment.