OSDN Git Service

[Draw][OpenGL][OSD] Prepare to direct update vram.
[csp-qt/common_source_project-fm7.git] / source / src / qt / osd_base.h
index 72a67b9..94bcc7b 100644 (file)
 #define _QT_OSD_BASE_H_
 
 
-#include <QWidget>
+#include <QList>
 #include <QThread>
-#include <QMutex>
-#include <QSemaphore>
-#include <QPainter>
-#include <QElapsedTimer>
 #include <QString>
-#include <QQueue>
 #include <QImage>
-#include <QList>
-
 #include <SDL.h>
-#include "simd_types.h"
+//#include "simd_types.h"
 
-#include <ctime>
+//#include <ctime>
+//#include <limits>
+//#include <osd_base.h>
 
 //#include "../vm/vm.h"
 //#include "../emu.h"
 #include "../config.h"
-#include "../fileio.h"
-#include "../fifo.h"
-#if !defined(Q_OS_WIN32)
-#include "qt_input.h"
-#endif
+//#include "../fileio.h"
+//#include "../fifo.h"
+//#if !defined(Q_OS_WIN32)
+//#include "qt_input.h"
+//#endif
 #define SOCKET_MAX 4
 #define SOCKET_BUFFER_MAX 0x100000
 #include "osd_types.h"
@@ -51,9 +46,7 @@
 #define MAX_CAPTURE_DEVS 8
 //#endif
 
-#include "qt_main.h"
-//#include "mainwidget.h"
-#include "config.h"
+//#include "qt_main.h"
 
 class GLDrawClass;
 class EmuThreadClass;
@@ -62,8 +55,11 @@ class Ui_MainWindow;
 class EMU;
 class VM;
 class FIFO;
+class FILEIO;
 class CSP_KeyTables;
 class USING_FLAGS;
+class CSP_logger;
+class QMutex;
 
 QT_BEGIN_NAMESPACE
 
@@ -72,17 +68,29 @@ typedef struct {
        const _TCHAR *name;
 } device_node_t;
 
+typedef struct {
+       QString string;
+       union {
+               int64_t ivalue;
+               double  fvalue;
+       } v;
+} supportedlist_t;
+
 class DLL_PREFIX OSD_BASE : public QThread
 {
        Q_OBJECT
 protected:
        EmuThreadClass *parent_thread;
-       QSemaphore *VMSemaphore;
-       QSemaphore *DebugSemaphore;
        sdl_snddata_t snddata;
        USING_FLAGS *using_flags;
        config_t *p_config;
+       CSP_Logger *p_logger;
+
+       QList<supportedlist_t> SupportedFeatures;
        
+       bool __USE_AUTO_KEY;
+       bool __USE_SHIFT_NUMPAD_KEY;
+   
        _TCHAR app_path[_MAX_PATH];
        QElapsedTimer osd_timer;
        bool locked_vm;
@@ -114,13 +122,15 @@ protected:
        int joy_num;
        uint32_t joy_mask[4];
        
-       int mouse_status[3];    // x, y, button (b0 = left, b1 = right)
+       int32_t mouse_status[3];        // x, y, button (b0 = left, b1 = right)
        bool mouse_enabled;
        int mouse_ptrx;
        int mouse_ptry;
        int mouse_button;
        int mouse_oldx;
        int mouse_oldy;
+       int delta_x;
+       int delta_y;
        //Qt::CursorShape mouse_shape;
        
        QImage background_image;
@@ -183,7 +193,7 @@ protected:
        int sound_write_pos;
        bool sound_exit;
        bool sound_debug;
-       SDL_sem *snd_apply_sem;
+       bool sound_initialized;
        Sint16 *sound_buf_ptr;
        Uint8 snd_total_volume;
 #if defined(USE_SDL2)   
@@ -197,6 +207,10 @@ protected:
        virtual void initialize_video();
        virtual void release_video();
   
+       scrntype_t *mapped_screen_pointer;
+       int mapped_screen_width;
+       int mapped_screen_height;
+       bool mapped_screen_status;
        bitmap_t dshow_screen_buffer;
        int direct_show_width, direct_show_height;
        bool direct_show_mute[2];
@@ -248,8 +262,11 @@ protected:
        virtual int get_screen_width(void);
        virtual int get_screen_height(void);
        virtual int get_vm_buttons_code(int num);
+
+       virtual void init_sound_files();
+       virtual void release_sound_files();
 public:
-       OSD_BASE(USING_FLAGS *p);
+       OSD_BASE(USING_FLAGS *p, CSP_Logger *logger);
        ~OSD_BASE();
        
        // common
@@ -258,6 +275,7 @@ public:
        class Ui_MainWindow *main_window_handle;
        GLDrawClass *glv;
        QMutex *screen_mutex;
+       QMutex *vm_mutex;
        
        int host_cpus;
        bool now_auto_key;
@@ -280,13 +298,13 @@ public:
        bool is_console_active();
        void set_console_text_attribute(unsigned short attr);
        void write_console(_TCHAR* buffer, unsigned int length);
-       int read_console_input(_TCHAR* buffer);
+       int read_console_input(_TCHAR* buffer, int length);
        bool is_console_key_pressed(uint32_t ch);
        
        // common input
        void update_input();
-       void key_down(int code, bool repeat);
-       void key_up(int code);
+       void key_down(int code, bool extended, bool repeat);
+       void key_up(int code, bool extended);
        void key_down_native(int code, bool repeat);
        void key_up_native(int code);
        void key_lost_focus();
@@ -307,7 +325,7 @@ public:
        void modify_key_buffer(int code, uint8_t val);
        uint8_t* get_key_buffer();
        uint32_t* get_joy_buffer();
-       int* get_mouse_buffer();
+       int32_t* get_mouse_buffer();
        // common printer
        void reset_printer();
        void update_printer();
@@ -324,13 +342,14 @@ public:
        int get_window_mode_height(int mode);
        void set_host_window_size(int window_width, int window_height, bool window_mode);
        void set_vm_screen_size(int width, int height, int width_aspect, int height_aspect, int window_width, int window_height);
+       void set_vm_screen_lines(int lines); // 20170118
        int get_vm_window_width();
        int get_vm_window_height();
        int get_vm_window_width_aspect();
        int get_vm_window_height_aspect();
        scrntype_t* get_vm_screen_buffer(int y);
-       int draw_screen();
-       int no_draw_screen();
+       //int draw_screen();
+       //int no_draw_screen();
        void reload_bitmap();
        void capture_screen();
        bool start_record_video(int fps);
@@ -348,6 +367,9 @@ public:
        void restart_record_sound();
        bool now_record_sound;
        int get_sound_rate();
+       // Wrapper : Sound
+       virtual void load_sound_file(int id, const _TCHAR *name, int16_t **data, int *dst_size);
+       virtual void free_sound_file(int id, int16_t **data);
        
        // common video device
        virtual void get_video_buffer();
@@ -421,12 +443,38 @@ public:
        virtual void set_draw_thread(DrawThreadClass *handler);
        virtual QString get_vm_config_name(void);
        virtual double vm_frame_rate(void);
-       
        virtual void reset_vm_node(void);
+       virtual void set_device_name(int id, char *name);
+       
        virtual void set_vm_node(int id, const _TCHAR *name);
        virtual const _TCHAR *get_vm_node_name(int id);
        virtual int get_vm_node_size(void);
        
+       // Get #define S to value.You may use inside of VM/ .
+       virtual void set_features(void) {}
+       void add_feature(const _TCHAR *key, double value);
+       void add_feature(const _TCHAR *key, float value);
+       void add_feature(const _TCHAR *key, int value = 1);
+       void add_feature(const _TCHAR *key, int64_t value);
+       void add_feature(const _TCHAR *key, uint32_t value);
+       void add_feature(const _TCHAR *key, uint16_t value);
+       void add_feature(const _TCHAR *key, uint8_t value);
+       bool check_feature(const _TCHAR *key);
+       double get_feature_double_value(const _TCHAR *key);
+       int64_t get_feature_int_value(const _TCHAR *key);
+       uint32_t get_feature_uint32_value(const _TCHAR *key);
+       uint16_t get_feature_uint16_value(const _TCHAR *key);
+       uint8_t get_feature_uint8_value(const _TCHAR *key);
+
+       void debug_log(int level, const char *fmt, ...);
+       void debug_log(int level, int domain_num, const char *fmt, ...);
+       virtual void debug_log(int level, int domain_num, char *strbuf);
+
+       USING_FLAGS *get_config_flags(void) { return using_flags; }
+
+       // Special
+       CSP_Logger *get_logger(void) { return p_logger; }
+       
 public slots:
        void do_write_inputdata(QString s);
        void do_set_input_string(QString s);
@@ -440,11 +488,18 @@ public slots:
        void do_video_movie_end(bool flag);
        void do_video_decoding_error(int num);
        virtual void do_run_movie_audio_callback(uint8_t *data, long len);
+       int draw_screen();
+       int no_draw_screen();
+       void do_draw(bool flag);
+       void do_set_screen_map_texture_address(scrntype_t *p, int width, int height);
+
 signals:
        int sig_update_screen(bitmap_t *);
        int sig_save_screen(const char *);
+       int sig_draw_frames(int);
        int sig_close_window(void);
        int sig_resize_vm_screen(QImage *, int, int);
+       int sig_resize_vm_lines(int);
        int sig_put_string_debugger(QString);
        int sig_console_input_string(QString);
        int sig_enqueue_video(int, int, int, QImage *); 
@@ -462,6 +517,12 @@ signals:
        int sig_movie_seek_frame(bool, int);
 
        int sig_update_device_node_name(int id, const _TCHAR *name);
+       int sig_enable_mouse(void);
+       int sig_disable_mouse(void);
+       int sig_close_console(void);
+
+       int sig_move_mouse_to_center(void);
+       
 };
 QT_END_NAMESPACE