]> Shamusworld >> Repos - virtualjaguar/commitdiff
Hooked up the UI/frontend controller #2 to the Jaguar core, final fixes to the
authorShamus Hammons <jlhamm@acm.org>
Thu, 21 Jul 2011 17:53:35 +0000 (17:53 +0000)
committerShamus Hammons <jlhamm@acm.org>
Thu, 21 Jul 2011 17:53:35 +0000 (17:53 +0000)
controller configuration dialog.

src/gui/configdialog.cpp
src/gui/controllertab.cpp
src/gui/controllertab.h
src/gui/controllerwidget.cpp
src/gui/controllerwidget.h
src/gui/keygrabber.cpp
src/gui/keygrabber.h
src/gui/mainwin.cpp
src/joystick.cpp

index 4107e6b6748020d9c9cff6f9bc3e199da8346b23..ab12b13f02631d9f94c311f9be957156b4a4c274 100644 (file)
 
 #include "configdialog.h"
 
-#include "generaltab.h"
-#include "controllertab.h"
 #include "alpinetab.h"
+#include "controllertab.h"
+#include "controllerwidget.h"
+#include "generaltab.h"
 #include "settings.h"
 
 
@@ -50,8 +51,8 @@ ConfigDialog::ConfigDialog(QWidget * parent/*= 0*/): QDialog(parent)
        setWindowTitle(tr("Virtual Jaguar Settings"));
 
        LoadDialogFromSettings();
-       controllerTab1->UpdateLabel();                          // Now it's safe to do this... ;-)
-       controllerTab2->UpdateLabel();                          // Now it's safe to do this... ;-)
+//     controllerTab1->UpdateLabel();                          // Now it's safe to do this... ;-)
+//     controllerTab2->UpdateLabel();                          // Now it's safe to do this... ;-)
 }
 
 ConfigDialog::~ConfigDialog()
@@ -78,8 +79,10 @@ void ConfigDialog::LoadDialogFromSettings(void)
 
        for(int i=0; i<21; i++)
        {
-               controllerTab1->p1Keys[i] = vjs.p1KeyBindings[i];
-               controllerTab2->p1Keys[i] = vjs.p2KeyBindings[i];
+//             controllerTab1->p1Keys[i] = vjs.p1KeyBindings[i];
+//             controllerTab2->p1Keys[i] = vjs.p2KeyBindings[i];
+               controllerTab1->controllerWidget->keys[i] = vjs.p1KeyBindings[i];
+               controllerTab2->controllerWidget->keys[i] = vjs.p2KeyBindings[i];
        }
 }
 
@@ -103,7 +106,9 @@ void ConfigDialog::UpdateVJSettings(void)
 
        for(int i=0; i<21; i++)
        {
-               vjs.p1KeyBindings[i] = controllerTab1->p1Keys[i];
-               vjs.p2KeyBindings[i] = controllerTab2->p1Keys[i];
+//             vjs.p1KeyBindings[i] = controllerTab1->p1Keys[i];
+//             vjs.p2KeyBindings[i] = controllerTab2->p1Keys[i];
+               vjs.p1KeyBindings[i] = controllerTab1->controllerWidget->keys[i];
+               vjs.p2KeyBindings[i] = controllerTab2->controllerWidget->keys[i];
        }
 }
index f6d8cbcb3336c9532e5639bdae27cf67411f410e..34ca1558541b30ab1e73709bc150d437eac00c4c 100644 (file)
 
 #include "controllertab.h"
 
+#include "controllerwidget.h"
 #include "joystick.h"
 #include "keygrabber.h"
-#include "settings.h"
 
-// These tables are used to convert Qt keycodes into human readable form. Note that
-// a lot of these are just filler.
-char ControllerTab::keyName1[96][16] = {
-       "Space",
-       "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/",
-       "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?",
-       "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
-       "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
-       "[", "]", "\\", "^", "_", "`",
-       "$61", "$62", "$63", "$64", "$65", "$66", "$67", "$68", "$69", "$6A", "$6B", "$6C", "$6D", 
-       "$6E", "$6F", "$70", "$71", "$72", "$73", "$74", "$75", "$76", "$77", "$78", "$79", "$7A", 
-       "{", "|", "}", "~"
-};
-
-char ControllerTab::keyName2[64][16] = {
-       "Esc", "Tab", "BTab", "BS", "Ret", "Ent", "Ins", "Del", "Pause", "Prt", "SRq", "Clr",
-       "$C", "$D", "$E", "$F", "Hm", "End", "Lf", "Up", "Rt", "Dn", "PgU", "PgD", "$18",
-       "$19", "$1A", "$1B", "$1C", "$1D", "$1E", "$1F", "Shf", "Ctl", "Mta", "Alt",
-       "Cap", "Num", "ScL", "$27", "$28", "$29", "$2A", "$2B", "$2C", "$2D", "$2E", "$2F",
-       "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13",
-       "F14", "F15", "F16"
-};
 
 ControllerTab::ControllerTab(QWidget * parent/*= 0*/): QWidget(parent)
 {
-       controllerPic = new QLabel;
-       QImage controller(":/res/controller.png");
-       controllerPic->setPixmap(QPixmap::fromImage(controller));
-
-       redefineAll = new QPushButton(tr("Redefine All Keys"));
+       controllerWidget = new ControllerWidget(this);
+       redefineAll = new QPushButton(tr("Define All Keys"));
 
        QVBoxLayout * layout = new QVBoxLayout;
-       layout->addWidget(controllerPic);
+       layout->addWidget(controllerWidget);
        layout->addWidget(redefineAll);
        setLayout(layout);
 
@@ -64,15 +39,16 @@ ControllerTab::~ControllerTab()
 
 void ControllerTab::DefineAllKeys(void)
 {
-       char jagButtonName[21][10] = { "Up", "Down", "Left", "Right",
-               "*", "7", "4", "1", "0", "8", "5", "2", "#", "9", "6", "3",
-               "A", "B", "C", "Option", "Pause" };
+//     char jagButtonName[21][10] = { "Up", "Down", "Left", "Right",
+//             "*", "7", "4", "1", "0", "8", "5", "2", "#", "9", "6", "3",
+//             "A", "B", "C", "Option", "Pause" };
        int orderToDefine[21] = { 0, 1, 2, 3, 18, 17, 16, 20, 19, 7, 11, 15, 6, 10, 14, 5, 9, 13, 8, 4, 12 };
        KeyGrabber keyGrab(this);
 
        for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
        {
-               keyGrab.SetText(jagButtonName[orderToDefine[i]]);
+//             keyGrab.SetText(jagButtonName[orderToDefine[i]]);
+               keyGrab.SetKeyText(orderToDefine[i]);
                keyGrab.exec();
                int key = keyGrab.key;
 
@@ -80,85 +56,7 @@ void ControllerTab::DefineAllKeys(void)
                        break;
 
                // Otherwise, populate the appropriate spot in the settings & update screen...
-               p1Keys[orderToDefine[i]] = key;
-               UpdateLabel();
+               controllerWidget->keys[orderToDefine[i]] = key;
+               controllerWidget->update();
        }
 }
-
-void ControllerTab::UpdateLabel(void)
-{
-       QImage controller(":/res/controller.png");
-       QPainter painter(&controller);
-       painter.setRenderHint(QPainter::Antialiasing);
-
-       // Bump up the size of the default font...
-       QFont font = painter.font();
-       font.setPixelSize(15);
-       font.setBold(true);
-       painter.setFont(font);
-//     painter.setPen(QColor(48, 255, 255, 255));      // This is R,G,B,A
-       painter.setPen(QColor(0, 0, 0, 255));           // This is R,G,B,A
-       painter.setBrush(QBrush(QColor(48, 255, 255, 255)));
-
-       // This is hard-coded crap. It's crap-tastic!
-       int buttonPos[21][2] = { { 87-1, 64-5 }, { 87-1, 94 }, { 73-5, 78-2 }, { 105+3, 77-1 },
-               { 125, 223 }, { 125, 200 }, { 125, 177 }, { 125, 153 },
-               { 160, 223 }, { 160, 200 }, { 160, 177 }, { 160, 153 },
-               { 196, 223 }, { 196, 200 }, { 196, 177 }, { 196, 153 },
-               { 242, 60 }, { 225-1, 80 }, { 209-2, 104 }, { 162+2, 108-7}, { 141, 108+13 }
-       };
-
-       // First, draw black oversize line, then dot, then colored line
-       QPen blackPen(QColor(0, 0, 0, 255));
-       blackPen.setWidth(4);
-       QPen colorPen(QColor(48, 255, 255, 255));
-       colorPen.setWidth(2);
-       QLine line(QPoint(141, 100), QPoint(141, 108+5));
-
-       painter.setPen(blackPen);
-       painter.drawLine(line);//QPoint(141, 100), QPoint(141, 108+5));
-       blackPen.setWidth(1);
-       painter.setPen(blackPen);
-       painter.drawEllipse(QPoint(141, 100), 4, 4);
-       painter.setPen(colorPen);
-       painter.drawLine(line);//QPoint(141, 100), QPoint(141, 108+5));
-
-       for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
-       {
-               if (p1Keys[i] < 0x80)
-                       DrawBorderedText(painter, buttonPos[i][0] /*- 5*/, buttonPos[i][1] /*+ 5*/,
-                               QString(keyName1[p1Keys[i] - 0x20]));
-               else if ((p1Keys[i] & 0xFFFFFF00) == 0x01000000)
-               {
-                       DrawBorderedText(painter, buttonPos[i][0] /*- 5*/, buttonPos[i][1] /*+ 5*/,
-                               QString(keyName2[p1Keys[i] & 0x3F]));
-               }
-               else
-                       DrawBorderedText(painter, buttonPos[i][0] - 5, buttonPos[i][1] + 5, QString("???"));
-       }
-
-       painter.end();
-       controllerPic->setPixmap(QPixmap::fromImage(controller));
-}
-
-void ControllerTab::DrawBorderedText(QPainter & painter, int x, int y, QString text)
-{
-       // Text is drawn centered at (x, y) as well, using a bounding rect for the purpose.
-       QRect rect(0, 0, 60, 30);
-       painter.setPen(QColor(0, 0, 0, 255));           // This is R,G,B,A
-
-       for(int i=-1; i<=1; i++)
-       {
-               for(int j=-1; j<=1; j++)
-               {
-//                     painter.drawText(QPoint(x + i, y + j), text);
-                       rect.moveCenter(QPoint(x + i, y + j));
-                       painter.drawText(rect, Qt::AlignCenter, text);
-               }
-       }
-
-       painter.setPen(QColor(48, 255, 255, 255));      // This is R,G,B,A
-//     painter.drawText(QPoint(x, y), text);
-       rect.moveCenter(QPoint(x, y));
-       painter.drawText(rect, Qt::AlignCenter, text);
-}
index 545e5bc3a6beb5cf304385abcec1f77a84a87124..011eec2b00785b27fc876a29bb074aba81bcca48 100644 (file)
@@ -4,6 +4,8 @@
 #include <QtGui>
 #include <stdint.h>
 
+class ControllerWidget;
+
 class ControllerTab: public QWidget
 {
        Q_OBJECT
@@ -11,24 +13,15 @@ class ControllerTab: public QWidget
        public:
                ControllerTab(QWidget * parent = 0);
                ~ControllerTab();
-               void UpdateLabel(void);
 
        protected slots:
                void DefineAllKeys(void);
 
        private:
                QPushButton * redefineAll;
-               void DrawBorderedText(QPainter &, int, int, QString);
 
        public:
-               uint32_t p1Keys[21];
-
-       private:
-               QLabel * controllerPic;
-
-               // Class data
-               static char keyName1[96][16];
-               static char keyName2[64][16];
+               ControllerWidget * controllerWidget;
 };
 
 #endif // __CONTROLLERTAB_H__
index c33a863567aa23805e1bdd9ee6bc092e2612feaa..c5167b131c1d30b1bb134222fb1518e6f4ab2fd0 100644 (file)
 
 #include "controllerwidget.h"
 
-//#include "joystick.h"
-//#include "keygrabber.h"
-//#include "settings.h"
+#include "joystick.h"
+#include "keygrabber.h"
 
+// These tables are used to convert Qt keycodes into human readable form. Note that
+// a lot of these are just filler.
+char ControllerWidget::keyName1[96][16] = {
+       "Space",
+       "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/",
+       "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?",
+       "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
+       "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
+       "[", "]", "\\", "^", "_", "`",
+       "$61", "$62", "$63", "$64", "$65", "$66", "$67", "$68", "$69", "$6A", "$6B", "$6C", "$6D", 
+       "$6E", "$6F", "$70", "$71", "$72", "$73", "$74", "$75", "$76", "$77", "$78", "$79", "$7A", 
+       "{", "|", "}", "~"
+};
 
-ControllerWidget::ControllerWidget(QWidget * parent/*= 0*/): QWidget(parent)
+char ControllerWidget::keyName2[64][16] = {
+       "Esc", "Tab", "BTab", "BS", "Ret", "Ent", "Ins", "Del", "Pause", "Prt", "SRq", "Clr",
+       "$C", "$D", "$E", "$F", "Hm", "End", "Lf", "Up", "Rt", "Dn", "PgU", "PgD", "$18",
+       "$19", "$1A", "$1B", "$1C", "$1D", "$1E", "$1F", "Shf", "Ctl", "Mta", "Alt",
+       "Cap", "Num", "ScL", "$27", "$28", "$29", "$2A", "$2B", "$2C", "$2D", "$2E", "$2F",
+       "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13",
+       "F14", "F15", "F16"
+};
+
+// This is hard-coded crap. It's crap-tastic!
+// These are the positions to draw the button names at, ordered by the BUTTON_* sequence
+// found in joystick.h.
+int ControllerWidget::buttonPos[21][2] = { { 86, 59 }, { 86, 94 }, { 68, 76 }, { 108, 76 },
+       { 125, 223 }, { 125, 200 }, { 125, 177 }, { 125, 153 },
+       { 160, 223 }, { 160, 200 }, { 160, 177 }, { 160, 153 },
+       { 196, 223 }, { 196, 200 }, { 196, 177 }, { 196, 153 },
+       { 242, 60 }, { 224, 80 }, { 207, 104 }, { 164, 101 }, { 141, 108+13 }
+};
+
+ControllerWidget::ControllerWidget(QWidget * parent/*= 0*/): QWidget(parent),
+       controllerPic(":/res/controller.png"), widgetSize(controllerPic.size()),
+       keyToHighlight(-1), mouseDown(false)
 {
+       // Seems we have to pad this stuff, otherwise it clips on the right side
+       widgetSize += QSize(4, 4);
+       // We want to know when the mouse is moving over our widget...
+       setMouseTracking(true);
 }
 
 ControllerWidget::~ControllerWidget()
 {
 }
 
+QSize ControllerWidget::sizeHint(void) const
+{
+       return widgetSize;
+}
+
+QSizePolicy ControllerWidget::sizePolicy(void) const
+{
+       return QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+}
+
+void ControllerWidget::paintEvent(QPaintEvent * /*event*/)
+{
+       QPainter painter(this);
+       painter.setRenderHint(QPainter::Antialiasing);
+       painter.drawImage(QPoint(0, 0), controllerPic);
+
+       // Bump up the size of the default font...
+       QFont font = painter.font();
+       font.setPixelSize(15);
+       font.setBold(true);
+       painter.setFont(font);
+//     painter.setPen(QColor(48, 255, 255, 255));      // This is R,G,B,A
+       painter.setPen(QColor(0, 0, 0, 255));           // This is R,G,B,A
+       painter.setBrush(QBrush(QColor(48, 255, 255, 255)));
+
+       // First, draw black oversize line, then dot, then colored line
+       QPen blackPen(QColor(0, 0, 0, 255));
+       blackPen.setWidth(4);
+       QPen colorPen(QColor(48, 255, 255, 255));
+       colorPen.setWidth(2);
+       QLine line(QPoint(141, 100), QPoint(141, 108+5));
+
+       painter.setPen(blackPen);
+       painter.drawLine(line);
+       blackPen.setWidth(1);
+       painter.setPen(blackPen);
+       painter.drawEllipse(QPoint(141, 100), 4, 4);
+       painter.setPen(colorPen);
+       painter.drawLine(line);
+
+       for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
+       {
+               if (keyToHighlight == i)
+               {
+                       painter.setPen(QColor(255, 48, 255, 255));      // This is R,G,B,A
+                       font.setPixelSize(mouseDown ? 15 : 18);
+                       painter.setFont(font);
+               }
+               else
+               {
+                       painter.setPen(QColor(48, 255, 255, 255));      // This is R,G,B,A
+                       font.setPixelSize(15);
+                       painter.setFont(font);
+               }
+
+               if (keys[i] < 0x80)
+                       DrawBorderedText(painter, buttonPos[i][0], buttonPos[i][1],
+                               QString(keyName1[keys[i] - 0x20]));
+               else if ((keys[i] & 0xFFFFFF00) == 0x01000000)
+               {
+                       DrawBorderedText(painter, buttonPos[i][0], buttonPos[i][1],
+                               QString(keyName2[keys[i] & 0x3F]));
+               }
+               else
+                       DrawBorderedText(painter, buttonPos[i][0], buttonPos[i][1], QString("???"));
+       }
+}
+
+void ControllerWidget::mousePressEvent(QMouseEvent * event)
+{
+       mouseDown = true;
+       update();
+}
+
+void ControllerWidget::mouseReleaseEvent(QMouseEvent * event)
+{
+       mouseDown = false;
+       // Spawning the keygrabber causes leaveEvent() to be called, so we need to save this
+       int keyToHighlightSave = keyToHighlight;
+
+       KeyGrabber keyGrab(this);
+       keyGrab.SetKeyText(keyToHighlightSave);
+       keyGrab.exec();
+       int key = keyGrab.key;
+
+       if (key != Qt::Key_Escape)
+               keys[keyToHighlightSave] = key;
+
+       keyToHighlight = keyToHighlightSave;
+       update();
+}
+
+void ControllerWidget::mouseMoveEvent(QMouseEvent * event)
+{
+       if (mouseDown)
+               return;
+
+       // Save the current closest item
+       int keyToHighlightOld = keyToHighlight;
+       // Set up closest distance (this should be large enough)
+//     uint32_t closestX = 100000, closestY = 100000;
+       double closest = 1e9;
+
+       for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
+       {
+               // We loop through the button text positions, to see which one is closest.
+               double distX = (double)(event->x() - buttonPos[i][0]);
+               double distY = (double)(event->y() - buttonPos[i][1]);
+               double currentDistance = sqrt((distX * distX) + (distY * distY));
+
+               if (currentDistance < closest)
+               {
+                       closest = currentDistance;
+                       keyToHighlight = i;
+               }
+       }
+
+       if (keyToHighlightOld != keyToHighlight)
+               update();
+}
+
+void ControllerWidget::leaveEvent(QEvent * /*event*/)
+{
+       keyToHighlight = -1;
+//     mouseDown = false;
+       update();
+}
+
+void ControllerWidget::DrawBorderedText(QPainter & painter, int x, int y, QString text)
+{
+       // Text is drawn centered at (x, y) as well, using a bounding rect for the purpose.
+       QRect rect(0, 0, 60, 30);
+       QPen oldPen = painter.pen();
+       painter.setPen(QColor(0, 0, 0, 255));           // This is R,G,B,A
+
+       for(int i=-1; i<=1; i++)
+       {
+               for(int j=-1; j<=1; j++)
+               {
+                       rect.moveCenter(QPoint(x + i, y + j));
+                       painter.drawText(rect, Qt::AlignCenter, text);
+               }
+       }
+
+       painter.setPen(oldPen);
+       rect.moveCenter(QPoint(x, y));
+       painter.drawText(rect, Qt::AlignCenter, text);
+}
index 09dae521924e098d2baff5e8590ec11e487a447b..cf42469c7a9d54b5e710da6d812d571869dc9549 100644 (file)
@@ -2,6 +2,7 @@
 #define __CONTROLLERWIDGET_H__
 
 #include <QtGui>
+#include <stdint.h>
 
 class ControllerWidget: public QWidget
 {
@@ -10,8 +11,32 @@ class ControllerWidget: public QWidget
        public:
                ControllerWidget(QWidget * parent = 0);
                ~ControllerWidget();
+               QSize sizeHint(void) const;
+               QSizePolicy sizePolicy(void) const;
 
-       //need paint, mousemove, mousedown, mouseup, etc
+       protected:
+               void paintEvent(QPaintEvent *);
+               void mousePressEvent(QMouseEvent *);
+               void mouseReleaseEvent(QMouseEvent *);
+               void mouseMoveEvent(QMouseEvent *);
+               void leaveEvent(QEvent *);
+
+       private:
+               void DrawBorderedText(QPainter &, int, int, QString);
+
+       public:
+               uint32_t keys[21];
+
+       private:
+               QImage controllerPic;
+               QSize widgetSize;
+               int keyToHighlight;
+               bool mouseDown;
+
+               // Class data
+               static char keyName1[96][16];
+               static char keyName2[64][16];
+               static int buttonPos[21][2];
 };
 
 #endif // __CONTROLLERWIDGET_H__
index 371c61991122a3d2a700a96b8ad8e90b37d89251..0bea66f33ae636846745f29d5fcd3ba5b220f9b5 100644 (file)
@@ -27,9 +27,15 @@ KeyGrabber::~KeyGrabber()
 {
 }
 
-void KeyGrabber::SetText(QString keyText)
+//void KeyGrabber::SetText(QString keyText)
+void KeyGrabber::SetKeyText(int keyNum)
 {
-       QString text = QString(tr("Press key for \"%1\"<br>(ESC to cancel)")).arg(keyText);
+       char jagButtonName[21][10] = { "Up", "Down", "Left", "Right",
+               "*", "7", "4", "1", "0", "8", "5", "2", "#", "9", "6", "3",
+               "A", "B", "C", "Option", "Pause" };
+
+       QString text = QString(tr("Press key for \"%1\"<br>(ESC to cancel)"))
+               .arg(QString(jagButtonName[keyNum]));
        label->setText(text);
 }
 
index 481debbe71cbfcd5e67ade7a3ea98173f32ffbf8..6ea19d2e76b516f2052212b39c11fd71f0c6d019 100644 (file)
 
 #include <QtGui>
 
-//class GeneralTab;
-//class ControllerTab;
-//class AlpineTab;
-
 class KeyGrabber: public QDialog
 {
        Q_OBJECT
@@ -21,26 +17,16 @@ class KeyGrabber: public QDialog
        public:
                KeyGrabber(QWidget * parent = 0);
                ~KeyGrabber();
-//             void UpdateVJSettings(void);
-               void SetText(QString);
-//             int GetKeyGrabbed(void);
+               void SetKeyText(int);
 
        protected:
                void keyPressEvent(QKeyEvent *);
 
-//     private:
-//             void LoadDialogFromSettings(void);
-
-       private:
-//             QTabWidget * tabWidget;
-//             QDialogButtonBox * buttonBox;
+private:
                QLabel * label;
 
        public:
                int key;
-//             GeneralTab * generalTab;
-//             ControllerTab * controllerTab;
-//             AlpineTab * alpineTab;
 };
 
 #endif // __KEYGRABBER_H__
index 5794f2b0552ade2945e7b337f5dfe2e8b6351b84..892fb1fec0bdbab4b21bd3fcc5ad36d3f4ad7577 100644 (file)
@@ -316,6 +316,15 @@ void MainWin::HandleKeys(QKeyEvent * e, bool state)
                joypad_0_buttons[BUTTON_D] = 0;
        if (e->key() == (int)vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U])
                joypad_0_buttons[BUTTON_U] = 0;
+
+       if (e->key() == (int)vjs.p2KeyBindings[BUTTON_L] && joypad_1_buttons[BUTTON_R])
+               joypad_0_buttons[BUTTON_R] = 0;
+       if (e->key() == (int)vjs.p2KeyBindings[BUTTON_R] && joypad_1_buttons[BUTTON_L])
+               joypad_0_buttons[BUTTON_L] = 0;
+       if (e->key() == (int)vjs.p2KeyBindings[BUTTON_U] && joypad_1_buttons[BUTTON_D])
+               joypad_0_buttons[BUTTON_D] = 0;
+       if (e->key() == (int)vjs.p2KeyBindings[BUTTON_D] && joypad_1_buttons[BUTTON_U])
+               joypad_0_buttons[BUTTON_U] = 0;
 #endif
 
        // No bad combos exist, let's stuff the emulator key buffers...!
@@ -323,6 +332,9 @@ void MainWin::HandleKeys(QKeyEvent * e, bool state)
        {
                if (e->key() == (int)vjs.p1KeyBindings[i])
                        joypad_0_buttons[i] = (uint8)state;
+
+               if (e->key() == (int)vjs.p2KeyBindings[i])
+                       joypad_1_buttons[i] = (uint8)state;
        }
 }
 
index dc498d02134d87aeaeca92acb5d01185e8ef3203..fd8977fb8f2cd77303efab92941807ef33a73e2c 100644 (file)
@@ -377,6 +377,7 @@ uint8 JoystickReadByte(uint32 offset)
 //unused               int pad1Index = (joystick_ram[1] >> 4) & 0x0F;
 
 //WTF is this shit?
+#warning "!!! What is this? !!!"
                if (!(pad0Index & 0x01))
                {
                        if (joypad_0_buttons[BUTTON_PAUSE])