mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-08-21 09:48:51 +00:00
haze: misc comments
This commit is contained in:
parent
5298712061
commit
6c99a828af
4 changed files with 26 additions and 9 deletions
|
@ -138,7 +138,7 @@ namespace haze {
|
||||||
printf("\n" CONSOLE_ESC(38;5;196m) "Applet Mode" CONSOLE_ESC(0m) "\n");
|
printf("\n" CONSOLE_ESC(38;5;196m) "Applet Mode" CONSOLE_ESC(0m) "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
consoleUpdate(NULL);
|
consoleUpdate(nullptr);
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
void ProcessEvent() override {
|
void ProcessEvent() override {
|
||||||
|
|
|
@ -27,27 +27,31 @@ namespace haze {
|
||||||
u32 m_received_size;
|
u32 m_received_size;
|
||||||
u32 m_offset;
|
u32 m_offset;
|
||||||
u8 *m_data;
|
u8 *m_data;
|
||||||
bool m_eos;
|
bool m_eot;
|
||||||
private:
|
private:
|
||||||
Result Flush() {
|
Result Flush() {
|
||||||
R_UNLESS(!m_eos, haze::ResultEndOfTransmission());
|
R_UNLESS(!m_eot, haze::ResultEndOfTransmission());
|
||||||
|
|
||||||
m_received_size = 0;
|
m_received_size = 0;
|
||||||
m_offset = 0;
|
m_offset = 0;
|
||||||
|
|
||||||
ON_SCOPE_EXIT { m_eos = m_received_size < haze::UsbBulkPacketBufferSize; };
|
ON_SCOPE_EXIT {
|
||||||
|
/* End of transmission occurs when receiving a bulk transfer less than the buffer size. */
|
||||||
|
/* PTP uses zero-length termination, so zero is a possible size to receive. */
|
||||||
|
m_eot = m_received_size < haze::UsbBulkPacketBufferSize;
|
||||||
|
};
|
||||||
|
|
||||||
R_RETURN(m_server->ReadPacket(m_data, haze::UsbBulkPacketBufferSize, std::addressof(m_received_size)));
|
R_RETURN(m_server->ReadPacket(m_data, haze::UsbBulkPacketBufferSize, std::addressof(m_received_size)));
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
constexpr explicit PtpDataParser(void *data, AsyncUsbServer *server) : m_server(server), m_received_size(), m_offset(), m_data(static_cast<u8 *>(data)), m_eos() { /* ... */ }
|
constexpr explicit PtpDataParser(void *data, AsyncUsbServer *server) : m_server(server), m_received_size(), m_offset(), m_data(static_cast<u8 *>(data)), m_eot() { /* ... */ }
|
||||||
|
|
||||||
Result Finalize() {
|
Result Finalize() {
|
||||||
/* Read until the transmission completes. */
|
/* Read until the transmission completes. */
|
||||||
while (true) {
|
while (true) {
|
||||||
Result rc = this->Flush();
|
Result rc = this->Flush();
|
||||||
|
|
||||||
R_SUCCEED_IF(m_eos || haze::ResultEndOfTransmission::Includes(rc));
|
R_SUCCEED_IF(m_eot || haze::ResultEndOfTransmission::Includes(rc));
|
||||||
R_TRY(rc);
|
R_TRY(rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,26 +17,39 @@
|
||||||
#include <haze/console_main_loop.hpp>
|
#include <haze/console_main_loop.hpp>
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
/* Declare the object heap, to hold the database for an active session. */
|
||||||
haze::PtpObjectHeap ptp_object_heap;
|
haze::PtpObjectHeap ptp_object_heap;
|
||||||
|
|
||||||
|
/* Declare the event reactor, and components which use it. */
|
||||||
haze::EventReactor event_reactor;
|
haze::EventReactor event_reactor;
|
||||||
haze::PtpResponder ptp_responder;
|
haze::PtpResponder ptp_responder;
|
||||||
haze::ConsoleMainLoop console_main_loop;
|
haze::ConsoleMainLoop console_main_loop;
|
||||||
|
|
||||||
consoleInit(NULL);
|
/* Initialize the console.*/
|
||||||
|
consoleInit(nullptr);
|
||||||
|
|
||||||
|
/* Ensure we don't go to sleep while transferring files. */
|
||||||
appletSetAutoSleepDisabled(true);
|
appletSetAutoSleepDisabled(true);
|
||||||
|
|
||||||
|
/* Configure the PTP responder and console main loop. */
|
||||||
ptp_responder.Initialize(std::addressof(event_reactor), std::addressof(ptp_object_heap));
|
ptp_responder.Initialize(std::addressof(event_reactor), std::addressof(ptp_object_heap));
|
||||||
console_main_loop.Initialize(std::addressof(event_reactor), std::addressof(ptp_object_heap));
|
console_main_loop.Initialize(std::addressof(event_reactor), std::addressof(ptp_object_heap));
|
||||||
|
|
||||||
|
/* Process events until the user requests exit. */
|
||||||
while (!event_reactor.GetStopRequested()) {
|
while (!event_reactor.GetStopRequested()) {
|
||||||
ptp_responder.HandleRequest();
|
ptp_responder.HandleRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Finalize the console main loop and PTP responder. */
|
||||||
console_main_loop.Finalize();
|
console_main_loop.Finalize();
|
||||||
ptp_responder.Finalize();
|
ptp_responder.Finalize();
|
||||||
|
|
||||||
|
/* Restore auto sleep setting. */
|
||||||
appletSetAutoSleepDisabled(false);
|
appletSetAutoSleepDisabled(false);
|
||||||
consoleExit(NULL);
|
|
||||||
|
/* Finalize the console. */
|
||||||
|
consoleExit(nullptr);
|
||||||
|
|
||||||
|
/* Return to the loader. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ namespace haze {
|
||||||
if (hosversionAtLeast(5, 0, 0)) {
|
if (hosversionAtLeast(5, 0, 0)) {
|
||||||
static const u16 supported_langs[1] = { 0x0409 };
|
static const u16 supported_langs[1] = { 0x0409 };
|
||||||
|
|
||||||
R_TRY(usbDsAddUsbLanguageStringDescriptor(NULL, supported_langs, util::size(supported_langs)));
|
R_TRY(usbDsAddUsbLanguageStringDescriptor(nullptr, supported_langs, util::size(supported_langs)));
|
||||||
|
|
||||||
u8 iManufacturer, iProduct, iSerialNumber;
|
u8 iManufacturer, iProduct, iSerialNumber;
|
||||||
R_TRY(usbDsAddUsbStringDescriptor(std::addressof(iManufacturer), "Nintendo"));
|
R_TRY(usbDsAddUsbStringDescriptor(std::addressof(iManufacturer), "Nintendo"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue