diff --git a/.github/workflows/cd_main.yml b/.github/workflows/cd_main.yml index 4cf3f5c..5a226fd 100644 --- a/.github/workflows/cd_main.yml +++ b/.github/workflows/cd_main.yml @@ -90,6 +90,7 @@ jobs: with: name: cc3dsfs-single-${{matrix.platform.artifact_name}} path: build/cc3dsfs*.zip + if-no-files-found: error create_pi_setup: name: Create Pi Mono Setup @@ -114,6 +115,7 @@ jobs: with: name: cc3dsfs-single-rpi-mono path: cc3dsfs_rpi_kiosk_setup.zip + if-no-files-found: error publish: name: Publishing diff --git a/CMakeLists.txt b/CMakeLists.txt index 8db55f0..ea48e0b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,16 @@ else() endif() set(FETCHCONTENT_QUIET FALSE) set(EXTRA_CXX_FLAGS "") +if(MSVC) + list(APPEND EXTRA_CXX_FLAGS "/W3") +else() + list(APPEND EXTRA_CXX_FLAGS "-Wall") + list(APPEND EXTRA_CXX_FLAGS "-Wextra") + list(APPEND EXTRA_CXX_FLAGS "-Wno-unused") + list(APPEND EXTRA_CXX_FLAGS "-Wno-unused-parameter") + list(APPEND EXTRA_CXX_FLAGS "-Wno-ignored-qualifiers") + list(APPEND EXTRA_CXX_FLAGS "-Wno-missing-field-initializers") +endif() set(RASPBERRY_PI_COMPILATION FALSE CACHE BOOL "Option for compiling the Raspberry Pi GPIO library in") set(SFML_BUILD_NETWORK FALSE) set(EXTRA_LIBRARIES "") diff --git a/include/CaptureDeviceSpecific/usb_generic.hpp b/include/CaptureDeviceSpecific/usb_generic.hpp index d50ea57..99fedeb 100644 --- a/include/CaptureDeviceSpecific/usb_generic.hpp +++ b/include/CaptureDeviceSpecific/usb_generic.hpp @@ -9,7 +9,6 @@ libusb_context* get_usb_ctx(); void usb_init(); void usb_close(); bool usb_is_initialized(); -int get_usb_total_filtered_devices(const uint16_t valid_vids[], size_t num_vids, const uint16_t valid_pids[], size_t num_pids); void libusb_check_and_detach_kernel_driver(void* handle, int interface); int libusb_check_and_set_configuration(void* handle, int wanted_configuration); diff --git a/include/Menus/ActionSelectionMenu.hpp b/include/Menus/ActionSelectionMenu.hpp index adc2bfe..cd98a6b 100755 --- a/include/Menus/ActionSelectionMenu.hpp +++ b/include/Menus/ActionSelectionMenu.hpp @@ -22,7 +22,7 @@ public: void reset_output_option(); protected: void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: diff --git a/include/Menus/AudioDeviceMenu.hpp b/include/Menus/AudioDeviceMenu.hpp index d9ff14e..42ea2f4 100644 --- a/include/Menus/AudioDeviceMenu.hpp +++ b/include/Menus/AudioDeviceMenu.hpp @@ -22,7 +22,7 @@ public: void reset_output_option(); protected: void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: diff --git a/include/Menus/AudioMenu.hpp b/include/Menus/AudioMenu.hpp index c9775e5..2aabdf3 100755 --- a/include/Menus/AudioMenu.hpp +++ b/include/Menus/AudioMenu.hpp @@ -35,11 +35,11 @@ public: protected: bool is_option_inc_dec(int index); void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/Menus/BFIMenu.hpp b/include/Menus/BFIMenu.hpp index 2839d2f..c5dfcf1 100755 --- a/include/Menus/BFIMenu.hpp +++ b/include/Menus/BFIMenu.hpp @@ -30,11 +30,11 @@ protected: bool is_option_selectable(int index, int action); bool is_option_inc_dec(int index); void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/Menus/ColorCorrectionMenu.hpp b/include/Menus/ColorCorrectionMenu.hpp index 877ee56..bace70f 100644 --- a/include/Menus/ColorCorrectionMenu.hpp +++ b/include/Menus/ColorCorrectionMenu.hpp @@ -22,7 +22,7 @@ public: void reset_output_option(); protected: void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: diff --git a/include/Menus/ConnectionMenu.hpp b/include/Menus/ConnectionMenu.hpp index 988fe04..f29a404 100755 --- a/include/Menus/ConnectionMenu.hpp +++ b/include/Menus/ConnectionMenu.hpp @@ -17,7 +17,7 @@ public: void reset_output_option(); protected: void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: diff --git a/include/Menus/CropMenu.hpp b/include/Menus/CropMenu.hpp index 1e1b8b3..17ed836 100755 --- a/include/Menus/CropMenu.hpp +++ b/include/Menus/CropMenu.hpp @@ -21,7 +21,7 @@ public: void reset_output_option(); protected: void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: diff --git a/include/Menus/ExtraSettingsMenu.hpp b/include/Menus/ExtraSettingsMenu.hpp index 9067668..9749b66 100755 --- a/include/Menus/ExtraSettingsMenu.hpp +++ b/include/Menus/ExtraSettingsMenu.hpp @@ -27,11 +27,11 @@ public: protected: void set_output_option(int index, int action); bool is_option_selectable(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/Menus/FileConfigMenu.hpp b/include/Menus/FileConfigMenu.hpp index f222c20..e659c6b 100755 --- a/include/Menus/FileConfigMenu.hpp +++ b/include/Menus/FileConfigMenu.hpp @@ -27,7 +27,7 @@ public: void reset_output_option(); protected: void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: diff --git a/include/Menus/ISNitroMenu.hpp b/include/Menus/ISNitroMenu.hpp index 22f00d0..d805c89 100644 --- a/include/Menus/ISNitroMenu.hpp +++ b/include/Menus/ISNitroMenu.hpp @@ -35,11 +35,11 @@ protected: bool is_option_selectable(int index, int action); bool is_option_inc_dec(int index); void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/Menus/InputMenu.hpp b/include/Menus/InputMenu.hpp index 1773619..c8ace16 100644 --- a/include/Menus/InputMenu.hpp +++ b/include/Menus/InputMenu.hpp @@ -29,11 +29,11 @@ public: void reset_output_option(); protected: void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/Menus/LicenseMenu.hpp b/include/Menus/LicenseMenu.hpp index c413910..50a55e2 100755 --- a/include/Menus/LicenseMenu.hpp +++ b/include/Menus/LicenseMenu.hpp @@ -24,11 +24,11 @@ public: protected: bool is_option_selectable(int index, int action); void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/Menus/Main3DMenu.hpp b/include/Menus/Main3DMenu.hpp index e006d7b..9cec1dc 100644 --- a/include/Menus/Main3DMenu.hpp +++ b/include/Menus/Main3DMenu.hpp @@ -34,11 +34,11 @@ protected: bool is_option_selectable(int index, int action); bool is_option_inc_dec(int index); void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/Menus/MainMenu.hpp b/include/Menus/MainMenu.hpp index 7a7be83..8990321 100755 --- a/include/Menus/MainMenu.hpp +++ b/include/Menus/MainMenu.hpp @@ -40,11 +40,11 @@ public: void reset_output_option(); protected: void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/Menus/OffsetMenu.hpp b/include/Menus/OffsetMenu.hpp index 18496b0..5eafad1 100755 --- a/include/Menus/OffsetMenu.hpp +++ b/include/Menus/OffsetMenu.hpp @@ -32,11 +32,11 @@ public: protected: bool is_option_inc_dec(int index); void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/Menus/OptionSelectionMenu.hpp b/include/Menus/OptionSelectionMenu.hpp index 41b38bb..c8f91a7 100755 --- a/include/Menus/OptionSelectionMenu.hpp +++ b/include/Menus/OptionSelectionMenu.hpp @@ -18,7 +18,7 @@ class OptionSelectionMenu { public: OptionSelectionMenu(); - ~OptionSelectionMenu(); + virtual ~OptionSelectionMenu(); bool poll(SFEvent &event_data); void draw(float scaling_factor, sf::RenderTarget &window); void reset_data(); @@ -43,7 +43,7 @@ protected: virtual bool is_option_selectable(int index, int action); virtual bool is_option_inc_dec(int index); virtual void set_output_option(int index, int action); - virtual int get_num_options(); + virtual size_t get_num_options(); virtual std::string get_string_option(int index, int action); virtual void class_setup(); @@ -84,9 +84,7 @@ private: int next_page_id; std::chrono::time_point last_action_time; - const float action_timeout = 0.1; - int loaded_page = 0; - int option_selected = -1; + const float action_timeout = 0.1f; bool *selectable_labels; bool *loaded_enabled_labels; MenuData loaded_data; diff --git a/include/Menus/PARMenu.hpp b/include/Menus/PARMenu.hpp index 97e1e53..049813c 100755 --- a/include/Menus/PARMenu.hpp +++ b/include/Menus/PARMenu.hpp @@ -22,7 +22,7 @@ public: void reset_output_option(); protected: void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: diff --git a/include/Menus/RelativePositionMenu.hpp b/include/Menus/RelativePositionMenu.hpp index 0560c40..b1b585c 100755 --- a/include/Menus/RelativePositionMenu.hpp +++ b/include/Menus/RelativePositionMenu.hpp @@ -20,7 +20,7 @@ class RelativePositionMenu { public: RelativePositionMenu(); RelativePositionMenu(bool font_load_success, sf::Font &text_font); - ~RelativePositionMenu(); + virtual ~RelativePositionMenu(); bool poll(SFEvent &event_data); void draw(float scaling_factor, sf::RenderTarget &window); void reset_data(); @@ -79,8 +79,7 @@ private: int title_id; std::chrono::time_point last_action_time; - const float action_timeout = 0.1; - int option_selected = -1; + const float action_timeout = 0.1f; RelPosMenuData loaded_data; sf::RectangleShape menu_rectangle = sf::RectangleShape(sf::Vector2f(1, 1)); diff --git a/include/Menus/ResolutionMenu.hpp b/include/Menus/ResolutionMenu.hpp index 2ae77f6..3af13f9 100755 --- a/include/Menus/ResolutionMenu.hpp +++ b/include/Menus/ResolutionMenu.hpp @@ -21,7 +21,7 @@ public: void reset_output_option(); protected: void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: diff --git a/include/Menus/RotationMenu.hpp b/include/Menus/RotationMenu.hpp index 683d60d..cd30cbb 100755 --- a/include/Menus/RotationMenu.hpp +++ b/include/Menus/RotationMenu.hpp @@ -30,11 +30,11 @@ public: protected: bool is_option_inc_dec(int index); void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/Menus/ScalingRatioMenu.hpp b/include/Menus/ScalingRatioMenu.hpp index dcc7303..e48ede7 100755 --- a/include/Menus/ScalingRatioMenu.hpp +++ b/include/Menus/ScalingRatioMenu.hpp @@ -31,12 +31,12 @@ public: protected: bool is_option_inc_dec(int index); void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; std::string setTextOptionDualPercentage(int index, float value_1, float value_2); }; #endif diff --git a/include/Menus/SeparatorMenu.hpp b/include/Menus/SeparatorMenu.hpp index 4affa1e..7ea059c 100644 --- a/include/Menus/SeparatorMenu.hpp +++ b/include/Menus/SeparatorMenu.hpp @@ -32,12 +32,12 @@ public: protected: bool is_option_inc_dec(int index); void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; std::string get_name_multiplier(int index, float value, bool is_fullscreen); }; #endif diff --git a/include/Menus/ShortcutMenu.hpp b/include/Menus/ShortcutMenu.hpp index e4d7992..9063587 100755 --- a/include/Menus/ShortcutMenu.hpp +++ b/include/Menus/ShortcutMenu.hpp @@ -21,7 +21,7 @@ public: void reset_output_option(); protected: void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: diff --git a/include/Menus/StatusMenu.hpp b/include/Menus/StatusMenu.hpp index 05cc1c7..80bdb34 100755 --- a/include/Menus/StatusMenu.hpp +++ b/include/Menus/StatusMenu.hpp @@ -26,7 +26,7 @@ protected: bool is_option_inc_dec(int index); bool is_option_selectable(int index, int action); void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: @@ -34,6 +34,6 @@ private: bool do_update; std::chrono::time_point last_update_time; int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/Menus/VideoEffectsMenu.hpp b/include/Menus/VideoEffectsMenu.hpp index 3b3793c..6b72e7c 100644 --- a/include/Menus/VideoEffectsMenu.hpp +++ b/include/Menus/VideoEffectsMenu.hpp @@ -30,11 +30,11 @@ protected: bool is_option_selectable(int index, int action); bool is_option_inc_dec(int index); void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/Menus/VideoMenu.hpp b/include/Menus/VideoMenu.hpp index 5ba6a90..15354a9 100755 --- a/include/Menus/VideoMenu.hpp +++ b/include/Menus/VideoMenu.hpp @@ -55,11 +55,11 @@ public: protected: bool is_option_inc_dec(int index); void set_output_option(int index, int action); - int get_num_options(); + size_t get_num_options(); std::string get_string_option(int index, int action); void class_setup(); private: int *options_indexes; - int num_enabled_options; + size_t num_enabled_options; }; #endif diff --git a/include/audio_data.hpp b/include/audio_data.hpp index a9828c5..2b09869 100755 --- a/include/audio_data.hpp +++ b/include/audio_data.hpp @@ -30,7 +30,7 @@ public: AudioMode get_audio_mode_output(); std::string get_audio_output_name(); std::string get_audio_mode_name(); - int get_max_audio_latency(); + size_t get_max_audio_latency(); int get_final_volume(); bool has_text_to_print(); std::string text_to_print(); @@ -44,7 +44,7 @@ public: private: int volume; - int max_audio_latency; + size_t max_audio_latency; bool mute; AudioOutputType output_type; audio_output_device_data output_device; diff --git a/include/capture_structs.hpp b/include/capture_structs.hpp index 00375ce..c962358 100755 --- a/include/capture_structs.hpp +++ b/include/capture_structs.hpp @@ -181,6 +181,7 @@ struct ALIGNED(16) PACKED ISTWLCaptureVideoReceived { ISTWLCaptureVideoInputData video_in; uint32_t time; uint32_t frame; + uint64_t random_data; }; struct ALIGNED(16) PACKED ISTWLCaptureVideoInternalReceived { @@ -248,10 +249,10 @@ union CaptureReceived { struct CaptureDevice { // This is so messy... Wish there was a clearer way... - CaptureDevice(std::string serial_number, std::string name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, uint64_t max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type) : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), video_data_type(video_data_type), long_name(name) {} - CaptureDevice(std::string serial_number, std::string name, std::string long_name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, uint64_t max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type, std::string path = "") : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), video_data_type(video_data_type), path(path), long_name(long_name) {} - CaptureDevice(std::string serial_number, std::string name, std::string long_name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, uint64_t max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type, int firmware_id, bool is_rgb_888, std::string path = "") : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), path(path), video_data_type(video_data_type), firmware_id(firmware_id), is_rgb_888(is_rgb_888), long_name(long_name) {} - CaptureDevice(std::string serial_number, std::string name, std::string long_name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int width_3d, int height_3d, uint64_t max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int second_top_screen_x, int second_top_screen_y, int bot_screen_x, int bot_screen_y, bool is_second_top_screen_right, InputVideoDataType video_data_type, uint32_t usb_speed, std::string path = "") : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), video_data_type(video_data_type), long_name(long_name), usb_speed(usb_speed), second_top_screen_x(second_top_screen_x), second_top_screen_y(second_top_screen_y), width_3d(width_3d), height_3d(height_3d), is_second_top_screen_right(is_second_top_screen_right), path(path) {} + CaptureDevice(std::string serial_number, std::string name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, uint64_t max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type) : serial_number(serial_number), name(name), long_name(name), cc_type(cc_type), video_data_type(video_data_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y) {} + CaptureDevice(std::string serial_number, std::string name, std::string long_name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, uint64_t max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type, std::string path = "") : serial_number(serial_number), name(name), long_name(long_name), path(path), cc_type(cc_type), video_data_type(video_data_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y) {} + CaptureDevice(std::string serial_number, std::string name, std::string long_name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, uint64_t max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type, int firmware_id, bool is_rgb_888, std::string path = "") : serial_number(serial_number), name(name), long_name(long_name), path(path), cc_type(cc_type), video_data_type(video_data_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), firmware_id(firmware_id), is_rgb_888(is_rgb_888) {} + CaptureDevice(std::string serial_number, std::string name, std::string long_name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int width_3d, int height_3d, uint64_t max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int second_top_screen_x, int second_top_screen_y, int bot_screen_x, int bot_screen_y, bool is_second_top_screen_right, InputVideoDataType video_data_type, uint32_t usb_speed, std::string path = "") : serial_number(serial_number), name(name), long_name(long_name), path(path), cc_type(cc_type), video_data_type(video_data_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), width_3d(width_3d), height_3d(height_3d), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), second_top_screen_x(second_top_screen_x), second_top_screen_y(second_top_screen_y), is_second_top_screen_right(is_second_top_screen_right), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), usb_speed(usb_speed) {} CaptureDevice() : usb_speed(0) {} std::string serial_number = ""; diff --git a/include/frontend.hpp b/include/frontend.hpp index dff0daa..23903f6 100755 --- a/include/frontend.hpp +++ b/include/frontend.hpp @@ -306,7 +306,7 @@ private: sf::Vector2u get_desk_mode_3d_multiplied(ScreenInfo* info); sf::Vector2f get_3d_offset_out_rect(ScreenInfo* info, bool is_second_screen); int prepare_screen_ratio(ResizingScreenData *own_screen, int width_limit, int height_limit, int other_rotation); - float get_ratio_compared_other_screen(ResizingScreenData *own_screen, ResizingScreenData* other_screen, float other_scaling); + int get_ratio_compared_other_screen(ResizingScreenData *own_screen, ResizingScreenData* other_screen, int other_scaling); bool can_non_integerly_scale(); void calc_scaling_resize_screens(ResizingScreenData *own_screen, ResizingScreenData* other_screen, bool increase, bool mantain, bool set_to_zero, bool cycle); void rescale_nonint_subscreen(ResizingScreenData *main_screen_resize_data, ResizingScreenData *sub_screen_resize_data); diff --git a/include/utils.hpp b/include/utils.hpp index c14d3dc..379b440 100755 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -81,7 +81,7 @@ private: std::condition_variable_any condition; const float base_time_fps = 30; int count = 0; - float time_multiplier = 1.0; + float time_multiplier = 1.0f; }; class SharedConsumerMutex { @@ -104,7 +104,7 @@ private: const float base_time_fps = 30; int* counts; int num_elements; - float time_multiplier = 1.0; + float time_multiplier = 1.0f; }; #endif diff --git a/source/CaptureDataBuffers.cpp b/source/CaptureDataBuffers.cpp index ab3a111..099e679 100644 --- a/source/CaptureDataBuffers.cpp +++ b/source/CaptureDataBuffers.cpp @@ -5,11 +5,11 @@ CaptureDataBuffers::CaptureDataBuffers() { last_curr_in = 0; for(int i = 0; i < NUM_CONCURRENT_DATA_BUFFER_WRITERS; i++) { curr_writer_pos[i] = -1; - is_being_written_to[i] = false; } for(int i = 0; i < NUM_CONCURRENT_DATA_BUFFER_READERS; i++) curr_reader_pos[i] = -1; for(int i = 0; i < NUM_CONCURRENT_DATA_BUFFERS; i++) { + is_being_written_to[i] = false; num_readers[i] = 0; for(int j = 0; j < NUM_CONCURRENT_DATA_BUFFER_READERS; j++) has_read_data[i][j] = true; @@ -105,7 +105,7 @@ void CaptureDataBuffers::WriteToBuffer(CaptureReceived* buffer, uint64_t read, d if(target == NULL) return; if(buffer != NULL) { - memcpy(&target->capture_buf, ((uint8_t*)buffer) + offset, read - offset); + memcpy(&target->capture_buf, ((uint8_t*)buffer) + offset, (size_t)(read - offset)); // Make sure to also copy the extra needed data, if any if((device->cc_type == CAPTURE_CONN_USB) && (!device->is_3ds)) memcpy(&target->capture_buf.usb_received_old_ds.frameinfo, &buffer->usb_received_old_ds.frameinfo, sizeof(buffer->usb_received_old_ds.frameinfo)); diff --git a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_compatibility.cpp b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_compatibility.cpp index de5a946..392710b 100644 --- a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_compatibility.cpp +++ b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_compatibility.cpp @@ -13,17 +13,21 @@ #include #endif +#ifdef USE_FTD3_LIBUSB +#define CHECK_DRIVER_VALUE false +#else +#define CHECK_DRIVER_VALUE true +#endif + void ftd3_list_devices_compat(std::vector &devices_list, std::vector &no_access_list, const std::vector &valid_descriptions) { bool no_access_elems = false; bool not_supported_elems = false; int curr_serial_extra_id_ftd3 = 0; - bool check_driver_too = true; #ifdef USE_FTD3_LIBUSB - check_driver_too = false; ftd3_libusb_list_devices(devices_list, &no_access_elems, ¬_supported_elems, &curr_serial_extra_id_ftd3, valid_descriptions); #endif #ifdef USE_FTD3XX - if(check_driver_too || not_supported_elems) + if(CHECK_DRIVER_VALUE || not_supported_elems) ftd3_driver_list_devices(devices_list, &curr_serial_extra_id_ftd3, valid_descriptions); #endif if(no_access_elems) @@ -86,7 +90,7 @@ int ftd3_set_stream_pipe_compat(ftd3_device_device_handlers* handlers, int pipe, #endif #ifdef USE_FTD3XX if(handlers->driver_handle) - return FT_SetStreamPipe(handlers->driver_handle, false, false, pipe, length); + return FT_SetStreamPipe(handlers->driver_handle, false, false, pipe, (ULONG)length); #endif return 0; } @@ -99,7 +103,7 @@ int ftd3_write_pipe_compat(ftd3_device_device_handlers* handlers, int pipe, cons #ifdef USE_FTD3XX if(handlers->driver_handle) { ULONG transferred_ftd3xx = 0; - int result = FT_WritePipe(handlers->driver_handle, pipe, (uint8_t*)data, size, &transferred_ftd3xx, 0); + int result = FT_WritePipe(handlers->driver_handle, pipe, (uint8_t*)data, (ULONG)size, &transferred_ftd3xx, 0); if(FT_FAILED(result)) return result; *num_transferred = (int)transferred_ftd3xx; @@ -117,7 +121,7 @@ int ftd3_read_pipe_compat(ftd3_device_device_handlers* handlers, int pipe, uint8 #ifdef USE_FTD3XX if(handlers->driver_handle) { ULONG transferred_ftd3xx = 0; - int result = FT_ReadPipe(handlers->driver_handle, pipe, data, size, &transferred_ftd3xx, 0); + int result = FT_ReadPipe(handlers->driver_handle, pipe, data, (ULONG)size, &transferred_ftd3xx, 0); if(FT_FAILED(result)) return result; *num_transferred = (int)transferred_ftd3xx; diff --git a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_driver_acquisition.cpp b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_driver_acquisition.cpp index c96d1dd..4922fdd 100644 --- a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_driver_acquisition.cpp +++ b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_driver_acquisition.cpp @@ -40,7 +40,7 @@ static bool fast_capture_call_init_async_transfers(FTD3XXReceivedDataBuffer* rec CaptureDataSingleBuffer* data_buf = capture_data->data_buffers.GetWriterBuffer(inner_curr_in); uint8_t* buffer = (uint8_t*)&data_buf->capture_buf; received_buffer[inner_curr_in].is_3d = could_use_3d && stored_3d_status; - FT_STATUS ftStatus = FT_ASYNC_CALL(handle, fifo_channel, buffer, ftd3_get_capture_size(received_buffer[inner_curr_in].is_3d), &received_buffer[inner_curr_in].read_buffer, &received_buffer[inner_curr_in].overlap); + FT_STATUS ftStatus = FT_ASYNC_CALL(handle, fifo_channel, buffer, (ULONG)ftd3_get_capture_size(received_buffer[inner_curr_in].is_3d), &received_buffer[inner_curr_in].read_buffer, &received_buffer[inner_curr_in].overlap); if(ftStatus != FT_IO_PENDING) { capture_error_print(true, capture_data, "Disconnected: Read failed"); return false; @@ -93,7 +93,7 @@ static void fast_capture_call(FTD3XXReceivedDataBuffer* received_buffer, Capture CaptureDataSingleBuffer* data_buf = capture_data->data_buffers.GetWriterBuffer(inner_curr_in); uint8_t* buffer = (uint8_t*)&data_buf->capture_buf; received_buffer[inner_curr_in].is_3d = could_use_3d && stored_3d_status; - ftStatus = FT_ASYNC_CALL(handle, fifo_channel, buffer, ftd3_get_capture_size(received_buffer[inner_curr_in].is_3d), &received_buffer[inner_curr_in].read_buffer, &received_buffer[inner_curr_in].overlap); + ftStatus = FT_ASYNC_CALL(handle, fifo_channel, buffer, (ULONG)ftd3_get_capture_size(received_buffer[inner_curr_in].is_3d), &received_buffer[inner_curr_in].read_buffer, &received_buffer[inner_curr_in].overlap); if(ftStatus != FT_IO_PENDING) { capture_error_print(true, capture_data, "Disconnected: Read failed"); return; @@ -131,9 +131,9 @@ static bool safe_capture_call(FTD3XXReceivedDataBuffer* received_buffer, Capture uint8_t* buffer = (uint8_t*)&data_buf->capture_buf; received_buffer->is_3d = could_use_3d && stored_3d_status; #ifdef _WIN32 - FT_STATUS ftStatus = FT_ReadPipeEx(handle, fifo_channel, buffer, ftd3_get_capture_size(received_buffer->is_3d), &received_buffer->read_buffer, NULL); + FT_STATUS ftStatus = FT_ReadPipeEx(handle, fifo_channel, buffer, (ULONG)ftd3_get_capture_size(received_buffer->is_3d), &received_buffer->read_buffer, NULL); #else - FT_STATUS ftStatus = FT_ReadPipeEx(handle, fifo_channel, buffer, ftd3_get_capture_size(received_buffer->is_3d), &received_buffer->read_buffer, 1000); + FT_STATUS ftStatus = FT_ReadPipeEx(handle, fifo_channel, buffer, (ULONG)ftd3_get_capture_size(received_buffer->is_3d), &received_buffer->read_buffer, 1000); #endif if(FT_FAILED(ftStatus)) { capture_error_print(true, capture_data, "Disconnected: Read failed"); diff --git a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_driver_comms.cpp b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_driver_comms.cpp index dde344f..d4fbd6c 100644 --- a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_driver_comms.cpp +++ b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_driver_comms.cpp @@ -90,7 +90,7 @@ void ftd3_driver_list_devices(std::vector &devices_list, int *cur SerialNumber, Description, &ftHandle); if(FT_FAILED(ftStatus)) continue; - for(int j = 0; j < valid_descriptions.size(); j++) { + for(size_t j = 0; j < valid_descriptions.size(); j++) { if(Description == valid_descriptions[j]) { ftStatus = FT_Create(SerialNumber, FT_OPEN_BY_SERIAL_NUMBER, &ftHandle); if(FT_FAILED(ftStatus)) @@ -107,7 +107,7 @@ ftd3_device_device_handlers* ftd3_driver_serial_reconnection(std::string wanted_ ftd3_device_device_handlers* final_handlers = NULL; ftd3_device_device_handlers inside_handlers; char SerialNumber[SERIAL_NUMBER_SIZE] = { 0 }; - strncpy(SerialNumber, wanted_serial_number.c_str(), REAL_SERIAL_NUMBER_SIZE); + strncpy_s(SerialNumber, REAL_SERIAL_NUMBER_SIZE, wanted_serial_number.c_str(), REAL_SERIAL_NUMBER_SIZE); SerialNumber[REAL_SERIAL_NUMBER_SIZE] = 0; if(!FT_FAILED(FT_Create(SerialNumber, FT_OPEN_BY_SERIAL_NUMBER, &inside_handlers.driver_handle))) { final_handlers = new ftd3_device_device_handlers; diff --git a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_libusb_acquisition.cpp b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_libusb_acquisition.cpp index 139e31f..f8c14b1 100644 --- a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_libusb_acquisition.cpp +++ b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_libusb_acquisition.cpp @@ -44,10 +44,6 @@ static void error_ftd3_libusb_status(FTD3LibusbCaptureReceivedData* ftd3_libusb_ *ftd3_libusb_capture_recv_data[0].status = error_val; } -static void reset_ftd3_libusb_status(FTD3LibusbCaptureReceivedData* ftd3_libusb_capture_recv_data) { - error_ftd3_libusb_status(ftd3_libusb_capture_recv_data, 0); -} - static void ftd3_libusb_read_frame_request(CaptureData* capture_data, FTD3LibusbCaptureReceivedData* ftd3_libusb_capture_recv_data, uint32_t index, int pipe, bool is_3d) { if(ftd3_libusb_capture_recv_data == NULL) return; @@ -58,7 +54,7 @@ static void ftd3_libusb_read_frame_request(CaptureData* capture_data, FTD3Libusb CaptureDataSingleBuffer* data_buf = capture_data->data_buffers.GetWriterBuffer(ftd3_libusb_capture_recv_data->internal_index); uint8_t* buffer = (uint8_t*)&data_buf->capture_buf; ftd3_libusb_capture_recv_data->is_3d = is_3d; - ftd3_libusb_async_in_start((ftd3_device_device_handlers*)capture_data->handle, pipe, MAX_TIME_WAIT * 1000, buffer, ftd3_get_capture_size(is_3d), &ftd3_libusb_capture_recv_data->cb_data); + ftd3_libusb_async_in_start((ftd3_device_device_handlers*)capture_data->handle, pipe, (uint32_t)(MAX_TIME_WAIT * 1000), buffer, (int)ftd3_get_capture_size(is_3d), &ftd3_libusb_capture_recv_data->cb_data); } static void end_ftd3_libusb_read_frame_cb(FTD3LibusbCaptureReceivedData* ftd3_libusb_capture_recv_data, bool early_release) { @@ -90,14 +86,6 @@ static void ftd3_libusb_read_frame_cb(void* user_data, int transfer_length, int end_ftd3_libusb_read_frame_cb(ftd3_libusb_capture_recv_data, false); } -static int ftd3_libusb_get_num_free_buffers(FTD3LibusbCaptureReceivedData* ftd3_libusb_capture_recv_data) { - int num_free = 0; - for(int i = 0; i < FTD3_CONCURRENT_BUFFERS; i++) - if(!ftd3_libusb_capture_recv_data[i].in_use) - num_free += 1; - return num_free; -} - static void close_all_reads_error(FTD3LibusbCaptureReceivedData* ftd3_libusb_capture_recv_data, bool &async_read_closed) { if(get_ftd3_libusb_status(ftd3_libusb_capture_recv_data) >= 0) return; @@ -153,10 +141,6 @@ static void wait_one_ftd3_libusb_buffer_free(FTD3LibusbCaptureReceivedData* ftd3 } } -static bool ftd3_libusb_are_buffers_all_free(FTD3LibusbCaptureReceivedData* ftd3_libusb_capture_recv_data) { - return ftd3_libusb_get_num_free_buffers(ftd3_libusb_capture_recv_data) == FTD3_CONCURRENT_BUFFERS; -} - static FTD3LibusbCaptureReceivedData* ftd3_libusb_get_free_buffer(FTD3LibusbCaptureReceivedData* ftd3_libusb_capture_recv_data) { wait_one_ftd3_libusb_buffer_free(ftd3_libusb_capture_recv_data); if(get_ftd3_libusb_status(ftd3_libusb_capture_recv_data) < 0) diff --git a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_libusb_comms.cpp b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_libusb_comms.cpp index 208c8ac..1f7f370 100644 --- a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_libusb_comms.cpp +++ b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_libusb_comms.cpp @@ -119,10 +119,10 @@ int ftd3_libusb_async_in_start(ftd3_device_device_handlers* handlers, int endpoi static int ftd3_libusb_send_command(libusb_device_handle* handle, uint8_t* data, size_t length) { int num_transferred = 0; - int result = libusb_bulk_transfer(handle, FTD3_COMMAND_BULK_PIPE_ID, data, length, &num_transferred, FTD3_COMMAND_TIMEOUT); + int result = libusb_bulk_transfer(handle, FTD3_COMMAND_BULK_PIPE_ID, data, (int)length, &num_transferred, FTD3_COMMAND_TIMEOUT); if(result < 0) return result; - if(num_transferred != length) + if(num_transferred != ((int)length)) return -1; return result; } @@ -159,21 +159,21 @@ int ftd3_libusb_abort_pipe(ftd3_device_device_handlers* handlers, int pipe) { } int ftd3_libusb_write_pipe(ftd3_device_device_handlers* handlers, int pipe, const uint8_t* data, size_t length, int* num_transferred) { - int result = ftd3_libusb_send_len_data_command((libusb_device_handle*)handlers->usb_handle, pipe, FTD3_COMMAND_RW_OPERATION_PREPARE_ID, length); + int result = ftd3_libusb_send_len_data_command((libusb_device_handle*)handlers->usb_handle, pipe, FTD3_COMMAND_RW_OPERATION_PREPARE_ID, (uint32_t)length); if(result < 0) return result; - return ftd3_libusb_bulk_out(handlers, pipe, FTD3_COMMAND_TIMEOUT, data, length, num_transferred); + return ftd3_libusb_bulk_out(handlers, pipe, FTD3_COMMAND_TIMEOUT, data, (int)length, num_transferred); } int ftd3_libusb_read_pipe(ftd3_device_device_handlers* handlers, int pipe, uint8_t* data, size_t length, int* num_transferred) { - int result = ftd3_libusb_send_len_data_command((libusb_device_handle*)handlers->usb_handle, pipe, FTD3_COMMAND_RW_OPERATION_PREPARE_ID, length); + int result = ftd3_libusb_send_len_data_command((libusb_device_handle*)handlers->usb_handle, pipe, FTD3_COMMAND_RW_OPERATION_PREPARE_ID, (uint32_t)length); if(result < 0) return result; - return ftd3_libusb_bulk_in(handlers, pipe, FTD3_COMMAND_TIMEOUT, data, length, num_transferred); + return ftd3_libusb_bulk_in(handlers, pipe, FTD3_COMMAND_TIMEOUT, data, (int)length, num_transferred); } int ftd3_libusb_set_stream_pipe(ftd3_device_device_handlers* handlers, int pipe, size_t length) { - return ftd3_libusb_send_len_data_command((libusb_device_handle*)handlers->usb_handle, pipe, FTD3_COMMAND_SET_STREAM_PIPE_ID, length); + return ftd3_libusb_send_len_data_command((libusb_device_handle*)handlers->usb_handle, pipe, FTD3_COMMAND_SET_STREAM_PIPE_ID, (uint32_t)length); } static bool ftd3_libusb_setup_connection(libusb_device_handle* handle, bool* claimed_cmd, bool* claimed_bulk) { @@ -222,7 +222,7 @@ static int ftd3_libusb_insert_device(std::vector &devices_list, l char serial[0x100]; read_strings(handle, usb_descriptor, manufacturer, product, serial); bool found = false; - for(int i = 0; i < valid_descriptions.size(); i++) + for(size_t i = 0; i < valid_descriptions.size(); i++) if(product == valid_descriptions[i]) { found = true; break; @@ -248,16 +248,16 @@ static int ftd3_libusb_insert_device(std::vector &devices_list, l return result; } -static ftd3_device_device_handlers* ftd3_libusb_serial_find_in_list(libusb_device **usb_devices, int num_devices, std::string wanted_serial_number, int &curr_serial_extra_id, const std::vector &valid_descriptions) { - for(int i = 0; i < num_devices; i++) { +static ftd3_device_device_handlers* ftd3_libusb_serial_find_in_list(libusb_device **usb_devices, ssize_t num_devices, std::string wanted_serial_number, int &curr_serial_extra_id, const std::vector &valid_descriptions) { + for(ssize_t i = 0; i < num_devices; i++) { libusb_device_descriptor usb_descriptor{}; int result = libusb_get_device_descriptor(usb_devices[i], &usb_descriptor); if(result < 0) continue; - for(int j = 0; j < ftd3_num_vids; j++) { + for(size_t j = 0; j < ftd3_num_vids; j++) { if(usb_descriptor.idVendor != ftd3_valid_vids[j]) continue; - for(int k = 0; k < ftd3_num_pids; k++) { + for(size_t k = 0; k < ftd3_num_pids; k++) { if(usb_descriptor.idProduct != ftd3_valid_pids[k]) continue; ftd3_device_device_handlers handlers; @@ -268,7 +268,7 @@ static ftd3_device_device_handlers* ftd3_libusb_serial_find_in_list(libusb_devic char product[0x100]; char serial[0x100]; read_strings((libusb_device_handle*)handlers.usb_handle, &usb_descriptor, manufacturer, product, serial); - for(int l = 0; l < valid_descriptions.size(); l++) { + for(size_t l = 0; l < valid_descriptions.size(); l++) { if(product != valid_descriptions[l]) continue; std::string device_serial_number = ftd3_get_serial((std::string)(serial), curr_serial_extra_id); @@ -296,7 +296,7 @@ ftd3_device_device_handlers* ftd3_libusb_serial_reconnection(std::string wanted_ if(!usb_is_initialized()) return NULL; libusb_device **usb_devices; - int num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); + ssize_t num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); ftd3_device_device_handlers* final_handlers = ftd3_libusb_serial_find_in_list(usb_devices, num_devices, wanted_serial_number, curr_serial_extra_id, valid_descriptions); @@ -321,17 +321,17 @@ void ftd3_libusb_list_devices(std::vector &devices_list, bool* no if(!usb_is_initialized()) return; libusb_device **usb_devices; - int num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); + ssize_t num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); libusb_device_descriptor usb_descriptor{}; - for(int i = 0; i < num_devices; i++) { + for(ssize_t i = 0; i < num_devices; i++) { int result = libusb_get_device_descriptor(usb_devices[i], &usb_descriptor); if(result < 0) continue; - for(int j = 0; j < ftd3_num_vids; j++) { + for(size_t j = 0; j < ftd3_num_vids; j++) { if(usb_descriptor.idVendor != ftd3_valid_vids[j]) continue; - for(int k = 0; k < ftd3_num_pids; k++) { + for(size_t k = 0; k < ftd3_num_pids; k++) { if(usb_descriptor.idProduct != ftd3_valid_pids[k]) continue; result = ftd3_libusb_insert_device(devices_list, usb_devices[i], &usb_descriptor, *curr_serial_extra_id_ftd3, valid_descriptions); diff --git a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_shared.cpp b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_shared.cpp index 57a1c20..6eb2cde 100644 --- a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_shared.cpp +++ b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_shared.cpp @@ -249,7 +249,7 @@ bool ftd3_capture_3d_setup(CaptureData* capture_data, bool first_pass, bool& sto return false; } - if(ftd3_is_error_compat(handlers, ftd3_set_stream_pipe_compat(handlers, BULK_IN, ftd3_get_capture_size(_3d_enabled_result || (first_pass && is_driver))))) { + if(ftd3_is_error_compat(handlers, ftd3_set_stream_pipe_compat(handlers, BULK_IN, (size_t)ftd3_get_capture_size(_3d_enabled_result || (first_pass && is_driver))))) { capture_error_print(print_failed, capture_data, "Stream failed"); preemptive_close_connection(capture_data); return false; @@ -262,7 +262,7 @@ bool ftd3_capture_3d_setup(CaptureData* capture_data, bool first_pass, bool& sto return false; } - if(ftd3_is_error_compat(handlers, ftd3_set_stream_pipe_compat(handlers, BULK_IN, ftd3_get_capture_size(_3d_enabled_result || (first_pass && is_driver))))) { + if(ftd3_is_error_compat(handlers, ftd3_set_stream_pipe_compat(handlers, BULK_IN, (size_t)ftd3_get_capture_size(_3d_enabled_result || (first_pass && is_driver))))) { capture_error_print(print_failed, capture_data, "Stream failed"); preemptive_close_connection(capture_data); return false; @@ -273,7 +273,6 @@ bool ftd3_capture_3d_setup(CaptureData* capture_data, bool first_pass, bool& sto } void ftd3_capture_main_loop(CaptureData* capture_data) { - bool could_have_3d = get_3d_enabled(&capture_data->status, true); ftd3_main_loop_compat(capture_data, BULK_IN); } diff --git a/source/CaptureDeviceSpecific/CypressShared/cypress_shared_driver_comms.cpp b/source/CaptureDeviceSpecific/CypressShared/cypress_shared_driver_comms.cpp index f872fec..797108e 100644 --- a/source/CaptureDeviceSpecific/CypressShared/cypress_shared_driver_comms.cpp +++ b/source/CaptureDeviceSpecific/CypressShared/cypress_shared_driver_comms.cpp @@ -153,7 +153,7 @@ static GUID* get_driver_guid(CypressWindowsDriversEnum driver) { static bool cypress_driver_process_async_transfers(std::vector *cb_data_vector, cy_device_device_handlers* handlers) { bool found = false; - for (int i = 0; i < cb_data_vector->size(); i++) { + for(size_t i = 0; i < cb_data_vector->size(); i++) { cy_async_callback_data* cb_data = cb_data_vector->at(i); bool possible_result = false; bool is_data_ready = false; @@ -195,12 +195,12 @@ static bool cypress_driver_process_async_transfers(std::vector *cb_data_vector, cy_device_device_handlers* handlers) { int ret = 0; HANDLE* to_wait_array = new HANDLE[cb_data_vector->size()]; - for(int i = 0; i < cb_data_vector->size(); i++) + for(size_t i = 0; i < cb_data_vector->size(); i++) to_wait_array[i] = ((OVERLAPPED*)cb_data_vector->at(i)->base_transfer_data)->hEvent; while(*usb_thread_run) { if(cypress_driver_process_async_transfers(cb_data_vector, handlers)) { - for (int i = 0; i < cb_data_vector->size(); i++) { + for(size_t i = 0; i < cb_data_vector->size(); i++) { cy_async_callback_data* cb_data = cb_data_vector->at(i); bool is_data_ready = false; cb_data->transfer_data_access.lock(); @@ -208,12 +208,12 @@ static void cypress_driver_function(bool* usb_thread_run, std::vectortransfer_data_access.unlock(); if((*cb_data->in_use_ptr) && is_data_ready) { cb_data->is_data_ready = false; - cb_data->function(cb_data->actual_user_data, cb_data->actual_length, cb_data->status_value); + cb_data->function(cb_data->actual_user_data, (int)cb_data->actual_length, cb_data->status_value); } } } else - WaitForMultipleObjects(cb_data_vector->size(), to_wait_array, false, 300); + WaitForMultipleObjects((DWORD)cb_data_vector->size(), to_wait_array, false, 300); } delete []to_wait_array; } @@ -221,7 +221,7 @@ static void cypress_driver_function(bool* usb_thread_run, std::vectorucEndpointAddress = ep_num; - bool retval = DeviceIoControl(handle, IOCTL_ADAPT_SEND_NON_EP0_DIRECT, single_transfer, sizeof(CYPRESS_SINGLE_TRANSFER), buffer, size, num_read, overlap); + bool retval = DeviceIoControl(handle, IOCTL_ADAPT_SEND_NON_EP0_DIRECT, single_transfer, sizeof(CYPRESS_SINGLE_TRANSFER), buffer, (DWORD)size, num_read, overlap); return retval; } @@ -238,17 +238,17 @@ static bool cypress_driver_generic_ctrl_transfer(HANDLE handle, uint8_t* buffer, single_transfer->SetupPacket.bmReqType.Direction = direction; single_transfer->SetupPacket.bmReqType.Type = type; single_transfer->SetupPacket.bmReqType.Recipient = recipient; - single_transfer->SetupPacket.bRequest = request_code; + single_transfer->SetupPacket.bRequest = (UCHAR)request_code; single_transfer->SetupPacket.wVal.hiByte = val_hi; single_transfer->SetupPacket.wVal.lowByte = val_low; single_transfer->SetupPacket.wIndex = index; - single_transfer->SetupPacket.wLength = inner_size; + single_transfer->SetupPacket.wLength = (USHORT)inner_size; single_transfer->SetupPacket.ulTimeOut = timeout_s; single_transfer->BufferLength = single_transfer->SetupPacket.wLength; single_transfer->BufferOffset = sizeof(CYPRESS_SINGLE_TRANSFER); if(direction == DIR_HOST_TO_DEVICE) memcpy(full_buffer + single_transfer->BufferOffset, buffer, inner_size); - bool retval = DeviceIoControl(handle, IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER, full_buffer, full_size, full_buffer, full_size, num_read, NULL); + bool retval = DeviceIoControl(handle, IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER, full_buffer, (DWORD)full_size, full_buffer, (DWORD)full_size, num_read, NULL); if((*num_read) >= sizeof(CYPRESS_SINGLE_TRANSFER)) *num_read -= sizeof(CYPRESS_SINGLE_TRANSFER); else @@ -304,7 +304,7 @@ static bool cypress_driver_get_string_info(HANDLE handle, UCHAR string_index, US if(retval && num_read >= 2) { uint8_t bytes = buffer[0]; if(bytes > num_read) - bytes = num_read; + bytes = (uint8_t)num_read; uint8_t signature = buffer[1]; if((signature == 3) && (bytes > 2)) out_str = read_string(buffer + 2, bytes - 2); @@ -469,7 +469,7 @@ void cypress_driver_list_devices(std::vector &devices_list, bool* UCHAR iserial = 0; if(!cypress_driver_get_device_pid_vid_imanufacturer_iserial_number(path, vid, pid, imanufacturer, iserial, bcd_device)) continue; - for (int j = 0; j < device_descriptions.size(); j++) { + for(size_t j = 0; j < device_descriptions.size(); j++) { const cy_device_usb_device* usb_device_desc = device_descriptions[j]; uint16_t masked_wanted_bcd_device = usb_device_desc->bcd_device_mask & usb_device_desc->bcd_device_wanted_value; if(not_supported_elems[j] && (usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && (masked_wanted_bcd_device == (bcd_device & usb_device_desc->bcd_device_mask))) { @@ -667,7 +667,7 @@ void cypress_driver_find_used_serial(const cy_device_usb_device* usb_device_desc continue; std::string read_serial = cypress_get_serial(usb_device_desc, serial, bcd_device, curr_serial_extra_id); try { - int pos = std::stoi(read_serial); + size_t pos = std::stoi(read_serial); if((pos < 0) || (pos >= num_free_fw_ids)) continue; found[pos] = true; @@ -691,7 +691,7 @@ int cypress_driver_async_in_start(cy_device_device_handlers* handlers, const cy_ cb_data->requested_length = length; cb_data->buffer = buf; cb_data->start_request = std::chrono::high_resolution_clock::now(); - cb_data->timeout_s = usb_device_desc->bulk_timeout / 1000.0; + cb_data->timeout_s = usb_device_desc->bulk_timeout / 1000.0f; OVERLAPPED* overlap_data = (OVERLAPPED*)cb_data->transfer_data; cb_data->is_transfer_done_mutex->specific_try_lock(cb_data->internal_index); int retval = cypress_driver_bulk_async_start(cb_data->handle, cb_data->buffer, cb_data->requested_length, NULL, usb_device_desc->ep_bulk_in, overlap_data, (CYPRESS_SINGLE_TRANSFER*)cb_data->extra_transfer_data); @@ -708,7 +708,7 @@ int cypress_driver_async_in_start(cy_device_device_handlers* handlers, const cy_ void cypress_driver_start_thread(std::thread* thread_ptr, bool* usb_thread_run, std::vector &cb_data_vector, cy_device_device_handlers* handlers) { #ifdef _WIN32 *usb_thread_run = true; - for (int i = 0; i < cb_data_vector.size(); i++) { + for (size_t i = 0; i < cb_data_vector.size(); i++) { cb_data_vector[i]->extra_transfer_data = new CYPRESS_SINGLE_TRANSFER; cb_data_vector[i]->base_transfer_data = new OVERLAPPED; ((OVERLAPPED*)cb_data_vector[i]->base_transfer_data)->hEvent = CreateEvent(NULL, false, false, NULL); @@ -721,7 +721,7 @@ void cypress_driver_close_thread(std::thread* thread_ptr, bool* usb_thread_run, #ifdef _WIN32 *usb_thread_run = false; thread_ptr->join(); - for (int i = 0; i < cb_data_vector.size(); i++) { + for(size_t i = 0; i < cb_data_vector.size(); i++) { CloseHandle(((OVERLAPPED*)cb_data_vector[i]->base_transfer_data)->hEvent); delete ((OVERLAPPED*)cb_data_vector[i]->base_transfer_data); delete ((CYPRESS_SINGLE_TRANSFER*)cb_data_vector[i]->extra_transfer_data); @@ -751,7 +751,7 @@ void cypress_driver_set_transfer_size_bulk_in(cy_device_device_handlers* handler new_transfer_size = ((new_transfer_size + usb_device_desc->max_usb_packet_size - 1) / usb_device_desc->max_usb_packet_size) * usb_device_desc->max_usb_packet_size; SetTransferInfo.EndpointAddress = usb_device_desc->ep_bulk_in; - SetTransferInfo.TransferSize = new_transfer_size; + SetTransferInfo.TransferSize = (ULONG)new_transfer_size; DeviceIoControl(handlers->read_handle, IOCTL_ADAPT_SET_TRANSFER_SIZE, &SetTransferInfo, sizeof(CYPRESS_SET_TRANSFER_SIZE_INFO), &SetTransferInfo, sizeof(CYPRESS_SET_TRANSFER_SIZE_INFO), &transferred, NULL); #endif diff --git a/source/CaptureDeviceSpecific/CypressShared/cypress_shared_libusb_comms.cpp b/source/CaptureDeviceSpecific/CypressShared/cypress_shared_libusb_comms.cpp index cbd93ee..18a993d 100644 --- a/source/CaptureDeviceSpecific/CypressShared/cypress_shared_libusb_comms.cpp +++ b/source/CaptureDeviceSpecific/CypressShared/cypress_shared_libusb_comms.cpp @@ -133,11 +133,11 @@ cy_device_device_handlers* cypress_libusb_serial_reconnection(const cy_device_us if(!usb_is_initialized()) return NULL; libusb_device **usb_devices; - int num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); + ssize_t num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); libusb_device_descriptor usb_descriptor{}; cy_device_device_handlers* final_handlers = NULL; - for(int i = 0; i < num_devices; i++) { + for(ssize_t i = 0; i < num_devices; i++) { cy_device_device_handlers handlers; int result = libusb_get_device_descriptor(usb_devices[i], &usb_descriptor); if(result < 0) @@ -174,7 +174,7 @@ cy_device_device_handlers* cypress_libusb_serial_reconnection(const cy_device_us } void cypress_libusb_end_connection(cy_device_device_handlers* handlers, const cy_device_usb_device* device_desc, bool interface_claimed) { - if (interface_claimed) + if(interface_claimed) libusb_release_interface(handlers->usb_handle, device_desc->default_interface); libusb_close(handlers->usb_handle); handlers->usb_handle = NULL; @@ -184,11 +184,10 @@ void cypress_libusb_find_used_serial(const cy_device_usb_device* usb_device_desc if(!usb_is_initialized()) return; libusb_device **usb_devices; - int num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); + ssize_t num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); libusb_device_descriptor usb_descriptor{}; - cy_device_device_handlers* final_handlers = NULL; - for(int i = 0; i < num_devices; i++) { + for(ssize_t i = 0; i < num_devices; i++) { cy_device_device_handlers handlers; int result = libusb_get_device_descriptor(usb_devices[i], &usb_descriptor); if(result < 0) @@ -208,7 +207,7 @@ void cypress_libusb_find_used_serial(const cy_device_usb_device* usb_device_desc std::string device_serial_number = cypress_get_serial(usb_device_desc, (std::string)(serial), usb_descriptor.bcdDevice, curr_serial_extra_id); try { int pos = std::stoi(device_serial_number); - if((pos < 0) || (pos >= num_free_fw_ids)) + if((pos < 0) || (pos >= ((int)num_free_fw_ids))) continue; found[pos] = true; } @@ -227,19 +226,19 @@ void cypress_libusb_list_devices(std::vector &devices_list, bool* if(!usb_is_initialized()) return; libusb_device **usb_devices; - int num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); + ssize_t num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); libusb_device_descriptor usb_descriptor{}; - for(int i = 0; i < num_devices; i++) { + for(ssize_t i = 0; i < num_devices; i++) { int result = libusb_get_device_descriptor(usb_devices[i], &usb_descriptor); if(result < 0) continue; - for (int j = 0; j < device_descriptions.size(); j++) { + for(size_t j = 0; j < device_descriptions.size(); j++) { result = cypress_libusb_insert_device(devices_list, device_descriptions[j], usb_devices[i], &usb_descriptor, curr_serial_extra_id_cypress[j]); - if (result != LIBUSB_ERROR_NOT_FOUND) { - if (result == LIBUSB_ERROR_ACCESS) + if(result != LIBUSB_ERROR_NOT_FOUND) { + if(result == LIBUSB_ERROR_ACCESS) no_access_elems[j] = true; - if (result == LIBUSB_ERROR_NOT_SUPPORTED) + if(result == LIBUSB_ERROR_NOT_SUPPORTED) not_supported_elems[j] = true; break; } diff --git a/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_compatibility.cpp b/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_compatibility.cpp index 4f6c463..2820d4b 100644 --- a/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_compatibility.cpp +++ b/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_compatibility.cpp @@ -28,8 +28,8 @@ void list_devices_ftd2_compatibility(std::vector &devices_list, s } void ftd2_capture_main_loop(CaptureData* capture_data) { - bool is_ftd2_libusb = capture_data->status.device.descriptor != NULL; #ifdef USE_FTD2_DRIVER + bool is_ftd2_libusb = capture_data->status.device.descriptor != NULL; if(!is_ftd2_libusb) return ftd2_capture_main_loop_driver(capture_data); #endif @@ -70,7 +70,7 @@ int ftd2_write(void* handle, bool is_ftd2_libusb, const uint8_t* data, size_t si #ifdef USE_FTD2_DRIVER if(!is_ftd2_libusb) { DWORD inner_sent = 0; - FT_STATUS ftStatus = FT_Write(handle, (void*)data, size, &inner_sent); + FT_STATUS ftStatus = FT_Write(handle, (void*)data, (DWORD)size, &inner_sent); *sent = inner_sent; return ftStatus; } @@ -86,7 +86,7 @@ int ftd2_read(void* handle, bool is_ftd2_libusb, uint8_t* data, size_t size, siz #ifdef USE_FTD2_DRIVER if(!is_ftd2_libusb) { DWORD inner_bytes_in = 0; - FT_STATUS ftStatus = FT_Read(handle, (void*)data, size, &inner_bytes_in); + FT_STATUS ftStatus = FT_Read(handle, (void*)data, (DWORD)size, &inner_bytes_in); *bytesIn = inner_bytes_in; return ftStatus; } @@ -126,10 +126,10 @@ int ftd2_reset_device(void* handle, bool is_ftd2_libusb) { int ftd2_set_usb_parameters(void* handle, bool is_ftd2_libusb, size_t size_in, size_t size_out) { #ifdef USE_FTD2_DRIVER if(!is_ftd2_libusb) - return FT_SetUSBParameters(handle, size_in, size_out); + return FT_SetUSBParameters(handle, (ULONG)size_in, (ULONG)size_out); #endif #ifdef USE_FTD2_LIBUSB - return ftd2_libusb_set_usb_chunksizes(handle, size_in, size_out); + return ftd2_libusb_set_usb_chunksizes(handle, (unsigned int)size_in, (unsigned int)size_out); #else return FT_OK; #endif diff --git a/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_driver_acquisition.cpp b/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_driver_acquisition.cpp index a36b82b..975fde7 100644 --- a/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_driver_acquisition.cpp +++ b/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_driver_acquisition.cpp @@ -57,7 +57,7 @@ void ftd2_capture_main_loop_driver(CaptureData* capture_data) { auto clock_start = std::chrono::high_resolution_clock::now(); int curr_data_buffer_index = 0; int next_data_buffer_index = 0; - const size_t full_size = get_capture_size(capture_data->status.device.is_rgb_888); + const size_t full_size = (size_t)get_capture_size(capture_data->status.device.is_rgb_888); size_t next_size = full_size; size_t bytesIn; @@ -79,6 +79,6 @@ void ftd2_capture_main_loop_driver(CaptureData* capture_data) { if(has_synch_failed) { continue; } - data_output_update(curr_data_buffer_index, capture_data, full_size, clock_start); + data_output_update(curr_data_buffer_index, capture_data, (int)full_size, clock_start); } } diff --git a/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_driver_comms.cpp b/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_driver_comms.cpp index 72ddb5d..4d35310 100644 --- a/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_driver_comms.cpp +++ b/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_driver_comms.cpp @@ -44,7 +44,7 @@ void list_devices_ftd2_driver(std::vector &devices_list, std::vec int ftd2_driver_open_serial(CaptureDevice* device, void** handle) { char SerialNumber[SERIAL_NUMBER_SIZE] = { 0 }; - strncpy(SerialNumber, device->serial_number.c_str(), SERIAL_NUMBER_SIZE); + strncpy_s(SerialNumber, SERIAL_NUMBER_SIZE, device->serial_number.c_str(), SERIAL_NUMBER_SIZE); SerialNumber[REAL_SERIAL_NUMBER_SIZE] = 0; return FT_OpenEx(SerialNumber, FT_OPEN_BY_SERIAL_NUMBER, handle); } diff --git a/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_libusb_acquisition.cpp b/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_libusb_acquisition.cpp index 33c6162..025504a 100644 --- a/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_libusb_acquisition.cpp +++ b/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_libusb_acquisition.cpp @@ -34,14 +34,13 @@ static void STDCALL ftd2_libusb_read_callback(libusb_transfer* transfer) { // Read from bulk static void ftd2_libusb_schedule_read(ftd2_async_callback_data* cb_data, uint8_t* buffer_raw, int length) { - const int max_packet_size = MAX_PACKET_SIZE_USB2; libusb_transfer *transfer_in = libusb_alloc_transfer(0); if(!transfer_in) return; cb_data->transfer_data_access.lock(); cb_data->transfer_data = transfer_in; cb_data->is_transfer_done_mutex->specific_try_lock(cb_data->internal_index); - length = ftd2_libusb_get_expanded_length(length); + length = (int)ftd2_libusb_get_expanded_length(length); cb_data->requested_length = length; ftd2_libusb_async_bulk_in_prepare_and_submit(cb_data->handle, (void*)transfer_in, buffer_raw, length, (void*)ftd2_libusb_read_callback, (void*)cb_data, NUM_CAPTURE_RECEIVED_DATA_BUFFERS); cb_data->transfer_data_access.unlock(); @@ -51,41 +50,10 @@ static int get_ftd2_libusb_status(FTD2CaptureReceivedData* received_data_buffers return *received_data_buffers[0].status; } -static void reset_ftd2_libusb_status(FTD2CaptureReceivedData* received_data_buffers) { - *received_data_buffers[0].status = 0; -} - static void error_ftd2_libusb_status(FTD2CaptureReceivedData* received_data_buffers, int error) { *received_data_buffers[0].status = error; } -static int ftd2_libusb_get_num_free_buffers(FTD2CaptureReceivedData* received_data_buffers) { - int num_free = 0; - for(int i = 0; i < NUM_CAPTURE_RECEIVED_DATA_BUFFERS; i++) - if(!received_data_buffers[i].in_use) - num_free += 1; - return num_free; -} - -static void wait_all_ftd2_libusb_transfers_done(FTD2CaptureReceivedData* received_data_buffers) { - if (received_data_buffers == NULL) - return; - if (*received_data_buffers[0].status < 0) { - for (int i = 0; i < NUM_CAPTURE_RECEIVED_DATA_BUFFERS; i++) - ftd2_libusb_cancel_callback(&received_data_buffers[i].cb_data); - } - for (int i = 0; i < NUM_CAPTURE_RECEIVED_DATA_BUFFERS; i++) { - void* transfer_data; - do { - received_data_buffers[i].cb_data.transfer_data_access.lock(); - transfer_data = received_data_buffers[i].cb_data.transfer_data; - received_data_buffers[i].cb_data.transfer_data_access.unlock(); - if(transfer_data) - received_data_buffers[i].cb_data.is_transfer_done_mutex->specific_timed_lock(i); - } while(transfer_data); - } -} - static void wait_all_ftd2_libusb_buffers_free(FTD2CaptureReceivedData* received_data_buffers) { if(received_data_buffers == NULL) return; @@ -114,10 +82,6 @@ static void wait_one_ftd2_libusb_buffer_free(FTD2CaptureReceivedData* received_d } } -static bool ftd2_libusb_are_buffers_all_free(FTD2CaptureReceivedData* received_data_buffers) { - return ftd2_libusb_get_num_free_buffers(received_data_buffers) == NUM_CAPTURE_RECEIVED_DATA_BUFFERS; -} - static FTD2CaptureReceivedData* ftd2_libusb_get_free_buffer(FTD2CaptureReceivedData* received_data_buffers) { wait_one_ftd2_libusb_buffer_free(received_data_buffers); if(*received_data_buffers[0].status < 0) @@ -139,7 +103,7 @@ static void ftd2_libusb_start_read(FTD2CaptureReceivedData* received_data_buffer received_data_buffer->buffer_raw = (uint8_t*)&data_buffer->ftd2_received_old_ds_normal_plus_raw.raw_data; received_data_buffer->buffer_target = (uint32_t*)data_buffer; received_data_buffer->index = index; - ftd2_libusb_schedule_read(&received_data_buffer->cb_data, received_data_buffer->buffer_raw, size); + ftd2_libusb_schedule_read(&received_data_buffer->cb_data, received_data_buffer->buffer_raw, (int)size); } static void ftd2_libusb_copy_buffer_to_target_and_skip(uint8_t* buffer_written, uint8_t* buffer_target, const int max_packet_size, size_t length, size_t header_packet_size, size_t ignored_bytes) { @@ -148,25 +112,26 @@ static void ftd2_libusb_copy_buffer_to_target_and_skip(uint8_t* buffer_written, // Remove the small headers every 512 bytes... // The "- header_packet_size" instead of "-1" covers for partial header transfers... - int num_iters = (length + max_packet_size - header_packet_size) / max_packet_size; + int real_packet_size = (int)(max_packet_size - header_packet_size); + int num_iters = (int)((length + real_packet_size) / max_packet_size); if(num_iters <= 0) return; size_t inner_length = length - (num_iters * header_packet_size); - size_t fully_ignored_iters = ignored_bytes / (max_packet_size - header_packet_size); - size_t partially_ignored_iters = (ignored_bytes + (max_packet_size - header_packet_size) - 1) / (max_packet_size - header_packet_size); - num_iters -= fully_ignored_iters; + size_t fully_ignored_iters = ignored_bytes / real_packet_size; + size_t partially_ignored_iters = (ignored_bytes + real_packet_size - 1) / real_packet_size; + num_iters -= (int)fully_ignored_iters; if(num_iters <= 0) return; buffer_written += fully_ignored_iters * max_packet_size; // Skip inside a packet, since it's misaligned if(partially_ignored_iters != fully_ignored_iters) { - size_t offset_bytes = ignored_bytes % (max_packet_size - header_packet_size); - int rem_size = inner_length - ((max_packet_size - header_packet_size) * fully_ignored_iters); - if(rem_size > ((int)((max_packet_size - header_packet_size)))) - rem_size = max_packet_size - header_packet_size; - rem_size -= offset_bytes; + size_t offset_bytes = ignored_bytes % real_packet_size; + int rem_size = (int)(inner_length - (real_packet_size * fully_ignored_iters)); + if(rem_size > real_packet_size) + rem_size = real_packet_size; + rem_size -= (int)offset_bytes; if(rem_size > 0) { memcpy(buffer_target, buffer_written + header_packet_size + offset_bytes, rem_size); buffer_written += max_packet_size; @@ -202,7 +167,7 @@ static size_t ftd2_libusb_copy_buffer_to_target_and_skip_synch(uint8_t* in_buffe else *sync_offset = 0; uint16_t* out_u16 = (uint16_t*)out_buffer; - for(int i = 0; i < ignored_halfwords; i++) + for(size_t i = 0; i < ignored_halfwords; i++) out_u16[(real_length / 2) - ignored_halfwords + i] = FTD2_OLDDS_SYNCH_VALUES; return remove_synch_from_final_length(out_buffer, real_length); } @@ -241,7 +206,7 @@ static void ftd2_libusb_capture_process_data(void* in_user_data, int transfer_le *user_data->status = LIBUSB_ERROR_OTHER; return end_ftd2_libusb_read_frame_cb(user_data, false); } - if(transfer_length < user_data->cb_data.requested_length) + if(((size_t)transfer_length) < user_data->cb_data.requested_length) return end_ftd2_libusb_read_frame_cb(user_data, false); if(((int32_t)(user_data->index - (*user_data->last_used_index))) <= 0) { //*user_data->status = LIBUSB_ERROR_INTERRUPTED; @@ -307,18 +272,13 @@ static void resync_offset(FTD2CaptureReceivedData* received_data_buffers, uint32 void ftd2_capture_main_loop_libusb(CaptureData* capture_data) { const bool is_ftd2_libusb = true; bool is_done = false; - int inner_curr_in = 0; - int retval = 0; auto clock_start = std::chrono::high_resolution_clock::now(); FTD2CaptureReceivedData* received_data_buffers = new FTD2CaptureReceivedData[NUM_CAPTURE_RECEIVED_DATA_BUFFERS]; - int curr_data_buffer = 0; - int next_data_buffer = 0; int status = 0; uint32_t last_used_index = -1; uint32_t index = 0; size_t curr_offset = 0; - const size_t full_size = get_capture_size(capture_data->status.device.is_rgb_888); - size_t bytesIn; + const size_t full_size = (size_t)get_capture_size(capture_data->status.device.is_rgb_888); libusb_register_to_event_thread(); diff --git a/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_libusb_comms.cpp b/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_libusb_comms.cpp index 7f878f3..ba10bde 100644 --- a/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_libusb_comms.cpp +++ b/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_libusb_comms.cpp @@ -45,7 +45,7 @@ static const vid_pid_descriptor* accepted_devices[] = { }; static const vid_pid_descriptor* get_device_descriptor(int vid, int pid) { - for(int i = 0; i < sizeof(accepted_devices) / sizeof(*accepted_devices); i++) + for(size_t i = 0; i < sizeof(accepted_devices) / sizeof(*accepted_devices); i++) if((vid == accepted_devices[i]->vid) && (pid == accepted_devices[i]->pid)) return accepted_devices[i]; return NULL; @@ -131,15 +131,14 @@ void list_devices_ftd2_libusb(std::vector &devices_list, std::vec if(!usb_is_initialized()) return; libusb_device **usb_devices; - int num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); - libusb_device_descriptor usb_descriptor{}; + ssize_t num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); char description[DESCRIPTION_SIZE], SerialNumber[SERIAL_NUMBER_SIZE]; int debug_multiplier = 1; bool insert_anyway = false; bool perm_error = false; const vid_pid_descriptor* curr_descriptor; - for(int i = 0; i < num_devices; i++) { + for(ssize_t i = 0; i < num_devices; i++) { int retval = check_single_device_valid_ftd2_libusb(usb_devices[i], description, SerialNumber, &curr_descriptor); if(retval < 0) { if(retval == LIBUSB_ERROR_ACCESS) @@ -148,7 +147,7 @@ void list_devices_ftd2_libusb(std::vector &devices_list, std::vec } std::string serial_number = std::string(SerialNumber); bool is_already_inserted = false; - for(int j = 0; j < devices_list.size(); j++) { + for(size_t j = 0; j < devices_list.size(); j++) { if((devices_list[j].cc_type == CAPTURE_CONN_FTD2) && (devices_list[j].serial_number == serial_number)) { is_already_inserted = true; break; @@ -170,7 +169,7 @@ static int ftd2_libusb_ctrl_out(ftd2_libusb_handle_data* handle, uint8_t request return -1; if(handle->usb_handle == NULL) return -1; - return libusb_control_transfer(handle->usb_handle, 0x40, request, value, index, (uint8_t*)data, size, handle->timeout_w_ms); + return libusb_control_transfer(handle->usb_handle, 0x40, request, value, index, (uint8_t*)data, (uint16_t)size, handle->timeout_w_ms); } static int ftd2_libusb_ctrl_in(ftd2_libusb_handle_data* handle, uint8_t request, uint16_t value, uint16_t index, uint8_t* data, size_t size) { @@ -178,7 +177,7 @@ static int ftd2_libusb_ctrl_in(ftd2_libusb_handle_data* handle, uint8_t request, return -1; if(handle->usb_handle == NULL) return -1; - return libusb_control_transfer(handle->usb_handle, 0xC0, request, value, index, data, size, handle->timeout_r_ms); + return libusb_control_transfer(handle->usb_handle, 0xC0, request, value, index, data, (uint16_t)size, handle->timeout_r_ms); } static int ftd2_libusb_ctrl_out_with_index(ftd2_libusb_handle_data* handle, uint8_t request, uint16_t value, uint16_t index, uint8_t* data, size_t size) { @@ -192,7 +191,7 @@ static int ftd2_libusb_bulk_out(ftd2_libusb_handle_data* handle, const uint8_t* return -1; if(handle->usb_handle == NULL) return -1; - return libusb_bulk_transfer(handle->usb_handle, handle->ep_out, (uint8_t*)data, size, transferred, handle->timeout_w_ms); + return libusb_bulk_transfer(handle->usb_handle, handle->ep_out, (uint8_t*)data, (int)size, transferred, handle->timeout_w_ms); } static int ftd2_libusb_bulk_in(ftd2_libusb_handle_data* handle, uint8_t* data, size_t size, int* transferred) { @@ -200,7 +199,7 @@ static int ftd2_libusb_bulk_in(ftd2_libusb_handle_data* handle, uint8_t* data, s return -1; if(handle->usb_handle == NULL) return -1; - return libusb_bulk_transfer(handle->usb_handle, handle->ep_in, data, size, transferred, handle->timeout_r_ms); + return libusb_bulk_transfer(handle->usb_handle, handle->ep_in, data, (int)size, transferred, handle->timeout_r_ms); } int ftd2_libusb_async_bulk_in_prepare_and_submit(void* handle, void* transfer_in, uint8_t* buffer_raw, size_t size, void* cb_fn, void* cb_data, int timeout_multiplier) { @@ -212,7 +211,7 @@ int ftd2_libusb_async_bulk_in_prepare_and_submit(void* handle, void* transfer_in if(!transfer_in) return -1; libusb_transfer* transfer = (libusb_transfer*)transfer_in; - libusb_fill_bulk_transfer(transfer, in_handle->usb_handle, in_handle->ep_in, buffer_raw, size, (libusb_transfer_cb_fn)cb_fn, cb_data, in_handle->timeout_r_ms * timeout_multiplier); + libusb_fill_bulk_transfer(transfer, in_handle->usb_handle, in_handle->ep_in, buffer_raw, (int)size, (libusb_transfer_cb_fn)cb_fn, cb_data, in_handle->timeout_r_ms * timeout_multiplier); transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER; libusb_submit_transfer(transfer); return 0; @@ -304,7 +303,7 @@ size_t ftd2_libusb_get_expanded_length(size_t length) { size_t ftd2_libusb_get_actual_length(const int max_packet_size, size_t length, size_t header_packet_size) { // Remove the small headers every 512 bytes... // The "- header_packet_size" instead of "-1" covers for partial header transfers... - int num_iters = (length + max_packet_size - header_packet_size) / max_packet_size; + int num_iters = (int)((length + max_packet_size - header_packet_size) / max_packet_size); if(num_iters > 0) length -= (num_iters * header_packet_size); else @@ -319,15 +318,16 @@ size_t ftd2_libusb_get_actual_length(size_t length) { void ftd2_libusb_copy_buffer_to_target(uint8_t* buffer_written, uint8_t* buffer_target, const int max_packet_size, size_t length, size_t header_packet_size) { // Remove the small headers every 512 bytes... // The "- header_packet_size" instead of "-1" covers for partial header transfers... - int num_iters = (length + max_packet_size - header_packet_size) / max_packet_size; + int num_iters = (int)((length + max_packet_size - header_packet_size) / max_packet_size); if(num_iters <= 0) return; length -= (num_iters * header_packet_size); + const int real_packet_size = (int)(max_packet_size - header_packet_size); for(int i = 0; i < num_iters; i++) { - int rem_size = length - ((max_packet_size - header_packet_size) * i); - if(rem_size > ((int)(max_packet_size - header_packet_size))) - rem_size = max_packet_size - header_packet_size; + int rem_size = (int)(length - (real_packet_size * i)); + if(rem_size > real_packet_size) + rem_size = real_packet_size; if(rem_size <= 0) break; memcpy(buffer_target + ((max_packet_size - header_packet_size) * i), buffer_written + header_packet_size + (max_packet_size * i), rem_size); @@ -403,16 +403,12 @@ int ftd2_libusb_open_serial(CaptureDevice* device, void** handle) { *handle = NULL; libusb_device **usb_devices; - int num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); - libusb_device_descriptor usb_descriptor{}; + ssize_t num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); char description[DESCRIPTION_SIZE], SerialNumber[SERIAL_NUMBER_SIZE]; - int debug_multiplier = 1; - bool insert_anyway = false; - bool perm_error = false; const vid_pid_descriptor* curr_descriptor; int ret = LIBUSB_ERROR_OTHER; - for(int i = 0; i < num_devices; i++) { + for(ssize_t i = 0; i < num_devices; i++) { ftd2_libusb_handle_data out_handle; int retval = init_handle_and_populate_device_info_ftd2_libusb(&out_handle.usb_handle, usb_devices[i], description, SerialNumber, &curr_descriptor); if(retval != LIBUSB_SUCCESS) diff --git a/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_shared.cpp b/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_shared.cpp index e1d2b43..dd64ae7 100644 --- a/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_shared.cpp +++ b/source/CaptureDeviceSpecific/DSCapture_FTD2/dscapture_ftd2_shared.cpp @@ -137,12 +137,11 @@ static int end_spi_tx(uint8_t *txBuf, int retval) { return retval; } -static int ftd2_spi_tx(void* handle, bool is_ftd2_libusb, const uint8_t* buf, int size) { +static int ftd2_spi_tx(void* handle, bool is_ftd2_libusb, const uint8_t* buf, size_t size) { uint8_t *txBuf = new uint8_t[TX_SPI_SIZE + TX_SPI_OFFSET]; int retval = 0; - int len; + size_t len; size_t sent; - size_t bytesIn; size_t wrote = 0; if(!pass_if_FT_queue_empty(handle, is_ftd2_libusb)) @@ -173,7 +172,7 @@ static int ftd2_spi_tx(void* handle, bool is_ftd2_libusb, const uint8_t* buf, in return end_spi_tx(txBuf, 0); } -static bool fpga_config(void* handle, bool is_ftd2_libusb, const uint8_t* bitstream, int size) { +static bool fpga_config(void* handle, bool is_ftd2_libusb, const uint8_t* bitstream, size_t size) { //D6=CDONE (in) //D3=SS (out) //D2=TDO (in) diff --git a/source/CaptureDeviceSpecific/ISDevices/usb_is_device_acquisition.cpp b/source/CaptureDeviceSpecific/ISDevices/usb_is_device_acquisition.cpp index 9996125..1444128 100644 --- a/source/CaptureDeviceSpecific/ISDevices/usb_is_device_acquisition.cpp +++ b/source/CaptureDeviceSpecific/ISDevices/usb_is_device_acquisition.cpp @@ -58,9 +58,9 @@ std::string get_serial(const is_device_usb_device* usb_device_desc, is_device_de bool conn_success = true; if(initial_cleanup(usb_device_desc, handlers)) conn_success = false; - if (conn_success && (GetDeviceSerial(handlers, data, usb_device_desc) != LIBUSB_SUCCESS)) + if(conn_success && (GetDeviceSerial(handlers, data, usb_device_desc) != LIBUSB_SUCCESS)) conn_success = false; - if (conn_success) { + if(conn_success) { data[IS_DEVICE_REAL_SERIAL_NUMBER_SIZE] = '\0'; serial_str = std::string((const char*)data); } @@ -82,7 +82,7 @@ static is_device_device_handlers* usb_find_by_serial_number(const is_device_usb_ int curr_serial_extra_id = 0; final_handlers = is_device_libusb_serial_reconnection(usb_device_desc, device, curr_serial_extra_id); - if (final_handlers == NULL) + if(final_handlers == NULL) final_handlers = is_driver_serial_reconnection(device); return final_handlers; } @@ -92,7 +92,7 @@ void list_devices_is_device(std::vector &devices_list, std::vecto int* curr_serial_extra_id_is_device = new int[num_is_device_desc]; bool* no_access_elems = new bool[num_is_device_desc]; bool* not_supported_elems = new bool[num_is_device_desc]; - for (int i = 0; i < num_is_device_desc; i++) { + for(size_t i = 0; i < num_is_device_desc; i++) { no_access_elems[i] = false; not_supported_elems[i] = false; curr_serial_extra_id_is_device[i] = 0; @@ -100,11 +100,11 @@ void list_devices_is_device(std::vector &devices_list, std::vecto is_device_libusb_list_devices(devices_list, no_access_elems, not_supported_elems, curr_serial_extra_id_is_device, num_is_device_desc); bool any_not_supported = false; - for(int i = 0; i < num_is_device_desc; i++) + for(size_t i = 0; i < num_is_device_desc; i++) any_not_supported |= not_supported_elems[i]; - for(int i = 0; i < num_is_device_desc; i++) + for(size_t i = 0; i < num_is_device_desc; i++) if(no_access_elems[i]) { - const is_device_usb_device* usb_device = GetISDeviceDesc(i); + const is_device_usb_device* usb_device = GetISDeviceDesc((int)i); no_access_list.emplace_back(usb_device->vid, usb_device->pid); } if(any_not_supported) @@ -116,9 +116,9 @@ void list_devices_is_device(std::vector &devices_list, std::vecto } static void is_device_connection_end(is_device_device_handlers* handlers, const is_device_usb_device *device_desc, bool interface_claimed = true) { - if (handlers == NULL) + if(handlers == NULL) return; - if (handlers->usb_handle) + if(handlers->usb_handle) is_device_libusb_end_connection(handlers, device_desc, interface_claimed); else is_driver_end_connection(handlers); @@ -212,13 +212,12 @@ int EndAcquisition(const is_device_usb_device* usb_device_desc, is_device_device void output_to_thread(CaptureData* capture_data, int internal_index, CaptureScreensType curr_capture_type, std::chrono::time_point* clock_start, size_t read_size) { // Output to the other threads... - const is_device_usb_device* usb_device_info = (const is_device_usb_device*)capture_data->status.device.descriptor; const auto curr_time = std::chrono::high_resolution_clock::now(); const std::chrono::duration diff = curr_time - (*clock_start); *clock_start = curr_time; capture_data->data_buffers.WriteToBuffer(NULL, read_size, diff.count(), &capture_data->status.device, curr_capture_type, internal_index); - if (capture_data->status.cooldown_curr_in) + if(capture_data->status.cooldown_curr_in) capture_data->status.cooldown_curr_in = capture_data->status.cooldown_curr_in - 1; capture_data->status.video_wait.unlock(); capture_data->status.audio_wait.unlock(); @@ -226,15 +225,15 @@ void output_to_thread(CaptureData* capture_data, int internal_index, CaptureScre static void output_to_thread(CaptureData* capture_data, int internal_index, CaptureScreensType curr_capture_type, std::chrono::time_point* clock_start) { const is_device_usb_device* usb_device_info = (const is_device_usb_device*)capture_data->status.device.descriptor; - output_to_thread(capture_data, internal_index, curr_capture_type, clock_start, usb_is_device_get_video_in_size(curr_capture_type, usb_device_info->device_type)); + output_to_thread(capture_data, internal_index, curr_capture_type, clock_start, (size_t)usb_is_device_get_video_in_size(curr_capture_type, usb_device_info->device_type)); } int is_device_read_frame_and_output(CaptureData* capture_data, int internal_index, CaptureScreensType curr_capture_type, std::chrono::time_point &clock_start) { const is_device_usb_device* usb_device_info = (const is_device_usb_device*)capture_data->status.device.descriptor; CaptureDataSingleBuffer* target = capture_data->data_buffers.GetWriterBuffer(internal_index); CaptureReceived* buffer = &target->capture_buf; - int ret = ReadFrame((is_device_device_handlers*)capture_data->handle, (uint8_t*)buffer, usb_is_device_get_video_in_size(curr_capture_type, usb_device_info->device_type), usb_device_info); - if (ret < 0) { + int ret = ReadFrame((is_device_device_handlers*)capture_data->handle, (uint8_t*)buffer, (int)usb_is_device_get_video_in_size(curr_capture_type, usb_device_info->device_type), usb_device_info); + if(ret < 0) { capture_data->data_buffers.ReleaseWriterBuffer(internal_index, false); return ret; } @@ -253,7 +252,7 @@ void is_device_read_frame_request(CaptureData* capture_data, ISDeviceCaptureRece is_device_capture_recv_data->cb_data.function = is_device_read_frame_cb; CaptureDataSingleBuffer* target = capture_data->data_buffers.GetWriterBuffer(is_device_capture_recv_data->cb_data.internal_index); CaptureReceived* buffer = &target->capture_buf; - ReadFrameAsync((is_device_device_handlers*)capture_data->handle, (uint8_t*)buffer, usb_is_device_get_video_in_size(curr_capture_type, usb_device_info->device_type), usb_device_info, &is_device_capture_recv_data->cb_data); + ReadFrameAsync((is_device_device_handlers*)capture_data->handle, (uint8_t*)buffer, (int)usb_is_device_get_video_in_size(curr_capture_type, usb_device_info->device_type), usb_device_info, &is_device_capture_recv_data->cb_data); } static void end_is_device_read_frame_cb(ISDeviceCaptureReceivedData* is_device_capture_recv_data, bool pre_release) { @@ -294,7 +293,7 @@ static void close_all_reads_error(CaptureData* capture_data, ISDeviceCaptureRece if(get_is_device_status(is_device_capture_recv_data) >= 0) return; if(!async_read_closed) { - for (int i = 0; i < NUM_CAPTURE_RECEIVED_DATA_BUFFERS; i++) + for(int i = 0; i < NUM_CAPTURE_RECEIVED_DATA_BUFFERS; i++) CloseAsyncRead((is_device_device_handlers*)capture_data->handle, &is_device_capture_recv_data[i].cb_data); async_read_closed = true; } @@ -332,7 +331,7 @@ void wait_all_is_device_transfers_done(CaptureData* capture_data, ISDeviceCaptur bool reset_usb_device = false; close_all_reads_error(capture_data, is_device_capture_recv_data, async_read_closed, reset_usb_device, false); const auto start_time = std::chrono::high_resolution_clock::now(); - for (int i = 0; i < NUM_CAPTURE_RECEIVED_DATA_BUFFERS; i++) { + for(int i = 0; i < NUM_CAPTURE_RECEIVED_DATA_BUFFERS; i++) { void* transfer_data; do { is_device_capture_recv_data[i].cb_data.transfer_data_access.lock(); diff --git a/source/CaptureDeviceSpecific/ISDevices/usb_is_device_communications.cpp b/source/CaptureDeviceSpecific/ISDevices/usb_is_device_communications.cpp index 68c31e2..b8550ea 100644 --- a/source/CaptureDeviceSpecific/ISDevices/usb_is_device_communications.cpp +++ b/source/CaptureDeviceSpecific/ISDevices/usb_is_device_communications.cpp @@ -270,7 +270,7 @@ static void fix_endianness_header(is_nitro_nec_packet_header* header) { static uint32_t get_crc32_data_comm(uint8_t* data, size_t size) { uint32_t value = 0xFFFFFFFF; - for(int i = 0; i < size; i++) { + for(size_t i = 0; i < size; i++) { uint8_t inner_value = (value >> 24) ^ data[i]; value <<= 8; value ^= read_le32(is_twl_cap_crc32_table, inner_value); @@ -295,29 +295,29 @@ static void apply_enc_dec_action_value(uint32_t action_value, uint32_t rotating_ } switch((action_value & 0xFF) - 1) { case 0: - for(int j = 0; j < size_u16; j++) + for(size_t j = 0; j < size_u16; j++) write_be16(data, read_le16(data, j), j); break; case 1: - for(int j = 0; j < size_u16; j++) { + for(size_t j = 0; j < size_u16; j++) { write_le16(data, read_le16(data, j) ^ rotating_value, j); rotating_value += increment; } break; case 2: - for(int j = 0; j < size_u16; j++) { + for(size_t j = 0; j < size_u16; j++) { write_le16(data, read_le16(data, j) + rotating_value, j); rotating_value += increment; } break; case 3: - for(int j = 0; j < size_u16; j++) { + for(size_t j = 0; j < size_u16; j++) { write_le16(data, read_le16(data, j) - rotating_value, j); rotating_value += increment; } break; case 4: - for(int j = 0; j < (size_u16 / 2); j++) { + for(size_t j = 0; j < (size_u16 / 2); j++) { first_val = read_le16(data, j); write_le16(data, read_le16(data, size_u16 - 1 - j), j); write_le16(data, first_val, size_u16 - 1 - j); @@ -325,13 +325,13 @@ static void apply_enc_dec_action_value(uint32_t action_value, uint32_t rotating_ break; case 5: first_val = read_le16(data); - for(int j = 0; j < (size_u16 - 1); j++) + for(size_t j = 0; j < (size_u16 - 1); j++) write_le16(data, read_le16(data, j + 1), j); write_le16(data, first_val, size_u16 - 1); break; case 6: last_val = read_le16(data, size_u16 - 1); - for(int j = 0; j < (size_u16 - 1); j++) + for(size_t j = 0; j < (size_u16 - 1); j++) write_le16(data, read_le16(data, size_u16 - 1 - j - 1), size_u16 - 1 - j); write_le16(data, last_val); break; @@ -488,9 +488,9 @@ static int SendWritePacket(is_device_device_handlers* handlers, uint16_t command bool append_mode = true; if(device_desc->device_type == IS_NITRO_CAPTURE_DEVICE) append_mode = false; - int single_packet_covered_size = device_desc->max_usb_packet_size - sizeof(header); + int single_packet_covered_size = (int)(device_desc->max_usb_packet_size - sizeof(header)); if(!append_mode) - single_packet_covered_size = device_desc->max_usb_packet_size; + single_packet_covered_size = (int)device_desc->max_usb_packet_size; int num_iters = (length + single_packet_covered_size - 1) / single_packet_covered_size; if(!num_iters) num_iters = 1; @@ -513,7 +513,7 @@ static int SendWritePacket(is_device_device_handlers* handlers, uint16_t command fix_endianness_header(&header); int ret = 0; int num_bytes = 0; - for(int j = 0; j < sizeof(is_device_packet_header); j++) + for(size_t j = 0; j < sizeof(is_device_packet_header); j++) single_usb_packet[j] = ((uint8_t*)&header)[j]; if(append_mode && (buf != NULL)) { for(int j = 0; j < transfer_size; j++) @@ -533,7 +533,7 @@ static int SendWritePacket(is_device_device_handlers* handlers, uint16_t command } if(ret < 0) return return_and_delete(single_usb_packet, ret); - if(num_bytes != (transfer_size + sizeof(is_device_packet_header))) + if(num_bytes != ((int)(transfer_size + sizeof(is_device_packet_header)))) return return_and_delete(single_usb_packet, LIBUSB_ERROR_INTERRUPTED); } if((device_desc->device_type == IS_NITRO_CAPTURE_DEVICE) && expect_result) { @@ -552,7 +552,7 @@ static int SendWritePacket(is_device_device_handlers* handlers, uint16_t command static int SendReadPacket(is_device_device_handlers* handlers, uint16_t command, is_device_packet_type type, uint32_t address, uint8_t* buf, int length, const is_device_usb_device* device_desc, bool expect_result = true) { is_device_packet_header header; - int single_packet_covered_size = device_desc->max_usb_packet_size; + int single_packet_covered_size = (int)device_desc->max_usb_packet_size; int num_iters = (length + single_packet_covered_size - 1) / single_packet_covered_size; if(num_iters == 0) num_iters = 1; @@ -601,11 +601,11 @@ static int SendReadWritePacket(is_device_device_handlers* handlers, uint16_t com if((device_desc->device_type == IS_NITRO_EMULATOR_DEVICE) || (device_desc->device_type == IS_NITRO_CAPTURE_DEVICE)) return LIBUSB_SUCCESS; is_device_rw_packet_header header; - int single_packet_covered_size_w = device_desc->max_usb_packet_size - sizeof(header); + int single_packet_covered_size_w = (int)(device_desc->max_usb_packet_size - sizeof(header)); int num_iters_w = (length_w + single_packet_covered_size_w - 1) / single_packet_covered_size_w; if(!num_iters_w) num_iters_w = 1; - int single_packet_covered_size_r = device_desc->max_usb_packet_size; + int single_packet_covered_size_r = (int)device_desc->max_usb_packet_size; int num_iters_r = (length_r + single_packet_covered_size_r - 1) / single_packet_covered_size_r; if(!num_iters_r) num_iters_r = 1; @@ -635,7 +635,7 @@ static int SendReadWritePacket(is_device_device_handlers* handlers, uint16_t com int ret = 0; int num_bytes = 0; if(is_packet_direction_write(device_desc->device_type, packet_direction)) { - for(int j = 0; j < sizeof(is_device_rw_packet_header); j++) + for(size_t j = 0; j < sizeof(is_device_rw_packet_header); j++) single_usb_packet[j] = ((uint8_t*)&header)[j]; if(buf_w != NULL) { for(int j = 0; j < transfer_size_w; j++) @@ -648,7 +648,7 @@ static int SendReadWritePacket(is_device_device_handlers* handlers, uint16_t com } if(ret < 0) return return_and_delete(single_usb_packet, ret); - if(num_bytes != (transfer_size_w + sizeof(is_device_rw_packet_header))) + if(num_bytes != ((int)(transfer_size_w + sizeof(is_device_rw_packet_header)))) return return_and_delete(single_usb_packet, LIBUSB_ERROR_INTERRUPTED); } else { @@ -803,9 +803,9 @@ int WriteNecMem(is_device_device_handlers* handlers, uint32_t address, uint8_t u header.count = count; header.address = address; fix_endianness_header(&header); - for(int i = 0; i < sizeof(is_nitro_nec_packet_header); i++) + for(size_t i = 0; i < sizeof(is_nitro_nec_packet_header); i++) buffer[i] = ((uint8_t*)&header)[i]; - for(int i = 0; i < count * unit_size; i++) + for(int i = 0; i < (count * unit_size); i++) buffer[i + sizeof(is_nitro_nec_packet_header)] = buf[i]; int ret = SendWriteCommand(handlers, header.command, buffer, (count * unit_size) + sizeof(is_nitro_nec_packet_header), device_desc); delete []buffer; diff --git a/source/CaptureDeviceSpecific/ISDevices/usb_is_device_is_driver.cpp b/source/CaptureDeviceSpecific/ISDevices/usb_is_device_is_driver.cpp index 49bd813..6ccb795 100644 --- a/source/CaptureDeviceSpecific/ISDevices/usb_is_device_is_driver.cpp +++ b/source/CaptureDeviceSpecific/ISDevices/usb_is_device_is_driver.cpp @@ -40,7 +40,7 @@ static void is_device_is_driver_function(bool* usb_thread_run, ISDeviceCaptureRe cb_data->is_data_ready = false; cb_data->transfer_data_access.unlock(); if(is_device_capture_recv_data[i].in_use && read_data_ready) - cb_data->function(&is_device_capture_recv_data[i], cb_data->actual_length, cb_data->status_value); + cb_data->function(&is_device_capture_recv_data[i], (int)cb_data->actual_length, cb_data->status_value); } int dummy = 0; is_device_capture_recv_data[0].cb_data.is_transfer_data_ready_mutex->general_timed_lock(&dummy); @@ -48,7 +48,7 @@ static void is_device_is_driver_function(bool* usb_thread_run, ISDeviceCaptureRe } static bool read_is_driver_device_info(HANDLE handle, uint8_t* buffer, size_t size, DWORD* num_read) { - return DeviceIoControl(handle, 0x22000C, buffer, size, buffer, size, num_read, NULL); + return DeviceIoControl(handle, 0x22000C, buffer, (DWORD)size, buffer, (DWORD)size, num_read, NULL); } static bool is_driver_send_ioctl(HANDLE handle, uint8_t* buffer, size_t size, uint8_t request, uint16_t index, DWORD* num_read) { @@ -58,7 +58,7 @@ static bool is_driver_send_ioctl(HANDLE handle, uint8_t* buffer, size_t size, ui write_le32(data, 2, 1); write_le32(data, ((uint32_t)request) << 8, 2); write_le32(data, index, 3); - return DeviceIoControl(handle, 0x220020, data, 0x10, buffer, size, num_read, NULL); + return DeviceIoControl(handle, 0x220020, data, 0x10, buffer, (DWORD)size, num_read, NULL); } static bool is_driver_device_reset(HANDLE handle) { @@ -250,8 +250,8 @@ void is_driver_list_devices(std::vector &devices_list, bool* not_ uint16_t pid = 0; if(!is_driver_get_device_pid_vid(path, vid, pid)) continue; - for (int j = 0; j < num_is_device_desc; j++) { - const is_device_usb_device* usb_device_desc = GetISDeviceDesc(j); + for(size_t j = 0; j < num_is_device_desc; j++) { + const is_device_usb_device* usb_device_desc = GetISDeviceDesc((int)j); if(not_supported_elems[j] && (usb_device_desc->vid == vid) && (usb_device_desc->pid == pid)) { is_device_device_handlers handlers; if(is_driver_setup_connection(&handlers, path, usb_device_desc->read_pipe, usb_device_desc->write_pipe, usb_device_desc->do_pipe_clear_reset)) @@ -319,7 +319,7 @@ int is_drive_async_in_start(is_device_device_handlers* handlers, const is_device memset(overlap_data, 0, sizeof(OVERLAPPED)); cb_data->is_transfer_done_mutex->specific_try_lock(cb_data->internal_index); cb_data->is_transfer_data_ready_mutex->specific_try_lock(cb_data->internal_index); - int retval = ReadFileEx(cb_data->handle, cb_data->buffer, cb_data->requested_length, (OVERLAPPED*)cb_data->transfer_data, OverlappedCompletionNothingRoutine); + int retval = ReadFileEx(cb_data->handle, cb_data->buffer, (DWORD)cb_data->requested_length, (OVERLAPPED*)cb_data->transfer_data, OverlappedCompletionNothingRoutine); cb_data->transfer_data_access.unlock(); if (retval == 0) return LIBUSB_ERROR_BUSY; diff --git a/source/CaptureDeviceSpecific/ISDevices/usb_is_device_libusb.cpp b/source/CaptureDeviceSpecific/ISDevices/usb_is_device_libusb.cpp index 415df81..75bc891 100644 --- a/source/CaptureDeviceSpecific/ISDevices/usb_is_device_libusb.cpp +++ b/source/CaptureDeviceSpecific/ISDevices/usb_is_device_libusb.cpp @@ -65,11 +65,11 @@ is_device_device_handlers* is_device_libusb_serial_reconnection(const is_device_ if(!usb_is_initialized()) return NULL; libusb_device **usb_devices; - int num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); + ssize_t num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); libusb_device_descriptor usb_descriptor{}; is_device_device_handlers* final_handlers = NULL; - for(int i = 0; i < num_devices; i++) { + for(ssize_t i = 0; i < num_devices; i++) { is_device_device_handlers handlers; int result = libusb_get_device_descriptor(usb_devices[i], &usb_descriptor); if(result < 0) @@ -110,15 +110,15 @@ void is_device_libusb_list_devices(std::vector &devices_list, boo if(!usb_is_initialized()) return; libusb_device **usb_devices; - int num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); + ssize_t num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); libusb_device_descriptor usb_descriptor{}; - for(int i = 0; i < num_devices; i++) { + for(ssize_t i = 0; i < num_devices; i++) { int result = libusb_get_device_descriptor(usb_devices[i], &usb_descriptor); if(result < 0) continue; - for (int j = 0; j < num_is_device_desc; j++) { - result = is_device_libusb_insert_device(devices_list, GetISDeviceDesc(j), usb_devices[i], &usb_descriptor, curr_serial_extra_id_is_device[j]); + for (size_t j = 0; j < num_is_device_desc; j++) { + result = is_device_libusb_insert_device(devices_list, GetISDeviceDesc((int)j), usb_devices[i], &usb_descriptor, curr_serial_extra_id_is_device[j]); if (result != LIBUSB_ERROR_NOT_FOUND) { if (result == LIBUSB_ERROR_ACCESS) no_access_elems[j] = true; diff --git a/source/CaptureDeviceSpecific/ISDevices/usb_is_nitro_acquisition_capture.cpp b/source/CaptureDeviceSpecific/ISDevices/usb_is_nitro_acquisition_capture.cpp index ad4fd49..a551546 100644 --- a/source/CaptureDeviceSpecific/ISDevices/usb_is_nitro_acquisition_capture.cpp +++ b/source/CaptureDeviceSpecific/ISDevices/usb_is_nitro_acquisition_capture.cpp @@ -102,8 +102,6 @@ int EndAcquisitionCapture(const is_device_usb_device* usb_device_desc, is_device } void is_nitro_acquisition_capture_main_loop(CaptureData* capture_data, ISDeviceCaptureReceivedData* is_device_capture_recv_data) { - 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; bool is_acquisition_off = true; uint32_t index = 0; CaptureScreensType curr_capture_type = capture_data->status.capture_type; diff --git a/source/CaptureDeviceSpecific/ISDevices/usb_is_nitro_acquisition_emulator.cpp b/source/CaptureDeviceSpecific/ISDevices/usb_is_nitro_acquisition_emulator.cpp index 02fbb76..249084f 100644 --- a/source/CaptureDeviceSpecific/ISDevices/usb_is_nitro_acquisition_emulator.cpp +++ b/source/CaptureDeviceSpecific/ISDevices/usb_is_nitro_acquisition_emulator.cpp @@ -35,7 +35,7 @@ static int drain_frames(is_device_device_handlers* handlers, int num_frames, int start_frames, CaptureScreensType capture_type, const is_device_usb_device* usb_device_desc) { ISNitroEmulatorVideoInputData* video_in_buffer = new ISNitroEmulatorVideoInputData; for (int i = start_frames; i < num_frames; i++) { - int ret = ReadFrame(handlers, (uint8_t*)video_in_buffer, usb_is_device_get_video_in_size(capture_type, usb_device_desc->device_type), usb_device_desc); + int ret = ReadFrame(handlers, (uint8_t*)video_in_buffer, (int)usb_is_device_get_video_in_size(capture_type, usb_device_desc->device_type), usb_device_desc); if(ret < 0) { delete video_in_buffer; return ret; @@ -104,7 +104,7 @@ static int StartAcquisitionEmulator(is_device_device_handlers* handlers, uint16_ break; } const auto curr_time = std::chrono::high_resolution_clock::now(); - const std::chrono::duration diff = curr_time - clock_start; + const std::chrono::duration diff = curr_time - clock_start; // Sometimes the upper 8 bits aren't updated... Use only the lower 8 bits. newFrameCount &= 0xFF; oldFrameCount &= 0xFF; @@ -149,12 +149,12 @@ static bool do_sleep(float single_frame_time, std::chrono::time_point 0) { - float adding_single_frame_time_multiplier = adding_single_frame_time_divisor - 1; + float adding_single_frame_time_multiplier = (float)(adding_single_frame_time_divisor - 1); if(adding_single_frame_time_multiplier == 0) - adding_single_frame_time_multiplier = 0.33; + adding_single_frame_time_multiplier = 0.33f; expected_time += (single_frame_time * adding_single_frame_time_multiplier) / adding_single_frame_time_divisor; } - float low_single_frame_time = 1.0 / ((int)((1.0 / single_frame_time) + 1)); + float low_single_frame_time = 1.0f / ((int)((1.0 / single_frame_time) + 1)); float low_expected_time = low_single_frame_time * curr_frame_counter; // If the current time is too low, sleep a bit to make sure we don't overrun the framerate counter // Don't do it regardless of the situation, and only in small increments... @@ -172,11 +172,8 @@ static void frame_wait(float single_frame_time, std::chrono::time_point &clock_last_reset, CaptureScreensType &curr_capture_type, CaptureScreensType wanted_capture_type, CaptureSpeedsType &curr_capture_speed, CaptureSpeedsType wanted_capture_speed, ISDeviceCaptureReceivedData* is_device_capture_recv_data) { @@ -226,13 +223,13 @@ static int reset_acquisition_frames(CaptureData* capture_data, uint16_t &curr_fr int frame_diff = 0; int diff_target = FRAME_BUFFER_SIZE * multiplier; std::chrono::time_point curr_time; - std::chrono::duration diff; + std::chrono::duration diff; do { // Is this not the first loop? Also, do not sleep too much... if((frame_diff > 0) && (((internalFrameCount & (FRAME_BUFFER_SIZE - 1)) < (FRAME_BUFFER_SIZE - 1)))) { float expected_time = single_frame_time * FRAME_BUFFER_SIZE; if(diff.count() < expected_time) - default_sleep(single_frame_time * 1000.0 / SLEEP_TIME_DIVISOR); + default_sleep(single_frame_time * 1000.0f / SLEEP_TIME_DIVISOR); } // Check how many frames have passed... ret = GetFrameCounter(handlers, &internalFrameCount, usb_device_desc); diff --git a/source/CaptureDeviceSpecific/ISDevices/usb_is_twl_acquisition_capture.cpp b/source/CaptureDeviceSpecific/ISDevices/usb_is_twl_acquisition_capture.cpp index 60024a7..34eb5ff 100644 --- a/source/CaptureDeviceSpecific/ISDevices/usb_is_twl_acquisition_capture.cpp +++ b/source/CaptureDeviceSpecific/ISDevices/usb_is_twl_acquisition_capture.cpp @@ -22,7 +22,7 @@ static void output_to_thread_reset_processed_data(CaptureData* capture_data, int } static int process_frame_and_read(CaptureData* capture_data, int internal_index, CaptureScreensType curr_capture_type, CaptureSpeedsType curr_capture_speed, std::chrono::time_point* clock_start, uint32_t &last_read_frame_index, uint32_t video_address, uint32_t video_length, size_t &video_length_processed, uint32_t audio_address, uint32_t audio_length, size_t &audio_length_processed, bool &processed, float &last_frame_length, bool &reprocess) { - const size_t video_processed_size = usb_is_device_get_video_in_size(curr_capture_type, IS_TWL_CAPTURE_DEVICE); + const size_t video_processed_size = (size_t)usb_is_device_get_video_in_size(curr_capture_type, IS_TWL_CAPTURE_DEVICE); processed = false; if((video_length == 0) && (audio_length == 0)) { if(reprocess) @@ -58,7 +58,7 @@ static int process_frame_and_read(CaptureData* capture_data, int internal_index, audio_address += -audio_diff_from_max; audio_length = max_audio_length; } - int audio_processed_diff_from_max = max_audio_length - audio_length_processed; + int audio_processed_diff_from_max = (int)(max_audio_length - audio_length_processed); if(audio_processed_diff_from_max >= 0) audio_processed_diff_from_max = 0; else @@ -70,19 +70,19 @@ static int process_frame_and_read(CaptureData* capture_data, int internal_index, return ret; audio_length_processed += audio_length; // Have enough video frames been received? If yes, output! - int num_curr_available_frames = video_length / sizeof(ISTWLCaptureVideoInternalReceived); - int num_available_frames = video_length_processed / sizeof(ISTWLCaptureVideoInternalReceived); + int num_curr_available_frames = (int)(video_length / sizeof(ISTWLCaptureVideoInternalReceived)); + int num_available_frames = (int)(video_length_processed / sizeof(ISTWLCaptureVideoInternalReceived)); if(num_available_frames < multiplier) return 0; if(num_curr_available_frames > 0) { int frame_next = num_curr_available_frames - 1; last_read_frame_index += num_curr_available_frames; video_address = video_address + (frame_next * sizeof(ISTWLCaptureVideoInternalReceived)); - ret = ReadFrame(handlers, (uint8_t*)&capture_buf->is_twl_capture_received.video_capture_in, video_address, video_processed_size, usb_device_desc); + ret = ReadFrame(handlers, (uint8_t*)&capture_buf->is_twl_capture_received.video_capture_in, video_address, (int)video_processed_size, usb_device_desc); if(ret < 0) return ret; const auto curr_time = std::chrono::high_resolution_clock::now(); - const std::chrono::duration diff = curr_time - (*clock_start); + const std::chrono::duration diff = curr_time - (*clock_start); last_frame_length = diff.count(); } // Possible issue: there is more video or audio data available @@ -210,7 +210,7 @@ void is_twl_acquisition_capture_main_loop(CaptureData* capture_data, ISDeviceCap capture_error_print(true, capture_data, "Initial Frame Info Set: Failed"); return; } - default_sleep(DEFAULT_FRAME_TIME_MS / SLEEP_FRAME_DIVIDER); + default_sleep((float)(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"); @@ -247,7 +247,7 @@ void is_twl_acquisition_capture_main_loop(CaptureData* capture_data, ISDeviceCap if((last_frame_length > 0) && (last_frame_length < CUTOFF_LAST_FRAME_TIME)) default_sleep((last_frame_length * 1000) / SLEEP_FRAME_DIVIDER); else - default_sleep(DEFAULT_FRAME_TIME_MS / SLEEP_FRAME_DIVIDER); + default_sleep((float)(DEFAULT_FRAME_TIME_MS / SLEEP_FRAME_DIVIDER)); ret = CaptureResetHardware(capture_data, clock_last_reset); if(ret < 0) { capture_error_print(true, capture_data, "Hardware Reset: Failed"); diff --git a/source/CaptureDeviceSpecific/Nisetro/cypress_nisetro_acquisition.cpp b/source/CaptureDeviceSpecific/Nisetro/cypress_nisetro_acquisition.cpp index d143cb4..cfe1562 100644 --- a/source/CaptureDeviceSpecific/Nisetro/cypress_nisetro_acquisition.cpp +++ b/source/CaptureDeviceSpecific/Nisetro/cypress_nisetro_acquisition.cpp @@ -124,19 +124,19 @@ void list_devices_cyni_device(std::vector &devices_list, std::vec bool* no_access_elems = new bool[num_cyni_device_desc]; bool* not_supported_elems = new bool[num_cyni_device_desc]; std::vector usb_devices_to_check; - for (int i = 0; i < num_cyni_device_desc; i++) { + for (size_t i = 0; i < num_cyni_device_desc; i++) { no_access_elems[i] = false; not_supported_elems[i] = false; curr_serial_extra_id_cyni_device[i] = 0; - const cyni_device_usb_device* curr_device_desc = GetCyNiDeviceDesc(i); + const cyni_device_usb_device* curr_device_desc = GetCyNiDeviceDesc((int)i); usb_devices_to_check.push_back(get_cy_usb_info(curr_device_desc)); } cypress_libusb_list_devices(devices_list, no_access_elems, not_supported_elems, curr_serial_extra_id_cyni_device, usb_devices_to_check); bool any_not_supported = false; - for(int i = 0; i < num_cyni_device_desc; i++) + for(size_t i = 0; i < num_cyni_device_desc; i++) any_not_supported |= not_supported_elems[i]; - for(int i = 0; i < num_cyni_device_desc; i++) + for(size_t i = 0; i < num_cyni_device_desc; i++) if(no_access_elems[i]) no_access_list.emplace_back(usb_devices_to_check[i]->vid, usb_devices_to_check[i]->pid); if(any_not_supported) @@ -200,12 +200,12 @@ static int find_first_vsync_byte(CaptureReceived* capture_buf, size_t read_size) uint8_t* data_in = (uint8_t*)capture_buf->cypress_nisetro_capture_received.video_in.screen_data; if((data_in[0] & 0x80) && (!(data_in[read_size - 1] & 0x80))) return 0; - int pos = 0; + size_t pos = 0; while((pos < read_size) && (data_in[pos] & 0x80)) pos++; while((pos < read_size) && (!(data_in[pos] & 0x80))) pos++; - return pos; + return (int)pos; } static void cypress_output_to_thread(CaptureData* capture_data, int internal_index, std::chrono::time_point* clock_start, size_t read_size, size_t* scheduled_special_read, bool* recalibration_request) { @@ -231,24 +231,6 @@ static void cypress_output_to_thread(CaptureData* capture_data, int internal_ind capture_data->status.audio_wait.unlock(); } -static int cypress_device_read_frame_and_output(CaptureData* capture_data, int internal_index, std::chrono::time_point &clock_start, size_t* scheduled_special_read, bool* recalibration_request) { - const cyni_device_usb_device* usb_device_info = (const cyni_device_usb_device*)capture_data->status.device.descriptor; - size_t read_size = cyni_device_get_video_in_size(usb_device_info->device_type); - if(*scheduled_special_read) - read_size = *scheduled_special_read; - CaptureDataSingleBuffer* data_buf = capture_data->data_buffers.GetWriterBuffer(internal_index); - uint8_t* buffer = (uint8_t*)&data_buf->capture_buf; - int ret = ReadFrame((cy_device_device_handlers*)capture_data->handle, buffer, read_size, usb_device_info); - if (ret < 0) - return ret; - if(*scheduled_special_read) { - *scheduled_special_read = 0; - return ret; - } - cypress_output_to_thread(capture_data, internal_index, &clock_start, read_size, scheduled_special_read, recalibration_request); - return ret; -} - static int cypress_device_read_frame_request(CaptureData* capture_data, CypressNisetroDeviceCaptureReceivedData* cypress_device_capture_recv_data, uint32_t index) { if(cypress_device_capture_recv_data == NULL) return LIBUSB_SUCCESS; @@ -259,7 +241,7 @@ static int cypress_device_read_frame_request(CaptureData* capture_data, CypressN const cyni_device_usb_device* usb_device_info = (const cyni_device_usb_device*)capture_data->status.device.descriptor; cypress_device_capture_recv_data->index = index; cypress_device_capture_recv_data->cb_data.function = cypress_device_read_frame_cb; - size_t read_size = cyni_device_get_video_in_size(usb_device_info->device_type); + size_t read_size = (size_t)cyni_device_get_video_in_size(usb_device_info->device_type); if(*cypress_device_capture_recv_data->scheduled_special_read) { read_size = *cypress_device_capture_recv_data->scheduled_special_read; *cypress_device_capture_recv_data->active_special_read_index = index; @@ -268,7 +250,7 @@ static int cypress_device_read_frame_request(CaptureData* capture_data, CypressN } CaptureDataSingleBuffer* data_buf = capture_data->data_buffers.GetWriterBuffer(cypress_device_capture_recv_data->cb_data.internal_index); uint8_t* buffer = (uint8_t*)&data_buf->capture_buf; - return ReadFrameAsync((cy_device_device_handlers*)capture_data->handle, buffer, read_size, usb_device_info, &cypress_device_capture_recv_data->cb_data); + return ReadFrameAsync((cy_device_device_handlers*)capture_data->handle, buffer, (int)read_size, usb_device_info, &cypress_device_capture_recv_data->cb_data); } static void end_cypress_device_read_frame_cb(CypressNisetroDeviceCaptureReceivedData* cypress_device_capture_recv_data, bool early_release) { @@ -316,14 +298,6 @@ static void cypress_device_read_frame_cb(void* user_data, int transfer_length, i end_cypress_device_read_frame_cb(cypress_device_capture_recv_data, false); } -static int cypress_device_get_num_free_buffers(CypressNisetroDeviceCaptureReceivedData* cypress_device_capture_recv_data) { - int num_free = 0; - for(int i = 0; i < NUM_NISETRO_CYPRESS_BUFFERS; i++) - if(!cypress_device_capture_recv_data[i].in_use) - num_free += 1; - return num_free; -} - static void close_all_reads_error(CaptureData* capture_data, CypressNisetroDeviceCaptureReceivedData* cypress_device_capture_recv_data, bool &async_read_closed) { cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle; const cyni_device_usb_device* usb_device_desc = (const cyni_device_usb_device*)capture_data->status.device.descriptor; @@ -356,7 +330,6 @@ static void error_too_much_time_passed(CaptureData* capture_data, CypressNisetro static void wait_all_cypress_device_buffers_free(CaptureData* capture_data, CypressNisetroDeviceCaptureReceivedData* cypress_device_capture_recv_data) { if(cypress_device_capture_recv_data == NULL) return; - cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle; bool async_read_closed = false; close_all_reads_error(capture_data, cypress_device_capture_recv_data, async_read_closed); const auto start_time = std::chrono::high_resolution_clock::now(); @@ -368,7 +341,6 @@ static void wait_all_cypress_device_buffers_free(CaptureData* capture_data, Cypr } static void wait_one_cypress_device_buffer_free(CaptureData* capture_data, CypressNisetroDeviceCaptureReceivedData* cypress_device_capture_recv_data) { - cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle; bool done = false; const auto start_time = std::chrono::high_resolution_clock::now(); while(!done) { @@ -388,7 +360,6 @@ static void wait_one_cypress_device_buffer_free(CaptureData* capture_data, Cypre } static void wait_specific_cypress_device_buffer_free(CaptureData* capture_data, CypressNisetroDeviceCaptureReceivedData* cypress_device_capture_recv_data) { - cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle; bool done = false; const auto start_time = std::chrono::high_resolution_clock::now(); while(!done) { @@ -405,10 +376,6 @@ static void wait_specific_cypress_device_buffer_free(CaptureData* capture_data, } } -static bool cypress_device_are_buffers_all_free(CypressNisetroDeviceCaptureReceivedData* cypress_device_capture_recv_data) { - return cypress_device_get_num_free_buffers(cypress_device_capture_recv_data) == NUM_NISETRO_CYPRESS_BUFFERS; -} - static CypressNisetroDeviceCaptureReceivedData* cypress_device_get_free_buffer(CaptureData* capture_data, CypressNisetroDeviceCaptureReceivedData* cypress_device_capture_recv_data) { wait_one_cypress_device_buffer_free(capture_data, cypress_device_capture_recv_data); if(get_cypress_device_status(cypress_device_capture_recv_data) < 0) @@ -488,8 +455,7 @@ static bool cyni_device_acquisition_loop(CaptureData* capture_data, CypressNiset capture_error_print(true, capture_data, "Capture Start: Failed"); return false; } - CypressSetMaxTransferSize(handlers, get_cy_usb_info(usb_device_desc), cyni_device_get_video_in_size(usb_device_desc->device_type)); - auto clock_last_reset = std::chrono::high_resolution_clock::now(); + CypressSetMaxTransferSize(handlers, get_cy_usb_info(usb_device_desc), (size_t)cyni_device_get_video_in_size(usb_device_desc->device_type)); for(int i = 0; i < NUM_NISETRO_CYPRESS_BUFFERS; i++) { CypressNisetroDeviceCaptureReceivedData* chosen_buffer = cypress_device_get_free_buffer(capture_data, cypress_device_capture_recv_data); ret = cypress_device_read_frame_request(capture_data, chosen_buffer, index++); @@ -546,11 +512,9 @@ void cyni_device_acquisition_main_loop(CaptureData* capture_data) { uint32_t last_index = -1; int status = 0; std::vector cb_queue; - int queue_elems = 0; size_t scheduled_special_read = 0; uint32_t active_special_read_index = 0; bool is_active_special_read = false; - bool one_transfer_active = false; bool recalibration_request = false; int errors_since_last_output = 0; int consecutive_output_to_thread = 0; diff --git a/source/CaptureDeviceSpecific/Nisetro/cypress_nisetro_communications.cpp b/source/CaptureDeviceSpecific/Nisetro/cypress_nisetro_communications.cpp index 47edd86..e8216cf 100644 --- a/source/CaptureDeviceSpecific/Nisetro/cypress_nisetro_communications.cpp +++ b/source/CaptureDeviceSpecific/Nisetro/cypress_nisetro_communications.cpp @@ -134,9 +134,9 @@ bool load_firmware(cy_device_device_handlers* handlers, const cyni_device_usb_de if(ret < 0) return free_firmware_and_return(fw_data, false); bool done = false; - int fw_pos = read_le16(fw_data); + uint16_t fw_pos = read_le16(fw_data); while(!done) { - int inside_len = read_be16(fw_data + fw_pos); + uint32_t inside_len = read_be16(fw_data + fw_pos); int offset = read_be16(fw_data + fw_pos, 1); done = (inside_len & 0x8000) != 0; inside_len &= 0x7FFF; diff --git a/source/CaptureDeviceSpecific/Optimize_3DS/cypress_optimize_3ds_acquisition.cpp b/source/CaptureDeviceSpecific/Optimize_3DS/cypress_optimize_3ds_acquisition.cpp index 47d5ace..18436bb 100644 --- a/source/CaptureDeviceSpecific/Optimize_3DS/cypress_optimize_3ds_acquisition.cpp +++ b/source/CaptureDeviceSpecific/Optimize_3DS/cypress_optimize_3ds_acquisition.cpp @@ -131,19 +131,19 @@ void list_devices_cyop_device(std::vector &devices_list, std::vec bool* no_access_elems = new bool[num_cyop_device_desc]; bool* not_supported_elems = new bool[num_cyop_device_desc]; std::vector usb_devices_to_check; - for (int i = 0; i < num_cyop_device_desc; i++) { + for (size_t i = 0; i < num_cyop_device_desc; i++) { no_access_elems[i] = false; not_supported_elems[i] = false; curr_serial_extra_id_cyop_device[i] = 0; - const cyop_device_usb_device* curr_device_desc = GetCyOpDeviceDesc(i); + const cyop_device_usb_device* curr_device_desc = GetCyOpDeviceDesc((int)i); usb_devices_to_check.push_back(get_cy_usb_info(curr_device_desc)); } cypress_libusb_list_devices(devices_list, no_access_elems, not_supported_elems, curr_serial_extra_id_cyop_device, usb_devices_to_check); bool any_not_supported = false; - for(int i = 0; i < num_cyop_device_desc; i++) + for(size_t i = 0; i < num_cyop_device_desc; i++) any_not_supported |= not_supported_elems[i]; - for(int i = 0; i < num_cyop_device_desc; i++) + for(size_t i = 0; i < num_cyop_device_desc; i++) if(no_access_elems[i]) no_access_list.emplace_back(usb_devices_to_check[i]->vid, usb_devices_to_check[i]->pid); if(any_not_supported) @@ -231,7 +231,7 @@ static int cypress_device_read_frame_request(CaptureData* capture_data, CypressO cypress_device_capture_recv_data->is_buffer_free_shared_mutex->specific_try_lock(cypress_device_capture_recv_data->cb_data.internal_index); cypress_device_capture_recv_data->in_use = true; cypress_device_capture_recv_data->to_process = true; - return ReadFrameAsync((cy_device_device_handlers*)capture_data->handle, buffer, read_size, usb_device_info, &cypress_device_capture_recv_data->cb_data); + return ReadFrameAsync((cy_device_device_handlers*)capture_data->handle, buffer, (int)read_size, usb_device_info, &cypress_device_capture_recv_data->cb_data); } static void unlock_buffer_directly(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data_real) { @@ -243,7 +243,7 @@ static void unlock_buffer_directly(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data_real->is_buffer_free_shared_mutex->specific_unlock(cypress_device_capture_recv_data_real->cb_data.internal_index); } -static void unlock_buffer_slice_index(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, int slice_index) { +static void unlock_buffer_slice_index(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, size_t slice_index) { int index = cypress_device_capture_recv_data->buffer_ring_slice_to_array_ptr[slice_index]; if(index == -1) return; @@ -334,7 +334,7 @@ static void cypress_device_read_frame_cb(void* user_data, int transfer_length, i unlock_buffer_slice_index(cypress_device_capture_recv_data, check_index); } else { - *cypress_device_capture_recv_data->last_used_ring_buffer_slice_index = check_index; + *cypress_device_capture_recv_data->last_used_ring_buffer_slice_index = (int)check_index; *cypress_device_capture_recv_data->last_used_ring_buffer_slice_pos = result; break; } @@ -348,9 +348,9 @@ static void cypress_device_read_frame_cb(void* user_data, int transfer_length, i volatile size_t read_slice_pos = *cypress_device_capture_recv_data->last_used_ring_buffer_slice_pos; if(read_slice_index != -1) { int num_consecutive_ready_buffers = get_num_consecutive_ready_ring_buffer_slices(cypress_device_capture_recv_data, read_slice_index); - size_t video_in_size = cyop_device_get_video_in_size(*cypress_device_capture_recv_data->stored_is_3d, *cypress_device_capture_recv_data->stored_video_data_type); + size_t video_in_size = (size_t)cyop_device_get_video_in_size(*cypress_device_capture_recv_data->stored_is_3d, *cypress_device_capture_recv_data->stored_video_data_type); size_t raw_new_pos = read_slice_pos + video_in_size; - int num_needed_buffers = (raw_new_pos + SINGLE_RING_BUFFER_SLICE_SIZE - 1) / SINGLE_RING_BUFFER_SLICE_SIZE; + int num_needed_buffers = (int)((raw_new_pos + SINGLE_RING_BUFFER_SLICE_SIZE - 1) / SINGLE_RING_BUFFER_SLICE_SIZE); if(num_consecutive_ready_buffers >= num_needed_buffers) { // Enough data. Time to do output... cypress_output_to_thread(cypress_device_capture_recv_data->capture_data, cypress_device_capture_recv_data->ring_slice_buffer_arr, read_slice_index, read_slice_pos, 0, cypress_device_capture_recv_data->clock_start, video_in_size); @@ -374,14 +374,6 @@ static void cypress_device_read_frame_cb(void* user_data, int transfer_length, i return end_cypress_device_read_frame_cb(cypress_device_capture_recv_data, to_free); } -static int cypress_device_get_num_free_buffers(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) { - int num_free = 0; - for(int i = 0; i < NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++) - if(!cypress_device_capture_recv_data[i].in_use) - num_free += 1; - return num_free; -} - static void close_all_reads_error(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, bool &async_read_closed) { cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle; const cyop_device_usb_device* usb_device_desc = (const cyop_device_usb_device*)capture_data->status.device.descriptor; @@ -421,7 +413,6 @@ static void check_unlock_waiting_with_error(CypressOptimize3DSDeviceCaptureRecei static void wait_all_cypress_device_buffers_free(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) { if(cypress_device_capture_recv_data == NULL) return; - cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle; bool async_read_closed = false; close_all_reads_error(capture_data, cypress_device_capture_recv_data, async_read_closed); const auto start_time = std::chrono::high_resolution_clock::now(); @@ -434,7 +425,6 @@ static void wait_all_cypress_device_buffers_free(CaptureData* capture_data, Cypr } static void wait_one_cypress_device_buffer_free(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) { - cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle; bool done = false; const auto start_time = std::chrono::high_resolution_clock::now(); while(!done) { @@ -453,28 +443,6 @@ static void wait_one_cypress_device_buffer_free(CaptureData* capture_data, Cypre } } -static void wait_specific_cypress_device_buffer_free(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) { - cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle; - bool done = false; - const auto start_time = std::chrono::high_resolution_clock::now(); - while(!done) { - if(!cypress_device_capture_recv_data->in_use) - done = true; - if(!done) { - if(has_too_much_time_passed(start_time)) - return; - if(get_cypress_device_status(cypress_device_capture_recv_data) < 0) - return; - int dummy = 0; - cypress_device_capture_recv_data->is_buffer_free_shared_mutex->general_timed_lock(&dummy); - } - } -} - -static bool cypress_device_are_buffers_all_free(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) { - return cypress_device_get_num_free_buffers(cypress_device_capture_recv_data) == NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; -} - static CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_get_free_buffer(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) { wait_one_cypress_device_buffer_free(capture_data, cypress_device_capture_recv_data); if(get_cypress_device_status(cypress_device_capture_recv_data) < 0) @@ -501,10 +469,6 @@ static void exported_error_cypress_device_status(void* data, int error_val) { return error_cypress_device_status((CypressOptimize3DSDeviceCaptureReceivedData*)data, error_val); } -static void reset_cypress_device_status(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) { - error_cypress_device_status(cypress_device_capture_recv_data, 0); -} - static bool cyop_device_acquisition_loop(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, InputVideoDataType &stored_video_data_type, bool &stored_is_3d) { cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle; const cyop_device_usb_device* usb_device_desc = (const cyop_device_usb_device*)capture_data->status.device.descriptor; @@ -514,8 +478,7 @@ static bool cyop_device_acquisition_loop(CaptureData* capture_data, CypressOptim capture_error_print(true, capture_data, "Capture Start: Failed"); return false; } - CypressSetMaxTransferSize(handlers, get_cy_usb_info(usb_device_desc), cyop_device_get_video_in_size(stored_is_3d, stored_video_data_type)); - auto clock_last_reset = std::chrono::high_resolution_clock::now(); + CypressSetMaxTransferSize(handlers, get_cy_usb_info(usb_device_desc), (size_t)cyop_device_get_video_in_size(stored_is_3d, stored_video_data_type)); for(int i = 0; i < NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++) { CypressOptimize3DSDeviceCaptureReceivedData* chosen_buffer = cypress_device_get_free_buffer(capture_data, cypress_device_capture_recv_data); ret = cypress_device_read_frame_request(capture_data, chosen_buffer, index++, stored_is_3d, stored_video_data_type); diff --git a/source/CaptureDeviceSpecific/Optimize_3DS/cypress_optimize_3ds_communications.cpp b/source/CaptureDeviceSpecific/Optimize_3DS/cypress_optimize_3ds_communications.cpp index 9a11c1f..c6ed1a8 100644 --- a/source/CaptureDeviceSpecific/Optimize_3DS/cypress_optimize_3ds_communications.cpp +++ b/source/CaptureDeviceSpecific/Optimize_3DS/cypress_optimize_3ds_communications.cpp @@ -201,11 +201,11 @@ bool load_firmware(cy_device_device_handlers* handlers, const cyop_device_usb_de if(ret < 0) return free_firmware_and_return(fw_data, false); bool done = false; - int fw_pos = read_le16(fw_data); + uint16_t fw_pos = read_le16(fw_data); while(!done) { int offset = read_le16(fw_data + fw_pos); int index = read_le16(fw_data + fw_pos, 1); - int inside_len = read_le16(fw_data + fw_pos, 2); + uint32_t inside_len = read_le16(fw_data + fw_pos, 2); done = (inside_len & 0x8000) != 0; inside_len &= 0x7FFF; fw_pos += 6; @@ -259,7 +259,7 @@ static int read_second_device_id(cy_device_device_handlers* handlers, const cyop ret = cypress_ctrl_bulk_in_transfer(handlers, get_cy_usb_info(device), in_buffer, sizeof(in_buffer), &transferred); if(ret < 0) return ret; - if(transferred < sizeof(in_buffer)) + if(((size_t)transferred) < sizeof(in_buffer)) return -1; second_device_id = read_le64(in_buffer); return ret; @@ -275,11 +275,11 @@ static int read_device_id(cy_device_device_handlers* handlers, const cyop_device ret = cypress_ctrl_bulk_in_transfer(handlers, get_cy_usb_info(device), in_buffer, sizeof(in_buffer), &transferred); if(ret < 0) return ret; - if(transferred < sizeof(in_buffer)) + if(((size_t)transferred) < sizeof(in_buffer)) return -1; device_id = read_le64(in_buffer); is_full_0s = true; - for(int i = 0; i < sizeof(in_buffer); i++) + for(size_t i = 0; i < sizeof(in_buffer); i++) if(in_buffer[i] != 0) { is_full_0s = false; break; @@ -297,7 +297,7 @@ static int read_first_unk_value(cy_device_device_handlers* handlers, const cyop_ ret = cypress_ctrl_bulk_in_transfer(handlers, get_cy_usb_info(device), in_buffer, sizeof(in_buffer), &transferred); if(ret < 0) return ret; - if(transferred < sizeof(in_buffer)) + if(((size_t)transferred) < sizeof(in_buffer)) return -1; value = read_le32(in_buffer); return ret; @@ -364,9 +364,9 @@ static int fpga_pl_load(cy_device_device_handlers* handlers, const cyop_device_u if(ret < 0) return ret; - const int fpga_pl_transfer_total_size = 64; - const int fpga_pl_transfer_header_size = 2; - const int fpga_pl_transfer_piece_size = fpga_pl_transfer_total_size - fpga_pl_transfer_header_size; + const size_t fpga_pl_transfer_total_size = 64; + const size_t fpga_pl_transfer_header_size = 2; + const size_t fpga_pl_transfer_piece_size = fpga_pl_transfer_total_size - fpga_pl_transfer_header_size; const size_t num_iters = (fpga_pl_size + fpga_pl_transfer_piece_size - 1) / fpga_pl_transfer_piece_size; uint8_t pl_buffer[fpga_pl_transfer_total_size]; pl_buffer[0] = 0x60; @@ -376,7 +376,7 @@ static int fpga_pl_load(cy_device_device_handlers* handlers, const cyop_device_u if(remaining_size > fpga_pl_transfer_piece_size) remaining_size = fpga_pl_transfer_piece_size; memcpy(pl_buffer + fpga_pl_transfer_header_size, fpga_pl + (fpga_pl_transfer_piece_size * i), remaining_size); - ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), pl_buffer, remaining_size + fpga_pl_transfer_header_size, &transferred); + ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), pl_buffer, (int)(remaining_size + fpga_pl_transfer_header_size), &transferred); if(ret < 0) return ret; } @@ -432,7 +432,6 @@ static int final_capture_start_transfer(cy_device_device_handlers* handlers, con } int capture_start(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, bool is_first_load, bool is_rgb888) { - int transferred = 0; int ret = 0; uint32_t value32 = 0; uint64_t device_id = 0; diff --git a/source/CaptureDeviceSpecific/usb_ds_3ds_capture.cpp b/source/CaptureDeviceSpecific/usb_ds_3ds_capture.cpp index 8804cf3..38b600d 100644 --- a/source/CaptureDeviceSpecific/usb_ds_3ds_capture.cpp +++ b/source/CaptureDeviceSpecific/usb_ds_3ds_capture.cpp @@ -143,7 +143,6 @@ static int do_usb_config_device(libusb_device_handle *handle, const usb_device* static int insert_device(std::vector &devices_list, const usb_device* usb_device_desc, libusb_device *usb_device, libusb_device_descriptor *usb_descriptor, int &curr_serial_extra_id) { libusb_device_handle *handle = NULL; - uint8_t data[SERIAL_NUMBER_SIZE]; if((usb_descriptor->idVendor != usb_device_desc->vid) || (usb_descriptor->idProduct != usb_device_desc->pid)) return LIBUSB_ERROR_NOT_FOUND; int result = libusb_open(usb_device, &handle); @@ -174,14 +173,13 @@ static libusb_device_handle* usb_find_by_serial_number(const usb_device* usb_dev if(!usb_is_initialized()) return NULL; libusb_device **usb_devices; - int num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); + ssize_t num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); libusb_device_descriptor usb_descriptor{}; libusb_device_handle *final_handle = NULL; int curr_serial_extra_id = 0; - for(int i = 0; i < num_devices; i++) { + for(ssize_t i = 0; i < num_devices; i++) { libusb_device_handle *handle = NULL; - uint8_t data[SERIAL_NUMBER_SIZE]; int result = libusb_get_device_descriptor(usb_devices[i], &usb_descriptor); if(result < 0) continue; @@ -232,7 +230,7 @@ static usb_capture_status capture_read_oldds_3ds(CaptureData* capture_data, size libusb_device_handle* handle = (libusb_device_handle*)capture_data->handle; const usb_device* usb_device_desc = get_usb_device_desc(capture_data); const bool enabled_3d = get_3d_enabled(&capture_data->status); - int bytesIn = 0; + size_t bytesIn = 0; int transferred = 0; int result = 0; uint64_t video_size = _usb_get_video_in_size(usb_device_desc, enabled_3d); @@ -248,8 +246,8 @@ static usb_capture_status capture_read_oldds_3ds(CaptureData* capture_data, size // Both DS and 3DS old CCs send data until end of frame, followed by 0-length packets do { - int transferSize = ((full_in_size - bytesIn) + (EXTRA_DATA_BUFFER_USB_SIZE - 1)) & ~(EXTRA_DATA_BUFFER_USB_SIZE - 1); // multiple of maxPacketSize - result = bulk_in(handle, usb_device_desc, video_data_ptr + bytesIn, transferSize, &transferred); + size_t transferSize = ((full_in_size - bytesIn) + (EXTRA_DATA_BUFFER_USB_SIZE - 1)) & ~(EXTRA_DATA_BUFFER_USB_SIZE - 1); // multiple of maxPacketSize + result = bulk_in(handle, usb_device_desc, video_data_ptr + bytesIn, (int)transferSize, &transferred); if(result == LIBUSB_SUCCESS) bytesIn += transferred; } while((bytesIn < full_in_size) && (result == LIBUSB_SUCCESS) && (transferred > 0)); @@ -329,21 +327,21 @@ void list_devices_usb_ds_3ds(std::vector &devices_list, std::vect if(!usb_is_initialized()) return; libusb_device **usb_devices; - int num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); + ssize_t num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); libusb_device_descriptor usb_descriptor{}; const size_t num_usb_desc = sizeof(usb_devices_desc_list) / sizeof(usb_devices_desc_list[0]); bool no_access_elems[num_usb_desc]; int curr_serial_extra_ids[num_usb_desc]; - for (int i = 0; i < num_usb_desc; i++) { + for (size_t i = 0; i < num_usb_desc; i++) { no_access_elems[i] = false; curr_serial_extra_ids[i] = 0; } - for(int i = 0; i < num_devices; i++) { + for(ssize_t i = 0; i < num_devices; i++) { int result = libusb_get_device_descriptor(usb_devices[i], &usb_descriptor); if(result < 0) continue; - for(int j = 0; j < num_usb_desc; j++) + for(size_t j = 0; j < num_usb_desc; j++) if(insert_device(devices_list, usb_devices_desc_list[j], usb_devices[i], &usb_descriptor, curr_serial_extra_ids[j]) != LIBUSB_ERROR_NOT_FOUND) { if (result == LIBUSB_ERROR_ACCESS) no_access_elems[j] = true; @@ -354,7 +352,7 @@ void list_devices_usb_ds_3ds(std::vector &devices_list, std::vect if(num_devices >= 0) libusb_free_device_list(usb_devices, 1); - for(int i = 0; i < num_usb_desc; i++) + for(size_t i = 0; i < num_usb_desc; i++) if(no_access_elems[i]) no_access_list.emplace_back(usb_devices_desc_list[i]->vid, usb_devices_desc_list[i]->pid); } @@ -383,7 +381,7 @@ bool connect_usb(bool print_failed, CaptureData* capture_data, CaptureDevice* de //FW bug(?) workaround- first read times out sometimes uint8_t dummy; vend_out(dev, usb_device_desc, usb_device_desc->cmdout_capture_start, 0, 0, 0, &dummy); - default_sleep(usb_device_desc->bulk_timeout); + default_sleep((float)usb_device_desc->bulk_timeout); } capture_data->handle = (void*)dev; diff --git a/source/CaptureDeviceSpecific/usb_generic.cpp b/source/CaptureDeviceSpecific/usb_generic.cpp index 93dc7e8..ff22de8 100644 --- a/source/CaptureDeviceSpecific/usb_generic.cpp +++ b/source/CaptureDeviceSpecific/usb_generic.cpp @@ -35,40 +35,6 @@ libusb_context* get_usb_ctx() { return usb_ctx; } -int get_usb_total_filtered_devices(const uint16_t valid_vids[], size_t num_vids, const uint16_t valid_pids[], size_t num_pids) { - if(!usb_is_initialized()) - return 0; - libusb_device **usb_devices; - int num_devices = libusb_get_device_list(get_usb_ctx(), &usb_devices); - libusb_device_descriptor usb_descriptor{}; - int num_devices_found = 0; - - for(int i = 0; i < num_devices; i++) { - int result = libusb_get_device_descriptor(usb_devices[i], &usb_descriptor); - if(result < 0) - continue; - bool found_vid = false; - for(int j = 0; j < num_vids; j++) - if(usb_descriptor.idVendor == valid_vids[j]) { - found_vid = true; - break; - } - if(!found_vid) - continue; - for(int j = 0; j < num_pids; j++) { - if(usb_descriptor.idProduct == valid_pids[j]) { - num_devices_found += 1; - break; - } - } - } - - if(num_devices >= 0) - libusb_free_device_list(usb_devices, 1); - - return num_devices_found; -} - void libusb_check_and_detach_kernel_driver(void* handle, int interface) { if(handle == NULL) return; diff --git a/source/ExtraButtons.cpp b/source/ExtraButtons.cpp index 49c1480..4af6759 100755 --- a/source/ExtraButtons.cpp +++ b/source/ExtraButtons.cpp @@ -1,5 +1,7 @@ #include "ExtraButtons.hpp" +#define NUM_PI_BUTTONS (sizeof(pi_buttons) / sizeof(pi_buttons[0])) + static ExtraButton pi_page_up, pi_page_down, pi_enter, pi_power; static ExtraButton* pi_buttons[] = {&pi_page_up, &pi_page_down, &pi_enter, &pi_power}; @@ -99,17 +101,17 @@ void ExtraButton::poll(std::queue &events_queue) { } std::string get_extra_button_name(sf::Keyboard::Key corresponding_key) { - for(int i = 0; i < sizeof(pi_buttons) / sizeof(pi_buttons[0]); i++) + for(size_t i = 0; i < NUM_PI_BUTTONS; i++) if(pi_buttons[i]->is_button_x(corresponding_key)) return pi_buttons[i]->get_name(); return ""; } void init_extra_buttons_poll(int page_up_id, int page_down_id, int enter_id, int power_id, bool use_pud_up) { - pi_page_up.initialize(page_up_id, sf::Keyboard::Key::PageUp, false, 0.5, 0.03, use_pud_up, "Select"); - pi_page_down.initialize(page_down_id, sf::Keyboard::Key::PageDown, false, 0.5, 0.03, use_pud_up, "Menu"); - pi_enter.initialize(enter_id, sf::Keyboard::Key::Enter, false, 0.5, 0.075, use_pud_up, "Enter"); - pi_power.initialize(power_id, sf::Keyboard::Key::Escape, true, 30.0, 30.0, use_pud_up, "Power"); + pi_page_up.initialize(page_up_id, sf::Keyboard::Key::PageUp, false, 0.5f, 0.03f, use_pud_up, "Select"); + pi_page_down.initialize(page_down_id, sf::Keyboard::Key::PageDown, false, 0.5f, 0.03f, use_pud_up, "Menu"); + pi_enter.initialize(enter_id, sf::Keyboard::Key::Enter, false, 0.5f, 0.075f, use_pud_up, "Enter"); + pi_power.initialize(power_id, sf::Keyboard::Key::Escape, true, 30.0f, 30.0f, use_pud_up, "Power"); } bool are_extra_buttons_usable() { @@ -117,11 +119,11 @@ bool are_extra_buttons_usable() { } void end_extra_buttons_poll() { - for(int i = 0; i < sizeof(pi_buttons) / sizeof(pi_buttons[0]); i++) + for(size_t i = 0; i < NUM_PI_BUTTONS; i++) pi_buttons[i]->end(); } void extra_buttons_poll(std::queue &events_queue) { - for(int i = 0; i < sizeof(pi_buttons) / sizeof(pi_buttons[0]); i++) + for(size_t i = 0; i < NUM_PI_BUTTONS; i++) pi_buttons[i]->poll(events_queue); } diff --git a/source/Menus/ActionSelectionMenu.cpp b/source/Menus/ActionSelectionMenu.cpp index e8e3fb4..372d3bc 100755 --- a/source/Menus/ActionSelectionMenu.cpp +++ b/source/Menus/ActionSelectionMenu.cpp @@ -14,8 +14,8 @@ void ActionSelectionMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Action Choice"; this->show_back_x = true; @@ -33,7 +33,7 @@ void ActionSelectionMenu::reset_output_option() { } void ActionSelectionMenu::set_output_option(int index, int action) { - if(index >= this->get_num_options()) + if(index >= ((int)this->get_num_options())) this->selected_index = ACTION_SELECTION_MENU_BACK; else if(index == BACK_X_OUTPUT_OPTION) this->selected_index = ACTION_SELECTION_MENU_BACK; @@ -41,7 +41,7 @@ void ActionSelectionMenu::set_output_option(int index, int action) { this->selected_index = index; } -int ActionSelectionMenu::get_num_options() { +size_t ActionSelectionMenu::get_num_options() { return this->possible_actions->size(); } diff --git a/source/Menus/AudioDeviceMenu.cpp b/source/Menus/AudioDeviceMenu.cpp index 94514e3..9219862 100644 --- a/source/Menus/AudioDeviceMenu.cpp +++ b/source/Menus/AudioDeviceMenu.cpp @@ -14,8 +14,8 @@ void AudioDeviceMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Audio Device Selection"; this->show_back_x = true; @@ -39,7 +39,7 @@ void AudioDeviceMenu::set_output_option(int index, int action) { this->selected_index = index; } -int AudioDeviceMenu::get_num_options() { +size_t AudioDeviceMenu::get_num_options() { return this->possible_devices->size() + 1; } diff --git a/source/Menus/AudioMenu.cpp b/source/Menus/AudioMenu.cpp index 991ea58..a6c3266 100755 --- a/source/Menus/AudioMenu.cpp +++ b/source/Menus/AudioMenu.cpp @@ -77,8 +77,8 @@ void AudioMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Audio Settings"; this->show_back_x = true; @@ -88,8 +88,8 @@ void AudioMenu::class_setup() { void AudioMenu::insert_data() { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { - this->options_indexes[this->num_enabled_options] = i; + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } this->prepare_options(); @@ -108,7 +108,7 @@ void AudioMenu::set_output_option(int index, int action) { this->selected_index = pollable_options[this->options_indexes[index]]->out_action; } -int AudioMenu::get_num_options() { +size_t AudioMenu::get_num_options() { return this->num_enabled_options; } @@ -142,7 +142,7 @@ void AudioMenu::prepare(float menu_scaling_factor, int view_size_x, int view_siz this->labels[index]->setText(this->setTextOptionInt(real_index, audio_data->get_real_volume())); break; case AUDIO_MENU_MAX_LATENCY_DEC: - this->labels[index]->setText(this->setTextOptionInt(real_index, audio_data->get_max_audio_latency())); + this->labels[index]->setText(this->setTextOptionInt(real_index, (int)audio_data->get_max_audio_latency())); break; case AUDIO_MENU_OUTPUT_DEC: this->labels[index]->setText(this->setTextOptionString(real_index, audio_data->get_audio_output_name())); diff --git a/source/Menus/BFIMenu.cpp b/source/Menus/BFIMenu.cpp index 0a683bd..380f997 100755 --- a/source/Menus/BFIMenu.cpp +++ b/source/Menus/BFIMenu.cpp @@ -63,8 +63,8 @@ void BFIMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "BFI Settings"; this->show_back_x = true; @@ -74,8 +74,8 @@ void BFIMenu::class_setup() { void BFIMenu::insert_data() { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { - this->options_indexes[this->num_enabled_options] = i; + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } this->prepare_options(); @@ -94,7 +94,7 @@ void BFIMenu::set_output_option(int index, int action) { this->selected_index = pollable_options[this->options_indexes[index]]->out_action; } -int BFIMenu::get_num_options() { +size_t BFIMenu::get_num_options() { return this->num_enabled_options; } diff --git a/source/Menus/ColorCorrectionMenu.cpp b/source/Menus/ColorCorrectionMenu.cpp index 3f393e0..8fcaedf 100644 --- a/source/Menus/ColorCorrectionMenu.cpp +++ b/source/Menus/ColorCorrectionMenu.cpp @@ -14,8 +14,8 @@ void ColorCorrectionMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = this->base_name; this->show_back_x = true; @@ -43,7 +43,7 @@ void ColorCorrectionMenu::set_output_option(int index, int action) { this->selected_index = index; } -int ColorCorrectionMenu::get_num_options() { +size_t ColorCorrectionMenu::get_num_options() { return (*this->possible_correction_data).size(); } diff --git a/source/Menus/ConnectionMenu.cpp b/source/Menus/ConnectionMenu.cpp index 837354f..6b12cb7 100755 --- a/source/Menus/ConnectionMenu.cpp +++ b/source/Menus/ConnectionMenu.cpp @@ -14,8 +14,8 @@ void ConnectionMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 10; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Device Selection"; this->show_back_x = false; @@ -36,7 +36,7 @@ void ConnectionMenu::set_output_option(int index, int action) { this->selected_index = index; } -int ConnectionMenu::get_num_options() { +size_t ConnectionMenu::get_num_options() { return this->devices_list->size(); } diff --git a/source/Menus/CropMenu.cpp b/source/Menus/CropMenu.cpp index 74f6232..de8d9d7 100755 --- a/source/Menus/CropMenu.cpp +++ b/source/Menus/CropMenu.cpp @@ -14,8 +14,8 @@ void CropMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Crop Settings"; this->show_back_x = true; @@ -39,7 +39,7 @@ void CropMenu::set_output_option(int index, int action) { this->selected_index = index; } -int CropMenu::get_num_options() { +size_t CropMenu::get_num_options() { return (*this->possible_crops).size(); } diff --git a/source/Menus/ExtraSettingsMenu.cpp b/source/Menus/ExtraSettingsMenu.cpp index 8a420d3..32fa180 100755 --- a/source/Menus/ExtraSettingsMenu.cpp +++ b/source/Menus/ExtraSettingsMenu.cpp @@ -75,8 +75,8 @@ void ExtraSettingsMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Extra Settings"; this->show_back_x = true; @@ -86,7 +86,7 @@ void ExtraSettingsMenu::class_setup() { void ExtraSettingsMenu::insert_data(ScreenType s_type, bool is_fullscreen) { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { bool valid = true; if(is_fullscreen) valid = valid && pollable_options[i]->active_fullscreen; @@ -99,7 +99,7 @@ void ExtraSettingsMenu::insert_data(ScreenType s_type, bool is_fullscreen) { else valid = valid && pollable_options[i]->active_joint_screen; if(valid) { - this->options_indexes[this->num_enabled_options] = i; + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } } @@ -121,7 +121,7 @@ bool ExtraSettingsMenu::is_option_selectable(int index, int action) { return pollable_options[this->options_indexes[index]]->is_selectable; } -int ExtraSettingsMenu::get_num_options() { +size_t ExtraSettingsMenu::get_num_options() { return this->num_enabled_options; } diff --git a/source/Menus/FileConfigMenu.cpp b/source/Menus/FileConfigMenu.cpp index d9c6413..924f7f1 100755 --- a/source/Menus/FileConfigMenu.cpp +++ b/source/Menus/FileConfigMenu.cpp @@ -14,8 +14,8 @@ void FileConfigMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = this->base_name; this->show_back_x = true; @@ -43,7 +43,7 @@ void FileConfigMenu::set_output_option(int index, int action) { this->selected_index = (*this->possible_files)[index].index; } -int FileConfigMenu::get_num_options() { +size_t FileConfigMenu::get_num_options() { return (*this->possible_files).size(); } diff --git a/source/Menus/ISNitroMenu.cpp b/source/Menus/ISNitroMenu.cpp index 0964078..a94be44 100644 --- a/source/Menus/ISNitroMenu.cpp +++ b/source/Menus/ISNitroMenu.cpp @@ -86,8 +86,8 @@ void ISNitroMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "IS Nitro Settings"; this->show_back_x = true; @@ -105,7 +105,7 @@ void ISNitroMenu::insert_data(CaptureDevice* device) { is_twl = is_device_is_twl(device); #endif this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { bool valid = true; if(is_capture) valid = valid && pollable_options[i]->is_capture_valid; @@ -116,7 +116,7 @@ void ISNitroMenu::insert_data(CaptureDevice* device) { if(is_twl) valid = valid && pollable_options[i]->is_twl_valid; if(valid) { - this->options_indexes[this->num_enabled_options] = i; + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } } @@ -140,7 +140,7 @@ void ISNitroMenu::set_output_option(int index, int action) { this->selected_index = pollable_options[this->options_indexes[index]]->out_action; } -int ISNitroMenu::get_num_options() { +size_t ISNitroMenu::get_num_options() { return this->num_enabled_options; } diff --git a/source/Menus/InputMenu.cpp b/source/Menus/InputMenu.cpp index f8daa41..a31eaf7 100644 --- a/source/Menus/InputMenu.cpp +++ b/source/Menus/InputMenu.cpp @@ -58,8 +58,8 @@ void InputMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Input Settings"; this->show_back_x = true; @@ -69,7 +69,7 @@ void InputMenu::class_setup() { void InputMenu::insert_data(bool enabled_shortcuts, bool enabled_extra_buttons) { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { bool valid = true; InputMenuOutAction out_action = pollable_options[i]->out_action; if((out_action == INPUT_MENU_SHORTCUT_SETTINGS) && (!enabled_shortcuts)) @@ -77,7 +77,7 @@ void InputMenu::insert_data(bool enabled_shortcuts, bool enabled_extra_buttons) if((out_action == INPUT_MENU_TOGGLE_BUTTONS) && (!(enabled_shortcuts || enabled_extra_buttons))) valid = false; if(valid) { - this->options_indexes[this->num_enabled_options] = i; + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } } @@ -95,7 +95,7 @@ void InputMenu::set_output_option(int index, int action) { this->selected_index = pollable_options[this->options_indexes[index]]->out_action; } -int InputMenu::get_num_options() { +size_t InputMenu::get_num_options() { return this->num_enabled_options; } diff --git a/source/Menus/LicenseMenu.cpp b/source/Menus/LicenseMenu.cpp index 0d33631..329ee19 100755 --- a/source/Menus/LicenseMenu.cpp +++ b/source/Menus/LicenseMenu.cpp @@ -182,8 +182,8 @@ void LicenseMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Licenses"; this->show_back_x = true; @@ -193,8 +193,8 @@ void LicenseMenu::class_setup() { void LicenseMenu::insert_data() { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { - this->options_indexes[this->num_enabled_options] = i; + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } this->prepare_options(); @@ -209,7 +209,7 @@ void LicenseMenu::set_output_option(int index, int action) { this->selected_index = LICENSE_MENU_BACK; } -int LicenseMenu::get_num_options() { +size_t LicenseMenu::get_num_options() { return this->num_enabled_options; } diff --git a/source/Menus/Main3DMenu.cpp b/source/Menus/Main3DMenu.cpp index 36f382d..39b1dcc 100644 --- a/source/Menus/Main3DMenu.cpp +++ b/source/Menus/Main3DMenu.cpp @@ -100,8 +100,8 @@ void Main3DMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "3D Settings"; this->show_back_x = true; @@ -111,14 +111,14 @@ void Main3DMenu::class_setup() { void Main3DMenu::insert_data(ScreenType stype) { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { if((stype == ScreenType::BOTTOM) && (!pollable_options[i]->selectable_bottom)) continue; if((stype == ScreenType::TOP) && (!pollable_options[i]->selectable_top)) continue; if((stype == ScreenType::JOINT) && (!pollable_options[i]->selectable_joint)) continue; - this->options_indexes[this->num_enabled_options] = i; + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } this->prepare_options(); @@ -137,7 +137,7 @@ void Main3DMenu::set_output_option(int index, int action) { this->selected_index = pollable_options[this->options_indexes[index]]->out_action; } -int Main3DMenu::get_num_options() { +size_t Main3DMenu::get_num_options() { return this->num_enabled_options; } diff --git a/source/Menus/MainMenu.cpp b/source/Menus/MainMenu.cpp index d3a4687..dfaa6ea 100755 --- a/source/Menus/MainMenu.cpp +++ b/source/Menus/MainMenu.cpp @@ -183,8 +183,8 @@ void MainMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Main Menu"; this->show_back_x = true; @@ -204,7 +204,7 @@ static bool check_cc_specific_option(const MainMenuOptionInfo* option, CaptureDe void MainMenu::insert_data(ScreenType s_type, bool is_fullscreen, bool mono_app_mode, CaptureDevice* device, bool connected) { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { bool valid = true; if(is_fullscreen) valid = valid && pollable_options[i]->active_fullscreen; @@ -225,7 +225,7 @@ void MainMenu::insert_data(ScreenType s_type, bool is_fullscreen, bool mono_app_ //if((pollable_options[i]->out_action == MAIN_MENU_SHORTCUT_SETTINGS) && (!enable_shortcut)) // valid = false; if(valid) { - this->options_indexes[this->num_enabled_options] = i; + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } } @@ -243,7 +243,7 @@ void MainMenu::set_output_option(int index, int action) { this->selected_index = pollable_options[this->options_indexes[index]]->out_action; } -int MainMenu::get_num_options() { +size_t MainMenu::get_num_options() { return this->num_enabled_options; } diff --git a/source/Menus/OffsetMenu.cpp b/source/Menus/OffsetMenu.cpp index 8c4f584..b5698d3 100755 --- a/source/Menus/OffsetMenu.cpp +++ b/source/Menus/OffsetMenu.cpp @@ -55,8 +55,8 @@ void OffsetMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Offset Settings"; this->show_back_x = true; @@ -66,8 +66,8 @@ void OffsetMenu::class_setup() { void OffsetMenu::insert_data() { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { - this->options_indexes[this->num_enabled_options] = i; + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } this->prepare_options(); @@ -86,7 +86,7 @@ void OffsetMenu::set_output_option(int index, int action) { this->selected_index = pollable_options[this->options_indexes[index]]->out_action; } -int OffsetMenu::get_num_options() { +size_t OffsetMenu::get_num_options() { return this->num_enabled_options; } diff --git a/source/Menus/OptionSelectionMenu.cpp b/source/Menus/OptionSelectionMenu.cpp index 5c36a8e..e79cb36 100755 --- a/source/Menus/OptionSelectionMenu.cpp +++ b/source/Menus/OptionSelectionMenu.cpp @@ -50,8 +50,8 @@ void OptionSelectionMenu::class_setup() { this->width_divisor_menu = 1; this->base_height_factor_menu = 1; this->base_height_divisor_menu = 1; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Sample Menu"; this->show_back_x = false; @@ -110,8 +110,6 @@ bool OptionSelectionMenu::is_option_element(int option) { } bool OptionSelectionMenu::is_option_location_multichoice(int option) { - bool location_left = true; - if((option == this->next_page_id) || (option == this->prev_page_id)) return true; if(this->is_option_element(option) && (((option - this->elements_start_id) % this->single_option_multiplier) != 0)) @@ -197,7 +195,7 @@ void OptionSelectionMenu::reset_output_option() { void OptionSelectionMenu::set_output_option(int index, int action) { } -int OptionSelectionMenu::get_num_options() { +size_t OptionSelectionMenu::get_num_options() { return this->num_options_per_screen; } @@ -233,8 +231,8 @@ std::string OptionSelectionMenu::setTextOptionFloat(int index, float value, int } int OptionSelectionMenu::get_num_pages() { - int num_pages = 1 + ((this->get_num_options() - 1) / this->num_options_per_screen); - if(this->get_num_options() == (this->num_options_per_screen + 1)) + int num_pages = (int)(1 + ((this->get_num_options() - 1) / this->num_options_per_screen)); + if(this->get_num_options() == ((size_t)(this->num_options_per_screen + 1))) num_pages = 1; return num_pages; } @@ -244,7 +242,7 @@ void OptionSelectionMenu::prepare_options() { if(this->future_data.page >= num_pages) this->future_data.page = num_pages - 1; int start = this->future_data.page * this->num_options_per_screen; - int total_elements = this->get_num_options() - start; + int total_elements = (int)(this->get_num_options() - start); if((num_pages > 1) && (total_elements > this->num_options_per_screen)) total_elements = this->num_options_per_screen; for(int i = 0; i < this->num_elements_displayed_per_screen; i++) { @@ -322,9 +320,9 @@ void OptionSelectionMenu::option_selection_handling() { this->set_output_option((elem_index / this->single_option_multiplier) + start, elem_index % this->single_option_multiplier); this->last_action_time = std::chrono::high_resolution_clock::now(); } - else if((this->future_data.option_selected == this->prev_page_id) && this->future_data.page > 0) + else if((this->future_data.option_selected == this->prev_page_id) && (this->future_data.page > 0)) this->future_data.page--; - else if((this->future_data.option_selected == this->next_page_id) && this->future_data.page < ((this->get_num_options() - 1) / this->num_options_per_screen)) + else if((this->future_data.option_selected == this->next_page_id) && (this->future_data.page < ((int)((this->get_num_options() - 1) / this->num_options_per_screen)))) this->future_data.page++; if(old_loaded_page != this->future_data.page) { this->prepare_options(); @@ -384,14 +382,8 @@ bool OptionSelectionMenu::poll(SFEvent &event_data) { bool consumed = true; switch (event_data.type) { case EVENT_TEXT_ENTERED: - switch (event_data.unicode) { - default: - consumed = false; - break; - } - + consumed = false; break; - case EVENT_KEY_PRESSED: switch (event_data.code) { case sf::Keyboard::Key::Up: @@ -490,7 +482,7 @@ bool OptionSelectionMenu::poll(SFEvent &event_data) { void OptionSelectionMenu::draw(float scaling_factor, sf::RenderTarget &window) { const sf::Vector2f rect_size = this->menu_rectangle.getSize(); if((this->loaded_data.menu_width != rect_size.x) || (this->loaded_data.menu_height != rect_size.y)) { - this->menu_rectangle.setSize(sf::Vector2f(this->loaded_data.menu_width, this->loaded_data.menu_height)); + this->menu_rectangle.setSize(sf::Vector2f((float)this->loaded_data.menu_width, (float)this->loaded_data.menu_height)); } this->menu_rectangle.setPosition({(float)this->loaded_data.pos_x, (float)this->loaded_data.pos_y}); window.draw(this->menu_rectangle); @@ -541,7 +533,7 @@ void OptionSelectionMenu::base_prepare(float menu_scaling_factor, int view_size_ has_bottom = true; if(has_bottom) num_elements += 1; - const float base_height = (this->num_vertical_slices * BASE_PIXEL_FONT_HEIGHT * 11) / 9; + const float base_height = (this->num_vertical_slices * BASE_PIXEL_FONT_HEIGHT * 11.0f) / 9.0f; int max_width = (view_size_x * 9) / 10; int max_height = (view_size_y * 9) / 10; float max_width_corresponding_height = (max_width * this->width_divisor_menu * this->max_width_slack) / this->width_factor_menu; @@ -561,14 +553,12 @@ void OptionSelectionMenu::base_prepare(float menu_scaling_factor, int view_size_ if(num_elements_text_scaling_factor < this->min_elements_text_scaling_factor) num_elements_text_scaling_factor = this->min_elements_text_scaling_factor; float text_scaling_factor = (menu_scaling_factor * this->num_vertical_slices) / num_elements_text_scaling_factor; - this->future_data.menu_height = base_height * final_menu_scaling_factor; + this->future_data.menu_height = (int)(base_height * final_menu_scaling_factor); this->future_data.menu_width = (this->future_data.menu_height * this->width_factor_menu) / this->width_divisor_menu; if(this->future_data.menu_width > max_width) this->future_data.menu_width = max_width; this->future_data.pos_x = (view_size_x - this->future_data.menu_width) / 2; this->future_data.pos_y = (view_size_y - this->future_data.menu_height) / 2; - int slice_y_size = this->future_data.menu_height / num_elements; - int slice_x_size = this->future_data.menu_width / this->num_page_elements; int num_rendered_y = 0; if(this->future_enabled_labels[this->back_x_id]) { int top_divisor = 1; diff --git a/source/Menus/PARMenu.cpp b/source/Menus/PARMenu.cpp index 02d2302..2234d31 100755 --- a/source/Menus/PARMenu.cpp +++ b/source/Menus/PARMenu.cpp @@ -14,8 +14,8 @@ void PARMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = this->base_name; this->show_back_x = true; @@ -43,7 +43,7 @@ void PARMenu::set_output_option(int index, int action) { this->selected_index = index; } -int PARMenu::get_num_options() { +size_t PARMenu::get_num_options() { return (*this->possible_pars).size(); } diff --git a/source/Menus/RelativePositionMenu.cpp b/source/Menus/RelativePositionMenu.cpp index 25be698..9db6510 100755 --- a/source/Menus/RelativePositionMenu.cpp +++ b/source/Menus/RelativePositionMenu.cpp @@ -43,14 +43,14 @@ static const RelativePositionMenuOptionInfo below_option = { static const RelativePositionMenuOptionInfo desc_option = { .base_name = "Top Screen", .is_selectable = false, .position_x = 1, .position_y = 2, .multiplier_y = 2, -.text_factor_multiplier = 0.95, +.text_factor_multiplier = 0.95f, .out_action = BOT_REL_POS_END, .divisor_x = 3}; static const RelativePositionMenuOptionInfo desc2_option = { .base_name = "Position", .is_selectable = false, .position_x = 1, .position_y = 3, .multiplier_y = 2, -.text_factor_multiplier = 0.95, +.text_factor_multiplier = 0.95f, .out_action = BOT_REL_POS_END, .divisor_x = 3}; @@ -109,8 +109,8 @@ void RelativePositionMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Screens Placement"; } @@ -159,20 +159,22 @@ void RelativePositionMenu::set_default_cursor_position() { } } +// This is reversed, due to it being the position of the bottom screen. +// But we ask the user the position of the top screen. bool RelativePositionMenu::is_option_left(int index) { - return pollable_options[index]->out_action == LEFT_TOP; -} - -bool RelativePositionMenu::is_option_right(int index) { return pollable_options[index]->out_action == RIGHT_TOP; } +bool RelativePositionMenu::is_option_right(int index) { + return pollable_options[index]->out_action == LEFT_TOP; +} + bool RelativePositionMenu::is_option_above(int index) { - return pollable_options[index]->out_action == ABOVE_TOP; + return pollable_options[index]->out_action == UNDER_TOP; } bool RelativePositionMenu::is_option_below(int index) { - return pollable_options[index]->out_action == UNDER_TOP; + return pollable_options[index]->out_action == ABOVE_TOP; } void RelativePositionMenu::decrement_selected_option(bool is_simple) { @@ -182,7 +184,7 @@ void RelativePositionMenu::decrement_selected_option(bool is_simple) { } int elem_index = this->future_data.option_selected - this->elements_start_id; if(!is_simple) { - if(this->is_option_element(this->future_data.option_selected) && (this->is_option_left(elem_index) || this->is_option_above(elem_index))) + if(this->is_option_element(this->future_data.option_selected) && (this->is_option_right(elem_index) || this->is_option_below(elem_index))) this->future_data.option_selected -= 1; } do { @@ -199,7 +201,7 @@ void RelativePositionMenu::increment_selected_option(bool is_simple) { } int elem_index = this->future_data.option_selected - this->elements_start_id; if(!is_simple) { - if(this->is_option_element(this->future_data.option_selected) && this->is_option_right(elem_index)) + if(this->is_option_element(this->future_data.option_selected) && this->is_option_left(elem_index)) this->future_data.option_selected += 1; } do { @@ -282,27 +284,10 @@ void RelativePositionMenu::down_code(bool is_simple) { } void RelativePositionMenu::left_code() { - if(!this->can_execute_action()) - return; - if(this->is_option_element(this->future_data.option_selected) && this->is_option_right(this->future_data.option_selected - this->elements_start_id)) - this->option_selection_handling(); - else { - this->future_data.option_selected -= 1; - for(int i = 0; i < this->num_options_per_screen; i++) { - if(this->is_option_right(i)) { - this->future_data.option_selected = i + this->elements_start_id; - break; - } - } - this->last_action_time = std::chrono::high_resolution_clock::now(); - } -} - -void RelativePositionMenu::right_code() { if(!this->can_execute_action()) return; int elem_index = this->future_data.option_selected - this->elements_start_id; - if(this->is_option_element(this->future_data.option_selected) && this->is_option_left(this->future_data.option_selected - this->elements_start_id)) + if(this->is_option_element(this->future_data.option_selected) && this->is_option_left(elem_index)) this->option_selection_handling(); else { this->future_data.option_selected -= 1; @@ -316,18 +301,30 @@ void RelativePositionMenu::right_code() { } } +void RelativePositionMenu::right_code() { + if(!this->can_execute_action()) + return; + int elem_index = this->future_data.option_selected - this->elements_start_id; + if(this->is_option_element(this->future_data.option_selected) && this->is_option_right(elem_index)) + this->option_selection_handling(); + else { + this->future_data.option_selected -= 1; + for(int i = 0; i < this->num_options_per_screen; i++) { + if(this->is_option_right(i)) { + this->future_data.option_selected = i + this->elements_start_id; + break; + } + } + this->last_action_time = std::chrono::high_resolution_clock::now(); + } +} + bool RelativePositionMenu::poll(SFEvent &event_data) { bool consumed = true; switch (event_data.type) { case EVENT_TEXT_ENTERED: - switch (event_data.unicode) { - default: - consumed = false; - break; - } - + consumed = false; break; - case EVENT_KEY_PRESSED: switch (event_data.code) { case sf::Keyboard::Key::Up: @@ -426,7 +423,7 @@ bool RelativePositionMenu::poll(SFEvent &event_data) { void RelativePositionMenu::draw(float scaling_factor, sf::RenderTarget &window) { const sf::Vector2f rect_size = this->menu_rectangle.getSize(); if((this->loaded_data.menu_width != rect_size.x) || (this->loaded_data.menu_height != rect_size.y)) { - this->menu_rectangle.setSize(sf::Vector2f(this->loaded_data.menu_width, this->loaded_data.menu_height)); + this->menu_rectangle.setSize(sf::Vector2f((float)this->loaded_data.menu_width, (float)this->loaded_data.menu_height)); } this->menu_rectangle.setPosition({(float)this->loaded_data.pos_x, (float)this->loaded_data.pos_y}); window.draw(this->menu_rectangle); @@ -499,16 +496,12 @@ void RelativePositionMenu::base_prepare(float menu_scaling_factor, int view_size if(num_elements_text_scaling_factor < this->min_elements_text_scaling_factor) num_elements_text_scaling_factor = this->min_elements_text_scaling_factor; float text_scaling_factor = (menu_scaling_factor * this->num_vertical_slices) / num_elements_text_scaling_factor; - this->future_data.menu_height = base_height * final_menu_scaling_factor; + this->future_data.menu_height = (int)(base_height * final_menu_scaling_factor); this->future_data.menu_width = (this->future_data.menu_height * this->width_factor_menu) / this->width_divisor_menu; if(this->future_data.menu_width > max_width) this->future_data.menu_width = max_width; this->future_data.pos_x = (view_size_x - this->future_data.menu_width) / 2; this->future_data.pos_y = (view_size_y - this->future_data.menu_height) / 2; - int slice_y_size = this->future_data.menu_height / this->num_vertical_slices; - int slice_x_size = 3; - int num_rendered_y = 0; - int top_divisor = 6; this->prepare_text_slices(0, 6, 0, this->num_vertical_slices, this->back_x_id, text_scaling_factor); this->prepare_text_slices(0, 1, 0, this->num_vertical_slices, this->title_id, text_scaling_factor); for(int i = 0; i < this->num_options_per_screen; i++) { diff --git a/source/Menus/ResolutionMenu.cpp b/source/Menus/ResolutionMenu.cpp index b9a0f3a..06a2be7 100755 --- a/source/Menus/ResolutionMenu.cpp +++ b/source/Menus/ResolutionMenu.cpp @@ -14,8 +14,8 @@ void ResolutionMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Resolution Settings"; this->show_back_x = true; @@ -40,7 +40,7 @@ void ResolutionMenu::set_output_option(int index, int action) { this->selected_index = index; } -int ResolutionMenu::get_num_options() { +size_t ResolutionMenu::get_num_options() { return (*this->possible_resolutions).size(); } @@ -67,7 +67,7 @@ void ResolutionMenu::prepare(float menu_scaling_factor, int view_size_x, int vie continue; int mode_index = start + i; sf::VideoMode mode = this->get_resolution(mode_index); - if((mode.size.x == fullscreen_mode_width) && (mode.size.y == fullscreen_mode_height)) + if((mode.size.x == ((size_t)fullscreen_mode_width)) && (mode.size.y == ((size_t)fullscreen_mode_height))) this->labels[index]->setText("<" + this->get_string_option(mode_index, DEFAULT_ACTION) + ">"); else this->labels[index]->setText(this->get_string_option(mode_index, DEFAULT_ACTION)); diff --git a/source/Menus/RotationMenu.cpp b/source/Menus/RotationMenu.cpp index ef029d8..2094917 100755 --- a/source/Menus/RotationMenu.cpp +++ b/source/Menus/RotationMenu.cpp @@ -49,8 +49,8 @@ void RotationMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Rotation Settings"; this->show_back_x = true; @@ -60,8 +60,8 @@ void RotationMenu::class_setup() { void RotationMenu::insert_data() { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { - this->options_indexes[this->num_enabled_options] = i; + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } this->prepare_options(); @@ -80,7 +80,7 @@ void RotationMenu::set_output_option(int index, int action) { this->selected_index = pollable_options[this->options_indexes[index]]->out_action; } -int RotationMenu::get_num_options() { +size_t RotationMenu::get_num_options() { return this->num_enabled_options; } diff --git a/source/Menus/ScalingRatioMenu.cpp b/source/Menus/ScalingRatioMenu.cpp index dd380de..39a1501 100755 --- a/source/Menus/ScalingRatioMenu.cpp +++ b/source/Menus/ScalingRatioMenu.cpp @@ -63,8 +63,8 @@ void ScalingRatioMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Scaling & Ratio Settings"; this->show_back_x = true; @@ -74,8 +74,8 @@ void ScalingRatioMenu::class_setup() { void ScalingRatioMenu::insert_data() { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { - this->options_indexes[this->num_enabled_options] = i; + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } this->prepare_options(); @@ -94,7 +94,7 @@ void ScalingRatioMenu::set_output_option(int index, int action) { this->selected_index = pollable_options[this->options_indexes[index]]->out_action; } -int ScalingRatioMenu::get_num_options() { +size_t ScalingRatioMenu::get_num_options() { return this->num_enabled_options; } diff --git a/source/Menus/SecondScreen3DRelativePositionMenu.cpp b/source/Menus/SecondScreen3DRelativePositionMenu.cpp index ee84692..5d6f3a6 100644 --- a/source/Menus/SecondScreen3DRelativePositionMenu.cpp +++ b/source/Menus/SecondScreen3DRelativePositionMenu.cpp @@ -55,7 +55,7 @@ static const SecondScreen3DRelativePositionMenuOptionInfo desc_option = { .base_name = "3D Screen", .false_name = "", .is_selectable = false, .position_x = 1, .position_y = 4, .multiplier_y = 2, -.text_factor_multiplier = 0.95, +.text_factor_multiplier = 0.95f, .out_action = SECOND_SCREEN_3D_REL_POS_MENU_NO_ACTION, .out_position = SECOND_SCREEN_3D_REL_POS_END, .divisor_x = 3, .exists_non_joint = true}; @@ -64,7 +64,7 @@ static const SecondScreen3DRelativePositionMenuOptionInfo desc2_option = { .base_name = "Position", .false_name = "", .is_selectable = false, .position_x = 1, .position_y = 5, .multiplier_y = 2, -.text_factor_multiplier = 0.95, +.text_factor_multiplier = 0.95f, .out_action = SECOND_SCREEN_3D_REL_POS_MENU_NO_ACTION, .out_position = SECOND_SCREEN_3D_REL_POS_END, .divisor_x = 3, .exists_non_joint = true}; @@ -108,8 +108,8 @@ void SecondScreen3DRelativePositionMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "3D Screen Placement"; } @@ -164,19 +164,19 @@ bool SecondScreen3DRelativePositionMenu::is_option_element(int option) { } bool SecondScreen3DRelativePositionMenu::is_option_left(int index) { - return (pollable_options[index]->out_action == SECOND_SCREEN_3D_REL_POS_MENU_CONFIRM) && (pollable_options[index]->out_position == RIGHT_FIRST); -} - -bool SecondScreen3DRelativePositionMenu::is_option_right(int index) { return (pollable_options[index]->out_action == SECOND_SCREEN_3D_REL_POS_MENU_CONFIRM) && (pollable_options[index]->out_position == LEFT_FIRST); } +bool SecondScreen3DRelativePositionMenu::is_option_right(int index) { + return (pollable_options[index]->out_action == SECOND_SCREEN_3D_REL_POS_MENU_CONFIRM) && (pollable_options[index]->out_position == RIGHT_FIRST); +} + bool SecondScreen3DRelativePositionMenu::is_option_above(int index) { - return (pollable_options[index]->out_action == SECOND_SCREEN_3D_REL_POS_MENU_CONFIRM) && (pollable_options[index]->out_position == UNDER_FIRST); + return (pollable_options[index]->out_action == SECOND_SCREEN_3D_REL_POS_MENU_CONFIRM) && (pollable_options[index]->out_position == ABOVE_FIRST); } bool SecondScreen3DRelativePositionMenu::is_option_below(int index) { - return (pollable_options[index]->out_action == SECOND_SCREEN_3D_REL_POS_MENU_CONFIRM) && (pollable_options[index]->out_position == ABOVE_FIRST); + return (pollable_options[index]->out_action == SECOND_SCREEN_3D_REL_POS_MENU_CONFIRM) && (pollable_options[index]->out_position == UNDER_FIRST); } std::string SecondScreen3DRelativePositionMenu::setTextOptionBool(int index, bool value) { diff --git a/source/Menus/SeparatorMenu.cpp b/source/Menus/SeparatorMenu.cpp index a7b919f..63c7100 100644 --- a/source/Menus/SeparatorMenu.cpp +++ b/source/Menus/SeparatorMenu.cpp @@ -61,8 +61,8 @@ void SeparatorMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Separator Settings"; this->show_back_x = true; @@ -72,12 +72,12 @@ void SeparatorMenu::class_setup() { void SeparatorMenu::insert_data(bool is_fullscreen) { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { if(is_fullscreen && (!pollable_options[i]->show_fullscreen)) continue; if((!is_fullscreen) && (!pollable_options[i]->show_windowed)) continue; - this->options_indexes[this->num_enabled_options] = i; + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } this->prepare_options(); @@ -96,7 +96,7 @@ void SeparatorMenu::set_output_option(int index, int action) { this->selected_index = pollable_options[this->options_indexes[index]]->out_action; } -int SeparatorMenu::get_num_options() { +size_t SeparatorMenu::get_num_options() { return this->num_enabled_options; } diff --git a/source/Menus/ShortcutMenu.cpp b/source/Menus/ShortcutMenu.cpp index 7045d3b..440366a 100755 --- a/source/Menus/ShortcutMenu.cpp +++ b/source/Menus/ShortcutMenu.cpp @@ -14,8 +14,8 @@ void ShortcutMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Shortcut Settings"; this->show_back_x = true; @@ -33,7 +33,7 @@ void ShortcutMenu::reset_output_option() { } void ShortcutMenu::set_output_option(int index, int action) { - if(index >= this->get_num_options()) + if(index >= ((int)this->get_num_options())) this->selected_index = SHORTCUT_MENU_BACK; else if(index == BACK_X_OUTPUT_OPTION) this->selected_index = SHORTCUT_MENU_BACK; @@ -41,7 +41,7 @@ void ShortcutMenu::set_output_option(int index, int action) { this->selected_index = index; } -int ShortcutMenu::get_num_options() { +size_t ShortcutMenu::get_num_options() { return this->shortcut_names->size(); } diff --git a/source/Menus/StatusMenu.cpp b/source/Menus/StatusMenu.cpp index c71d325..e581e95 100755 --- a/source/Menus/StatusMenu.cpp +++ b/source/Menus/StatusMenu.cpp @@ -76,8 +76,8 @@ void StatusMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Status"; this->show_back_x = true; @@ -89,8 +89,8 @@ void StatusMenu::insert_data() { this->last_update_time = std::chrono::high_resolution_clock::now(); this->do_update = true; this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { - this->options_indexes[this->num_enabled_options] = i; + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } this->prepare_options(); @@ -105,7 +105,7 @@ void StatusMenu::set_output_option(int index, int action) { this->selected_index = STATUS_MENU_BACK; } -int StatusMenu::get_num_options() { +size_t StatusMenu::get_num_options() { return this->num_enabled_options; } @@ -161,13 +161,13 @@ void StatusMenu::prepare(float menu_scaling_factor, int view_size_x, int view_si this->labels[index]->setText(get_usb_speed_text(get_usb_speed_of_device(capture_status))); break; case STATUS_MENU_FPS_IN: - this->labels[index + INC_ACTION]->setText(get_float_str_decimals(in_fps, 2)); + this->labels[index + INC_ACTION]->setText(get_float_str_decimals((float)in_fps, 2)); break; case STATUS_MENU_FPS_POLL: - this->labels[index + INC_ACTION]->setText(get_float_str_decimals(poll_fps, 2)); + this->labels[index + INC_ACTION]->setText(get_float_str_decimals((float)poll_fps, 2)); break; case STATUS_MENU_FPS_DRAW: - this->labels[index + INC_ACTION]->setText(get_float_str_decimals(draw_fps, 2)); + this->labels[index + INC_ACTION]->setText(get_float_str_decimals((float)draw_fps, 2)); break; default: break; diff --git a/source/Menus/VideoEffectsMenu.cpp b/source/Menus/VideoEffectsMenu.cpp index 4171e9b..2c56eba 100644 --- a/source/Menus/VideoEffectsMenu.cpp +++ b/source/Menus/VideoEffectsMenu.cpp @@ -52,8 +52,8 @@ void VideoEffectsMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Video Effects Settings"; this->show_back_x = true; @@ -63,8 +63,8 @@ void VideoEffectsMenu::class_setup() { void VideoEffectsMenu::insert_data() { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { - this->options_indexes[this->num_enabled_options] = i; + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } this->prepare_options(); @@ -83,7 +83,7 @@ void VideoEffectsMenu::set_output_option(int index, int action) { this->selected_index = pollable_options[this->options_indexes[index]]->out_action; } -int VideoEffectsMenu::get_num_options() { +size_t VideoEffectsMenu::get_num_options() { return this->num_enabled_options; } diff --git a/source/Menus/VideoMenu.cpp b/source/Menus/VideoMenu.cpp index eef1462..c6f8694 100755 --- a/source/Menus/VideoMenu.cpp +++ b/source/Menus/VideoMenu.cpp @@ -248,8 +248,8 @@ void VideoMenu::class_setup() { this->width_divisor_menu = 9; this->base_height_factor_menu = 12; this->base_height_divisor_menu = 6; - this->min_text_size = 0.3; - this->max_width_slack = 1.1; + this->min_text_size = 0.3f; + this->max_width_slack = 1.1f; this->menu_color = sf::Color(30, 30, 60, 192); this->title = "Video Settings"; this->show_back_x = true; @@ -259,7 +259,7 @@ void VideoMenu::class_setup() { void VideoMenu::insert_data(ScreenType s_type, bool is_fullscreen, bool can_have_titlebar) { this->num_enabled_options = 0; - for(int i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { + for(size_t i = 0; i < NUM_TOTAL_MENU_OPTIONS; i++) { bool valid = true; if(is_fullscreen) valid = valid && pollable_options[i]->active_fullscreen; @@ -274,7 +274,7 @@ void VideoMenu::insert_data(ScreenType s_type, bool is_fullscreen, bool can_have if((!can_have_titlebar) && pollable_options[i]->requires_titlebar_possible) valid = false; if(valid) { - this->options_indexes[this->num_enabled_options] = i; + this->options_indexes[this->num_enabled_options] = (int)i; this->num_enabled_options++; } } @@ -294,7 +294,7 @@ void VideoMenu::set_output_option(int index, int action) { this->selected_index = pollable_options[this->options_indexes[index]]->out_action; } -int VideoMenu::get_num_options() { +size_t VideoMenu::get_num_options() { return this->num_enabled_options; } @@ -337,10 +337,10 @@ void VideoMenu::prepare(float menu_scaling_factor, int view_size_x, int view_siz this->labels[index]->setText(this->setTextOptionBool(real_index, info->rounded_corners_fix)); break; case VIDEO_MENU_WINDOW_SCALING_DEC: - this->labels[index]->setText(this->setTextOptionFloat(real_index, info->scaling)); + this->labels[index]->setText(this->setTextOptionFloat(real_index, (float)info->scaling)); break; case VIDEO_MENU_MENU_SCALING_DEC: - this->labels[index]->setText(this->setTextOptionFloat(real_index, info->menu_scaling_factor)); + this->labels[index]->setText(this->setTextOptionFloat(real_index, (float)info->menu_scaling_factor)); break; case VIDEO_MENU_SMALL_SCREEN_OFFSET_DEC: this->labels[index]->setText(this->setTextOptionFloat(real_index, info->subscreen_offset)); diff --git a/source/TextRectangle.cpp b/source/TextRectangle.cpp index 048f55a..25ea136 100755 --- a/source/TextRectangle.cpp +++ b/source/TextRectangle.cpp @@ -1,8 +1,8 @@ #include "TextRectangle.hpp" TextRectangle::TextRectangle(bool font_load_success, sf::Font &text_font) : actual_text(text_font) { + this->reset_data(this->future_data); this->font_load_success = font_load_success; - this->setSize(1, 1); this->setRealSize(1, 1, false); this->text_rect.out_rect.setTexture(&this->text_rect.out_tex.getTexture()); if(this->font_load_success) @@ -30,7 +30,7 @@ void TextRectangle::setRectangleKind(TextKind kind) { } void TextRectangle::setTextFactor(float size_multiplier) { - int new_pixel_height = BASE_PIXEL_FONT_HEIGHT * size_multiplier; + float new_pixel_height = BASE_PIXEL_FONT_HEIGHT * size_multiplier; if(this->future_data.font_pixel_height == new_pixel_height) return; this->future_data.font_pixel_height = new_pixel_height; @@ -98,7 +98,7 @@ void TextRectangle::setShowText(bool show_text) { void TextRectangle::draw(sf::RenderTarget &window) { if(this->loaded_data.render_text) { - this->updateText(window.getView().getSize().x); + this->updateText((int)window.getView().getSize().x); } if(font_load_success && this->loaded_data.show_text && (!this->is_done_showing_text)) { this->text_rect.out_rect.setPosition({(float)this->loaded_data.pos_x, (float)this->loaded_data.pos_y}); @@ -161,24 +161,24 @@ void TextRectangle::setTextWithLineWrapping(int x_limit) { bool is_done = false; bool line_started = false; std::string new_text = ""; - int pos = 0; + size_t pos = 0; while(!is_done) { std::string curr_text = new_text; if(line_started) curr_text += " "; - auto space_pos = this->loaded_data.printed_text.find(' ', pos); + size_t space_pos = this->loaded_data.printed_text.find(' ', pos); if(space_pos == std::string::npos) { is_done = true; space_pos = this->loaded_data.printed_text.length(); } - for(int i = pos; i < space_pos; i++) + for(size_t i = pos; i < space_pos; i++) curr_text += this->loaded_data.printed_text[i]; this->actual_text.setString(curr_text); sf::FloatRect globalBounds = this->actual_text.getGlobalBounds(); - int bounds_width = globalBounds.size.x + (globalBounds.position.x * 2); + int bounds_width = (int)(globalBounds.size.x + (globalBounds.position.x * 2)); if(line_started && (bounds_width > x_limit)) { curr_text = new_text + "\n"; - for(int i = pos; i < space_pos; i++) + for(size_t i = pos; i < space_pos; i++) curr_text += this->loaded_data.printed_text[i]; } pos = space_pos + 1; @@ -195,14 +195,14 @@ void TextRectangle::setRealSize(int width, int height, bool check_previous) { if((height == this->text_rect.out_rect.getSize().y) && (width == this->text_rect.out_rect.getSize().x)) return; } - this->text_rect.out_rect.setSize(sf::Vector2f(this->loaded_data.width, this->loaded_data.height)); + this->text_rect.out_rect.setSize(sf::Vector2f((float)this->loaded_data.width, (float)this->loaded_data.height)); (void)this->text_rect.out_tex.resize({(unsigned int)this->loaded_data.width, (unsigned int)this->loaded_data.height}); this->text_rect.out_rect.setTextureRect(sf::IntRect({0, 0}, {this->loaded_data.width, this->loaded_data.height})); } void TextRectangle::updateText(int x_limit) { // set the character size - this->actual_text.setCharacterSize(this->loaded_data.font_pixel_height); // in pixels, not points! + this->actual_text.setCharacterSize((unsigned int)this->loaded_data.font_pixel_height); // in pixels, not points! // set the color this->actual_text.setFillColor(sf::Color::White); // set the text style @@ -214,8 +214,8 @@ void TextRectangle::updateText(int x_limit) { globalBounds = this->actual_text.getGlobalBounds(); int new_width = this->loaded_data.width; int new_height = this->loaded_data.height; - int bounds_width = globalBounds.size.x + (globalBounds.position.x * 2); - int bounds_height = globalBounds.size.y + (globalBounds.position.y * 2); + int bounds_width = (int)(globalBounds.size.x + (globalBounds.position.x * 2)); + int bounds_height = (int)(globalBounds.size.y + (globalBounds.position.y * 2)); if(new_width < bounds_width) new_width = bounds_width; if(new_height < bounds_height) @@ -223,7 +223,7 @@ void TextRectangle::updateText(int x_limit) { this->setRealSize(new_width, new_height); this->actual_text.setPosition({(float)((int)(5 * (((float)this->loaded_data.font_pixel_height) / BASE_PIXEL_FONT_HEIGHT))), 0}); globalBounds = this->actual_text.getGlobalBounds(); - this->setRealSize(globalBounds.size.x + (globalBounds.position.x * 2), globalBounds.size.y + (globalBounds.position.y * 2)); + this->setRealSize((int)(globalBounds.size.x + (globalBounds.position.x * 2)), (int)(globalBounds.size.y + (globalBounds.position.y * 2))); } else { this->setRealSize(this->loaded_data.width, this->loaded_data.height); diff --git a/source/WindowCommands.cpp b/source/WindowCommands.cpp index a44c2f1..bdbaff4 100755 --- a/source/WindowCommands.cpp +++ b/source/WindowCommands.cpp @@ -1,5 +1,7 @@ #include "WindowCommands.hpp" +#define NUM_SELECTABLE_WINDOW_COMMANDS (sizeof(possible_cmds) / sizeof(possible_cmds[0])) + static const WindowCommand none_cmd = { .cmd = WINDOW_COMMAND_NONE, .name = "Nothing", @@ -348,13 +350,13 @@ static const WindowCommand* possible_cmds[] = { }; void create_window_commands_list(std::vector &list_to_fill, bool is_mono_extra) { - for(int i = 0; i < sizeof(possible_cmds) / sizeof(possible_cmds[0]); i++) + for(size_t i = 0; i < NUM_SELECTABLE_WINDOW_COMMANDS; i++) if(possible_cmds[i]->available_mono_extra || (!is_mono_extra)) list_to_fill.push_back(possible_cmds[i]); } const WindowCommand* get_window_command(PossibleWindowCommands cmd) { - for(int i = 0; i < sizeof(possible_cmds) / sizeof(possible_cmds[0]); i++) + for(size_t i = 0; i < NUM_SELECTABLE_WINDOW_COMMANDS; i++) if(possible_cmds[i]->cmd == cmd) return possible_cmds[i]; return &none_cmd; diff --git a/source/WindowScreen.cpp b/source/WindowScreen.cpp index 2e53361..1ba6ba2 100755 --- a/source/WindowScreen.cpp +++ b/source/WindowScreen.cpp @@ -104,6 +104,7 @@ WindowScreen::WindowScreen(ScreenType stype, CaptureStatus* capture_status, Disp } n_shader_refs += 1; this->was_last_frame_null = true; + this->main_thread_owns_window = true; this->created_proper_folder = created_proper_folder; } @@ -128,10 +129,6 @@ void WindowScreen::build() { sf::Vector2f top_screen_size = {(float)TOP_WIDTH_3DS * 2, (float)HEIGHT_3DS}; sf::Vector2f bot_screen_size = {(float)BOT_WIDTH_3DS, (float)HEIGHT_3DS}; - int width = TOP_WIDTH_3DS; - if(this->m_stype == ScreenType::BOTTOM) - width = BOT_WIDTH_3DS; - (void)this->m_out_rect_top.out_tex.resize({(unsigned int)top_screen_size.x, (unsigned int)top_screen_size.y}); this->m_out_rect_top.out_rect.setSize(top_screen_size); this->m_out_rect_top.out_rect.setTexture(&this->m_out_rect_top.out_tex.getTexture()); @@ -265,7 +262,7 @@ void WindowScreen::draw(double frame_time, VideoOutputData* out_buf) { loaded_info = m_info; m_info.initial_pos_x = DEFAULT_NO_POS_WINDOW_VALUE; m_info.initial_pos_y = DEFAULT_NO_POS_WINDOW_VALUE; - this->notification->setTextFactor(this->loaded_info.menu_scaling_factor); + this->notification->setTextFactor((float)this->loaded_info.menu_scaling_factor); this->notification->prepareRenderText(); this->frame_time = frame_time; this->scheduled_work_on_window = this->window_needs_work(); @@ -347,7 +344,7 @@ void WindowScreen::resize_in_rect(sf::RectangleShape &in_rect, int start_x, int in_rect.setSize({(float)target_width, (float)target_height}); in_rect.setOrigin({target_width / 2.0f, target_height / 2.0f}); - in_rect.setRotation(sf::degrees(target_rotation)); + in_rect.setRotation(sf::degrees((float)target_rotation)); in_rect.setPosition({width / 2.0f, height / 2.0f}); } @@ -548,7 +545,7 @@ int WindowScreen::_choose_color_emulation_shader(bool is_top) { int color_profile_index = this->loaded_info.top_color_correction; if(!is_top) color_profile_index = this->loaded_info.bot_color_correction; - if((color_profile_index >= possible_color_profiles.size()) || (color_profile_index < 0)) + if((color_profile_index >= ((int)possible_color_profiles.size())) || (color_profile_index < 0)) color_profile_index = 0; const ShaderColorEmulationData* shader_color_data = possible_color_profiles[color_profile_index]; @@ -653,8 +650,8 @@ int WindowScreen::_choose_shader(PossibleShaderTypes shader_type, bool is_top) { int WindowScreen::choose_shader(PossibleShaderTypes shader_type, bool is_top) { int chosen_shader = _choose_shader(shader_type, is_top); - if((chosen_shader >= 0) && (chosen_shader < usable_shaders.size()) && usable_shaders[chosen_shader].is_valid) - return chosen_shader; + if((chosen_shader >= 0) && (chosen_shader < ((int)usable_shaders.size())) && usable_shaders[chosen_shader].is_valid) + return (int)chosen_shader; return -1; } @@ -760,12 +757,12 @@ sf::Vector2u WindowScreen::get_desk_mode_3d_multiplied(ScreenInfo* info) { sf::Vector2f WindowScreen::get_3d_offset_out_rect(ScreenInfo* info, bool is_second_screen) { if((!get_3d_enabled(this->capture_status)) || (this->display_data->interleaved_3d)) return {0, 0}; - float x_contribution = this->m_width_no_manip; - float y_contribution = this->m_height_no_manip; + float x_contribution = (float)this->m_width_no_manip; + float y_contribution = (float)this->m_height_no_manip; if(info->is_fullscreen) { sf::Vector2u curr_desk_mode_3d_size = get_desk_mode_3d_multiplied(info); - x_contribution = curr_desk_mode_3d_size.x; - y_contribution = curr_desk_mode_3d_size.y; + x_contribution = (float)curr_desk_mode_3d_size.x; + y_contribution = (float)curr_desk_mode_3d_size.y; } float offset_x_first_screen = 0; float offset_y_first_screen = 0; @@ -845,10 +842,10 @@ void WindowScreen::window_render_call() { if(this->loaded_info.bfi_amount > (this->loaded_info.bfi_divider - 1)) this->loaded_info.bfi_amount = this->loaded_info.bfi_divider - 1; for(int i = 0; i < (this->loaded_info.bfi_divider - this->loaded_info.bfi_amount - 1); i++) { - sf::sleep(sf::seconds(frame_time / (this->loaded_info.bfi_divider * 1.1))); + sf::sleep(sf::seconds((float)(frame_time / (this->loaded_info.bfi_divider * 1.1)))); } for(int i = 0; i < this->loaded_info.bfi_amount; i++) { - sf::sleep(sf::seconds(frame_time / (this->loaded_info.bfi_divider * 1.1))); + sf::sleep(sf::seconds((float)(frame_time / (this->loaded_info.bfi_divider * 1.1)))); this->display_data_to_window(false); } } @@ -867,8 +864,8 @@ static bool should_have_separator(sf::Vector2f top_screen_size, sf::Vector2f bot static int get_separator_size_xy(float top_scaling, float bot_scaling, int separator_size, float separator_multiplier, bool is_fullscreen) { if((!is_fullscreen) && (separator_multiplier == SEP_FOLLOW_SCALING_MULTIPLIER)) - return separator_size * top_scaling; - return separator_size * separator_multiplier; + return (int)(separator_size * top_scaling); + return (int)(separator_size * separator_multiplier); } static int get_separator_size_x(sf::Vector2f top_screen_size, sf::Vector2f bot_screen_size, float top_scaling, float bot_scaling, ScreenType stype, BottomRelativePosition bottom_pos, int separator_size, float separator_multiplier, bool is_fullscreen) { @@ -890,19 +887,15 @@ static int get_separator_size_y(sf::Vector2f top_screen_size, sf::Vector2f bot_s void WindowScreen::set_position_screens(sf::Vector2f &curr_top_screen_size, sf::Vector2f &curr_bot_screen_size, int offset_x, int offset_y, int max_x, int max_y, int separator_size_x, int separator_size_y, bool do_work) { int top_screen_x = 0, top_screen_y = 0; int bot_screen_x = 0, bot_screen_y = 0; - int top_screen_width = curr_top_screen_size.x; - int top_screen_height = curr_top_screen_size.y; - int bot_screen_width = curr_bot_screen_size.x; - int bot_screen_height = curr_bot_screen_size.y; + int top_screen_width = (int)curr_top_screen_size.x; + int top_screen_height = (int)curr_top_screen_size.y; + int bot_screen_width = (int)curr_bot_screen_size.x; + int bot_screen_height = (int)curr_bot_screen_size.y; - if((this->loaded_info.top_rotation / 10) % 2) { - top_screen_width = curr_top_screen_size.y; - top_screen_height = curr_top_screen_size.x; - } - if((this->loaded_info.bot_rotation / 10) % 2) { - bot_screen_width = curr_bot_screen_size.y; - bot_screen_height = curr_bot_screen_size.x; - } + if((this->loaded_info.top_rotation / 10) % 2) + std::swap(top_screen_width, top_screen_height); + if((this->loaded_info.bot_rotation / 10) % 2) + std::swap(bot_screen_width, bot_screen_height); if(this->m_stype == ScreenType::TOP) bot_screen_width = bot_screen_height = 0; @@ -919,39 +912,39 @@ void WindowScreen::set_position_screens(sf::Vector2f &curr_top_screen_size, sf:: if(this->m_stype == ScreenType::JOINT) { switch(this->loaded_info.bottom_pos) { case UNDER_TOP: - bot_screen_x = (greatest_width - bot_screen_width) * this->loaded_info.subscreen_offset; - top_screen_x = (greatest_width - top_screen_width) * this->loaded_info.subscreen_offset; + bot_screen_x = (int)((greatest_width - bot_screen_width) * this->loaded_info.subscreen_offset); + top_screen_x = (int)((greatest_width - top_screen_width) * this->loaded_info.subscreen_offset); bot_screen_y = top_screen_height + separator_size_y; if(max_y > 0) - bot_screen_y += (max_y - bot_screen_height - separator_size_y - top_screen_height - offset_y) * this->loaded_info.subscreen_attached_offset; + bot_screen_y += (int)((max_y - bot_screen_height - separator_size_y - top_screen_height - offset_y) * this->loaded_info.subscreen_attached_offset); break; case RIGHT_TOP: - bot_screen_y = (greatest_height - bot_screen_height) * this->loaded_info.subscreen_offset; - top_screen_y = (greatest_height - top_screen_height) * this->loaded_info.subscreen_offset; + bot_screen_y = (int)((greatest_height - bot_screen_height) * this->loaded_info.subscreen_offset); + top_screen_y = (int)((greatest_height - top_screen_height) * this->loaded_info.subscreen_offset); bot_screen_x = top_screen_width + separator_size_x; if(max_x > 0) - bot_screen_x += (max_x - bot_screen_width - separator_size_x - top_screen_width - offset_x) * this->loaded_info.subscreen_attached_offset; + bot_screen_x += (int)((max_x - bot_screen_width - separator_size_x - top_screen_width - offset_x) * this->loaded_info.subscreen_attached_offset); break; case ABOVE_TOP: - bot_screen_x = (greatest_width - bot_screen_width) * this->loaded_info.subscreen_offset; - top_screen_x = (greatest_width - top_screen_width) * this->loaded_info.subscreen_offset; + bot_screen_x = (int)((greatest_width - bot_screen_width) * this->loaded_info.subscreen_offset); + top_screen_x = (int)((greatest_width - top_screen_width) * this->loaded_info.subscreen_offset); top_screen_y = bot_screen_height + separator_size_y; if(max_y > 0) - top_screen_y += (max_y - bot_screen_height - separator_size_y - top_screen_height - offset_y) * this->loaded_info.subscreen_attached_offset; + top_screen_y += (int)((max_y - bot_screen_height - separator_size_y - top_screen_height - offset_y) * this->loaded_info.subscreen_attached_offset); break; case LEFT_TOP: - bot_screen_y = (greatest_height - bot_screen_height) * this->loaded_info.subscreen_offset; - top_screen_y = (greatest_height - top_screen_height) * this->loaded_info.subscreen_offset; + bot_screen_y = (int)((greatest_height - bot_screen_height) * this->loaded_info.subscreen_offset); + top_screen_y = (int)((greatest_height - top_screen_height) * this->loaded_info.subscreen_offset); top_screen_x = bot_screen_width + separator_size_x; if(max_x > 0) - top_screen_x += (max_x - bot_screen_width - separator_size_x - top_screen_width - offset_x) * this->loaded_info.subscreen_attached_offset; + top_screen_x += (int)((max_x - bot_screen_width - separator_size_x - top_screen_width - offset_x) * this->loaded_info.subscreen_attached_offset); break; default: break; } } if(do_work) { - float scale_issue_fix_offset = -0.005; + float scale_issue_fix_offset = -0.005f; this->m_out_rect_top.out_rect.setPosition({top_screen_x + scale_issue_fix_offset + offset_x + get_screen_corner_modifier_x(this->loaded_info.top_rotation, top_screen_width), top_screen_y + offset_y + get_screen_corner_modifier_y(this->loaded_info.top_rotation, top_screen_height) + scale_issue_fix_offset}); this->m_out_rect_bot.out_rect.setPosition({bot_screen_x + scale_issue_fix_offset + offset_x + get_screen_corner_modifier_x(this->loaded_info.bot_rotation, bot_screen_width), bot_screen_y + offset_y + get_screen_corner_modifier_y(this->loaded_info.bot_rotation, bot_screen_height) + scale_issue_fix_offset}); } @@ -974,7 +967,7 @@ float WindowScreen::get_max_float_screen_multiplier(ResizingScreenData *own_scre if((other_rotation / 10) % 2) std::swap(width_limit, height_limit); - sf::Vector2f other_screen_size = sf::Vector2f(width_limit, height_limit); + sf::Vector2f other_screen_size = sf::Vector2f((float)width_limit, (float)height_limit); if((!is_size_valid(other_screen_size)) && is_two_screens_merged) other_screen_size = sf::Vector2f(1, 1); sf::Vector2u curr_desk_mode_3d_size = get_desk_mode_3d_multiplied(&this->m_info); @@ -1010,13 +1003,13 @@ float WindowScreen::get_max_float_screen_multiplier(ResizingScreenData *own_scre } int WindowScreen::prepare_screen_ratio(ResizingScreenData *own_screen, int width_limit, int height_limit, int other_rotation) { - return this->get_max_float_screen_multiplier(own_screen, width_limit, height_limit, other_rotation); + return (int)this->get_max_float_screen_multiplier(own_screen, width_limit, height_limit, other_rotation); } -float WindowScreen::get_ratio_compared_other_screen(ResizingScreenData *own_screen, ResizingScreenData* other_screen, float other_scaling) { - int other_width = other_screen->size.x; - int other_height = other_screen->size.y; - get_par_size(other_width, other_height, other_scaling, other_screen->par, other_screen->divide_3d_par); +int WindowScreen::get_ratio_compared_other_screen(ResizingScreenData *own_screen, ResizingScreenData* other_screen, int other_scaling) { + int other_width = (int)other_screen->size.x; + int other_height = (int)other_screen->size.y; + get_par_size(other_width, other_height, (float)other_scaling, other_screen->par, other_screen->divide_3d_par); return prepare_screen_ratio(own_screen, other_width, other_height, other_screen->rotation); } @@ -1038,7 +1031,7 @@ void WindowScreen::calc_scaling_resize_screens(ResizingScreenData *own_screen, R (*own_screen->scaling) = chosen_ratio; if(set_to_zero) (*own_screen->scaling) = 0; - if((increase && ((old_scaling == (*own_screen->scaling)) || ((*other_screen->scaling) == 0)) || (mantain && ((*other_screen->scaling) == 0))) && ((*own_screen->scaling) > 0)) + if(((increase && ((old_scaling == (*own_screen->scaling)) || ((*other_screen->scaling) == 0))) || (mantain && ((*other_screen->scaling) == 0))) && ((*own_screen->scaling) > 0)) (*other_screen->scaling) = 0; else (*other_screen->scaling) = get_ratio_compared_other_screen(other_screen, own_screen, *own_screen->scaling); @@ -1059,18 +1052,18 @@ bool WindowScreen::can_non_integerly_scale() { } void WindowScreen::rescale_nonint_subscreen(ResizingScreenData *main_screen_resize_data, ResizingScreenData *sub_screen_resize_data) { - int new_width = main_screen_resize_data->size.x; - int new_height = main_screen_resize_data->size.y; + int new_width = (int)main_screen_resize_data->size.x; + int new_height = (int)main_screen_resize_data->size.y; get_par_size(new_width, new_height, *main_screen_resize_data->non_int_scaling, main_screen_resize_data->par, main_screen_resize_data->divide_3d_par); *sub_screen_resize_data->non_int_scaling = this->get_max_float_screen_multiplier(sub_screen_resize_data, new_width, new_height, main_screen_resize_data->rotation); if(!sub_screen_resize_data->use_non_int_scaling) - *sub_screen_resize_data->non_int_scaling = static_cast(*sub_screen_resize_data->non_int_scaling); + *sub_screen_resize_data->non_int_scaling = std::floor(*sub_screen_resize_data->non_int_scaling); } void WindowScreen::direct_scale_nonint_screen(ResizingScreenData *main_screen_resize_data, int sub_min_width, int sub_height_min, int sub_screen_rotation) { *main_screen_resize_data->non_int_scaling = this->get_max_float_screen_multiplier(main_screen_resize_data, sub_min_width, sub_height_min, sub_screen_rotation); if(!main_screen_resize_data->use_non_int_scaling) - *main_screen_resize_data->non_int_scaling = static_cast(*main_screen_resize_data->non_int_scaling); + *main_screen_resize_data->non_int_scaling = std::floor(*main_screen_resize_data->non_int_scaling); } void WindowScreen::non_int_scale_screens_with_main(ResizingScreenData *main_screen_resize_data, ResizingScreenData *sub_screen_resize_data, int sub_min_width, int sub_height_min) { @@ -1079,8 +1072,8 @@ void WindowScreen::non_int_scale_screens_with_main(ResizingScreenData *main_scre } void WindowScreen::non_int_scale_screens_both(ResizingScreenData *main_screen_resize_data, ResizingScreenData *sub_screen_resize_data, int free_width, int free_height, float multiplier_main, int main_min_width, int main_height_min, int sub_min_width, int sub_height_min) { - int main_free_width = (free_width * multiplier_main) + 0.5; - int main_free_height = (free_height * multiplier_main) + 0.5; + int main_free_width = (int)((free_width * multiplier_main) + 0.5f); + int main_free_height = (int)((free_height * multiplier_main) + 0.5f); int sub_free_width = free_width - main_free_width; int sub_free_height = free_height - main_free_height; this->direct_scale_nonint_screen(main_screen_resize_data, sub_min_width + sub_free_width, sub_height_min + sub_free_height, sub_screen_resize_data->rotation); @@ -1091,8 +1084,8 @@ void WindowScreen::non_int_scale_screens_both(ResizingScreenData *main_screen_re void WindowScreen::non_integer_scale_screens(ResizingScreenData *top_screen_resize_data, ResizingScreenData *bot_screen_resize_data) { if(!this->can_non_integerly_scale()) { - this->m_info.non_integer_top_scaling = this->m_info.top_scaling; - this->m_info.non_integer_bot_scaling = this->m_info.bot_scaling; + this->m_info.non_integer_top_scaling = (float)this->m_info.top_scaling; + this->m_info.non_integer_bot_scaling = (float)this->m_info.bot_scaling; return; } if(this->m_info.top_scaling == 0) { @@ -1123,12 +1116,12 @@ void WindowScreen::non_integer_scale_screens(ResizingScreenData *top_screen_resi min_top_scaling = this->m_info.top_scaling; if(min_bot_scaling > this->m_info.bot_scaling) min_bot_scaling = this->m_info.bot_scaling; - int min_top_screen_width = top_screen_resize_data->size.x; - int min_top_screen_height = top_screen_resize_data->size.y; - int min_bot_screen_width = bot_screen_resize_data->size.x; - int min_bot_screen_height = bot_screen_resize_data->size.y; - get_par_size(min_top_screen_width, min_top_screen_height, min_top_scaling, top_screen_resize_data->par, top_screen_resize_data->divide_3d_par); - get_par_size(min_bot_screen_width, min_bot_screen_height, min_bot_scaling, bot_screen_resize_data->par, bot_screen_resize_data->divide_3d_par); + int min_top_screen_width = (int)top_screen_resize_data->size.x; + int min_top_screen_height = (int)top_screen_resize_data->size.y; + int min_bot_screen_width = (int)bot_screen_resize_data->size.x; + int min_bot_screen_height = (int)bot_screen_resize_data->size.y; + get_par_size(min_top_screen_width, min_top_screen_height, (float)min_top_scaling, top_screen_resize_data->par, top_screen_resize_data->divide_3d_par); + get_par_size(min_bot_screen_width, min_bot_screen_height, (float)min_bot_scaling, bot_screen_resize_data->par, bot_screen_resize_data->divide_3d_par); ResizingScreenData *bigger_screen_resize_data = top_screen_resize_data; ResizingScreenData *smaller_screen_resize_data = bot_screen_resize_data; @@ -1206,8 +1199,8 @@ void WindowScreen::merge_screens_data(ResizingScreenData* top_screen_resize_data else merged_screen_resize_data->use_non_int_scaling = false; merged_screen_resize_data->rotation = 0; - *merged_screen_resize_data->scaling = 1.0; - *merged_screen_resize_data->non_int_scaling = 1.0; + *merged_screen_resize_data->scaling = 1; + *merged_screen_resize_data->non_int_scaling = 1.0f; merged_screen_resize_data->par = get_base_par(); } @@ -1219,11 +1212,11 @@ bool WindowScreen::prepare_screens_same_scaling_factor(ResizingScreenData* top_s ResizingScreenData merged_screen_resize_data = {.size = {}, .scaling = &scaling_merged, .non_int_scaling = &non_int_scaling_merged, .use_non_int_scaling = false, .rotation = 0, .par = NULL, .divide_3d_par = false}; merge_screens_data(top_screen_resize_data, bot_screen_resize_data, &merged_screen_resize_data, this->m_info.bottom_pos); non_int_scaling_merged = this->get_max_float_screen_multiplier(&merged_screen_resize_data, 0, 0, 0, true); - scaling_merged = non_int_scaling_merged; + scaling_merged = (int)non_int_scaling_merged; if(non_int_scaling_merged < 1.0) return false; - *top_screen_resize_data->non_int_scaling = scaling_merged; - *bot_screen_resize_data->non_int_scaling = scaling_merged; + *top_screen_resize_data->non_int_scaling = (float)scaling_merged; + *bot_screen_resize_data->non_int_scaling = (float)scaling_merged; if(merged_screen_resize_data.use_non_int_scaling) { *top_screen_resize_data->non_int_scaling = non_int_scaling_merged; *bot_screen_resize_data->non_int_scaling = non_int_scaling_merged; @@ -1260,9 +1253,9 @@ void WindowScreen::prepare_size_ratios(bool top_increase, bool bot_increase, boo bot_increase = false; } bool prioritize_top = (!bot_increase) && (top_increase || (this->m_info.bottom_pos == UNDER_TOP) || (this->m_info.bottom_pos == RIGHT_TOP)); - if((this->m_info.top_par >= this->possible_pars.size()) || (this->m_info.top_par < 0)) + if((this->m_info.top_par >= ((int)this->possible_pars.size())) || (this->m_info.top_par < 0)) this->m_info.top_par = 0; - if((this->m_info.bot_par >= this->possible_pars.size()) || (this->m_info.bot_par < 0)) + if((this->m_info.bot_par >= ((int)this->possible_pars.size())) || (this->m_info.bot_par < 0)) this->m_info.bot_par = 0; ResizingScreenData top_screen_resize_data = {.size = top_screen_size, .scaling = &this->m_info.top_scaling, .non_int_scaling = &this->m_info.non_integer_top_scaling, .use_non_int_scaling = this->m_info.use_non_integer_scaling_top, .rotation = this->m_info.top_rotation, .par = this->possible_pars[this->m_info.top_par], .divide_3d_par = get_divide_3d_par(true, &this->m_info)}; ResizingScreenData bot_screen_resize_data = {.size = bot_screen_size, .scaling = &this->m_info.bot_scaling, .non_int_scaling = &this->m_info.non_integer_bot_scaling, .use_non_int_scaling = this->m_info.use_non_integer_scaling_bottom, .rotation = this->m_info.bot_rotation, .par = this->possible_pars[this->m_info.bot_par], .divide_3d_par = get_divide_3d_par(false, &this->m_info)}; @@ -1301,7 +1294,7 @@ int WindowScreen::get_fullscreen_offset_x(int top_width, int top_height, int bot return 0; } sf::Vector2u curr_desk_mode_3d_size = get_desk_mode_3d_multiplied(&this->loaded_info); - return (curr_desk_mode_3d_size.x - offset_contribute) * this->loaded_info.total_offset_x; + return (int)((curr_desk_mode_3d_size.x - offset_contribute) * this->loaded_info.total_offset_x); } int WindowScreen::get_fullscreen_offset_y(int top_width, int top_height, int bot_width, int bot_height, int separator_contribute) { @@ -1324,18 +1317,18 @@ int WindowScreen::get_fullscreen_offset_y(int top_width, int top_height, int bot return 0; } sf::Vector2u curr_desk_mode_3d_size = get_desk_mode_3d_multiplied(&this->loaded_info); - return (curr_desk_mode_3d_size.y - offset_contribute) * this->loaded_info.total_offset_y; + return (int)((curr_desk_mode_3d_size.y - offset_contribute) * this->loaded_info.total_offset_y); } void WindowScreen::resize_window_and_out_rects(bool do_work) { sf::Vector2f top_screen_size = getShownScreenSize(true, &this->loaded_info); sf::Vector2f bot_screen_size = getShownScreenSize(false, &this->loaded_info); - int top_width = top_screen_size.x; - int top_height = top_screen_size.y; - float top_scaling = this->loaded_info.scaling; - int bot_width = bot_screen_size.x; - int bot_height = bot_screen_size.y; - float bot_scaling = this->loaded_info.scaling; + int top_width = (int)top_screen_size.x; + int top_height = (int)top_screen_size.y; + float top_scaling = (float)this->loaded_info.scaling; + int bot_width = (int)bot_screen_size.x; + int bot_height = (int)bot_screen_size.y; + float bot_scaling = (float)this->loaded_info.scaling; int offset_x = 0; int offset_y = 0; int max_x = 0; @@ -1349,9 +1342,9 @@ void WindowScreen::resize_window_and_out_rects(bool do_work) { bot_scaling = this->loaded_info.non_integer_bot_scaling; sep_multiplier = this->loaded_info.separator_fullscreen_multiplier; } - if((this->loaded_info.top_par >= this->possible_pars.size()) || (this->loaded_info.top_par < 0)) + if((this->loaded_info.top_par >= ((int)this->possible_pars.size())) || (this->loaded_info.top_par < 0)) this->loaded_info.top_par = 0; - if((this->loaded_info.bot_par >= this->possible_pars.size()) || (this->loaded_info.bot_par < 0)) + if((this->loaded_info.bot_par >= ((int)this->possible_pars.size())) || (this->loaded_info.bot_par < 0)) this->loaded_info.bot_par = 0; get_par_size(top_width, top_height, top_scaling, this->possible_pars[this->loaded_info.top_par], get_divide_3d_par(true, &this->loaded_info)); get_par_size(bot_width, bot_height, bot_scaling, this->possible_pars[this->loaded_info.bot_par], get_divide_3d_par(false, &this->loaded_info)); @@ -1389,8 +1382,8 @@ void WindowScreen::resize_window_and_out_rects(bool do_work) { sf::Vector2f offset_to_apply = offset_first_screen; if((offset_first_screen.x <= 0) && (offset_first_screen.y <= 0)) offset_to_apply = get_3d_offset_out_rect(&this->loaded_info, true); - this->m_width += offset_to_apply.x; - this->m_height += offset_to_apply.y; + this->m_width += (int)offset_to_apply.x; + this->m_height += (int)offset_to_apply.y; } } if((!this->loaded_info.is_fullscreen) && this->loaded_info.rounded_corners_fix) { @@ -1474,8 +1467,8 @@ void WindowScreen::update_screen_settings() { } void WindowScreen::rotate() { - this->m_out_rect_top.out_rect.setRotation(sf::degrees(this->loaded_info.top_rotation)); - this->m_out_rect_bot.out_rect.setRotation(sf::degrees(this->loaded_info.bot_rotation)); + this->m_out_rect_top.out_rect.setRotation(sf::degrees((float)this->loaded_info.top_rotation)); + this->m_out_rect_bot.out_rect.setRotation(sf::degrees((float)this->loaded_info.bot_rotation)); this->loaded_operations.call_screen_settings_update = true; } @@ -1501,7 +1494,7 @@ int* WindowScreen::get_crop_index_ptr(ScreenInfo* info) { sf::Vector2f WindowScreen::getShownScreenSize(bool is_top, ScreenInfo* info) { std::vector *crops = this->get_crop_data_vector(info); int *crop_kind = this->get_crop_index_ptr(info); - if(((*crop_kind) >= crops->size()) || ((*crop_kind) < 0)) + if(((*crop_kind) >= ((int)crops->size())) || ((*crop_kind) < 0)) *crop_kind = 0; int width = (*crops)[*crop_kind]->top_width; int height = (*crops)[*crop_kind]->top_height; @@ -1521,7 +1514,7 @@ void WindowScreen::crop() { sf::Vector2f top_screen_size = getShownScreenSize(true, &this->loaded_info); sf::Vector2f bot_screen_size = getShownScreenSize(false, &this->loaded_info); - this->resize_in_rect(this->m_in_rect_bot, this->capture_status->device.bot_screen_x + (*crops)[*crop_value]->bot_x, this->capture_status->device.bot_screen_y + (*crops)[*crop_value]->bot_y, bot_screen_size.x, bot_screen_size.y); + this->resize_in_rect(this->m_in_rect_bot, this->capture_status->device.bot_screen_x + (*crops)[*crop_value]->bot_x, this->capture_status->device.bot_screen_y + (*crops)[*crop_value]->bot_y, (int)bot_screen_size.x, (int)bot_screen_size.y); if(get_3d_enabled(this->capture_status) && (!this->display_data->interleaved_3d)) { int left_top_screen_x = this->capture_status->device.top_screen_x; int left_top_screen_y = this->capture_status->device.top_screen_y; @@ -1531,14 +1524,14 @@ void WindowScreen::crop() { std::swap(left_top_screen_x, right_top_screen_x); std::swap(left_top_screen_y, right_top_screen_y); } - this->resize_in_rect(this->m_in_rect_top, left_top_screen_x + (*crops)[*crop_value]->top_x, left_top_screen_y + (*crops)[*crop_value]->top_y, top_screen_size.x, top_screen_size.y); - this->resize_in_rect(this->m_in_rect_top_right, right_top_screen_x + (*crops)[*crop_value]->top_x, right_top_screen_y + (*crops)[*crop_value]->top_y, top_screen_size.x, top_screen_size.y); + this->resize_in_rect(this->m_in_rect_top, left_top_screen_x + (*crops)[*crop_value]->top_x, left_top_screen_y + (*crops)[*crop_value]->top_y, (int)top_screen_size.x, (int)top_screen_size.y); + this->resize_in_rect(this->m_in_rect_top_right, right_top_screen_x + (*crops)[*crop_value]->top_x, right_top_screen_y + (*crops)[*crop_value]->top_y, (int)top_screen_size.x, (int)top_screen_size.y); } else { float x_multiplier = 1.0; if(get_3d_enabled(this->capture_status) && this->display_data->interleaved_3d) x_multiplier = 2.0; - this->resize_in_rect(this->m_in_rect_top, this->capture_status->device.top_screen_x + ((*crops)[*crop_value]->top_x * x_multiplier), this->capture_status->device.top_screen_y + (*crops)[*crop_value]->top_y, top_screen_size.x, top_screen_size.y); + this->resize_in_rect(this->m_in_rect_top, (int)(this->capture_status->device.top_screen_x + ((*crops)[*crop_value]->top_x * x_multiplier)), this->capture_status->device.top_screen_y + (*crops)[*crop_value]->top_y, (int)top_screen_size.x, (int)top_screen_size.y); } this->loaded_operations.call_screen_settings_update = true; } diff --git a/source/WindowScreen_Menu.cpp b/source/WindowScreen_Menu.cpp index f1e7771..054c510 100755 --- a/source/WindowScreen_Menu.cpp +++ b/source/WindowScreen_Menu.cpp @@ -54,7 +54,7 @@ static void check_held_reset(bool value, HeldTime &action_time) { static float check_held_diff(std::chrono::time_point &curr_time, HeldTime &action_time) { if(!action_time.started) return 0.0; - const std::chrono::duration diff = curr_time - action_time.start_time; + const std::chrono::duration diff = curr_time - action_time.start_time; return diff.count(); } @@ -263,8 +263,9 @@ void WindowScreen::game_crop_enable_change() { void WindowScreen::crop_value_change(int new_crop_value, bool do_print_notification, bool do_cycle) { std::vector *crops = this->get_crop_data_vector(&this->m_info); int *crop_value = this->get_crop_index_ptr(&this->m_info); - int new_value = new_crop_value % crops->size(); - if((!do_cycle) && ((new_crop_value < 0) || (new_crop_value >= crops->size()))) + int num_crops = (int)crops->size(); + int new_value = new_crop_value % num_crops; + if((!do_cycle) && ((new_crop_value < 0) || (new_crop_value >= num_crops))) new_value = 0; if(new_value < 0) new_value = 0; @@ -391,7 +392,7 @@ void WindowScreen::menu_scaling_change(bool positive) { if(this->m_info.menu_scaling_factor > 9.95) this->m_info.menu_scaling_factor = 10.0; if(old_scaling != this->m_info.menu_scaling_factor) { - this->print_notification_float("Menu Scaling", this->m_info.menu_scaling_factor, 1); + this->print_notification_float("Menu Scaling", (float)this->m_info.menu_scaling_factor, 1); } } @@ -416,7 +417,7 @@ void WindowScreen::window_scaling_change(bool positive) { if (this->m_info.scaling > (MAX_WINDOW_SCALING_VALUE - (WINDOW_SCALING_CHANGE / 2))) this->m_info.scaling = MAX_WINDOW_SCALING_VALUE; if(old_scaling != this->m_info.scaling) { - this->print_notification_float("Scaling", this->m_info.scaling, 1); + this->print_notification_float("Scaling", (float)this->m_info.scaling, 1); this->future_operations.call_screen_settings_update = true; } } @@ -1035,13 +1036,13 @@ void WindowScreen::setup_resolution_menu(bool reset_data) { if(modes.size() > 0) { this->possible_resolutions.push_back(sf::VideoMode({0, 0}, 0)); this->possible_resolutions.push_back(modes[0]); - for(int i = 1; i < modes.size(); ++i) + for(size_t i = 1; i < modes.size(); ++i) if(modes[0].bitsPerPixel == modes[i].bitsPerPixel) this->possible_resolutions.push_back(modes[i]); } else { this->print_notification("No Fullscreen resolution found", TEXT_KIND_WARNING); - for(int i = 0; i < (sizeof(default_fs_modes) / sizeof(default_fs_modes[0])); i++) { + for(size_t i = 0; i < (sizeof(default_fs_modes) / sizeof(default_fs_modes[0])); i++) { this->possible_resolutions.push_back(*default_fs_modes[i]); } } @@ -1239,11 +1240,7 @@ bool WindowScreen::no_menu_poll(SFEvent &event_data) { bool consumed = true; switch(event_data.type) { case EVENT_TEXT_ENTERED: - switch(event_data.unicode) { - default: - consumed = false; - break; - } + consumed = false; break; case EVENT_KEY_PRESSED: switch(event_data.code) { @@ -1732,10 +1729,10 @@ void WindowScreen::poll(bool do_everything) { this->rotation_change(this->m_info.bot_rotation, true); break; case VIDEO_MENU_SMALL_SCREEN_OFFSET_DEC: - this->offset_change(this->m_info.subscreen_offset, -0.1); + this->offset_change(this->m_info.subscreen_offset, -0.1f); break; case VIDEO_MENU_SMALL_SCREEN_OFFSET_INC: - this->offset_change(this->m_info.subscreen_offset, 0.1); + this->offset_change(this->m_info.subscreen_offset, 0.1f); break; case VIDEO_MENU_ROTATION_SETTINGS: this->setup_rotation_menu(); @@ -1882,28 +1879,28 @@ void WindowScreen::poll(bool do_everything) { case OFFSET_MENU_NO_ACTION: break; case OFFSET_MENU_SMALL_OFFSET_DEC: - this->offset_change(this->m_info.subscreen_offset, -0.1); + this->offset_change(this->m_info.subscreen_offset, -0.1f); break; case OFFSET_MENU_SMALL_OFFSET_INC: - this->offset_change(this->m_info.subscreen_offset, 0.1); + this->offset_change(this->m_info.subscreen_offset, 0.1f); break; case OFFSET_MENU_SMALL_SCREEN_DISTANCE_DEC: - this->offset_change(this->m_info.subscreen_attached_offset, -0.1); + this->offset_change(this->m_info.subscreen_attached_offset, -0.1f); break; case OFFSET_MENU_SMALL_SCREEN_DISTANCE_INC: - this->offset_change(this->m_info.subscreen_attached_offset, 0.1); + this->offset_change(this->m_info.subscreen_attached_offset, 0.1f); break; case OFFSET_MENU_SCREENS_X_POS_DEC: - this->offset_change(this->m_info.total_offset_x, -0.1); + this->offset_change(this->m_info.total_offset_x, -0.1f); break; case OFFSET_MENU_SCREENS_X_POS_INC: - this->offset_change(this->m_info.total_offset_x, 0.1); + this->offset_change(this->m_info.total_offset_x, 0.1f); break; case OFFSET_MENU_SCREENS_Y_POS_DEC: - this->offset_change(this->m_info.total_offset_y, -0.1); + this->offset_change(this->m_info.total_offset_y, -0.1f); break; case OFFSET_MENU_SCREENS_Y_POS_INC: - this->offset_change(this->m_info.total_offset_y, 0.1); + this->offset_change(this->m_info.total_offset_y, 0.1f); break; default: break; @@ -2247,7 +2244,7 @@ void WindowScreen::poll(bool do_everything) { default: audio_output_device_data tmp_out_device; int output_device_index = this->audio_device_menu->selected_index - 1; - if((output_device_index >= 0) && (output_device_index < this->possible_audio_devices.size())) { + if((output_device_index >= 0) && (output_device_index < ((int)this->possible_audio_devices.size()))) { tmp_out_device.preference_requested = true; tmp_out_device.preferred = this->possible_audio_devices[output_device_index]; } @@ -2530,7 +2527,7 @@ void WindowScreen::poll_window(bool do_everything) { if(do_everything) { check_held_reset(sf::Mouse::isButtonPressed(sf::Mouse::Button::Right), this->right_click_action); bool found = false; - for(int i = 0; i < sf::Joystick::Count; i++) { + for(unsigned int i = 0; i < sf::Joystick::Count; i++) { if(!sf::Joystick::isConnected(i)) continue; if(sf::Joystick::getButtonCount(i) <= 0) @@ -2572,90 +2569,91 @@ void WindowScreen::poll_window(bool do_everything) { } void WindowScreen::prepare_menu_draws(int view_size_x, int view_size_y) { + float menu_scaling_factor = (float)this->loaded_info.menu_scaling_factor; switch(this->loaded_menu) { case CONNECT_MENU_TYPE: - this->connection_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y); + this->connection_menu->prepare(menu_scaling_factor, view_size_x, view_size_y); break; case MAIN_MENU_TYPE: - this->main_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->capture_status->connected); + this->main_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, this->capture_status->connected); break; case VIDEO_MENU_TYPE: - this->video_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info, this->m_stype); + this->video_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info, this->m_stype); break; case CROP_MENU_TYPE: - this->crop_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, *this->get_crop_index_ptr(&this->loaded_info)); + this->crop_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, *this->get_crop_index_ptr(&this->loaded_info)); break; case TOP_PAR_MENU_TYPE: - this->par_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.top_par); + this->par_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.top_par); break; case BOTTOM_PAR_MENU_TYPE: - this->par_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.bot_par); + this->par_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.bot_par); break; case ROTATION_MENU_TYPE: - this->rotation_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); + this->rotation_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); break; case OFFSET_MENU_TYPE: - this->offset_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); + this->offset_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); break; case AUDIO_MENU_TYPE: - this->audio_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->audio_data); + this->audio_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, this->audio_data); break; case BFI_MENU_TYPE: - this->bfi_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); + this->bfi_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); break; case RELATIVE_POS_MENU_TYPE: - this->relpos_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.bottom_pos); + this->relpos_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.bottom_pos); break; case RESOLUTION_MENU_TYPE: - this->resolution_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.fullscreen_mode_width, this->loaded_info.fullscreen_mode_height); + this->resolution_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.fullscreen_mode_width, this->loaded_info.fullscreen_mode_height); break; case SAVE_MENU_TYPE: - this->fileconfig_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y); + this->fileconfig_menu->prepare(menu_scaling_factor, view_size_x, view_size_y); break; case LOAD_MENU_TYPE: - this->fileconfig_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y); + this->fileconfig_menu->prepare(menu_scaling_factor, view_size_x, view_size_y); break; case EXTRA_MENU_TYPE: - this->extra_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y); + this->extra_menu->prepare(menu_scaling_factor, view_size_x, view_size_y); break; case SHORTCUTS_MENU_TYPE: - this->shortcut_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y); + this->shortcut_menu->prepare(menu_scaling_factor, view_size_x, view_size_y); break; case ACTION_SELECTION_MENU_TYPE: - this->action_selection_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, (*this->possible_buttons_ptrs[this->chosen_button])->cmd); + this->action_selection_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, (*this->possible_buttons_ptrs[this->chosen_button])->cmd); break; case STATUS_MENU_TYPE: - this->status_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, FPSArrayGetAverage(&in_fps), FPSArrayGetAverage(&poll_fps), FPSArrayGetAverage(&draw_fps), this->capture_status); + this->status_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, FPSArrayGetAverage(&in_fps), FPSArrayGetAverage(&poll_fps), FPSArrayGetAverage(&draw_fps), this->capture_status); break; case LICENSES_MENU_TYPE: - this->license_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y); + this->license_menu->prepare(menu_scaling_factor, view_size_x, view_size_y); break; case SCALING_RATIO_MENU_TYPE: - this->scaling_ratio_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); + this->scaling_ratio_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); break; case ISN_MENU_TYPE: - this->is_nitro_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->capture_status); + this->is_nitro_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, this->capture_status); break; case VIDEO_EFFECTS_MENU_TYPE: - this->video_effects_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); + this->video_effects_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); break; case INPUT_MENU_TYPE: - this->input_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->shared_data->input_data); + this->input_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, &this->shared_data->input_data); break; case AUDIO_DEVICE_MENU_TYPE: - this->audio_device_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->audio_data->get_audio_output_device_data()); + this->audio_device_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, this->audio_data->get_audio_output_device_data()); break; case SEPARATOR_MENU_TYPE: - this->separator_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); + this->separator_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); break; case COLOR_CORRECTION_MENU_TYPE: - this->color_correction_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.top_color_correction); + this->color_correction_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.top_color_correction); break; case MAIN_3D_MENU_TYPE: - this->main_3d_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info, this->display_data, this->capture_status); + this->main_3d_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info, this->display_data, this->capture_status); break; case SECOND_SCREEN_RELATIVE_POS_MENU_TYPE: - this->second_screen_3d_relpos_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); + this->second_screen_3d_relpos_menu->prepare(menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); break; default: break; @@ -2663,90 +2661,91 @@ void WindowScreen::prepare_menu_draws(int view_size_x, int view_size_y) { } void WindowScreen::execute_menu_draws() { + float menu_scaling_factor = (float)this->loaded_info.menu_scaling_factor; switch(this->loaded_menu) { case CONNECT_MENU_TYPE: - this->connection_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->connection_menu->draw(menu_scaling_factor, this->m_win); break; case MAIN_MENU_TYPE: - this->main_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->main_menu->draw(menu_scaling_factor, this->m_win); break; case VIDEO_MENU_TYPE: - this->video_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->video_menu->draw(menu_scaling_factor, this->m_win); break; case CROP_MENU_TYPE: - this->crop_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->crop_menu->draw(menu_scaling_factor, this->m_win); break; case TOP_PAR_MENU_TYPE: - this->par_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->par_menu->draw(menu_scaling_factor, this->m_win); break; case BOTTOM_PAR_MENU_TYPE: - this->par_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->par_menu->draw(menu_scaling_factor, this->m_win); break; case ROTATION_MENU_TYPE: - this->rotation_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->rotation_menu->draw(menu_scaling_factor, this->m_win); break; case OFFSET_MENU_TYPE: - this->offset_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->offset_menu->draw(menu_scaling_factor, this->m_win); break; case AUDIO_MENU_TYPE: - this->audio_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->audio_menu->draw(menu_scaling_factor, this->m_win); break; case BFI_MENU_TYPE: - this->bfi_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->bfi_menu->draw(menu_scaling_factor, this->m_win); break; case RELATIVE_POS_MENU_TYPE: - this->relpos_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->relpos_menu->draw(menu_scaling_factor, this->m_win); break; case RESOLUTION_MENU_TYPE: - this->resolution_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->resolution_menu->draw(menu_scaling_factor, this->m_win); break; case SAVE_MENU_TYPE: - this->fileconfig_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->fileconfig_menu->draw(menu_scaling_factor, this->m_win); break; case LOAD_MENU_TYPE: - this->fileconfig_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->fileconfig_menu->draw(menu_scaling_factor, this->m_win); break; case EXTRA_MENU_TYPE: - this->extra_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->extra_menu->draw(menu_scaling_factor, this->m_win); break; case SHORTCUTS_MENU_TYPE: - this->shortcut_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->shortcut_menu->draw(menu_scaling_factor, this->m_win); break; case ACTION_SELECTION_MENU_TYPE: - this->action_selection_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->action_selection_menu->draw(menu_scaling_factor, this->m_win); break; case STATUS_MENU_TYPE: - this->status_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->status_menu->draw(menu_scaling_factor, this->m_win); break; case LICENSES_MENU_TYPE: - this->license_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->license_menu->draw(menu_scaling_factor, this->m_win); break; case SCALING_RATIO_MENU_TYPE: - this->scaling_ratio_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->scaling_ratio_menu->draw(menu_scaling_factor, this->m_win); break; case ISN_MENU_TYPE: - this->is_nitro_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->is_nitro_menu->draw(menu_scaling_factor, this->m_win); break; case VIDEO_EFFECTS_MENU_TYPE: - this->video_effects_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->video_effects_menu->draw(menu_scaling_factor, this->m_win); break; case INPUT_MENU_TYPE: - this->input_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->input_menu->draw(menu_scaling_factor, this->m_win); break; case AUDIO_DEVICE_MENU_TYPE: - this->audio_device_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->audio_device_menu->draw(menu_scaling_factor, this->m_win); break; case SEPARATOR_MENU_TYPE: - this->separator_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->separator_menu->draw(menu_scaling_factor, this->m_win); break; case COLOR_CORRECTION_MENU_TYPE: - this->color_correction_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->color_correction_menu->draw(menu_scaling_factor, this->m_win); break; case MAIN_3D_MENU_TYPE: - this->main_3d_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->main_3d_menu->draw(menu_scaling_factor, this->m_win); break; case SECOND_SCREEN_RELATIVE_POS_MENU_TYPE: - this->second_screen_3d_relpos_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win); + this->second_screen_3d_relpos_menu->draw(menu_scaling_factor, this->m_win); break; default: break; diff --git a/source/audio.cpp b/source/audio.cpp index 3caaf37..5548ee2 100755 --- a/source/audio.cpp +++ b/source/audio.cpp @@ -39,7 +39,7 @@ Audio::~Audio() { void Audio::update_volume() { int new_final_volume = this->audio_data->get_final_volume(); if(this->final_volume != new_final_volume) - setVolume(new_final_volume); + setVolume((float)new_final_volume); this->final_volume = new_final_volume; } @@ -85,8 +85,8 @@ bool Audio::onGetData(sf::SoundStream::Chunk &data) { inside_clock_time_start = std::chrono::high_resolution_clock::now(); inside_onGetData = true; - int loaded_samples = samples.size(); - while(loaded_samples <= 0) { + size_t loaded_samples = samples.size(); + while(loaded_samples == 0) { switch(this->audio_data->get_audio_mode_output()) { case AUDIO_MODE_STABLE: inside_onGetData = false; @@ -98,7 +98,7 @@ bool Audio::onGetData(sf::SoundStream::Chunk &data) { return false; } loaded_samples = samples.size(); - if((loaded_samples <= 0) && this->hasTooMuchTimeElapsedInside()) { + if((loaded_samples == 0) && this->hasTooMuchTimeElapsedInside()) { // This is needed by MacOS... // But it also causes some trailing noise when // closing the lid on the devices. @@ -119,9 +119,9 @@ bool Audio::onGetData(sf::SoundStream::Chunk &data) { data.sampleCount = 0; - for(int i = 0; i < loaded_samples; i++) { + for(size_t i = 0; i < loaded_samples; i++) { const std::int16_t *data_samples = samples.front().bytes; - uint64_t count = samples.front().size; + size_t count = (size_t)samples.front().size; memcpy(buffer + data.sampleCount, data_samples, count * sizeof(std::int16_t)); // Unused, but could be useful info //double real_sample_rate = (1.0 / samples.front().time) * count / 2; @@ -130,7 +130,7 @@ bool Audio::onGetData(sf::SoundStream::Chunk &data) { } if(this->audio_data->get_audio_output_type() == AUDIO_OUTPUT_MONO) - for(int i = 0; i < data.sampleCount; i++) { + for(size_t i = 0; i < data.sampleCount; i++) { int sum = ((int)buffer[i * 2]) + buffer[(i * 2) + 1]; // >> is apparently implementation-dependent. Do it like this... int sign_mult = 1; @@ -146,7 +146,7 @@ bool Audio::onGetData(sf::SoundStream::Chunk &data) { #ifdef AUDIO_PANNING_TEST int max_diff = 0; - for(int i = 0; i < data.sampleCount; i++) { + for(size_t i = 0; i < data.sampleCount; i++) { int diff = abs(buffer[i * 2] - buffer[(i * 2) + 1]); if(diff > max_diff) max_diff = diff; diff --git a/source/audio_data.cpp b/source/audio_data.cpp index 05a1801..5a3d01d 100755 --- a/source/audio_data.cpp +++ b/source/audio_data.cpp @@ -2,11 +2,13 @@ int searchAudioDevice(std::string device_name, std::vector &audio_devices) { int index = -1; - for(int i = 0; i < audio_devices.size(); i++) + for(size_t i = 0; i < audio_devices.size(); i++) if(audio_devices[i] == device_name) { - index = i; + index = (int)i; break; } + if(index < 0) + index = -1; return index; } @@ -26,8 +28,8 @@ void AudioData::change_max_audio_latency(bool is_change_positive) { int change = 1; if(!is_change_positive) change = -1; - int initial_max_audio_latency = this->max_audio_latency; - this->set_max_audio_latency(this->max_audio_latency + change); + size_t initial_max_audio_latency = this->max_audio_latency; + this->set_max_audio_latency(((int)this->max_audio_latency) + change); if(this->max_audio_latency != initial_max_audio_latency) this->update_text("Max Audio Latency: " + std::to_string(this->max_audio_latency)); } @@ -159,7 +161,7 @@ std::string AudioData::get_audio_mode_name() { return chosen_str; } -int AudioData::get_max_audio_latency() { +size_t AudioData::get_max_audio_latency() { return this->max_audio_latency; } diff --git a/source/cc3dsfs.cpp b/source/cc3dsfs.cpp index c39847d..309bd15 100755 --- a/source/cc3dsfs.cpp +++ b/source/cc3dsfs.cpp @@ -378,27 +378,28 @@ static bool setDefaultAudioDevice(Audio &audio) { return success; } -static void handleAudioDeviceChanges(Audio &audio, AudioData *audio_data, std::optional &curr_device, audio_output_device_data &in_use_audio_output_device_data) { - // Code for audio device selection - in_use_audio_output_device_data = audio_data->get_audio_output_device_data(); - int index = -1; - bool success = false; - if(in_use_audio_output_device_data.preference_requested) { - std::vector audio_devices = sf::PlaybackDevice::getAvailableDevices(); - index = searchAudioDevice(in_use_audio_output_device_data.preferred, audio_devices); - if((index != -1) && (curr_device != audio_devices[index])) { - audio.stop_audio(); - audio.stop(); - success = sf::PlaybackDevice::setDevice(audio_devices[index]); - curr_device = audio_devices[index]; - } - } - if(index == -1) { - std::optional default_device = sf::PlaybackDevice::getDefaultDevice(); - if(default_device != curr_device) - success = setDefaultAudioDevice(audio); - curr_device = default_device; +static bool handleAudioDeviceChanges(Audio &audio, AudioData *audio_data, std::optional &curr_device, audio_output_device_data &in_use_audio_output_device_data) { + // Code for audio device selection + in_use_audio_output_device_data = audio_data->get_audio_output_device_data(); + int index = -1; + bool success = false; + if(in_use_audio_output_device_data.preference_requested) { + std::vector audio_devices = sf::PlaybackDevice::getAvailableDevices(); + index = searchAudioDevice(in_use_audio_output_device_data.preferred, audio_devices); + if((index != -1) && (curr_device != audio_devices[index])) { + audio.stop_audio(); + audio.stop(); + success = sf::PlaybackDevice::setDevice(audio_devices[index]); + curr_device = audio_devices[index]; } + } + if(index == -1) { + std::optional default_device = sf::PlaybackDevice::getDefaultDevice(); + if(default_device != curr_device) + success = setDefaultAudioDevice(audio); + curr_device = default_device; + } + return success; } static void soundCall(AudioData *audio_data, CaptureData* capture_data) { @@ -407,7 +408,7 @@ static void soundCall(AudioData *audio_data, CaptureData* capture_data) { int audio_buf_counter = 0; uint16_t last_buffer_index = -1; const bool endianness = is_big_endian(); - volatile int loaded_samples; + volatile size_t loaded_samples; audio_output_device_data in_use_audio_output_device_data; std::optional curr_device = sf::PlaybackDevice::getDevice(); std::chrono::time_point last_device_check_time = std::chrono::high_resolution_clock::now(); @@ -517,7 +518,6 @@ static float get_time_multiplier(CaptureData* capture_data, bool should_ignore_d static int mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data, bool created_proper_folder, override_all_data &override_data) { VideoOutputData *out_buf; double last_frame_time = 0.0; - int num_elements_fps_array = 0; FrontendData frontend_data; ConsumerMutex draw_lock; reset_display_data(&frontend_data.display_data); diff --git a/source/conversions.cpp b/source/conversions.cpp index 5e5057e..e864f58 100755 --- a/source/conversions.cpp +++ b/source/conversions.cpp @@ -82,9 +82,9 @@ static inline void usb_rgb565convertInterleaveVideoToOutputDirectOptLE(deinterle for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel = (output_halfline * real_num_iters) + i; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_bottom[output_halfline_pixel].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][bottom_pos]; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_top[output_halfline_pixel].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][top_pos]; } } @@ -96,7 +96,7 @@ static inline void usb_rgb565convertInterleaveVideoToOutputDirectOptLEMonoTop(de for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel = (output_halfline * real_num_iters) + i; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_top[output_halfline_pixel].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][top_pos]; } } @@ -108,7 +108,7 @@ static inline void usb_rgb565convertInterleaveVideoToOutputDirectOptLEMonoBottom for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel = (output_halfline * real_num_iters) + i; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_bottom[output_halfline_pixel].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][bottom_pos]; } } @@ -124,11 +124,11 @@ static inline void usb_rgb565convertInterleave3DVideoToOutputDirectOptLE(deinter size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel_bottom = output_halfline_pos + i; size_t output_halfline_pixel_top = (output_halfline_pos * multiplier_top) + i; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_bottom[output_halfline_pixel_bottom].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][bottom_pos]; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_top_l[output_halfline_pixel_top].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][top_l_pos]; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_top_r[output_halfline_pixel_top].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][top_r_pos]; } } @@ -142,9 +142,9 @@ static inline void usb_rgb565convertInterleave3DVideoToOutputDirectOptLEMonoTop( for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel_top = (output_halfline_pos * multiplier_top) + i; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_top_l[output_halfline_pixel_top].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][top_l_pos]; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_top_r[output_halfline_pixel_top].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][top_r_pos]; } } @@ -157,7 +157,7 @@ static inline void usb_rgb565convertInterleave3DVideoToOutputDirectOptLEMonoBott for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel = output_halfline_pos + i; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_bottom[output_halfline_pixel].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][bottom_pos]; } } @@ -170,9 +170,9 @@ static inline void usb_rgb565convertInterleaveVideoToOutputDirectOptBE(deinterle for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel = (output_halfline * real_num_iters) + i; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_bottom[output_halfline_pixel].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][bottom_pos]); - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_top[output_halfline_pixel].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][top_pos]); } } @@ -184,7 +184,7 @@ static inline void usb_rgb565convertInterleaveVideoToOutputDirectOptBEMonoTop(de for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel = (output_halfline * real_num_iters) + i; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_top[output_halfline_pixel].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][top_pos]); } } @@ -196,7 +196,7 @@ static inline void usb_rgb565convertInterleaveVideoToOutputDirectOptBEMonoBottom for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel = (output_halfline * real_num_iters) + i; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_bottom[output_halfline_pixel].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][bottom_pos]); } } @@ -212,11 +212,11 @@ static inline void usb_rgb565convertInterleave3DVideoToOutputDirectOptBE(deinter size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel_bottom = output_halfline_pos + i; size_t output_halfline_pixel_top = (output_halfline_pos * multiplier_top) + i; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_bottom[output_halfline_pixel_bottom].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][bottom_pos]); - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_top_l[output_halfline_pixel_top].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][top_l_pos]); - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_top_r[output_halfline_pixel_top].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][top_r_pos]); } } @@ -230,9 +230,9 @@ static inline void usb_rgb565convertInterleave3DVideoToOutputDirectOptBEMonoTop( for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel_top = (output_halfline_pos * multiplier_top) + i; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_top_l[output_halfline_pixel_top].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][top_l_pos]); - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_top_r[output_halfline_pixel_top].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][top_r_pos]); } } @@ -245,7 +245,7 @@ static inline void usb_rgb565convertInterleave3DVideoToOutputDirectOptBEMonoBott for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel_bottom = output_halfline_pos + i; - for(int j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB565_TOTAL_SIZE; j++) out_ptr_bottom[output_halfline_pixel_bottom].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][bottom_pos]); } } @@ -258,9 +258,9 @@ static inline void usb_rgb888convertInterleaveU16VideoToOutputDirectOpt(deinterl for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel = (output_halfline * real_num_iters) + i; - for(int j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) out_ptr_bottom[output_halfline_pixel].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][bottom_pos]); - for(int j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) out_ptr_top[output_halfline_pixel].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][top_pos]); } } @@ -272,7 +272,7 @@ static inline void usb_rgb888convertInterleaveU16VideoToOutputDirectOptMonoTop(d for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel = (output_halfline * real_num_iters) + i; - for(int j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) out_ptr_top[output_halfline_pixel].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][top_pos]); } } @@ -284,7 +284,7 @@ static inline void usb_rgb888convertInterleaveU16VideoToOutputDirectOptMonoBotto for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel = (output_halfline * real_num_iters) + i; - for(int j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) out_ptr_bottom[output_halfline_pixel].pixels[j] = _reverse_endianness(in_ptr[input_halfline_pixel].pixels[j][bottom_pos]); } } @@ -300,11 +300,11 @@ static inline void usb_rgb888convertInterleaveU163DVideoToOutputDirectOpt(deinte size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel_bottom = output_halfline_pos + i; size_t output_halfline_pixel_top = (output_halfline_pos * multiplier_top) + i; - for(int j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) out_ptr_bottom[output_halfline_pixel_bottom].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][bottom_pos]; - for(int j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) out_ptr_top_l[output_halfline_pixel_top].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][top_l_pos]; - for(int j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) out_ptr_top_r[output_halfline_pixel_top].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][top_r_pos]; } } @@ -318,9 +318,9 @@ static inline void usb_rgb888convertInterleaveU163DVideoToOutputDirectOptMonoTop for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel_top = (output_halfline_pos * multiplier_top) + i; - for(int j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) out_ptr_top_l[output_halfline_pixel_top].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][top_l_pos]; - for(int j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) out_ptr_top_r[output_halfline_pixel_top].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][top_r_pos]; } } @@ -333,17 +333,17 @@ static inline void usb_rgb888convertInterleaveU163DVideoToOutputDirectOptMonoBot for(size_t i = 0; i < real_num_iters; i++) { size_t input_halfline_pixel = (input_halfline * real_num_iters) + i; size_t output_halfline_pixel_bottom = output_halfline_pos + i; - for(int j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) + for(size_t j = 0; j < INTERLEAVED_RGB888_TOTAL_SIZE; j++) out_ptr_bottom[output_halfline_pixel_bottom].pixels[j] = in_ptr[input_halfline_pixel].pixels[j][bottom_pos]; } } -static inline void convertVideoToOutputChunk(RGB83DSVideoInputData *p_in, VideoOutputData *p_out, int iters, int start_in, int start_out) { +static inline void convertVideoToOutputChunk(RGB83DSVideoInputData *p_in, VideoOutputData *p_out, size_t iters, size_t start_in, size_t start_out) { memcpy(&p_out->screen_data[start_out], &p_in->screen_data[start_in], iters * 3); } -static inline void convertVideoToOutputChunk_3D(RGB83DSVideoInputData_3D *p_in, VideoOutputData *p_out, int iters, int start_in, int start_out) { +static inline void convertVideoToOutputChunk_3D(RGB83DSVideoInputData_3D *p_in, VideoOutputData *p_out, size_t iters, size_t start_in, size_t start_out) { memcpy(&p_out->screen_data[start_out], &p_in->screen_data[start_in], iters * 3); } @@ -381,7 +381,7 @@ static void ftd3_convertVideoToOutput(CaptureReceived *p_in, VideoOutputData *p_ convertVideoToOutputChunk_3D(&p_in->ftd3_received_3d.video_in, p_out, IN_VIDEO_WIDTH_3DS_3D, ((i * 2) + 1) * IN_VIDEO_WIDTH_3DS_3D, BOT_SIZE_3DS + (i * IN_VIDEO_WIDTH_3DS_3D)); } - for(int i = 0; i < last_line_index; i++) { + for(size_t i = 0; i < last_line_index; i++) { convertVideoToOutputChunk_3D(&p_in->ftd3_received_3d.video_in, p_out, IN_VIDEO_WIDTH_3DS_3D, (((i * 3) + 0) * IN_VIDEO_WIDTH_3DS_3D) + IN_VIDEO_NO_BOTTOM_SIZE_3DS_3D, BOT_SIZE_3DS + TOP_SIZE_3DS + (IN_VIDEO_NO_BOTTOM_SIZE_3DS_3D / 2) + (i * IN_VIDEO_WIDTH_3DS_3D)); convertVideoToOutputChunk_3D(&p_in->ftd3_received_3d.video_in, p_out, IN_VIDEO_WIDTH_3DS_3D, (((i * 3) + 1) * IN_VIDEO_WIDTH_3DS_3D) + IN_VIDEO_NO_BOTTOM_SIZE_3DS_3D, BOT_SIZE_3DS + (IN_VIDEO_NO_BOTTOM_SIZE_3DS_3D / 2) + (i * IN_VIDEO_WIDTH_3DS_3D)); convertVideoToOutputChunk_3D(&p_in->ftd3_received_3d.video_in, p_out, IN_VIDEO_WIDTH_3DS_3D, (((i * 3) + 2) * IN_VIDEO_WIDTH_3DS_3D) + IN_VIDEO_NO_BOTTOM_SIZE_3DS_3D, i * IN_VIDEO_WIDTH_3DS_3D); @@ -393,7 +393,7 @@ static void ftd3_convertVideoToOutput(CaptureReceived *p_in, VideoOutputData *p_ // Optimize for speed convertVideoToOutputChunk_3D(&p_in->ftd3_received_3d.video_in, p_out, IN_VIDEO_NO_BOTTOM_SIZE_3DS_3D, 0, BOT_SIZE_3DS); - for(int i = 0; i < last_line_index; i++) { + for(size_t i = 0; i < last_line_index; i++) { convertVideoToOutputChunk_3D(&p_in->ftd3_received_3d.video_in, p_out, IN_VIDEO_WIDTH_3DS_3D * 2, (((i * 3) + 0) * IN_VIDEO_WIDTH_3DS_3D) + IN_VIDEO_NO_BOTTOM_SIZE_3DS_3D, BOT_SIZE_3DS + IN_VIDEO_NO_BOTTOM_SIZE_3DS_3D + (i * IN_VIDEO_WIDTH_3DS_3D * 2)); convertVideoToOutputChunk_3D(&p_in->ftd3_received_3d.video_in, p_out, IN_VIDEO_WIDTH_3DS_3D, (((i * 3) + 2) * IN_VIDEO_WIDTH_3DS_3D) + IN_VIDEO_NO_BOTTOM_SIZE_3DS_3D, i * IN_VIDEO_WIDTH_3DS_3D); } @@ -411,7 +411,6 @@ static void ftd3_convertVideoToOutput(CaptureReceived *p_in, VideoOutputData *p_ static inline void usb_oldDSconvertVideoToOutputHalfLineDirectOptLE(USBOldDSCaptureReceived *p_in, VideoOutputData *p_out, int input_halfline, int output_halfline) { //de-interleave pixels const int pixels_size = 2; - const int num_screens = 2; const int num_halflines = 2; const size_t ptr_out_size = sizeof(deinterleaved_rgb565_pixels); deinterleaved_rgb565_pixels* out_ptr_top = (deinterleaved_rgb565_pixels*)p_out->screen_data; @@ -424,7 +423,6 @@ static inline void usb_oldDSconvertVideoToOutputHalfLineDirectOptLE(USBOldDSCapt static inline void usb_oldDSconvertVideoToOutputHalfLineDirectOptBE(USBOldDSCaptureReceived *p_in, VideoOutputData *p_out, int input_halfline, int output_halfline) { //de-interleave pixels const int pixels_size = 2; - const int num_screens = 2; const int num_halflines = 2; const size_t ptr_out_size = sizeof(deinterleaved_rgb565_pixels); deinterleaved_rgb565_pixels* out_ptr_top = (deinterleaved_rgb565_pixels*)p_out->screen_data; @@ -434,10 +432,9 @@ static inline void usb_oldDSconvertVideoToOutputHalfLineDirectOptBE(USBOldDSCapt usb_rgb565convertInterleaveVideoToOutputDirectOptBE(out_ptr_top, out_ptr_bottom, in_ptr, halfline_iters, input_halfline, output_halfline); } -static inline void usb_3DS565OptimizeconvertVideoToOutputLineDirectOptLE(USB5653DSOptimizeCaptureReceived *p_in, VideoOutputData *p_out, int column) { +static inline void usb_3DS565OptimizeconvertVideoToOutputLineDirectOptLE(USB5653DSOptimizeCaptureReceived *p_in, VideoOutputData *p_out, uint16_t column) { //de-interleave pixels const int pixels_size = 2; - const int num_screens = 2; const size_t column_start_bot_pos = (SCREEN_WIDTH_FIRST_PIXEL_BOTTOM_3DS * 2) + 2; const size_t column_pre_last_bot_pos = (SCREEN_WIDTH_FIRST_PIXEL_BOTTOM_3DS * 2); const size_t column_last_bot_pos = TOP_WIDTH_3DS; @@ -462,10 +459,9 @@ static inline void usb_3DS565OptimizeconvertVideoToOutputLineDirectOptLE(USB5653 } } -static inline void usb_3DS565OptimizeconvertVideoToOutputLineDirectOptBE(USB5653DSOptimizeCaptureReceived *p_in, VideoOutputData *p_out, int column) { +static inline void usb_3DS565OptimizeconvertVideoToOutputLineDirectOptBE(USB5653DSOptimizeCaptureReceived *p_in, VideoOutputData *p_out, uint16_t column) { //de-interleave pixels const int pixels_size = 2; - const int num_screens = 2; const size_t column_start_bot_pos = (SCREEN_WIDTH_FIRST_PIXEL_BOTTOM_3DS * 2) + 2; const size_t column_pre_last_bot_pos = (SCREEN_WIDTH_FIRST_PIXEL_BOTTOM_3DS * 2); const size_t column_last_bot_pos = TOP_WIDTH_3DS; @@ -490,10 +486,9 @@ static inline void usb_3DS565OptimizeconvertVideoToOutputLineDirectOptBE(USB5653 } } -static inline void usb_3DS565Optimizeconvert3DVideoToOutputLineDirectOptLE(USB5653DSOptimizeCaptureReceived_3D *p_in, VideoOutputData *p_out, int column, bool interleaved_3d) { +static inline void usb_3DS565Optimizeconvert3DVideoToOutputLineDirectOptLE(USB5653DSOptimizeCaptureReceived_3D *p_in, VideoOutputData *p_out, uint16_t column, bool interleaved_3d) { //de-interleave pixels const int pixels_size = 2; - const int num_screens = 3; const size_t column_start_bot_pos = (SCREEN_WIDTH_FIRST_PIXEL_BOTTOM_3DS * 2) + 2; const size_t column_pre_last_bot_pos = (SCREEN_WIDTH_FIRST_PIXEL_BOTTOM_3DS * 2); const size_t column_last_bot_pos = TOP_WIDTH_3DS; @@ -525,10 +520,9 @@ static inline void usb_3DS565Optimizeconvert3DVideoToOutputLineDirectOptLE(USB56 } } -static inline void usb_3DS565Optimizeconvert3DVideoToOutputLineDirectOptBE(USB5653DSOptimizeCaptureReceived_3D *p_in, VideoOutputData *p_out, int column, bool interleaved_3d) { +static inline void usb_3DS565Optimizeconvert3DVideoToOutputLineDirectOptBE(USB5653DSOptimizeCaptureReceived_3D *p_in, VideoOutputData *p_out, uint16_t column, bool interleaved_3d) { //de-interleave pixels const int pixels_size = 2; - const int num_screens = 3; const size_t column_start_bot_pos = (SCREEN_WIDTH_FIRST_PIXEL_BOTTOM_3DS * 2) + 2; const size_t column_pre_last_bot_pos = (SCREEN_WIDTH_FIRST_PIXEL_BOTTOM_3DS * 2); const size_t column_last_bot_pos = TOP_WIDTH_3DS; @@ -560,7 +554,7 @@ static inline void usb_3DS565Optimizeconvert3DVideoToOutputLineDirectOptBE(USB56 } } -static inline void usb_3DS888OptimizeconvertVideoToOutputLineDirectOpt(USB8883DSOptimizeCaptureReceived *p_in, VideoOutputData *p_out, int column) { +static inline void usb_3DS888OptimizeconvertVideoToOutputLineDirectOpt(USB8883DSOptimizeCaptureReceived *p_in, VideoOutputData *p_out, uint16_t column) { //de-interleave pixels const int pixels_size = 3; const size_t column_start_bot_pos = (SCREEN_WIDTH_FIRST_PIXEL_BOTTOM_3DS * 2) + 2; @@ -587,7 +581,7 @@ static inline void usb_3DS888OptimizeconvertVideoToOutputLineDirectOpt(USB8883DS } } -static inline void usb_3DS888Optimizeconvert3DVideoToOutputLineDirectOpt(USB8883DSOptimizeCaptureReceived_3D *p_in, VideoOutputData *p_out, int column, bool interleaved_3d) { +static inline void usb_3DS888Optimizeconvert3DVideoToOutputLineDirectOpt(USB8883DSOptimizeCaptureReceived_3D *p_in, VideoOutputData *p_out, uint16_t column, bool interleaved_3d) { //de-interleave pixels const int pixels_size = 3; const size_t column_start_bot_pos = (SCREEN_WIDTH_FIRST_PIXEL_BOTTOM_3DS * 2) + 2; @@ -709,7 +703,7 @@ static void usb_cypress_nisetro_ds_convertVideoToOutput(CaptureReceived *p_in, V int pos_bottom = WIDTH_DS * HEIGHT_DS * 3; uint8_t* data_in = (uint8_t*)p_in->cypress_nisetro_capture_received.video_in.screen_data; uint8_t* data_out = (uint8_t*)p_out->screen_data; - for(int i = 0; i < sizeof(CypressNisetroDSCaptureReceived); i++) { + for(size_t i = 0; i < sizeof(CypressNisetroDSCaptureReceived); i++) { uint8_t conv = to_8_bit_6(data_in[i]); if(data_in[i] & 0x40) data_out[pos_bottom++] = conv; @@ -757,22 +751,21 @@ static void usb_is_device_convertVideoToOutput(CaptureReceived *p_in, VideoOutpu is_nitro = is_device_is_nitro(&status->device); #endif if(is_nitro) { - int num_pixels = usb_is_device_get_video_in_size(status) / 3; - int out_start_pos = 0; - int out_clear_pos = num_pixels; + uint64_t num_pixels = usb_is_device_get_video_in_size(status) / 3; + uint64_t out_start_pos = 0; + uint64_t out_clear_pos = num_pixels; if(capture_type == CAPTURE_SCREENS_BOTTOM) { out_start_pos = num_pixels; out_clear_pos = 0; } if((capture_type == CAPTURE_SCREENS_BOTTOM) || (capture_type == CAPTURE_SCREENS_TOP)) - memset(p_out->screen_data[out_clear_pos], 0, num_pixels * 3); - memcpy(p_out->screen_data[out_start_pos], p_in->is_nitro_capture_received.video_in.screen_data, num_pixels * 3); + memset(p_out->screen_data[out_clear_pos], 0, (size_t)(num_pixels * 3)); + memcpy(p_out->screen_data[out_start_pos], p_in->is_nitro_capture_received.video_in.screen_data, (size_t)(num_pixels * 3)); return; } ISTWLCaptureVideoInputData* data = &p_in->is_twl_capture_received.video_capture_in.video_in; twl_16bit_pixels* data_16_bit = (twl_16bit_pixels*)data->screen_data; twl_2bit_pixels* data_2_bit = (twl_2bit_pixels*)data->bit_6_rb_screen_data; - int num_pixels = IN_VIDEO_SIZE_DS; const int num_pixels_struct = sizeof(twl_16bit_pixels) / sizeof(uint16_t); const int num_screens = 2; for(int i = 0; i < HEIGHT_DS; i++) { @@ -847,7 +840,7 @@ bool convertVideoToOutput(VideoOutputData *p_out, const bool is_big_endian, Capt return converted; } -static USB3DSOptimizeHeaderSoundData* getAudioHeaderPtrOptimize3DS(CaptureReceived* buffer, bool is_rgb888, bool is_data_3d, int column) { +static USB3DSOptimizeHeaderSoundData* getAudioHeaderPtrOptimize3DS(CaptureReceived* buffer, bool is_rgb888, bool is_data_3d, uint16_t column) { if(!is_rgb888) { if(!is_data_3d) return &buffer->cypress_optimize_received_565.columns_data[column].header_sound; @@ -887,7 +880,6 @@ static inline void copyAudioFromSoundDataOptimize3DSBE(std::int16_t *p_out, USB3 } static void copyAudioOptimize3DSLE(std::int16_t *p_out, uint64_t &n_samples, uint16_t &last_buffer_index, CaptureReceived* buffer, bool is_rgb888, bool is_data_3d) { - USB3DSOptimizeHeaderSoundData* first_column_data = getAudioHeaderPtrOptimize3DS(buffer, is_rgb888, is_data_3d, 0); uint64_t num_inserted = 0; int last_inserted_index = last_buffer_index; for(int i = 0; i < TOP_WIDTH_3DS; i++) { @@ -900,7 +892,6 @@ static void copyAudioOptimize3DSLE(std::int16_t *p_out, uint64_t &n_samples, uin } static void copyAudioOptimize3DSBE(std::int16_t *p_out, uint64_t &n_samples, uint16_t &last_buffer_index, CaptureReceived* buffer, bool is_rgb888, bool is_data_3d) { - USB3DSOptimizeHeaderSoundData* first_column_data = getAudioHeaderPtrOptimize3DS(buffer, is_rgb888, is_data_3d, 0); uint64_t num_inserted = 0; int last_inserted_index = last_buffer_index; for(int i = 0; i < TOP_WIDTH_3DS; i++) { @@ -943,13 +934,13 @@ bool convertAudioToOutput(std::int16_t *p_out, uint64_t &n_samples, uint16_t &la if(status->device.cc_type == CAPTURE_CONN_IS_NITRO) { base_ptr = (uint8_t*)p_in->is_twl_capture_received.audio_capture_in; uint16_t* base_ptr16 = (uint16_t*)base_ptr; - size_t size_real = n_samples * 2; + size_t size_real = (size_t)(n_samples * 2); size_t size_packet_converted = sizeof(ISTWLCaptureSoundData); size_t num_packets = size_real / size_packet_converted; - for(int i = 0; i < num_packets; i++) + for(size_t i = 0; i < num_packets; i++) memcpy(base_ptr + (i * size_packet_converted), ((uint8_t*)&p_in->is_twl_capture_received.audio_capture_in[i].sound_data.data), size_packet_converted); // Inverted L and R... - for(int i = 0; i < n_samples; i++) { + for(uint64_t i = 0; i < n_samples; i++) { uint16_t r_sample = base_ptr16[(i * 2)]; base_ptr16[(i * 2)] = base_ptr16[(i * 2) + 1]; base_ptr16[(i * 2) + 1] = r_sample; @@ -970,9 +961,9 @@ bool convertAudioToOutput(std::int16_t *p_out, uint64_t &n_samples, uint16_t &la if(base_ptr == NULL) return false; if(!is_big_endian) - memcpy(p_out, base_ptr, n_samples * 2); + memcpy(p_out, base_ptr, (size_t)(n_samples * 2)); else - for(int i = 0; i < n_samples; i++) + for(uint64_t i = 0; i < n_samples; i++) p_out[i] = (base_ptr[(i * 2) + 1] << 8) | base_ptr[i * 2]; return true; } diff --git a/source/devicecapture.cpp b/source/devicecapture.cpp index 75f8d5f..0143fe0 100755 --- a/source/devicecapture.cpp +++ b/source/devicecapture.cpp @@ -109,7 +109,7 @@ bool connect(bool print_failed, CaptureData* capture_data, FrontendData* fronten capture_error_print(print_failed, capture_data, "No device was found"); else { std::string full_error_part = ""; - for(int i = 0; i < no_access_list.size(); i++) { + for(size_t i = 0; i < no_access_list.size(); i++) { full_error_part += " - "; if(no_access_list[i].vid == -1) full_error_part += no_access_list[i].name; @@ -298,10 +298,12 @@ int get_usb_speed_of_device(CaptureStatus* capture_status) { bool is_usb_speed_of_device_enough_3d(CaptureStatus* capture_status) { switch(capture_status->device.cc_type) { - default: + case CAPTURE_CONN_FTD3: if(get_usb_speed_of_device(capture_status) < 3) return false; break; + default: + break; } return true; } diff --git a/source/frontend.cpp b/source/frontend.cpp index eb98dd0..1c6a3cf 100755 --- a/source/frontend.cpp +++ b/source/frontend.cpp @@ -331,22 +331,10 @@ const PARData fit_wide_vertical_par = { .is_width_main = false, .is_fit = true, .name = "Fit to 16:9 V."}; -const PARData special_3ds_horizontal_par = { -.width_multiplier = 1.0, .width_divisor = 2.0, -.is_width_main = true, .is_fit = false, -.name = "3DS 800x240 Horizontal"}; - -const PARData special_3ds_vertical_par = { -.width_multiplier = 1.0, .width_divisor = 2.0, -.is_width_main = false, .is_fit = false, -.name = "3DS 800x240 Vertical"}; - static const PARData* basic_possible_pars[] = { &base_par, &snes_horizontal_par, &snes_vertical_par, -//&special_3ds_horizontal_par, -//&special_3ds_vertical_par, &lb_horizontal_par, &lb_vertical_par, &top_3ds_horizontal_par, @@ -379,7 +367,7 @@ const ShaderColorEmulationData color_profile_identity = { }; const ShaderColorEmulationData color_profile_libretro_gba = { -.targetGamma = 2.2f + (0.28125 * 1.6), .lum = 0.91f, +.targetGamma = 2.2f + (0.28125f * 1.6f), .lum = 0.91f, .rgb_mod = { {0.905f, 0.195f, -0.1f}, {0.1f, 0.65f, 0.25f}, @@ -463,7 +451,7 @@ const ShaderColorEmulationData color_profile_libretro_emulators_gba = { }; const ShaderColorEmulationData color_profile_libretro_gbc = { -.targetGamma = 2.2f + (0.5 * (-1.0)), .lum = 0.91f, +.targetGamma = 2.2f + (0.5f * (-1.0f)), .lum = 0.91f, .rgb_mod = { {0.905f, 0.195f, -0.1f}, {0.1f, 0.65f, 0.25f}, @@ -516,20 +504,20 @@ static bool is_allowed_crop(const CropData* crop_data, ScreenType s_type, bool i } void insert_basic_crops(std::vector &crop_vector, ScreenType s_type, bool is_ds, bool allow_game_specific) { - for(int i = 0; i < (sizeof(basic_possible_crops) / sizeof(basic_possible_crops[0])); i++) { + for(size_t i = 0; i < (sizeof(basic_possible_crops) / sizeof(basic_possible_crops[0])); i++) { if(is_allowed_crop(basic_possible_crops[i], s_type, is_ds, allow_game_specific)) crop_vector.push_back(basic_possible_crops[i]); } } void insert_basic_pars(std::vector &par_vector) { - for(int i = 0; i < (sizeof(basic_possible_pars) / sizeof(basic_possible_pars[0])); i++) { + for(size_t i = 0; i < (sizeof(basic_possible_pars) / sizeof(basic_possible_pars[0])); i++) { par_vector.push_back(basic_possible_pars[i]); } } void insert_basic_color_profiles(std::vector &color_profiles_vector) { - for(int i = 0; i < (sizeof(basic_possible_color_profiles) / sizeof(basic_possible_color_profiles[0])); i++) { + for(size_t i = 0; i < (sizeof(basic_possible_color_profiles) / sizeof(basic_possible_color_profiles[0])); i++) { color_profiles_vector.push_back(basic_possible_color_profiles[i]); } } @@ -685,19 +673,19 @@ bool load_screen_info(std::string key, std::string value, std::string base, Scre return true; } if(key == (base + "sub_off")) { - info.subscreen_offset = offset_sanitization(std::stod(value)); + info.subscreen_offset = offset_sanitization(std::stof(value)); return true; } if(key == (base + "sub_att_off")) { - info.subscreen_attached_offset = offset_sanitization(std::stod(value)); + info.subscreen_attached_offset = offset_sanitization(std::stof(value)); return true; } if(key == (base + "off_x")) { - info.total_offset_x = offset_sanitization(std::stod(value)); + info.total_offset_x = offset_sanitization(std::stof(value)); return true; } if(key == (base + "off_y")) { - info.total_offset_y = offset_sanitization(std::stod(value)); + info.total_offset_y = offset_sanitization(std::stof(value)); return true; } if(key == (base + "top_rot")) { @@ -722,12 +710,12 @@ bool load_screen_info(std::string key, std::string value, std::string base, Scre } if(key == (base + "top_scaling")) { info.top_scaling = std::stoi(value); - info.non_integer_top_scaling = info.top_scaling; + info.non_integer_top_scaling = (float)info.top_scaling; return true; } if(key == (base + "bot_scaling")) { info.bot_scaling = std::stoi(value); - info.non_integer_bot_scaling = info.bot_scaling; + info.non_integer_bot_scaling = (float)info.bot_scaling; return true; } if(key == (base + "bfi")) { @@ -782,7 +770,7 @@ bool load_screen_info(std::string key, std::string value, std::string base, Scre info.separator_windowed_multiplier = SEP_WINDOW_SCALING_MIN_MULTIPLIER; if(info.separator_windowed_multiplier > MAX_WINDOW_SCALING_VALUE) info.separator_windowed_multiplier = MAX_WINDOW_SCALING_VALUE; - info.separator_windowed_multiplier = std::round(info.separator_windowed_multiplier / WINDOW_SCALING_CHANGE) * WINDOW_SCALING_CHANGE; + info.separator_windowed_multiplier = (float)(std::round(info.separator_windowed_multiplier / WINDOW_SCALING_CHANGE) * WINDOW_SCALING_CHANGE); return true; } if(key == (base + "separator_fullscreen_multiplier")) { @@ -791,7 +779,7 @@ bool load_screen_info(std::string key, std::string value, std::string base, Scre info.separator_fullscreen_multiplier = SEP_FULLSCREEN_SCALING_MIN_MULTIPLIER; if(info.separator_fullscreen_multiplier > MAX_WINDOW_SCALING_VALUE) info.separator_fullscreen_multiplier = MAX_WINDOW_SCALING_VALUE; - info.separator_fullscreen_multiplier = std::round(info.separator_fullscreen_multiplier / WINDOW_SCALING_CHANGE) * WINDOW_SCALING_CHANGE; + info.separator_fullscreen_multiplier = (float)(std::round(info.separator_fullscreen_multiplier / WINDOW_SCALING_CHANGE) * WINDOW_SCALING_CHANGE); return true; } if(key == (base + "top_par")) { @@ -932,11 +920,11 @@ std::string save_screen_info(std::string base, const ScreenInfo &info) { } void joystick_axis_poll(std::queue &events_queue) { - for(int i = 0; i < sf::Joystick::Count; i++) { + for(unsigned int i = 0; i < sf::Joystick::Count; i++) { if(!sf::Joystick::isConnected(i)) continue; - for(int j = 0; j < sf::Joystick::AxisCount; j++) { - sf::Joystick::Axis axis = sf::Joystick::Axis((int)sf::Joystick::Axis::X + j); + for(unsigned int j = 0; j < sf::Joystick::AxisCount; j++) { + sf::Joystick::Axis axis = sf::Joystick::Axis((unsigned int)sf::Joystick::Axis::X + j); if(sf::Joystick::hasAxis(i, axis)) events_queue.emplace(i, axis, sf::Joystick::getAxisPosition(i, axis)); } @@ -948,8 +936,8 @@ const PARData* get_base_par() { } void get_par_size(int &width, int &height, float multiplier_factor, const PARData *correction_factor, bool divide_3d_par) { - width *= multiplier_factor; - height *= multiplier_factor; + width = (int)(width * multiplier_factor); + height = (int)(height * multiplier_factor); float correction_factor_3d = 1.0; if(divide_3d_par) correction_factor_3d = 2.0; @@ -959,18 +947,18 @@ void get_par_size(int &width, int &height, float multiplier_factor, const PARDat float correction_factor_approx_contribute = correction_factor_divisor / 2; if(correction_factor->is_fit) { if(correction_factor->is_width_main) - width = ((height * correction_factor->width_multiplier) + correction_factor_approx_contribute) / correction_factor_divisor; + width = (int)(((height * correction_factor->width_multiplier) + correction_factor_approx_contribute) / correction_factor_divisor); else { - width /= correction_factor_3d; - height = ((width * correction_factor->width_divisor) + correction_factor_approx_contribute) / correction_factor_divisor; + width = (int)(width / correction_factor_3d); + height = (int)(((width * correction_factor->width_divisor) + correction_factor_approx_contribute) / correction_factor_divisor); } } else { if(correction_factor->is_width_main) - width = ((width * correction_factor->width_multiplier) + correction_factor_approx_contribute) / correction_factor_divisor; + width = (int)(((width * correction_factor->width_multiplier) + correction_factor_approx_contribute) / correction_factor_divisor); else - height = ((height * correction_factor->width_divisor) + correction_factor_approx_contribute) / correction_factor_divisor; - width /= correction_factor_3d; + height = (int)(((height * correction_factor->width_divisor) + correction_factor_approx_contribute) / correction_factor_divisor); + width = (int)(width / correction_factor_3d); } } @@ -1113,7 +1101,7 @@ void update_connected_specific_settings(FrontendData* frontend_data, const Captu void default_sleep(float wanted_ms) { if(wanted_ms < 0) - wanted_ms = 1000.0/USB_CHECKS_PER_SECOND; + wanted_ms = 1000.0f/USB_CHECKS_PER_SECOND; sf::sleep(sf::microseconds((int)(wanted_ms * 1000))); } diff --git a/source/utils.cpp b/source/utils.cpp index c39ff80..f81ac5c 100755 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -184,7 +184,7 @@ void write_be64(uint8_t* data, uint64_t value, size_t count, size_t multiplier) } void write_string(uint8_t* data, std::string text) { - for(int i = 0; i < text.size(); i++) + for(size_t i = 0; i < text.size(); i++) data[i] = (uint8_t)text[i]; } @@ -255,7 +255,7 @@ std::string get_version_string(bool get_letter) { } std::string get_float_str_decimals(float value, int decimals) { - float approx_factor = pow(0.1, decimals) * (0.5); + float approx_factor = (float)(pow(0.1f, decimals) * (0.5f)); int int_part = (int)(value + approx_factor); int dec_part = (int)((value + approx_factor - int_part) * pow(10, decimals)); std::string return_text = std::to_string(int_part);