Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SmartPad support #439

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
91 changes: 90 additions & 1 deletion gui/qt/keypad/keymap.cpp
Expand Up @@ -13,12 +13,32 @@
KEY(enter), KEY(add), KEY(sub), KEY(mul), KEY(div), KEY(pow), KEY(clr), &none, \
KEY(down), KEY(left), KEY(right), KEY(up), &none, &none, &none, &none \
}

// Alt+Win
#define AW(code) { Qt::Key_##code, 0, 0, Qt::AltModifier | Qt::MetaModifier, Qt::AltModifier | Qt::ControlModifier | Qt::MetaModifier | Qt::ShiftModifier, QStringLiteral(#code) }
// Ctrl+Win
#define CW(code) { Qt::Key_##code, 0, 0, Qt::ControlModifier | Qt::MetaModifier, Qt::AltModifier | Qt::ControlModifier | Qt::MetaModifier | Qt::ShiftModifier, QStringLiteral(#code) }
// Alt+Ctrl+Win
#define ACW(code) { Qt::Key_##code, 0, 0, Qt::AltModifier | Qt::ControlModifier | Qt::MetaModifier, Qt::AltModifier | Qt::ControlModifier | Qt::MetaModifier | Qt::ShiftModifier, QStringLiteral(#code) }
// Alt+Win+Shift
#define AWS(code) { Qt::Key_##code, 0, 0, Qt::AltModifier | Qt::MetaModifier | Qt::ShiftModifier, Qt::AltModifier | Qt::ControlModifier | Qt::MetaModifier | Qt::ShiftModifier, QStringLiteral(#code) }
// Ctrl+Win+Shift
#define CWS(code) { Qt::Key_##code, 0, 0, Qt::ControlModifier | Qt::MetaModifier | Qt::ShiftModifier, Qt::AltModifier | Qt::ControlModifier | Qt::MetaModifier | Qt::ShiftModifier, QStringLiteral(#code) }
// Alt+Ctrl+Win+Shift
#define ACWS(code) { Qt::Key_##code, 0, 0, Qt::AltModifier | Qt::ControlModifier | Qt::MetaModifier | Qt::ShiftModifier, Qt::AltModifier | Qt::ControlModifier | Qt::MetaModifier | Qt::ShiftModifier, QStringLiteral(#code) }

//This applies the final key to calc conversion for the following macros
#define HK(code, nativeCode, nativeMask, modifier, mask) { Qt::Key_##code, nativeCode, nativeMask, Qt::modifier##Modifier, Qt::mask##Modifier, QStringLiteral(#code) }
// NoRMal ignores modifiers
#define NRM(code) HK(code, 0, 0, No, No)
//NATive supports distinguishing what would otherwise be identical keys like left and right shift
#define NAT(code, nativeCode, nativeMask) HK(code, nativeCode, nativeMask, No, No)
//MODifiers supports checking a single modifier for being pressed (Shift, Shift) or not being pressed (No, Shift)
#define MOD(code, modifier, mask) HK(code, 0, 0, modifier, mask)

//Note:
//{ <key> , <key2> , none}
//This is an OR statement. Valid if <key> OR <key2> is pressed.

static HostKey none = { Qt::Key(0), 0, 0, Qt::NoModifier, Qt::NoModifier, {} };

// ------------
Expand Down Expand Up @@ -285,6 +305,75 @@ const KEYMAP(_83pce);
const KEYMAP(_84pce);
#undef KEY

// ------------
// SmartPad section
// ------------
#define KEY(key) smartpad_k##key

static const HostKey KEY(enter)[] = { NRM(Enter), NRM(Return), none };
static const HostKey KEY(2nd)[] = { CW(F6), none };
static const HostKey KEY(alpha)[] = { CW(F7), none };
static const HostKey KEY(sto)[] = { ACW(F4), none };
static const HostKey KEY(clr)[] = { CWS(F9), none };
static const HostKey KEY(del)[] = { ACWS(F4), none };

static const HostKey KEY(math)[] = { CW(F8), none };
static const HostKey KEY(apps)[] = { ACW(F8), none };
static const HostKey KEY(prgm)[] = { ACWS(F6), none };
static const HostKey KEY(vars)[] = { CWS(F2), none };
static const HostKey KEY(stat)[] = { ACWS(F5), none };
static const HostKey KEY(mode)[] = { ACW(F6), none };
static const HostKey KEY(xton)[] = { ACW(F7), none };

static const HostKey KEY(neg)[] = { CWS(F8), none };
static const HostKey KEY(add)[] = { CW(Plus), none };
static const HostKey KEY(sub)[] = { CW(Minus), none };
static const HostKey KEY(mul)[] = { CW(Asterisk), none };
static const HostKey KEY(div)[] = { CW(Slash), none };
static const HostKey KEY(pow)[] = { CWS(F11), none };

static const HostKey KEY(sq)[] = { ACW(F1), none };
static const HostKey KEY(inv)[] = { CW(F9), none };
static const HostKey KEY(ln)[] = { ACW(F3), none };
static const HostKey KEY(log)[] = { ACW(F2), none };
static const HostKey KEY(sin)[] = { ACW(F9), none };
static const HostKey KEY(cos)[] = { ACWS(F7), none };
static const HostKey KEY(tan)[] = { CWS(F3), none };

static const HostKey KEY(down)[] = { AWS(Down), none };
static const HostKey KEY(left)[] = { AWS(Left), none };
static const HostKey KEY(right)[] = { AWS(Right), none };
static const HostKey KEY(up)[] = { AWS(Up), none };

static const HostKey KEY(0)[] = { ACWS(F3), none };
static const HostKey KEY(1)[] = { ACWS(F2), none };
static const HostKey KEY(2)[] = { ACWS(F11), none };
static const HostKey KEY(3)[] = { CWS(F7), none };
static const HostKey KEY(4)[] = { ACWS(F1), none };
static const HostKey KEY(5)[] = { ACWS(F10), none };
static const HostKey KEY(6)[] = { CWS(F6), none };
static const HostKey KEY(7)[] = { ACW(F11), none };
static const HostKey KEY(8)[] = { ACWS(F9), none };
static const HostKey KEY(9)[] = { CWS(F5), none };

static const HostKey KEY(dot)[] ={ CWS(F1), none };
static const HostKey KEY(comma)[] = { ACW(F10), none };
static const HostKey KEY(lpar)[] = { ACWS(F8), none };
static const HostKey KEY(rpar)[] = { CWS(F4), none };

static const HostKey KEY(yequ)[] = { CW(F1) , none };
static const HostKey KEY(wind)[] = { CW(F2) , none };
static const HostKey KEY(zoom)[] = { CW(F3), none };
static const HostKey KEY(trace)[] = { CW(T), none };
static const HostKey KEY(graph)[] = { CW(F5), none };
static const HostKey KEY(on)[] = { ACW(F5), none };

const KEYMAP(_83pce);
const KEYMAP(_84pce);
#undef KEY



// ----------------
// custom section
// ----------------
Expand Down
2 changes: 2 additions & 0 deletions gui/qt/keypad/keymap.h
Expand Up @@ -14,11 +14,13 @@ extern const HostKey *const cemu_keymap_83pce[8*8];
extern const HostKey *const tilem_keymap_83pce[8*8];
extern const HostKey *const wabbitemu_keymap_83pce[8*8];
extern const HostKey *const jstified_keymap_83pce[8*8];
extern const HostKey *const smartpad_keymap_83pce[8*8];

extern const HostKey *const cemu_keymap_84pce[8*8];
extern const HostKey *const tilem_keymap_84pce[8*8];
extern const HostKey *const wabbitemu_keymap_84pce[8*8];
extern const HostKey *const jstified_keymap_84pce[8*8];
extern const HostKey *const smartpad_keymap_84pce[8*8];

extern HostKey *const custom_keymap[8*8];

Expand Down
3 changes: 3 additions & 0 deletions gui/qt/keypad/qtkeypadbridge.cpp
Expand Up @@ -39,6 +39,9 @@ bool QtKeypadBridge::setKeymap(KeymapMode map) {
case KEYMAP_JSTIFIED:
keymap = get_device_type() == TI84PCE ? jstified_keymap_84pce : jstified_keymap_83pce;
break;
case KEYMAP_SMARTPAD:
keymap = get_device_type() == TI84PCE ? smartpad_keymap_84pce : smartpad_keymap_83pce;
break;
case KEYMAP_CUSTOM:
keymap = custom_keymap;
break;
Expand Down
1 change: 1 addition & 0 deletions gui/qt/keypad/qtkeypadbridge.h
Expand Up @@ -21,6 +21,7 @@ class QtKeypadBridge : public QObject {
KEYMAP_TILEM,
KEYMAP_WABBITEMU,
KEYMAP_JSTIFIED,
KEYMAP_SMARTPAD,
KEYMAP_CUSTOM,
} KeymapMode;

Expand Down
1 change: 1 addition & 0 deletions gui/qt/mainwindow.cpp
Expand Up @@ -420,6 +420,7 @@ MainWindow::MainWindow(CEmuOpts &cliOpts, QWidget *p) : QMainWindow(p), ui(new U
connect(ui->radioTilEmKeys, &QRadioButton::clicked, this, &MainWindow::keymapChanged);
connect(ui->radioWabbitemuKeys, &QRadioButton::clicked, this, &MainWindow::keymapChanged);
connect(ui->radiojsTIfiedKeys, &QRadioButton::clicked, this, &MainWindow::keymapChanged);
connect(ui->radioSmartPadKeys, &QRadioButton::clicked, this, &MainWindow::keymapChanged);
connect(ui->radioCustomKeys, &QRadioButton::clicked, this, &MainWindow::keymapCustomSelected);

// keypad
Expand Down
1 change: 1 addition & 0 deletions gui/qt/mainwindow.h
Expand Up @@ -717,6 +717,7 @@ class MainWindow : public QMainWindow {
static const QString SETTING_KEYPAD_TILEM;
static const QString SETTING_KEYPAD_WABBITEMU;
static const QString SETTING_KEYPAD_JSTIFIED;
static const QString SETTING_KEYPAD_SMARTPAD;
static const QString SETTING_KEYPAD_CUSTOM;
static const QString SETTING_KEYPAD_CUSTOM_PATH;

Expand Down
78 changes: 44 additions & 34 deletions gui/qt/mainwindow.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1004</width>
<width>1050</width>
<height>1005</height>
</rect>
</property>
Expand Down Expand Up @@ -4212,15 +4212,15 @@
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>70</number>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
Expand Down Expand Up @@ -4363,15 +4363,15 @@
<property name="cornerButtonEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>70</number>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
Expand Down Expand Up @@ -4521,15 +4521,15 @@
<property name="cornerButtonEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>70</number>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
Expand Down Expand Up @@ -4659,15 +4659,15 @@
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>40</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>100</number>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>40</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
Expand Down Expand Up @@ -4784,15 +4784,15 @@
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>40</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>100</number>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>40</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
Expand Down Expand Up @@ -4940,15 +4940,15 @@
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>40</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>100</number>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>40</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
Expand Down Expand Up @@ -5050,15 +5050,15 @@
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>40</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>100</number>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>40</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
Expand Down Expand Up @@ -6316,7 +6316,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<property name="elideMode">
<enum>Qt::ElideLeft</enum>
Expand Down Expand Up @@ -6499,15 +6499,15 @@
<property name="wordWrap">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>40</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>100</number>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>40</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
Expand Down Expand Up @@ -6612,12 +6612,12 @@
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>70</number>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>70</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
Expand Down Expand Up @@ -8629,6 +8629,16 @@ QPushButton:pressed {
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioSmartPadKeys">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>SmartPad</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioCustomKeys">
<property name="sizePolicy">
Expand Down Expand Up @@ -9495,15 +9505,15 @@ QPushButton:pressed {
<property name="cornerButtonEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>70</number>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
Expand Down Expand Up @@ -9650,8 +9660,8 @@ QPushButton:pressed {
<rect>
<x>0</x>
<y>0</y>
<width>1004</width>
<height>22</height>
<width>1050</width>
<height>21</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down