OSDN Git Service

[UI][Qt] Add assign joystick dialog.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 23 Feb 2016 19:33:20 +0000 (04:33 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 23 Feb 2016 19:33:20 +0000 (04:33 +0900)
[UI][Qt][Keyboard] Use keyboard object.

20 files changed:
source/src/config.cpp
source/src/config.h
source/src/qt/common/qt_gldraw.cpp
source/src/qt/common/qt_gldraw.h
source/src/qt/gui/CMakeLists.txt
source/src/qt/gui/dropdown_joystick.cpp [new file with mode: 0644]
source/src/qt/gui/dropdown_joystick.h [new file with mode: 0644]
source/src/qt/gui/dropdown_jsbutton.cpp [new file with mode: 0644]
source/src/qt/gui/dropdown_jsbutton.h [new file with mode: 0644]
source/src/qt/gui/dropdown_jspage.cpp [new file with mode: 0644]
source/src/qt/gui/dropdown_jspage.h [new file with mode: 0644]
source/src/qt/gui/dropdown_keyset.cpp
source/src/qt/gui/dropdown_keyset.h
source/src/qt/gui/dropdown_keytables.h
source/src/qt/gui/mainwidget.h
source/src/qt/gui/menu_main.cpp
source/src/qt/gui/qt_input.cpp
source/src/qt/machines/fm7/MainWindow.cpp
source/src/qt/osd.h
source/src/qt/osd_input.cpp

index 136d05e..6194a61 100644 (file)
@@ -121,6 +121,7 @@ void init_config()
        config.use_direct_input = true;
        config.disable_dwm = false;
 #endif
+       config.keyboard_type = 0;
        for(int i = 0; i < 4; i++) {
                for(int j = 0; j < 16; j++) {
                        config.joy_buttons[i][j] = (i << 4) | j;
@@ -351,6 +352,7 @@ void load_config(const _TCHAR *config_path)
        config.use_direct_input = MyGetPrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path);
        config.disable_dwm = MyGetPrivateProfileBool(_T("Input"), _T("DisableDwm"), config.disable_dwm, config_path);
 #endif
+       config.keyboard_type = MyGetPrivateProfileInt(_T("Input"), _T("KeyboardType"), config.keyboard_type, config_path);
        for(int i = 0; i < 4; i++) {
                for(int j = 0; j < 16; j++) {
                        _TCHAR name[64];
@@ -565,6 +567,7 @@ void save_config(const _TCHAR *config_path)
        MyWritePrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path);
        MyWritePrivateProfileBool(_T("Input"), _T("DisableDwm"), config.disable_dwm, config_path);
 #endif
+       MyWritePrivateProfileInt(_T("Input"), _T("KeyboardType"), config.keyboard_type, config_path);
        for(int i = 0; i < 4; i++) {
                for(int j = 0; j < 16; j++) {
                        _TCHAR name[64];
@@ -590,7 +593,7 @@ void save_config(const _TCHAR *config_path)
 #endif
 }
 
-#define STATE_VERSION  4
+#define STATE_VERSION  5
 
 void save_config_state(void *f)
 {
@@ -632,7 +635,7 @@ void save_config_state(void *f)
 #ifdef USE_PRINTER
        state_fio->FputInt32(config.printer_device_type);
 #endif
-       
+       state_fio->FputInt32(config.keyboard_type);
 }
 
 bool load_config_state(void *f)
@@ -675,6 +678,7 @@ bool load_config_state(void *f)
 #ifdef USE_PRINTER
        config.printer_device_type = state_fio->FgetInt32();
 #endif
+       config.keyboard_type = state_fio->FgetInt32();
        return true;
 }
 
index 4bcae96..aef6eb9 100644 (file)
@@ -163,6 +163,7 @@ typedef struct {
        bool use_direct_input;
        bool disable_dwm;
 #endif
+       int keyboard_type;
        int joy_buttons[4][16];
 #ifdef _USE_QT
        _TCHAR assigned_joystick_name[16][256];
index 0e59300..467cec0 100644 (file)
 #endif
 #include <GL/glu.h>
 
-#undef _USE_OPENCL
-#ifdef _USE_OPENCL
-//# include "agar_glcl.h"
-#endif
-
 
 #ifdef USE_OPENMP
 #include <omp.h>
index 2b657ab..3250115 100644 (file)
@@ -9,12 +9,14 @@
 
 #include "emu.h"
 #include "osd.h"
+#include "dropdown_keyset.h"
 
 #include <QGLWidget>
 class EMU;
 class QEvent;
 class GLDraw_2_0;
 class GLDraw_3_0;
+class CSP_KeyTables;
 
 struct NativeScanCode {
        uint32_t vk;
@@ -41,9 +43,6 @@ class GLDrawClass: public QGLWidget
        bool delay_update;
 
  protected:
-       struct NativeScanCode NativeScanCode[257];
-       struct NativeVirtualKeyCode NativeVirtualKeyCode[257];
-
        void keyReleaseEvent(QKeyEvent *event);
        void keyPressEvent(QKeyEvent *event);
        void initializeGL();
@@ -51,7 +50,6 @@ class GLDrawClass: public QGLWidget
        void drawGrids(void);
 
        uint32_t get106Scancode2VK(uint32_t data);
-       uint32_t getNativeKey2VK(uint32_t data);
 #ifdef _USE_OPENCL
        //     extern class GLCLDraw *cldraw;
 #endif
@@ -63,6 +61,8 @@ class GLDrawClass: public QGLWidget
        bool save_pixmap_req;
        void SaveToPixmap(void);
        GLDraw_2_0 *extfunc;
+       CSP_KeyTables *key_table;
+       
 public:
        GLDrawClass(QWidget *parent = 0);
        ~GLDrawClass();
@@ -72,6 +72,11 @@ public:
        QSize getCanvasSize();
        QSize getDrawSize();
        
+       QStringList *getKeyNames(void);
+       QStringList *getVKNames(void);
+       keydef_table_t *getKeyTable(int index);
+       uint32 get_vk_from_index(int index);
+       uint32 get_scan_from_index(int index);
 
        quint32 getModState(void) { return modifier;}
        quint32 modifier;
@@ -107,13 +112,9 @@ public slots:
        void do_save_frame_screen(void);
        void do_save_frame_screen(const char *);
        void do_set_texture_size(QImage *p, int w, int h);
-       //void do_delete_vram_texture() {
-       //      this->deleteTexture(uVramTextureID);
-       //}
-       //void do_attach_vram_texture(QImage *p) {
-       //      uVramTextureID = this->bindTexture(*p);
-       //}
+       
        void do_set_screen_multiply(float mul);
+       void do_update_keyboard_scan_code(uint32 vk, uint32 scan);
 signals:
        void update_screenChanged(int tick);
        void do_notify_move_mouse(int x, int y);
index 408cc91..ee33128 100644 (file)
@@ -11,6 +11,10 @@ set(s_qt_gui_headers
          menu_binary.h
          display_about.h
          display_text_document.h
+         dropdown_keyset.h
+         dropdown_joystick.h
+         dropdown_jspage.h
+         dropdown_jsbutton.h
 )
 if(USE_QT_5)
   QT5_WRAP_CPP(s_qt_gui_headers_MOC ${s_qt_gui_headers})
@@ -40,6 +44,10 @@ add_library(qt_gui
          display_about.cpp
          display_text_document.cpp
          sound_dialog.cpp
+         dropdown_keyset.cpp
+         dropdown_joystick.cpp
+         dropdown_jspage.cpp
+         dropdown_jsbutton.cpp
          ${s_qt_gui_headers_MOC}
 )
 
diff --git a/source/src/qt/gui/dropdown_joystick.cpp b/source/src/qt/gui/dropdown_joystick.cpp
new file mode 100644 (file)
index 0000000..013d8b2
--- /dev/null
@@ -0,0 +1,51 @@
+
+
+#include "osd.h"
+#include "config.h"
+
+#include "dropdown_keyset.h"
+#include "dropdown_jsbutton.h"
+#include "dropdown_jspage.h"
+#include "dropdown_joystick.h"
+
+CSP_DropDownJoysticks::CSP_DropDownJoysticks(QWidget *parent, QStringList *lst) : QWidget(parent)
+{
+       p_wid = parent;
+
+       layout = new QHBoxLayout(this);
+       int i;
+
+       tabBox = new QTabWidget(this);
+       for(i = 0; i < 4; i++) {
+               QString tmps;
+               QString ns;
+               pages[i] = new CSP_DropDownJSPage(this, lst, i);
+               ns.setNum(i + 1);
+               tmps = QString::fromUtf8("Joystick") + ns;
+               tabBox->addTab(pages[i], tmps);
+       }
+       layout->addWidget(tabBox);
+       this->setLayout(layout);
+       this->show();
+}
+
+CSP_DropDownJoysticks::~CSP_DropDownJoysticks()
+{
+}
+
+void CSP_DropDownJoysticks::do_set_js_button(int jsnum, int button_num, int assigned_value)
+{
+       if((button_num < 0) || (button_num >= 16)) return;
+       if((jsnum < 0) || (jsnum >= 4)) return;
+       //printf("Select: %d %d %d\n", jsnum, button_num, assigned_value);
+       config.joy_buttons[jsnum][button_num] = assigned_value;
+}
+
+void CSP_DropDownJoysticks::do_set_js_button_idx(int jsnum, int button_num, int assigned_value)
+{
+       if((button_num < 0) || (button_num >= 16)) return;
+       if((jsnum < 0) || (jsnum >= 4)) return;
+       //printf("Select_Idx: %d %d %d\n", jsnum, button_num, assigned_value);
+       config.joy_buttons[jsnum][button_num] = assigned_value;
+}
+
diff --git a/source/src/qt/gui/dropdown_joystick.h b/source/src/qt/gui/dropdown_joystick.h
new file mode 100644 (file)
index 0000000..9edb674
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Common Source Project/ Qt
+ * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
+ *  Qt: Menu->Emulator->Define Strings
+ *  History: Feb 23, 2016 : Initial
+ */
+
+#ifndef _CSP_DROPDOWN_JOYSTICK_H
+#define _CSP_DROPDOWN_JOYSTICK_H
+
+#include <QWidget>
+#include <QTabWidget>
+#include <QStringList>
+#include <QString>
+#include <QHBoxLayout>
+
+class CSP_DropDownJSPage;
+
+QT_BEGIN_NAMESPACE
+
+class CSP_DropDownJoysticks: public QWidget {
+       Q_OBJECT
+protected:
+       QWidget *p_wid;
+       QWidget *window;
+       QHBoxLayout *layout;
+
+       QTabWidget *tabBox;
+       CSP_DropDownJSPage *pages[4];
+public:
+       CSP_DropDownJoysticks(QWidget *parent, QStringList *lst);
+       ~CSP_DropDownJoysticks();
+
+public slots:
+       void do_set_js_button(int jsnum, int button_num, int assigned_value);
+       void do_set_js_button_idx(int jsnum, int button_num, int assigned_value);
+
+signals:
+       
+};
+
+QT_END_NAMESPACE
+#endif //#ifndef _CSP_DROPDOWN_JOYSTICK_H
diff --git a/source/src/qt/gui/dropdown_jsbutton.cpp b/source/src/qt/gui/dropdown_jsbutton.cpp
new file mode 100644 (file)
index 0000000..6fbac3c
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Common Source Project/ Qt
+ * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
+ *  Qt: Menu->Emulator->Define Strings
+ *  History: Feb 23, 2016 : Initial
+ */
+
+#include "config.h"
+
+#include "dropdown_keyset.h"
+#include "dropdown_jsbutton.h"
+
+
+CSP_DropDownJSButton::CSP_DropDownJSButton(QWidget *parent, QStringList *lst, int jsnum, int button_num) : QWidget(parent)
+{
+       p_wid = parent;
+       bind_jsnum = jsnum;
+       bind_button = button_num;
+       layout = new QHBoxLayout(this);
+       combo = new QComboBox(this);    
+       int i;
+       for(i = 0; i < 16; i++) {
+               combo->addItem(QString::fromUtf8(joystick_define_tbl[i].name));
+       }
+       if(lst != NULL) combo->addItems(*lst);
+       connect(combo, SIGNAL(activated(int)), this, SLOT(do_select(int)));
+       if(p_wid != NULL) {
+               connect(this, SIGNAL(sig_select_js_button(int, int, int)), p_wid, SLOT(do_select_js_button(int, int, int)));
+               connect(this, SIGNAL(sig_select_js_button_idx(int, int, int)), p_wid, SLOT(do_select_js_button_idx(int, int, int)));
+       }
+       if((button_num < 16) && (button_num >= 0)) {
+               if((jsnum < 4) && (jsnum >= 0)){
+                       if((config.joy_buttons[jsnum][button_num] < 0) && (config.joy_buttons[jsnum][button_num] > -256)) {
+                               combo->setCurrentIndex(-config.joy_buttons[jsnum][button_num] + 16);
+                       } else if((config.joy_buttons[jsnum][button_num] >= 0) && (config.joy_buttons[jsnum][button_num] < 16)) {
+                               combo->setCurrentIndex(config.joy_buttons[jsnum][button_num]);
+                       }
+               }
+       }
+       layout->addWidget(combo);
+       this->setLayout(layout);
+}
+
+CSP_DropDownJSButton::~CSP_DropDownJSButton()
+{
+}
+
+void CSP_DropDownJSButton::do_select(int idx)
+{
+       if(idx < 0) return;
+       if(idx < 16) {
+               emit sig_select_js_button(bind_jsnum, bind_button, idx);
+               return;
+       }
+       emit sig_select_js_button_idx(bind_jsnum, bind_button, -(idx - 16));
+}
+
diff --git a/source/src/qt/gui/dropdown_jsbutton.h b/source/src/qt/gui/dropdown_jsbutton.h
new file mode 100644 (file)
index 0000000..fdb05e6
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Common Source Project/ Qt
+ * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
+ *  Qt: Menu->Emulator->Define Strings
+ *  History: Feb 23, 2016 : Initial
+ */
+
+#ifndef _CSP_QT_DROPDOWN_JSBUTTON_H
+#define _CSP_QT_DROPDOWN_JSBUTTON_H
+
+#include <QString>
+#include <QStringList>
+#include <QComboBox>
+#include <QWidget>
+#include <QHBoxLayout>
+
+#include "dropdown_keytables.h"
+
+class CSP_DropDownJSButton: public QWidget {
+       Q_OBJECT;
+protected:
+       QWidget *p_wid;
+       QHBoxLayout *layout;
+       QComboBox *combo;
+       
+       int bind_button;
+       int bind_jsnum;
+public:
+       CSP_DropDownJSButton(QWidget *parent = 0, QStringList *lst = 0, int jsnum = 0, int button_num = 0);
+       ~CSP_DropDownJSButton();
+public slots:
+       void do_select(int index);
+signals:
+       int sig_select_js_button(int jsnum, int button_num, int assigned_value);
+       int sig_select_js_button_idx(int jsnum, int button_num, int assigned_value);
+};
+
+#endif //_CSP_QT_DROPDOWN_JSBUTTON_H
diff --git a/source/src/qt/gui/dropdown_jspage.cpp b/source/src/qt/gui/dropdown_jspage.cpp
new file mode 100644 (file)
index 0000000..932d599
--- /dev/null
@@ -0,0 +1,96 @@
+
+#include "dropdown_keyset.h"
+#include "dropdown_jsbutton.h"
+#include "dropdown_jspage.h"
+#include <QApplication>
+
+CSP_DropDownJSPage::CSP_DropDownJSPage(QWidget *parent, QStringList *lst, int jsnum)
+{
+       int i;
+       p_wid = parent;
+       layout = new QGridLayout(this);
+       bind_jsnum = jsnum;
+       
+       for(i = 0; i < 4; i++) {
+               //label[i] = new QLabel(this);
+               combo_js[i] = new CSP_DropDownJSButton(this, lst, jsnum, i);
+       }
+
+       label_axis = new QLabel(QApplication::translate("MainWindow", "<B>Physical Axis:</B>", 0), this);
+       layout->addWidget(label_axis, 0, 0, Qt::AlignLeft);
+       // Down
+       layout->addWidget(combo_js[1], 1, 1, Qt::AlignRight);
+       // Up
+       layout->addWidget(combo_js[0], 3, 1, Qt::AlignRight);
+       // Left
+       layout->addWidget(combo_js[3], 2, 0, Qt::AlignRight);
+       // Right
+       layout->addWidget(combo_js[2], 2, 2, Qt::AlignRight);
+       label_buttons = new QLabel(QApplication::translate("MainWindow", "<B>Physical Buttons:</B>", 0), this);
+       layout->addWidget(label_buttons, 4, 0, Qt::AlignLeft);
+       for(i = 0; i < 12; i++) {
+               QString nm;
+               char tmps[20];
+               memset(tmps, 0x00, sizeof(char) * 20);
+               
+               label_button[i] = new QLabel(this);
+               js_button[i] = new CSP_DropDownJSButton(this, lst, jsnum, i + 4);
+               snprintf(tmps, 16, "<B>#%02d:</B>", i + 1);
+               nm = QString::fromUtf8(tmps);
+               label_button[i]->setText(nm);
+               layout->addWidget(label_button[i], (i / 4) * 2 + 5 + 0, i % 4, Qt::AlignLeft);
+               layout->addWidget(js_button[i], (i / 4) * 2 + 5 + 1, i % 4, Qt::AlignLeft);
+       }
+       this->setLayout(layout);
+       connect(this, SIGNAL(sig_select_js_button(int, int, int)), parent, SLOT(do_set_js_button(int, int, int)));
+       connect(this, SIGNAL(sig_select_js_button_idx(int, int, int)), parent, SLOT(do_set_js_button_idx(int, int, int)));
+}
+
+CSP_DropDownJSPage::~CSP_DropDownJSPage()
+{
+}
+
+
+void CSP_DropDownJSPage::do_select_up(int index)
+{
+       if(index < 16) {
+               emit sig_select_js_button(bind_jsnum, 0, joystick_define_tbl[index].scan);
+       }
+       emit sig_select_js_button_idx(bind_jsnum, 0, -(index - 16));
+}
+
+void CSP_DropDownJSPage::do_select_down(int index)
+{
+       if(index < 16) {
+               emit sig_select_js_button(bind_jsnum, 1, joystick_define_tbl[index].scan);
+       }
+       emit sig_select_js_button_idx(bind_jsnum, 1, -(index - 16));
+}
+
+void CSP_DropDownJSPage::do_select_left(int index)
+{
+       if(index < 16) {
+               emit sig_select_js_button(bind_jsnum, 2, joystick_define_tbl[index].scan);
+       }
+       emit sig_select_js_button_idx(bind_jsnum, 2, -(index - 16));
+}
+
+void CSP_DropDownJSPage::do_select_right(int index)
+{
+       if(index < 16) {
+               emit sig_select_js_button(bind_jsnum, 3, joystick_define_tbl[index].scan);
+       }
+       emit sig_select_js_button_idx(bind_jsnum, 3, -(index - 16));
+}
+
+void CSP_DropDownJSPage::do_select_js_button(int jsnum, int button, int scan)
+{
+       //printf("Select: %d %d %d\n", jsnum, button, scan);
+       emit sig_select_js_button(jsnum, button, scan);
+}
+
+void CSP_DropDownJSPage::do_select_js_button_idx(int jsnum, int button, int scan)
+{
+       emit sig_select_js_button_idx(jsnum, button, scan);
+       //printf("Select_Idx: %d %d %d\n", jsnum, button, scan);
+}
diff --git a/source/src/qt/gui/dropdown_jspage.h b/source/src/qt/gui/dropdown_jspage.h
new file mode 100644 (file)
index 0000000..804b6d9
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Common Source Project/ Qt
+ * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
+ *  Qt: Menu->Emulator->Define Strings
+ *  History: Feb 23, 2016 : Initial
+ */
+
+#ifndef _CSP_DROPDOWN_JSPAGE_H
+#define _CSP_DROPDOWN_JSPAGE_H
+
+#include <QWidget>
+#include <QGridLayout>
+#include <QLabel>
+#include <QStringList>
+#include <QString>
+
+#include "dropdown_jsbutton.h"
+
+
+QT_BEGIN_NAMESPACE
+
+class CSP_DropDownJSPage: public QWidget {
+       Q_OBJECT
+protected:
+       QWidget *p_wid;
+       QGridLayout *layout;
+       //QLabel *label[4];
+       QLabel *label_buttons;
+       QLabel *label_axis;
+
+       CSP_DropDownJSButton *combo_js[4];
+       
+       CSP_DropDownJSButton *js_button[12];
+       QLabel *label_button[12];
+       int bind_jsnum;
+public:
+       CSP_DropDownJSPage(QWidget *parent = 0, QStringList *lst = 0, int jsnum = 0);
+       ~CSP_DropDownJSPage();
+
+public slots:
+       void do_select_up(int index);
+       void do_select_down(int index);
+       void do_select_left(int index);
+       void do_select_right(int index);
+       void do_select_js_button(int jsnum, int button_num, int assigned_value);
+       void do_select_js_button_idx(int jsnum, int button_num, int assigned_value);
+signals:
+       int sig_select_js_button(int jsnum, int button_num, int assigned_value);
+       int sig_select_js_button_idx(int jsnum, int button_num, int assigned_value);
+};     
+
+QT_END_NAMESPACE
+#endif // _CSP_DROPDOWN_JSPAGE_H
index 8d79741..2b73452 100644 (file)
@@ -1,26 +1,32 @@
+/*
+ * Common Source Project/ Qt
+ * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
+ *  Qt: Menu->Emulator->Define Strings
+ *  History: Feb 23, 2016 : Initial
+ */
 
 #include "dropdown_keyset.h"
 
-CSP_KeyTables::CSP_KeyTables(QObject *parent, keydef_table_t *tbl) : QObject(parent)
+CSP_KeyTables::CSP_KeyTables(QObject *parent, const keydef_table_t *tbl) : QObject(parent)
 {
        int i;
        QString tmps;
-       vk_names.clear();
+       vk_names_list.clear();
        for(i = 0; i < 256; i++) {
                tmps = QString::fromUtf8(vk_names[i]);
-               vk_names.append(tmps);
+               vk_names_list.append(tmps);
        }
        memset(using_table, 0x00, KEYDEF_MAXIMUM * sizeof(keydef_table_t));
        base_table = NULL;
        table_size = 0;
-       set_key_table(tbl);
+       do_set_key_table(tbl);
 }
 
 CSP_KeyTables::~CSP_KeyTables()
 {
 }
 
-CSP_KeyTables::set_key_table(keydef_table_t *tbl)
+void CSP_KeyTables::do_set_key_table(keydef_table_t *tbl)
 {
        int i;
        
@@ -40,7 +46,7 @@ CSP_KeyTables::set_key_table(keydef_table_t *tbl)
        }
 }
 
-void CSP_KeyTables::set_scan_code(uint32 vk, uint32 scan)
+void CSP_KeyTables::do_set_scan_code(uint32 vk, uint32 scan)
 {
        int i;
        if(scan >= 0x80000000) return;
@@ -86,18 +92,18 @@ QString CSP_KeyTables::get_vk_name(uint32 vk)
 {
        QString s = QString::fromUtf8("");
        if(vk >= 256) return s;
-       s = vk_names.at((int)vk);
+       s = vk_names_list.at((int)vk);
        return s;
 }
 
-QStringList CSP_KeyTables::get_scan_name_list(void)
+QStringList *CSP_KeyTables::get_scan_name_list(void)
 {
-       return key_names;
+       return &key_names;
 }
 
-QStringList CSP_KeyTables::get_vk_name_list(void)
+QStringList *CSP_KeyTables::get_vk_name_list(void)
 {
-       return key_names;
+       return &vk_names_list;
 }
 
 int CSP_KeyTables::get_key_table_size(void)
@@ -155,3 +161,10 @@ uint32 CSP_KeyTables::get_vk_from_scan(uint32 scan)
        }
 }
 
+keydef_table_t *CSP_KeyTables::get_using_key_table(int index)
+{
+       if(index < 0) return NULL;
+       if(index >= table_size) return NULL;
+       if(index >= KEYDEF_MAXIMUM) return NULL;
+       return &(using_table[index]);
+}
index 9a612f4..eb9764e 100644 (file)
 
 #include <QString>
 #include <QStringList>
+#include <QComboBox>
+#include <QWidget>
+
 #include "dropdown_keytables.h"
 
-Q_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
 
-const keydet_table_t joystick_define[] = {
-       {0x80000000, 0x80000008, "Left (Joystick)"},
-       {0x80000000, 0x80000004, "Right (Joystick)"},
-       {0x80000000, 0x80000002, "Up (Joystick)"},
-       {0x80000000, 0x80000001, "Down (Joystick)"},
-       {0x80000000, 0x80000010, "Button1  (Joystick)"},
-       {0x80000000, 0x80000020, "Button2  (Joystick)"},
-       {0x80000000, 0x80000040, "Button3  (Joystick)"},
-       {0x80000000, 0x80000080, "Button4  (Joystick)"},
-       {0x80000000, 0x80000100, "Button5  (Joystick)"},
-       {0x80000000, 0x80000200, "Button6  (Joystick)"},
-       {0x80000000, 0x80000400, "Button7  (Joystick)"},
-       {0x80000000, 0x80000800, "Button8  (Joystick)"},
-       {0x80000000, 0x80001000, "Button9  (Joystick)"},
-       {0x80000000, 0x80002000, "Button10 (Joystick)"},
-       {0x80000000, 0x80004000, "Button11 (Joystick)"},
-       {0x80000000, 0x80008000, "Button12 (Joystick)"},
+const keydef_table_t joystick_define_tbl[] = {
+       {0x80000000, 0x00000001, "↓ (Joystick)"},
+       {0x80000000, 0x00000002, "↑ (Joystick)"},
+       {0x80000000, 0x00000004, "→ (Joystick)"},
+       {0x80000000, 0x00000008, "← (Joystick)"},
+       {0x80000000, 0x00000010, "△ (Joystick)"},
+       {0x80000000, 0x00000020, "○ (Joystick)"},
+       {0x80000000, 0x00000040, "× (Joystick)"},
+       {0x80000000, 0x00000080, "□ (Joystick)"},
+       {0x80000000, 0x00000100, "L2 (Joystick)"},
+       {0x80000000, 0x00000200, "R2 (Joystick)"},
+       {0x80000000, 0x00000400, "L1 (Joystick)"},
+       {0x80000000, 0x00000800, "R1 (Joystick)"},
+       {0x80000000, 0x00001000, "SEL(Joystick)"},
+       {0x80000000, 0x00002000, "RUN(Joystick)"},
+       {0x80000000, 0x00004000, "L3 (Joystick)"},
+       {0x80000000, 0x00008000, "R3 (Joystick)"},
 };
 
 #define KEYDEF_MAXIMUM 512
@@ -39,49 +42,36 @@ class CSP_KeyTables: public QObject {
 protected:
        QObject *p_obj;
        QStringList key_names;
-       QStringList vk_names;
+       QStringList vk_names_list;
        const keydef_table_t *base_table;
        int table_size;
        keydef_table_t using_table[KEYDEF_MAXIMUM];
 public:
        CSP_KeyTables(QObject *parent, const keydef_table_t *tbl = NULL);
-       ~CSP_KeyDropDown();
+       ~CSP_KeyTables();
        int conv_code(uint32 scan);
        void set_base_table(const keydef_table_t *p);
        QString get_vk_name(uint32 vk);
        QString get_scan_name(uint32 scan);
        QString get_default_scan_name(uint32 scan);
-       QStringList get_scan_name_list(void);
-       QStringList get_vk_name_list(void);
+       QStringList *get_scan_name_list(void);
+       QStringList *get_vk_name_list(void);
        int get_key_table_size(void);
        uint32 get_vk_from_index(int index);
        uint32 get_scan_from_index(int index);
        uint32 get_default_scan_from_index(int index);
-       
+       uint32 get_scan_from_vk(uint32 vk);
+       uint32 get_vk_from_scan(uint32 scan);
+
+       keydef_table_t *get_using_key_table(int index);
 public slots:
-       void set_scan_code(uint32 vk, uint32 scan);
-       void set_key_table(keydef_table_t *tbl);
+       void do_set_scan_code(uint32 vk, uint32 scan);
+       void do_set_key_table(keydef_table_t *tbl);
 };
 
 // Assign scancode to VK tables
-class CSP_DropDownKeys: public QWidget {
-       Q_OBJECT
-protected:
-       QWidget *p_wid;
-       QComboBox s_name_src;
-       QStringList s_name_dst;
-       QString src_name;
-
-       int index_src;
-public:
-       CSP_DropDownKeys(QWidget *parent);
-public slots:
-       void do_set_table(keydef_table_t *tbl);
-signals:
-       int sig_update_vk_scan(int vk, int scan);
-};
 
-Q_END_NAMESPACE
+QT_END_NAMESPACE
 
 
 #endif //_CSP_QT_DROPDOWN_KEYSET_H
index 235fd4b..5ede2dd 100644 (file)
@@ -17,7 +17,12 @@ typedef struct {
        const char *name;
 } keydef_table_t;
 
-const _TCHAR *vk_names[] = {
+enum {
+       KEYBOARD_109JP = 0,
+       KEYBOARD_84,
+};
+
+static const _TCHAR *vk_names[] = {
        _T("VK_$00"),                   _T("VK_LBUTTON"),               _T("VK_RBUTTON"),               _T("VK_CANCEL"),                
        _T("VK_MBUTTON"),               _T("VK_XBUTTON1"),              _T("VK_XBUTTON2"),              _T("VK_$07"),                   
        _T("VK_BACK"),                  _T("VK_TAB"),                   _T("VK_$0A"),                   _T("VK_$0B"),                   
@@ -84,7 +89,7 @@ const _TCHAR *vk_names[] = {
        _T("VK_NONAME"),                _T("VK_PA1"),                   _T("VK_OEM_CLEAR"),             _T("VK_$FF"),                   
 };
 
-const keydef_table_t default_key_table_106_QtScan[] = {
+static const keydef_table_t default_key_table_106_QtScan[] = {
        {VK_ESCAPE,  9, "ESC"},
        {VK_F1,  67, "PF1"},
        {VK_F2,  68, "PF2"},
index fd980f1..5c486d8 100644 (file)
@@ -90,13 +90,17 @@ class Ui_MainWindow : public QMainWindow
        void ConfigFloppyMenu(void);
        void ConfigSoundMenu(void);
        void CreateSoundMenu(void);
-
+       
+       void CreateEmulatorMenu(void);
+       void ConfigEmulatorMenu(void);
+       
        void OnWindowResize(void);
        void OnWindowMove(void);
        void OnWindowRedraw(void);
        void CreateFloppyMenu(int drv, int drv_base);
        void CreateFloppyPulldownMenu(int drv);
        void ConfigFloppyMenuSub(int drv);
+       
        void retranslateFloppyMenu(int drv, int basedrv);
        void CreateCMTMenu(void);
        void CreateCMTPulldownMenu(void);
@@ -122,6 +126,8 @@ class Ui_MainWindow : public QMainWindow
        void retranslateSoundMenu(void);
        virtual void retranslateVolumeLabels(Ui_SoundDialog *);
        
+       virtual void retranslateEmulatorMenu(void);
+       
        void ConfigScreenMenu(void);
        void ConfigScreenMenu_List(void);
        void CreateScreenMenu(void);
@@ -277,6 +283,10 @@ class Ui_MainWindow : public QMainWindow
        class Action_Control *actionPrintDevice[2];
   #endif
 #endif
+       // Emulator
+       class Action_Control *action_SetupJoystick;
+       class Action_Control *action_SetupKeyboard;
+       
        // Menus    
        QMenu *menuControl;
        QMenu *menuState;
@@ -422,6 +432,7 @@ public slots:
        void do_emu_update_rvolume(int num, int level);
        
        void rise_volume_dialog(void);
+       void rise_joystick_dialog(void);
 #ifdef USE_MULTIPLE_SOUNDCARDS
        void set_multiple_speakers(bool flag);
 #endif
index e6e1fbd..895a311 100644 (file)
@@ -102,7 +102,7 @@ void Ui_MainWindow::setupUi(void)
 #if defined(USE_CART1) || defined(USE_CART2)
        ConfigCartMenu();
 #endif
-       
+       ConfigEmulatorMenu();   
        actionAbout = new Action_Control(this);
        actionAbout->setObjectName(QString::fromUtf8("actionAbout"));
    
@@ -193,7 +193,7 @@ void Ui_MainWindow::setupUi(void)
 #if defined(USE_BINARY_FILE2)
        CreateBinaryMenu(1, 2);
 #endif
-
+       
        connect(this, SIGNAL(sig_update_screen(void)), graphicsView, SLOT(update(void)));
        //connect(this, SIGNAL(sig_update_screen(void)), graphicsView, SLOT(updateGL(void)));
 
@@ -220,6 +220,7 @@ void Ui_MainWindow::setupUi(void)
 #endif
        menuEmulator = new QMenu(menubar);
        menuEmulator->setObjectName(QString::fromUtf8("menuEmulator"));
+       
        menuHELP = new QMenu(menubar);
        menuHELP->setObjectName(QString::fromUtf8("menuHELP"));
        MainWindow->setMenuBar(menubar);
@@ -295,6 +296,7 @@ void Ui_MainWindow::setupUi(void)
 #if !defined(WITHOUT_SOUND)    
        CreateSoundMenu();
 #endif
+       CreateEmulatorMenu();
   
        menuHELP->addAction(actionAbout);
        connect(actionAbout, SIGNAL(triggered()), this, SLOT(do_show_about()));
@@ -438,6 +440,7 @@ void Ui_MainWindow::setupUi(void)
                double nd = actionScreenSize[config.window_mode]->binds->getDoubleValue();
                graphicsView->do_set_screen_multiply(nd);
        }
+       connect(action_SetupJoystick, SIGNAL(triggered()), this, SLOT(rise_joystick_dialog()));
           
        QImageReader reader(":/default.ico");
        QImage result = reader.read();
@@ -446,6 +449,35 @@ void Ui_MainWindow::setupUi(void)
 } // setupUi
 
 
+// Emulator
+#include "dropdown_joystick.h"
+
+void Ui_MainWindow::retranslateEmulatorMenu(void)
+{
+       action_SetupJoystick->setText(QApplication::translate("MainWindow", "Configure Joysticks", 0));
+       //action_SetupKeyboard->setText(QApplication::translate("MainWindow", "Configure Joysticks", 0));
+}
+void Ui_MainWindow::CreateEmulatorMenu(void)
+{
+       menuEmulator->addAction(action_SetupJoystick);
+}
+
+void Ui_MainWindow::ConfigEmulatorMenu(void)
+{
+       action_SetupJoystick = new Action_Control(this);
+}
+
+void Ui_MainWindow::rise_joystick_dialog(void)
+{
+       if(graphicsView != NULL) {
+               QStringList *lst = graphicsView->getVKNames();
+               CSP_DropDownJoysticks *dlg = new CSP_DropDownJoysticks(NULL, lst);
+               dlg->setWindowTitle(QApplication::translate("CSP_DropDownJoysticks", "Configure Joysticks", 0));
+               dlg->show();
+       }
+}
+
+// Retranslate
 void Ui_MainWindow::retranslateUI_Help(void)
 {
        menuHELP->setTitle(QApplication::translate("MainWindow", "HELP", 0));
@@ -532,6 +564,7 @@ void Ui_MainWindow::retranslateUi(void)
        retranslateBinaryMenu(0, 1);
        retranslateBinaryMenu(1, 2);
        retranslateMachineMenu();
+       retranslateEmulatorMenu();
        retranslateUI_Help();
    
        this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
index 6807119..f4b0a8d 100644 (file)
@@ -151,295 +151,6 @@ const struct NativeScanCode convTable_QTScan106[] = {
        {VK_RETURN, 0x011c},  // Enter(ten Key)
        {0xffffffff, 0xffffffff}
 };
-#else
-const struct NativeScanCode convTable_QTScan106[] = {
-       // Line 0
-       {VK_ESCAPE,  9},
-       {VK_F1,  67},
-       {VK_F2,  68},
-       {VK_F3,  69},
-       {VK_F4,  70},
-       {VK_F5,  71},
-       {VK_F6,  72},
-       {VK_F7,  73},
-       {VK_F8,  74},
-       {VK_F9,  75},
-       {VK_F10, 76},
-       {VK_F11, 95},
-       {VK_F12, 96},
-       // Power, Sleep, Wake is not implemented, they are'nt safety.
-       // Line 1
-       {VK_KANJI, 49}, // Hankaku/Zenkaku
-       {'0', 19},
-       {'1', 10},
-       {'2', 11},
-       {'3', 12},
-       {'4', 13},
-       {'5', 14},
-       {'6', 15},
-       {'7', 16},
-       {'8', 17},
-       {'9', 18},
-       {VK_OEM_MINUS, 20}, // - =
-       {VK_OEM_7, 21}, // ^~
-       {VK_OEM_5, 132}, // \|
-       {VK_BACK, 22}, // Backspace
-       // Line 2
-       {VK_TAB, 23},
-       {'Q', 24},
-       {'W', 25},
-       {'E', 26},
-       {'R', 27},
-       {'T', 28},
-       {'Y', 29},
-       {'U', 30},
-       {'I', 31},
-       {'O', 32},
-       {'P', 33},
-       {VK_OEM_3, 34}, // @
-       {VK_RETURN, 36}, // Enter (Full key)
-       {VK_OEM_4, 35}, // [
-       // Line 3
-       {VK_OEM_ATTN, 66}, // CAPS Lock
-       {'A', 38},
-       {'S', 39},
-       {'D', 40},
-       {'F', 41},
-       {'G', 42},
-       {'H', 43},
-       {'J', 44},
-       {'K', 45},
-       {'L', 46},
-       {VK_OEM_PLUS, 47}, // ;
-       {VK_OEM_1, 48}, // :
-       {VK_OEM_6, 51}, // ]
-       // Line 3
-       {VK_LSHIFT, 50}, // LShift
-       {'Z', 52},
-       {'X', 53},
-       {'C', 54},
-       {'V', 55},
-       {'B', 56},
-       {'N', 57},
-       {'M', 58},
-       {VK_OEM_COMMA, 59}, // ,
-       {VK_OEM_PERIOD, 60}, // .
-       {VK_OEM_2, 61}, // /(Slash)
-       {VK_OEM_102, 97}, //\_
-       {VK_RSHIFT, 62},
-       // Line 4
-       {VK_LCONTROL, 37},
-       {VK_LWIN, 133},
-       {VK_LMENU, 64},
-       {VK_NONCONVERT, 102}, // Muhenkan
-       {VK_SPACE, 65},
-       {VK_CONVERT, 100}, // Henkan
-       {VK_OEM_COPY, 101}, // Katakana_Hiragana
-       {VK_RMENU, 108},
-       {VK_RWIN,  134},
-       {VK_APPS, 135},
-       {VK_RCONTROL, 105},
-       // Cursors
-       {VK_UP, 111},
-       {VK_DOWN, 116},
-       {VK_LEFT, 113},
-       {VK_RIGHT,114},
-       // 
-       //     {VK_PRINT, },
-       {VK_SCROLL, 78},
-       {VK_PAUSE, 127},
-       {VK_INSERT, 118},
-       {VK_HOME, 110},
-       {VK_NEXT, 112},
-       {VK_DELETE, 119},
-       {VK_END, 115},
-       {VK_PRIOR, 117},
-       // TenKey
-       {VK_NUMPAD0, 90},
-       {VK_NUMPAD1, 87},
-       {VK_NUMPAD2, 88},
-       {VK_NUMPAD3, 89},
-       {VK_NUMPAD4, 83},
-       {VK_NUMPAD5, 84},
-       {VK_NUMPAD6, 85},
-       {VK_NUMPAD7, 79},
-       {VK_NUMPAD8, 80},
-       {VK_NUMPAD9, 81},
-       //
-       {VK_DECIMAL, 0x005b}, // NumLock     
-       {VK_DIVIDE, 106},
-       {VK_MULTIPLY, 63},
-       {VK_SUBTRACT, 82},
-       {VK_ADD, 86},
-       {VK_RETURN, 104},  // Enter(ten Key)
-       {0xffffffff, 0xffffffff}
-};
-#endif
-#if defined(Q_OS_WIN)
-#else // Linux or Unix
-const struct NativeVirtualKeyCode convTable_QTKey[] = {
-       // Line 0
-       {VK_ESCAPE,  0xff1b},
-       {VK_F1,  0xffbe},
-       {VK_F2,  0xffbf},
-       {VK_F3,  0xffc0},
-       {VK_F4,  0xffc1},
-       {VK_F5,  0xffc2},
-       {VK_F6,  0xffc3},
-       {VK_F7,  0xffc4},
-       {VK_F8,  0xffc5},
-       {VK_F9,  0xffc6},
-       {VK_F10, 0xffc7},
-       {VK_F11, 0xffc8},
-       {VK_F12, 0xffc9},
-       // Power, Sleep, Wake is not implemented, they are'nt safety.
-       // Line 1
-       {VK_KANJI, 0xff2a}, // Hankaku/Zenkaku
-       {VK_OEM_MINUS, 0x002d}, // -=
-       {VK_OEM_MINUS, 0x003d},
-       {VK_OEM_7, 0x005e}, // ^~
-       {VK_OEM_7, 0x007e},
-       {VK_OEM_5, 0x005c}, // \|
-       {VK_OEM_5, 0x007c},
-       {VK_BACK, 0xff08}, // Backspace
-       // Line 2
-       {VK_TAB, 0xff09},
-       {VK_RETURN, 0xff0d}, // Enter (Full key)
-       {VK_OEM_3, 0x0040}, // @
-       {VK_OEM_3, 0x0060}, // @
-
-       {VK_OEM_4, 0x005b}, // [
-       {VK_OEM_4, 0x007b}, // [
-       // Line 3
-       {VK_OEM_ATTN, 0xff30}, // CAPS Lock
-       {VK_OEM_PLUS, 0x002b}, // ;
-       {VK_OEM_PLUS, 0x003b}, // ;
-       {VK_OEM_1, 0x002a}, // :
-       {VK_OEM_1, 0x003a}, // :
-       {VK_OEM_6, 0x005d}, // ]
-       {VK_OEM_6, 0x007d}, // ]
-       // Line 3
-       {VK_LSHIFT, 0xffe1}, // LShift
-       {VK_OEM_COMMA, 0x2c}, // ,
-       {VK_OEM_COMMA, 0x3c}, // ,
-       {VK_OEM_PERIOD, 0x2e}, // .
-       {VK_OEM_PERIOD, 0x3e}, // .
-       {VK_OEM_2, 0x2f}, // /(Slash)
-       {VK_OEM_2, 0x3f}, // /(Slash)
-       {VK_OEM_102, 0x5f}, //\_
-       //{0xe2, 0x5c}, //\_
-       {VK_RSHIFT, 0xffe2},
-       // Line 4
-       {VK_LCONTROL, 0xffe3},
-       {VK_LWIN, 0xffeb},
-       {VK_LMENU, 0xffe9},
-       {VK_NONCONVERT, 0xff22}, // Muhenkan
-       {VK_SPACE, 0x0020},
-       //{VK_OEM_AUTO, 0xff23}, // Henkan
-       {VK_CONVERT, 0xff23}, // Henkan
-       {VK_OEM_COPY, 0xff27}, // Katakana_Hiragana
-       {VK_RMENU, 0xffea},
-       {VK_RWIN,  0xffec},
-       {VK_APPS, 0xff67},
-       {VK_RCONTROL, 0xffe4},
-       // Cursors
-       {VK_UP, 0xff52},
-       {VK_DOWN, 0xff54},
-       {VK_LEFT, 0xff51},
-       {VK_RIGHT,0xff53},
-       // 
-       //     {VK_PRINT, },
-       {VK_SCROLL, 0xff14},
-       {VK_PAUSE, 0xff13},
-       {VK_INSERT, 0xff63},
-       {VK_HOME, 0xff50},
-       {VK_NEXT, 0xff55},
-       {VK_DELETE, 0xffff},
-       {VK_END, 0xff57},
-       {VK_PRIOR, 0xff56},
-       // TenKey
-       {VK_NUMPAD0, 0xffb0},
-       {VK_NUMPAD1, 0xffb1},
-       {VK_NUMPAD2, 0xffb2},
-       {VK_NUMPAD3, 0xffb3},
-       {VK_NUMPAD4, 0xffb4},
-       {VK_NUMPAD5, 0xffb5},
-       {VK_NUMPAD6, 0xffb6},
-       {VK_NUMPAD7, 0xffb7},
-       {VK_NUMPAD8, 0xffb8},
-       {VK_NUMPAD9, 0xffb9},
-       //
-       {VK_DECIMAL, 0xff7f}, // NumLock     
-       {VK_DIVIDE, 0xffaf},
-       {VK_MULTIPLY, 0xffaa},
-       {VK_SUBTRACT, 0xffad},
-       {VK_ADD, 0xffab},
-       {VK_RETURN, 0xff8d},  // Enter(ten Key)
-       {VK_DECIMAL, 0xffae},  // Period(ten Key)
-       {0xffffffff, 0xffffffff}
-};
-#endif
-
-#if defined(Q_OS_WIN)
-uint32_t GLDrawClass::getNativeKey2VK(uint32_t data)
-{
-       uint32_t vk = data;
-#if defined(ENABLE_SWAP_KANJI_PAUSE)
-       if(config.swap_kanji_pause) {
-               if(vk == VK_KANJI) {
-                       vk = VK_PAUSE;
-               } else if(vk == VK_PAUSE) {
-                       vk = VK_KANJI;
-               }
-       }
-#endif
-       return vk;
-}
-#else
-uint32_t GLDrawClass::getNativeKey2VK(uint32_t data)
-{
-       uint32 val = 0;
-       uint32 vk;
-       int i = 0;
-
-       if(data < 0x100) {
-               if((data >= 'a') && (data <= 'z')) {
-                       return data & 0x5f;
-               }
-               if((data >= 'A') && (data <= 'Z')) {
-                       return data;
-               }
-               if((data >= '0') && (data <= '9')) {
-                       return data;
-               }
-               if((data > 0x20) && (data <= 0x29)) {
-                       return data | 0x10;
-               }
-       }
-       while(NativeVirtualKeyCode[i].vk != 0xffffffff) {
-               val = NativeVirtualKeyCode[i].key;
-               if(val == data) break;
-               i++;
-       }
-       vk = NativeVirtualKeyCode[i].vk;
-
-       if(vk == 0xffffffff) return 0;
-#if defined(ENABLE_SWAP_KANJI_PAUSE)
-       if(config.swap_kanji_pause) {
-               if(vk == VK_KANJI) {
-                       vk = VK_PAUSE;
-               } else if(vk == VK_PAUSE) {
-                       vk = VK_KANJI;
-               }
-       }
-#endif    
-#ifndef NOTIFY_KEY_DOWN_LR_SHIFT
-       if((vk == VK_LSHIFT) || (vk == VK_RSHIFT)) vk = VK_SHIFT;
-       if((vk == VK_LMENU) || (vk == VK_RMENU)) vk = VK_MENU;
-#endif   
-       if((vk == VK_LCONTROL) || (vk == VK_RCONTROL)) vk = VK_CONTROL;
-       return vk;
-}
 #endif
 
 uint32_t GLDrawClass::get106Scancode2VK(uint32_t data)
@@ -447,14 +158,7 @@ uint32_t GLDrawClass::get106Scancode2VK(uint32_t data)
        uint32_t val = 0;
        uint32_t vk;
        int i = 0;
-       while(NativeScanCode[i].vk != 0xffffffff) {
-               val = NativeScanCode[i].scan;
-               if(val == data) break;
-               i++;
-       }
-       vk = NativeScanCode[i].vk;
-       //printf("SCAN=%02x VK=%02x\n", val, vk);
-       if(vk == 0xffffffff) return 0;
+       vk = key_table->get_vk_from_scan(data);
 #if defined(ENABLE_SWAP_KANJI_PAUSE)
        if(config.swap_kanji_pause) {
                if(vk == VK_KANJI) {
@@ -475,18 +179,9 @@ uint32_t GLDrawClass::get106Scancode2VK(uint32_t data)
 void GLDrawClass::initKeyCode(void)
 {
        int i;
-       memset(NativeScanCode, 0x00, sizeof(NativeScanCode));
-       memset(NativeVirtualKeyCode, 0x00, sizeof(NativeVirtualKeyCode));
+       key_table = new CSP_KeyTables(this, default_key_table_106_QtScan);
 
-#if !defined(Q_QS_MAC)
        {
-               for(i = 0; i < 256; i++) {
-                       if(convTable_QTScan106[i].vk == 0xffffffff) break;
-                       NativeScanCode[i].vk = convTable_QTScan106[i].vk;
-                       NativeScanCode[i].scan = convTable_QTScan106[i].scan;
-               }
-               NativeScanCode[i].vk = 0xffffffff;
-               NativeScanCode[i].scan = 0xffffffff;
                // Replace only ScanCode
                FILEIO *fio = new FILEIO();
                std::string app_path2;
@@ -506,62 +201,7 @@ void GLDrawClass::initKeyCode(void)
                                uint32_t scan = nlist.at(1).toULong(&ok2, 16);
                                if((vk == 0) || (vk > 255)) continue;
                                if(ok1 && ok2) {
-                                       for(i = 0; i < 256; i++) {
-                                               if(NativeScanCode[i].vk == 0xffffffff) break;
-                                               if(NativeScanCode[i].scan == scan) {
-                                                       NativeScanCode[i].vk = (uint32_t)vk;
-                                                       break;
-                                               }
-                                       }
-                               }
-                       }
-                       fio->Fclose();
-               }
-               delete fio;
-       }
-#endif 
-
-       {
-#if !defined(Q_OS_WIN) && !defined(Q_OS_CYGWIN)
-               for(i = 0; i < 256; i++) {
-                       if(convTable_QTKey[i].vk == 0xffffffff) break;
-                       NativeVirtualKeyCode[i].vk = convTable_QTKey[i].vk;
-                       NativeVirtualKeyCode[i].key = convTable_QTKey[i].key;
-               }
-#else // Windows
-               for(i = 0; i < 256; i++) {
-                       NativeVirtualKeyCode[i].vk = (uint32_t)i;
-                       NativeVirtualKeyCode[i].key = NativeVirtualKeyCode[i].vk;
-               }
-#endif         
-               NativeVirtualKeyCode[i].vk = 0xffffffff;
-               NativeVirtualKeyCode[i].key = 0xffffffff;
-               // Replace only ScanCode
-               FILEIO *fio = new FILEIO();
-               std::string app_path2;
-               // Read scan table.
-               app_path2 = cpp_confdir + "virtual_key_code.cfg";
-               if(fio->Fopen(app_path2.c_str(), FILEIO_READ_ASCII)) {
-                       char buf[512];
-                       memset(buf, 0x00, sizeof(buf));
-                       while(fio->Fgets(buf, 512) != NULL) {
-                               QString nstr;
-                               QStringList nlist;
-                               bool ok1, ok2;
-                               nstr = QString::fromUtf8(buf);
-                               nlist = nstr.split(",", QString::SkipEmptyParts);
-                               if(nlist.count() < 2) continue;
-                               uint32_t vk   = nlist.at(0).toULong(&ok1, 16);
-                               uint32_t key  = nlist.at(1).toULong(&ok2, 16);
-                               if((vk == 0) || (vk > 256)) continue;
-                               if(ok1 && ok2) {
-                                       for(i = 0; i < 256; i++) {
-                                               if(NativeVirtualKeyCode[i].vk == 0xffffffff) break;
-                                               if(NativeVirtualKeyCode[i].key == key) {
-                                                       NativeVirtualKeyCode[i].vk = (uint32_t)vk;
-                                                       break;
-                                               }
-                                       }
+                                       key_table->do_set_scan_code(vk, scan);
                                }
                        }
                        fio->Fclose();
@@ -576,28 +216,22 @@ void GLDrawClass::releaseKeyCode(void)
        int i;
        FILEIO *fio = new FILEIO();
        std::string app_path2;
+       uint32 scan;
        // Read scan table.
-#if !defined(Q_OS_MAC) 
+
        app_path2 = cpp_confdir + "scancode.cfg";
        if(fio->Fopen(app_path2.c_str(), FILEIO_WRITE_ASCII)) {
                for(i = 0; i < 256; i++) {
-                       if(NativeScanCode[i].vk == 0xffffffff) break;
-                       fio->Fprintf("%02x,%08x\n", NativeScanCode[i].vk, NativeScanCode[i].scan);
+                       scan = key_table->get_scan_from_vk((uint32)i);
+                       if(scan >= 0xffffffff)  continue;
+                       fio->Fprintf("%02x,%08x\n", i, scan);
                }
                fio->Fclose();
        }
-#endif
-       {
-               app_path2 = cpp_confdir + "virtual_key_code.cfg";
-               if(fio->Fopen(app_path2.c_str(), FILEIO_WRITE_ASCII)) {
-                       for(i = 0; i < 256; i++) {
-                               if(NativeVirtualKeyCode[i].vk == 0xffffffff) break;
-                               fio->Fprintf("%02x,%08x\n", NativeVirtualKeyCode[i].vk, NativeVirtualKeyCode[i].key);
-                       }
-                       fio->Fclose();
-               }
+       if(key_table != NULL) {
+               delete key_table;
+               key_table = NULL;
        }
-       delete fio;     
 }
 
 void GLDrawClass::keyReleaseEvent(QKeyEvent *event)
@@ -670,3 +304,48 @@ void GLDrawClass::keyPressEvent(QKeyEvent *event)
 }
 
 
+QStringList *GLDrawClass::getKeyNames(void)
+{
+       if(key_table) {
+               return key_table->get_scan_name_list();
+       }
+       return NULL;
+}
+
+QStringList *GLDrawClass::getVKNames(void)
+{
+       if(key_table) {
+               return key_table->get_vk_name_list();
+       }
+       return NULL;
+}
+
+keydef_table_t *GLDrawClass::getKeyTable(int index)
+{
+       if(key_table) {
+               return key_table->get_using_key_table(index);
+       }
+       return NULL;
+}
+
+void GLDrawClass::do_update_keyboard_scan_code(uint32 vk, uint32 scan)
+{
+       if(key_table) {
+               key_table->do_set_scan_code(vk, scan);
+       }
+}
+
+uint32 GLDrawClass::get_vk_from_index(int index)
+{
+       if(key_table) {
+               key_table->get_vk_from_index(index);
+       }
+}
+
+uint32 GLDrawClass::get_scan_from_index(int index)
+{
+       if(key_table) {
+               key_table->get_scan_from_index(index);
+       }
+}
+
index 1fabfc3..d629e2b 100644 (file)
@@ -124,6 +124,7 @@ void META_MainWindow::retranslateUi(void)
        retranslateSoundMenu();
        retranslateScreenMenu();
        retranslateMachineMenu();
+       retranslateEmulatorMenu();
        retranslateUI_Help();
        
        this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
index 724bed2..37d3fd7 100644 (file)
@@ -178,6 +178,7 @@ class Ui_MainWindow;
 class EMU;
 class VM;
 class FIFO;
+class CSP_KeyTables;
 
 QT_BEGIN_NAMESPACE
 class OSD : public QThread
@@ -203,6 +204,8 @@ protected:
        void release_input();
        void key_down_sub(int code, bool repeat);
        void key_up_sub(int code);
+       CSP_KeyTables *key_table;
+       
        scrntype *get_buffer(bitmap_t *p, int y);
        bool dinput_key_ok;
 //     bool dinput_joy_ok;
@@ -646,6 +649,7 @@ public slots:
        void do_set_input_string(QString s);
        void do_close_debugger_console();
        void do_close_debugger_thread();
+       void do_assign_js_setting(int jsnum, int axis_idx, int assigned_value);
        
 signals:
        int sig_update_screen(bitmap_t *);
index 5892989..c322490 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "mainwidget.h"
 #include "agar_logger.h"
+#include "dropdown_keyset.h"
 
 #ifdef NOTIFY_KEY_DOWN_LR_SHIFT
 #define VK_SHIFT_TEMP  VK_LSHIFT
@@ -297,7 +298,6 @@ void OSD::initialize_input()
        autokey_buffer->clear();
        autokey_phase = autokey_shift = 0;
 #endif
-       
        lost_focus = false;
 }
 
@@ -317,6 +317,14 @@ void OSD::release_input()
 #endif
 }
 
+void OSD::do_assign_js_setting(int jsnum, int axis_idx, int assigned_value)
+{
+       if((jsnum < 0) || (jsnum >= 4)) return;
+       if((axis_idx < 0) || (axis_idx >= 16)) return;
+       if((assigned_value < -256) || (assigned_value >= 0x10000)) return;
+       config.joy_buttons[jsnum][axis_idx] = assigned_value;
+}
+
 void OSD::update_input()
 {
        int *keystat;