diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2019-07-31 16:59:49 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2019-07-31 16:59:49 +0200 |
commit | 1687222e1b9e74c89cafbb5910e72d8ec7bfd40f (patch) | |
tree | d78102ce30207c63e7608eeba743efd680c888dc /backend/genesys.h | |
parent | 58912f68c2489bcee787599837447e0d64dfd61a (diff) |
New upstream version 1.0.28upstream/1.0.28
Diffstat (limited to 'backend/genesys.h')
-rw-r--r-- | backend/genesys.h | 125 |
1 files changed, 105 insertions, 20 deletions
diff --git a/backend/genesys.h b/backend/genesys.h index eab92bb..47a684c 100644 --- a/backend/genesys.h +++ b/backend/genesys.h @@ -47,7 +47,12 @@ #ifndef GENESYS_H #define GENESYS_H +#ifndef BACKEND_NAME +# define BACKEND_NAME genesys +#endif + #include "genesys_low.h" +#include <queue> #ifndef PATH_MAX # define PATH_MAX 1024 @@ -69,8 +74,9 @@ /* Maximum time for lamp warm-up */ #define WARMUP_TIME 65 -#define FLATBED "Flatbed" -#define TRANSPARENCY_ADAPTER "Transparency Adapter" +#define STR_FLATBED "Flatbed" +#define STR_TRANSPARENCY_ADAPTER "Transparency Adapter" +#define STR_TRANSPARENCY_ADAPTER_INFRARED "Transparency Adapter Infrared" #ifndef SANE_I18N #define SANE_I18N(text) text @@ -135,31 +141,110 @@ enum Genesys_Option OPT_BUTTON_GROUP, OPT_CALIBRATE, OPT_CLEAR_CALIBRATION, + OPT_FORCE_CALIBRATION, /* must come last: */ NUM_OPTIONS }; +enum GenesysButtonName : unsigned { + BUTTON_SCAN_SW = 0, + BUTTON_FILE_SW, + BUTTON_EMAIL_SW, + BUTTON_COPY_SW, + BUTTON_PAGE_LOADED_SW, + BUTTON_OCR_SW, + BUTTON_POWER_SW, + BUTTON_EXTRA_SW, + NUM_BUTTONS +}; + +GenesysButtonName genesys_option_to_button(int option); + +class GenesysButton { +public: + void write(bool value) + { + if (value == value_) { + return; + } + values_to_read_.push(value); + value_ = value; + } + + bool read() + { + if (values_to_read_.empty()) { + return value_; + } + bool ret = values_to_read_.front(); + values_to_read_.pop(); + return ret; + } + +private: + bool value_ = false; + std::queue<bool> values_to_read_; +}; /** Scanner object. Should have better be called Session than Scanner */ -typedef struct Genesys_Scanner +struct Genesys_Scanner { - struct Genesys_Scanner *next; /**< Next scanner in list */ - Genesys_Device *dev; /**< Low-level device object */ - - /* SANE data */ - SANE_Bool scanning; /**< We are currently scanning */ - SANE_Option_Descriptor opt[NUM_OPTIONS]; /**< Option descriptors */ - Option_Value val[NUM_OPTIONS]; /**< Option values */ - Option_Value last_val[NUM_OPTIONS]; /**< Option values as read by the frontend. used for sensors. */ - SANE_Parameters params; /**< SANE Parameters */ - SANE_Int bpp_list[5]; /**< */ -} Genesys_Scanner; - -#ifdef UNIT_TESTING -SANE_Status genesys_dark_white_shading_calibration (Genesys_Device * dev); -char *calibration_filename(Genesys_Device *currdev); -void add_device(Genesys_Device *dev); -#endif + Genesys_Scanner() = default; + ~Genesys_Scanner() = default; + + // Next scanner in list + struct Genesys_Scanner *next; + + // Low-level device object + Genesys_Device* dev = nullptr; + + // SANE data + // We are currently scanning + SANE_Bool scanning; + // Option descriptors + SANE_Option_Descriptor opt[NUM_OPTIONS]; + + // Option values + SANE_Word bit_depth = 0; + SANE_Word resolution = 0; + bool preview = false; + SANE_Word threshold = 0; + SANE_Word threshold_curve = 0; + bool disable_dynamic_lineart = false; + bool disable_interpolation = false; + bool lamp_off = false; + SANE_Word lamp_off_time = 0; + bool swdeskew = false; + bool swcrop = false; + bool swdespeck = false; + bool swderotate = false; + SANE_Word swskip = 0; + SANE_Word despeck = 0; + SANE_Word contrast = 0; + SANE_Word brightness = 0; + SANE_Word expiration_time = 0; + bool custom_gamma = false; + + SANE_Word pos_top_left_y = 0; + SANE_Word pos_top_left_x = 0; + SANE_Word pos_bottom_right_y = 0; + SANE_Word pos_bottom_right_x = 0; + + std::string mode, source, color_filter; + + std::string calibration_file; + // Button states + GenesysButton buttons[NUM_BUTTONS]; + + // SANE Parameters + SANE_Parameters params = {}; + SANE_Int bpp_list[5] = {}; +}; + +void write_calibration(std::ostream& str, Genesys_Device::Calibration& cache); +bool read_calibration(std::istream& str, Genesys_Device::Calibration& cache, + const std::string& path); + #endif /* not GENESYS_H */ |