Add support for Open/Closed Apple with Left/Right Ctrl.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
457fc184d9
commit
a7e75078bb
4 changed files with 116 additions and 20 deletions
|
@ -6,6 +6,7 @@
|
|||
#include "StdAfx.h"
|
||||
#include "linux/data.h"
|
||||
#include "linux/keyboard.h"
|
||||
#include "linux/paddle.h"
|
||||
#include "Common.h"
|
||||
#include "CardManager.h"
|
||||
#include "MouseInterface.h"
|
||||
|
@ -76,8 +77,63 @@ void Video::paintEvent(QPaintEvent *)
|
|||
}
|
||||
}
|
||||
|
||||
bool Video::event(QEvent *event)
|
||||
{
|
||||
if (isEnabled() && (event->type() == QEvent::KeyPress))
|
||||
{
|
||||
// This code bypasses the special QWidget handling of QKeyEvents
|
||||
// Tab and Backtab (?) to move focus
|
||||
// KeyPad Navigation
|
||||
// F1 for whatsthis
|
||||
QKeyEvent *k = (QKeyEvent *)event;
|
||||
keyPressEvent(k);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return VIDEO_BASECLASS::event(event);
|
||||
}
|
||||
}
|
||||
|
||||
void Video::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
if (!event->isAutoRepeat())
|
||||
{
|
||||
// Qt::Key_Alt does not seem to work
|
||||
// Qt::Key_AltGr works well
|
||||
// and Left and Right Ctrl have the same key() value
|
||||
const int vKey = event->nativeVirtualKey();
|
||||
switch (vKey)
|
||||
{
|
||||
case 65507: // Left Ctrl
|
||||
Paddle::setButtonReleased(Paddle::ourOpenApple);
|
||||
break;
|
||||
case 65508: // Right Ctrl
|
||||
Paddle::setButtonReleased(Paddle::ourClosedApple);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// should we always call?
|
||||
VIDEO_BASECLASS::keyReleaseEvent(event);
|
||||
}
|
||||
|
||||
void Video::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (!event->isAutoRepeat())
|
||||
{
|
||||
const int vKey = event->nativeVirtualKey();
|
||||
switch (vKey)
|
||||
{
|
||||
case 65507: // Left Ctrl
|
||||
Paddle::setButtonPressed(Paddle::ourOpenApple);
|
||||
break;
|
||||
case 65508: // Right Ctrl
|
||||
Paddle::setButtonPressed(Paddle::ourClosedApple);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const int key = event->key();
|
||||
|
||||
BYTE ch = 0;
|
||||
|
|
|
@ -20,8 +20,11 @@ signals:
|
|||
public slots:
|
||||
|
||||
protected:
|
||||
virtual bool event(QEvent *event);
|
||||
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
virtual void keyPressEvent(QKeyEvent *event);
|
||||
virtual void keyReleaseEvent(QKeyEvent *event);
|
||||
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QMouseEvent *event);
|
||||
|
|
|
@ -7,8 +7,36 @@
|
|||
#include "Common.h"
|
||||
#include "CPU.h"
|
||||
|
||||
unsigned __int64 g_nJoyCntrResetCycle = 0; // Abs cycle that joystick counters were reset
|
||||
const double PDL_CNTR_INTERVAL = 2816.0 / 255.0; // 11.04 (From KEGS)
|
||||
namespace
|
||||
{
|
||||
unsigned __int64 g_nJoyCntrResetCycle = 0; // Abs cycle that joystick counters were reset
|
||||
const double PDL_CNTR_INTERVAL = 2816.0 / 255.0; // 11.04 (From KEGS)
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::shared_ptr<const Paddle> & Paddle::instance()
|
||||
{
|
||||
static std::shared_ptr<const Paddle> singleton = std::make_shared<Paddle>();
|
||||
return singleton;
|
||||
}
|
||||
|
||||
const int Paddle::ourOpenApple = 0x61;
|
||||
const int Paddle::ourClosedApple = 0x62;
|
||||
std::set<int> Paddle::ourButtons;
|
||||
|
||||
void Paddle::setButtonPressed(int i)
|
||||
{
|
||||
ourButtons.insert(i);
|
||||
}
|
||||
|
||||
void Paddle::setButtonReleased(int i)
|
||||
{
|
||||
ourButtons.erase(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Paddle::Paddle()
|
||||
{
|
||||
|
@ -24,12 +52,6 @@ int Paddle::getAxis(int i) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<const Paddle> & Paddle::instance()
|
||||
{
|
||||
static std::shared_ptr<const Paddle> singleton = std::make_shared<Paddle>();
|
||||
return singleton;
|
||||
}
|
||||
|
||||
Paddle::~Paddle()
|
||||
{
|
||||
}
|
||||
|
@ -39,20 +61,27 @@ BYTE __stdcall JoyReadButton(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG uExe
|
|||
addr &= 0xFF;
|
||||
BOOL pressed = 0;
|
||||
|
||||
const std::shared_ptr<const Paddle> & paddle = Paddle::instance();
|
||||
|
||||
if (paddle)
|
||||
if (Paddle::ourButtons.find(addr) != Paddle::ourButtons.end())
|
||||
{
|
||||
switch (addr)
|
||||
pressed = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::shared_ptr<const Paddle> & paddle = Paddle::instance();
|
||||
|
||||
if (paddle)
|
||||
{
|
||||
case 0x61:
|
||||
pressed = paddle->getButton(0);
|
||||
break;
|
||||
case 0x62:
|
||||
pressed = paddle->getButton(1);
|
||||
break;
|
||||
case 0x63:
|
||||
break;
|
||||
switch (addr)
|
||||
{
|
||||
case 0x61:
|
||||
pressed = paddle->getButton(0);
|
||||
break;
|
||||
case 0x62:
|
||||
pressed = paddle->getButton(1);
|
||||
break;
|
||||
case 0x63:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
class Paddle
|
||||
{
|
||||
|
@ -12,5 +13,12 @@ public:
|
|||
virtual bool getButton(int i) const;
|
||||
virtual int getAxis(int i) const;
|
||||
|
||||
static const int ourOpenApple;
|
||||
static const int ourClosedApple;
|
||||
|
||||
static void setButtonPressed(int i);
|
||||
static void setButtonReleased(int i);
|
||||
static std::set<int> ourButtons;
|
||||
|
||||
static std::shared_ptr<const Paddle> & instance();
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue