mirror of
https://github.com/Lorenzooone/cc3dsfs.git
synced 2026-04-24 23:17:43 -05:00
Add IS TWL Capture Battery and AC Adapter support
Some checks failed
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux32 flags:32 name:Linux GCC 32 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux64 flags:64 name:Linux GCC x64 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm32 flags:arm32 name:Linux GCC ARM 32 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm64 flags:arm64 name:Linux GCC ARM 64 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:macos name:macOS Apple Silicon os:macos-14]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win32 flags:-A Win32 name:Windows VS2022 Win32 os:windows-2022]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win64 flags:-A x64 name:Windows VS2022 x64 os:windows-2022]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:winarm64 flags:-A ARM64 name:Windows VS2022 ARM os:windows-2022]) (push) Has been cancelled
CD / Create Pi Mono Setup (push) Has been cancelled
CD / Publishing (push) Has been cancelled
Some checks failed
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux32 flags:32 name:Linux GCC 32 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux64 flags:64 name:Linux GCC x64 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm32 flags:arm32 name:Linux GCC ARM 32 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm64 flags:arm64 name:Linux GCC ARM 64 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:macos name:macOS Apple Silicon os:macos-14]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win32 flags:-A Win32 name:Windows VS2022 Win32 os:windows-2022]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win64 flags:-A x64 name:Windows VS2022 x64 os:windows-2022]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:winarm64 flags:-A ARM64 name:Windows VS2022 ARM os:windows-2022]) (push) Has been cancelled
CD / Create Pi Mono Setup (push) Has been cancelled
CD / Publishing (push) Has been cancelled
This commit is contained in:
parent
0610ffdb62
commit
2da2251409
|
|
@ -3,7 +3,9 @@
|
|||
cc3dsfs is a multi-platform capture and display program for [3dscapture's](https://3dscapture.com/) N3DSXL, 3DS and DS capture boards written in C++.
|
||||
The main goal is to offer the ability to use the Capture Card with a TV, via fullscreen mode.
|
||||
|
||||
IS Nitro Emulator (newer revisions) and IS Nitro Capture support is also present. Though results may vary (and the amount of video delay may be significantly higher based on the cable used).
|
||||
IS Nitro Emulator (newer revisions), IS Nitro Capture and IS TWL Capture support is also present. Though results may vary (and the amount of video delay may be significantly higher based on the cable used).
|
||||
|
||||
Support for a really old Optimize board is also present, used with Nisetro DS capture boards.
|
||||
|
||||
## Features
|
||||
|
||||
|
|
@ -145,4 +147,4 @@ On Windows, the profiles can be found in the ".config/cc3dsfs" folder inside the
|
|||
- Enabling Slow Poll may slightly boost the FPS of the software, at the cost of an extremely slight decrease in frame latency, and slower reaction times of the software to key presses. Disabled by default (as when the FPS are greater than the CC's, it's not reccomended).
|
||||
- On MacOS, you may get a notice about Apple being unable to check for malware, or the developer being unknown. To open the program regardless of that, check the [Official Guide for "Opening Applications from Unknown Developers" from Apple, for your version of MacOS](https://support.apple.com/guide/mac-help/open-a-mac-app-from-an-unknown-developer-mh40616/mac).
|
||||
- Certain TVs/Monitors may add some audio delay for the purpose of video/lip syncing. If you're experiencing too much audio delay when using this software, try checking in the TV/Monitor settings whether you can reduce that added delay. One of the names used for that setting is "Lip Sync", or something along that line.
|
||||
- When using IS Nitro Emulator or IS Nitro Capture devices on Windows, cc3dsfs is compatible with both the official driver and WinUSB, with the latter being useful if you don't have access to the official driver. To install and use WinUSB, plug in your device, download a software to install drivers like [Zadig](https://zadig.akeo.ie/), select the device in question and select WinUSB. Then install the driver and wait for it to finish. The devices should now work properly with this application.
|
||||
- When using IS Nitro Emulator, IS Nitro Capture or IS TWL Capture devices on Windows, cc3dsfs is compatible with both the official driver and WinUSB, with the latter being useful if you don't have access to the official driver. To install and use WinUSB, plug in your device, download a software to install drivers like [Zadig](https://zadig.akeo.ie/), select the device in question and select WinUSB. Then install the driver and wait for it to finish. The devices should now work properly with this application.
|
||||
|
|
|
|||
|
|
@ -108,6 +108,10 @@ int ReadPowerButtonState(is_device_device_handlers* handlers, bool* out, const i
|
|||
int ResetCPUStart(is_device_device_handlers* handlers, const is_device_usb_device* device_desc);
|
||||
int ResetCPUEnd(is_device_device_handlers* handlers, const is_device_usb_device* device_desc);
|
||||
int ResetFullHardware(is_device_device_handlers* handlers, const is_device_usb_device* device_desc);
|
||||
int SetBatteryPercentage(is_device_device_handlers* handlers, const is_device_usb_device* device_desc, int percentage);
|
||||
int SetACAdapterConnected(is_device_device_handlers* handlers, const is_device_usb_device* device_desc, bool connected);
|
||||
int GetBatteryPercentageValues(is_device_device_handlers* handlers, const is_device_usb_device* device_desc, int* percentage_one, int* percentage_two);
|
||||
int GetACAdapterConnectedValues(is_device_device_handlers* handlers, const is_device_usb_device* device_desc, bool* connected_one, bool* connected_two);
|
||||
int AskFrameLengthPos(is_device_device_handlers* handlers, uint32_t* video_address, uint32_t* video_length, bool video_enabled, uint32_t* audio_address, uint32_t* audio_length, bool audio_enabled, const is_device_usb_device* device_desc);
|
||||
int SetLastFrameInfo(is_device_device_handlers* handlers, uint32_t video_address, uint32_t video_length, uint32_t audio_address, uint32_t audio_length, const is_device_usb_device* device_desc);
|
||||
int ReadFrame(is_device_device_handlers* handlers, uint8_t* buf, uint32_t address, uint32_t length, const is_device_usb_device* device_desc);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ enum ISNitroMenuOutAction{
|
|||
ISN_MENU_RESET,
|
||||
ISN_MENU_SPEED_INC,
|
||||
ISN_MENU_SPEED_DEC,
|
||||
ISN_MENU_BATTERY_INC,
|
||||
ISN_MENU_BATTERY_DEC,
|
||||
ISN_MENU_AC_ADAPTER_TOGGLE,
|
||||
};
|
||||
|
||||
class ISNitroMenu : public OptionSelectionMenu {
|
||||
|
|
|
|||
|
|
@ -206,6 +206,8 @@ struct CaptureStatus {
|
|||
bool enabled_3d = false;
|
||||
CaptureScreensType capture_type;
|
||||
CaptureSpeedsType capture_speed;
|
||||
int battery_percentage;
|
||||
bool ac_adapter_connected;
|
||||
ConsumerMutex video_wait;
|
||||
ConsumerMutex audio_wait;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -233,6 +233,8 @@ private:
|
|||
void is_nitro_capture_type_change(bool positive);
|
||||
void is_nitro_capture_speed_change(bool positive);
|
||||
void is_nitro_capture_reset_hw();
|
||||
void is_nitro_battery_change(bool positive);
|
||||
void is_nitro_ac_adapter_change();
|
||||
void crop_value_change(int new_crop_value, bool do_print_notification = true, bool do_cycle = true);
|
||||
void par_value_change(int new_par_value, bool is_top);
|
||||
void offset_change(float &value, float change);
|
||||
|
|
|
|||
|
|
@ -107,8 +107,12 @@ enum is_twl_capture_command {
|
|||
IS_TWL_CAP_CMD_STOP_FRAME_READS = 0x88,
|
||||
IS_TWL_CAP_CMD_SET_LAST_FRAME_INFORMATION = 0x8B,
|
||||
IS_TWL_CAP_CMD_ACTS = 0x8C,
|
||||
IS_TWL_CAP_CMD_SET_BATTERY_PERCENTAGE = 0x8D,
|
||||
IS_TWL_CAP_CMD_SET_AC_ADAPTER_ON_OFF = 0x8E,
|
||||
IS_TWL_CAP_CMD_EPAC = 0x92,
|
||||
IS_TWL_CAP_CMD_POST_EPAC = 0x93,
|
||||
IS_TWL_CAP_CMD_GET_AC_ADAPTER_ON_OFF = 0x96,
|
||||
IS_TWL_CAP_CMD_GET_BATTERY_PERCENTAGE= 0x97,
|
||||
};
|
||||
|
||||
enum is_nitro_emulator_forward_bits {
|
||||
|
|
@ -695,6 +699,14 @@ int SendWriteCommandU32(is_device_device_handlers* handlers, uint16_t command, u
|
|||
return SendWriteCommand(handlers, command, (uint8_t*)&buffer, sizeof(uint32_t), device_desc);
|
||||
}
|
||||
|
||||
int SendReadWriteCommandU32(is_device_device_handlers* handlers, uint16_t command, uint32_t* out_value, uint32_t value, const is_device_usb_device* device_desc) {
|
||||
uint32_t out_buf = to_le(value);
|
||||
uint32_t in_buf = 0;
|
||||
int ret = SendReadWriteCommand(handlers, command, (uint8_t*)&out_buf, sizeof(uint32_t), (uint8_t*)&in_buf, sizeof(uint32_t), device_desc);
|
||||
*out_value = from_le(in_buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int AuthCtrlIn(is_device_device_handlers* handlers, const is_device_usb_device* device_desc) {
|
||||
int ret = 0;
|
||||
bool b_ret = true;
|
||||
|
|
@ -1079,7 +1091,7 @@ int ResetCPUStart(is_device_device_handlers* handlers, const is_device_usb_devic
|
|||
case IS_NITRO_CAPTURE_DEVICE:
|
||||
return SendWriteCommand(handlers, IS_NITRO_CAP_CMD_SET_RESET_CPU_ON, NULL, 0, device_desc);
|
||||
case IS_TWL_CAPTURE_DEVICE:
|
||||
return SendWriteCommandU32(handlers, IS_TWL_CAP_CMD_POWER_ON_OFF, 0x00070082, device_desc);
|
||||
return SendWriteCommandU32(handlers, IS_TWL_CAP_CMD_POWER_ON_OFF, 0x00070000 | IS_TWL_CAP_CMD_POWER_ON_OFF, device_desc);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1092,7 +1104,7 @@ int ResetCPUEnd(is_device_device_handlers* handlers, const is_device_usb_device*
|
|||
case IS_NITRO_CAPTURE_DEVICE:
|
||||
return SendWriteCommand(handlers, IS_NITRO_CAP_CMD_SET_RESET_CPU_OFF, NULL, 0, device_desc);
|
||||
case IS_TWL_CAPTURE_DEVICE:
|
||||
return SendWriteCommandU32(handlers, IS_TWL_CAP_CMD_POWER_ON_OFF, 0x00000082, device_desc);
|
||||
return SendWriteCommandU32(handlers, IS_TWL_CAP_CMD_POWER_ON_OFF, 0x00000000 | IS_TWL_CAP_CMD_POWER_ON_OFF, device_desc);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1110,6 +1122,68 @@ int ResetFullHardware(is_device_device_handlers* handlers, const is_device_usb_d
|
|||
}
|
||||
}
|
||||
|
||||
int SetBatteryPercentage(is_device_device_handlers* handlers, const is_device_usb_device* device_desc, int percentage) {
|
||||
int ret = 0;
|
||||
uint32_t out = 0;
|
||||
if(percentage < 1)
|
||||
percentage = 1;
|
||||
if(percentage > 100)
|
||||
percentage = 100;
|
||||
switch(device_desc->device_type) {
|
||||
case IS_TWL_CAPTURE_DEVICE:
|
||||
// Careful - 1 resets the DSi continuously (but the official software uses it), so...
|
||||
ret = SendReadWriteCommandU32(handlers, IS_TWL_CAP_CMD_SET_BATTERY_PERCENTAGE, &out, (percentage << 8) | IS_TWL_CAP_CMD_SET_BATTERY_PERCENTAGE, device_desc);
|
||||
if(out != 1)
|
||||
return -1;
|
||||
return ret;
|
||||
default:
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
int SetACAdapterConnected(is_device_device_handlers* handlers, const is_device_usb_device* device_desc, bool connected) {
|
||||
int ret = 0;
|
||||
uint32_t out = 0;
|
||||
int value = connected ? 1 : 0;
|
||||
switch(device_desc->device_type) {
|
||||
case IS_TWL_CAPTURE_DEVICE:
|
||||
ret = SendReadWriteCommandU32(handlers, IS_TWL_CAP_CMD_SET_AC_ADAPTER_ON_OFF, &out, (value << 8) | IS_TWL_CAP_CMD_SET_AC_ADAPTER_ON_OFF, device_desc);
|
||||
if(out != 1)
|
||||
return -1;
|
||||
return ret;
|
||||
default:
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
int GetBatteryPercentageValues(is_device_device_handlers* handlers, const is_device_usb_device* device_desc, int* percentage_one, int* percentage_two) {
|
||||
int ret = 0;
|
||||
uint32_t out = 0;
|
||||
switch(device_desc->device_type) {
|
||||
case IS_TWL_CAPTURE_DEVICE:
|
||||
ret = SendReadCommandU32(handlers, IS_TWL_CAP_CMD_GET_BATTERY_PERCENTAGE, &out, device_desc);
|
||||
*percentage_one = out & 0xFF;
|
||||
*percentage_two = (out >> 8) & 0xFF;
|
||||
return ret;
|
||||
default:
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
int GetACAdapterConnectedValues(is_device_device_handlers* handlers, const is_device_usb_device* device_desc, bool* connected_one, bool* connected_two) {
|
||||
int ret = 0;
|
||||
uint32_t out = 0;
|
||||
switch(device_desc->device_type) {
|
||||
case IS_TWL_CAPTURE_DEVICE:
|
||||
ret = SendReadCommandU32(handlers, IS_TWL_CAP_CMD_GET_AC_ADAPTER_ON_OFF, &out, device_desc);
|
||||
*connected_one = (out & 0xFF) ? true : false;
|
||||
*connected_two = ((out >> 8) & 0xFF) ? true : false;
|
||||
return ret;
|
||||
default:
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
int AskFrameLengthPos(is_device_device_handlers* handlers, uint32_t* video_address, uint32_t* video_length, bool video_enabled, uint32_t* audio_address, uint32_t* audio_length, bool audio_enabled, const is_device_usb_device* device_desc) {
|
||||
if(device_desc->device_type != IS_TWL_CAPTURE_DEVICE)
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
// Code created by analyzing the USB packets sent and received by the IS TWL Capture device.
|
||||
|
||||
#define RESET_TIMEOUT 4.0
|
||||
#define BATTERY_TIMEOUT 5.0
|
||||
#define SLEEP_RESET_TIME_MS 2000
|
||||
#define DEFAULT_FRAME_TIME_MS 16.7
|
||||
#define SLEEP_FRAME_DIVIDER 4
|
||||
|
|
@ -119,6 +120,37 @@ static int CaptureResetHardware(CaptureData* capture_data, std::chrono::time_poi
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int CaptureBatteryHandleHardware(CaptureData* capture_data, std::chrono::time_point<std::chrono::high_resolution_clock> &clock_last_battery_set, int &curr_battery_percentage, bool &curr_ac_adapter_connected) {
|
||||
is_device_device_handlers* handlers = (is_device_device_handlers*)capture_data->handle;
|
||||
const is_device_usb_device* usb_device_desc = (const is_device_usb_device*)capture_data->status.device.descriptor;
|
||||
int loaded_battery_percentage = capture_data->status.battery_percentage;
|
||||
bool loaded_ac_adapter_connected = capture_data->status.ac_adapter_connected;
|
||||
|
||||
const auto curr_time_battery = std::chrono::high_resolution_clock::now();
|
||||
const std::chrono::duration<double> diff_battery = curr_time_battery - clock_last_battery_set;
|
||||
if(diff_battery.count() > BATTERY_TIMEOUT) {
|
||||
if(curr_battery_percentage != loaded_battery_percentage) {
|
||||
int ret = SetBatteryPercentage(handlers, usb_device_desc, loaded_battery_percentage);
|
||||
if(ret < 0) {
|
||||
capture_error_print(true, capture_data, "Battery Set: Failed");
|
||||
return ret;
|
||||
}
|
||||
loaded_ac_adapter_connected = curr_battery_percentage < loaded_battery_percentage;
|
||||
clock_last_battery_set = curr_time_battery;
|
||||
curr_battery_percentage = loaded_battery_percentage;
|
||||
}
|
||||
if(curr_ac_adapter_connected != loaded_ac_adapter_connected) {
|
||||
int ret = SetACAdapterConnected(handlers, usb_device_desc, loaded_ac_adapter_connected);
|
||||
if(ret < 0) {
|
||||
capture_error_print(true, capture_data, "AC Adapter Set: Failed");
|
||||
return ret;
|
||||
}
|
||||
curr_ac_adapter_connected = loaded_ac_adapter_connected;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int initial_cleanup_twl_capture(const is_device_usb_device* usb_device_desc, is_device_device_handlers* handlers) {
|
||||
//EndAcquisition(handlers, usb_device_desc, false, 0, CAPTURE_SCREENS_BOTH);
|
||||
return LIBUSB_SUCCESS;
|
||||
|
|
@ -140,10 +172,13 @@ void is_twl_acquisition_capture_main_loop(CaptureData* capture_data, ISDeviceCap
|
|||
uint32_t last_read_frame_index = 0;
|
||||
CaptureScreensType curr_capture_type = capture_data->status.capture_type;
|
||||
CaptureSpeedsType curr_capture_speed = capture_data->status.capture_speed;
|
||||
int curr_battery_percentage = capture_data->status.battery_percentage;
|
||||
bool curr_ac_adapter_connected = capture_data->status.ac_adapter_connected;
|
||||
bool audio_enabled = true;
|
||||
bool reprocess = false;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> clock_last_frame = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> clock_last_reset = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> clock_last_battery_set = std::chrono::high_resolution_clock::now();
|
||||
float last_frame_length = 0.0;
|
||||
int ret = 0;
|
||||
uint32_t video_address = 0;
|
||||
|
|
@ -174,6 +209,16 @@ void is_twl_acquisition_capture_main_loop(CaptureData* capture_data, ISDeviceCap
|
|||
return;
|
||||
}
|
||||
default_sleep(DEFAULT_FRAME_TIME_MS / SLEEP_FRAME_DIVIDER);
|
||||
ret = SetBatteryPercentage(handlers, usb_device_desc, curr_battery_percentage);
|
||||
if(ret < 0) {
|
||||
capture_error_print(true, capture_data, "Initial Battery Set: Failed");
|
||||
return;
|
||||
}
|
||||
ret = SetACAdapterConnected(handlers, usb_device_desc, curr_ac_adapter_connected);
|
||||
if(ret < 0) {
|
||||
capture_error_print(true, capture_data, "Initial AC Adapter Set: Failed");
|
||||
return;
|
||||
}
|
||||
|
||||
while(capture_data->status.connected && capture_data->status.running) {
|
||||
bool processed = false;
|
||||
|
|
@ -206,6 +251,9 @@ void is_twl_acquisition_capture_main_loop(CaptureData* capture_data, ISDeviceCap
|
|||
capture_error_print(true, capture_data, "Hardware Reset: Failed");
|
||||
return;
|
||||
}
|
||||
ret = CaptureBatteryHandleHardware(capture_data, clock_last_battery_set, curr_battery_percentage, curr_ac_adapter_connected);
|
||||
if(ret < 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!is_acquisition_off)
|
||||
|
|
|
|||
|
|
@ -46,10 +46,26 @@ static const ISNitroMenuOptionInfo is_nitro_reset_option = {
|
|||
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = ISN_MENU_NO_ACTION,
|
||||
.out_action = ISN_MENU_RESET};
|
||||
|
||||
static const ISNitroMenuOptionInfo is_nitro_battery_percentage_option = {
|
||||
.base_name = "Battery Percentage", .false_name = "", .is_selectable = true,
|
||||
.is_capture_valid = true, .is_emulator_valid = false,
|
||||
.is_nitro_valid = false, .is_twl_valid = true,
|
||||
.is_inc = true, .dec_str = "-", .inc_str = "+", .inc_out_action = ISN_MENU_BATTERY_INC,
|
||||
.out_action = ISN_MENU_BATTERY_DEC};
|
||||
|
||||
static const ISNitroMenuOptionInfo is_nitro_ac_adapter_option = {
|
||||
.base_name = "Disconnect AC Adapter", .false_name = "Connect AC Adapter", .is_selectable = true,
|
||||
.is_capture_valid = true, .is_emulator_valid = false,
|
||||
.is_nitro_valid = false, .is_twl_valid = true,
|
||||
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = ISN_MENU_NO_ACTION,
|
||||
.out_action = ISN_MENU_AC_ADAPTER_TOGGLE};
|
||||
|
||||
static const ISNitroMenuOptionInfo* pollable_options[] = {
|
||||
&is_nitro_delay_option,
|
||||
&is_nitro_type_option,
|
||||
&is_nitro_speed_option,
|
||||
&is_nitro_battery_percentage_option,
|
||||
&is_nitro_ac_adapter_option,
|
||||
&is_nitro_reset_option,
|
||||
};
|
||||
|
||||
|
|
@ -191,6 +207,12 @@ void ISNitroMenu::prepare(float menu_scaling_factor, int view_size_x, int view_s
|
|||
case ISN_MENU_SPEED_INC:
|
||||
this->labels[index]->setText(this->setTextOptionString(real_index, get_capture_speed_name(capture_status->capture_speed)));
|
||||
break;
|
||||
case ISN_MENU_BATTERY_DEC:
|
||||
this->labels[index]->setText(this->setTextOptionInt(real_index, capture_status->battery_percentage));
|
||||
break;
|
||||
case ISN_MENU_AC_ADAPTER_TOGGLE:
|
||||
this->labels[index]->setText(this->setTextOptionBool(real_index, capture_status->ac_adapter_connected));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#define FPS_WINDOW_SIZE 64
|
||||
|
||||
static const int battery_levels[] = {1, 5, 12, 25, 50, 100};
|
||||
|
||||
static const sf::VideoMode default_fs_mode_4_5k_macos = sf::VideoMode({4480, 2520});
|
||||
static const sf::VideoMode default_fs_mode_4k_macos = sf::VideoMode({4096, 2304});
|
||||
static const sf::VideoMode default_fs_mode_4k = sf::VideoMode({3840, 2160});
|
||||
|
|
@ -207,6 +209,34 @@ void WindowScreen::is_nitro_capture_reset_hw() {
|
|||
this->capture_status->reset_hardware = true;
|
||||
}
|
||||
|
||||
void WindowScreen::is_nitro_battery_change(bool positive) {
|
||||
if(this->capture_status->battery_percentage < 1)
|
||||
this->capture_status->battery_percentage = 1;
|
||||
if(this->capture_status->battery_percentage > 100)
|
||||
this->capture_status->battery_percentage = 100;
|
||||
int closest_level = 0;
|
||||
int curr_diff = 100;
|
||||
const int num_levels = sizeof(battery_levels) / sizeof(battery_levels[0]);
|
||||
for(int i = 0; i < num_levels; i++) {
|
||||
int level_diff = abs(battery_levels[i] - this->capture_status->battery_percentage);
|
||||
if(level_diff < curr_diff) {
|
||||
closest_level = i;
|
||||
curr_diff = level_diff;
|
||||
}
|
||||
}
|
||||
if((!positive) && (closest_level > 0))
|
||||
closest_level -= 1;
|
||||
if((positive) && (closest_level < (num_levels - 1)))
|
||||
closest_level += 1;
|
||||
if(battery_levels[closest_level] != this->capture_status->battery_percentage)
|
||||
this->print_notification("Changing battery level...\nPlease wait...");
|
||||
this->capture_status->battery_percentage = battery_levels[closest_level];
|
||||
}
|
||||
|
||||
void WindowScreen::is_nitro_ac_adapter_change() {
|
||||
this->capture_status->ac_adapter_connected = !this->capture_status->ac_adapter_connected;
|
||||
}
|
||||
|
||||
void WindowScreen::padding_change() {
|
||||
if(this->m_info.is_fullscreen)
|
||||
return;
|
||||
|
|
@ -1921,6 +1951,15 @@ void WindowScreen::poll(bool do_everything) {
|
|||
case ISN_MENU_RESET:
|
||||
this->is_nitro_capture_reset_hw();
|
||||
break;
|
||||
case ISN_MENU_BATTERY_DEC:
|
||||
this->is_nitro_battery_change(false);
|
||||
break;
|
||||
case ISN_MENU_BATTERY_INC:
|
||||
this->is_nitro_battery_change(true);
|
||||
break;
|
||||
case ISN_MENU_AC_ADAPTER_TOGGLE:
|
||||
this->is_nitro_ac_adapter_change();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,6 +194,22 @@ static bool load(const std::string path, const std::string name, ScreenInfo &top
|
|||
continue;
|
||||
}
|
||||
|
||||
if(key == "is_battery_percentage") {
|
||||
capture_status->battery_percentage = std::stoi(value);
|
||||
// Even though 1 is allowed, it spam-resets the Hardware...
|
||||
// So don't allow it as the initial value!
|
||||
if(capture_status->battery_percentage <= 5)
|
||||
capture_status->battery_percentage = 5;
|
||||
if(capture_status->battery_percentage > 100)
|
||||
capture_status->battery_percentage = 100;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key == "is_ac_adapter_connected") {
|
||||
capture_status->ac_adapter_connected = std::stoi(value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(audio_data->load_audio_data(key, value))
|
||||
continue;
|
||||
}
|
||||
|
|
@ -213,6 +229,8 @@ static void defaults_reload(FrontendData *frontend_data, AudioData* audio_data,
|
|||
capture_status->enabled_3d = false;
|
||||
capture_status->capture_type = CAPTURE_SCREENS_BOTH;
|
||||
capture_status->capture_speed = CAPTURE_SPEEDS_FULL;
|
||||
capture_status->battery_percentage = 100;
|
||||
capture_status->ac_adapter_connected = true;
|
||||
reset_screen_info(frontend_data->top_screen->m_info);
|
||||
reset_screen_info(frontend_data->bot_screen->m_info);
|
||||
reset_screen_info(frontend_data->joint_screen->m_info);
|
||||
|
|
@ -293,6 +311,8 @@ static bool save(const std::string path, const std::string name, const std::stri
|
|||
file << "last_connected_ds=" << display_data.last_connected_ds << std::endl;
|
||||
file << "is_screen_capture_type=" << capture_status->capture_type << std::endl;
|
||||
file << "is_speed_capture=" << capture_status->capture_speed << std::endl;
|
||||
file << "is_battery_percentage=" << capture_status->battery_percentage << std::endl;
|
||||
file << "is_ac_adapter_connected=" << capture_status->ac_adapter_connected << std::endl;
|
||||
file << audio_data->save_audio_data();
|
||||
|
||||
file.close();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user