kopia lustrzana https://github.com/FreeSpacenav/spnavcfg
implemented keymapping, untested
rodzic
a437474d6e
commit
8bf1e25e6e
|
@ -18,7 +18,7 @@ incdir = -I.
|
|||
CFLAGS = $(warn) $(dbg) $(opt) $(incdir) -fPIC $(add_cflags) -MMD
|
||||
CXXFLAGS = $(warn) $(dbg) $(opt) $(incdir) -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets` \
|
||||
$(add_cflags) -MMD
|
||||
LDFLAGS = `pkg-config --libs Qt5Core Qt5Gui Qt5Widgets` -lspnav $(add_ldflags)
|
||||
LDFLAGS = `pkg-config --libs Qt5Core Qt5Gui Qt5Widgets` -lspnav -lX11 $(add_ldflags)
|
||||
|
||||
$(bin): $(obj)
|
||||
$(CXX) -o $@ $(obj) $(LDFLAGS)
|
||||
|
|
|
@ -20,6 +20,7 @@ struct config {
|
|||
int dead_thres[MAX_AXES];
|
||||
int map_bn[MAX_BUTTONS];
|
||||
int bnact[MAX_BUTTONS];
|
||||
int kbmap[MAX_BUTTONS];
|
||||
int led, grab;
|
||||
int repeat;
|
||||
char *serdev;
|
||||
|
|
49
src/ui.cc
49
src/ui.cc
|
@ -8,6 +8,8 @@
|
|||
#include "ui_bnmaprow.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
static QSlider *slider_sens_axis[6];
|
||||
static QCheckBox *chk_inv[6];
|
||||
static QComboBox *combo_axismap[6];
|
||||
|
@ -250,6 +252,7 @@ void MainWin::updateui()
|
|||
connect(bnrow[i].rad_action, SIGNAL(toggled(bool)), this, SLOT(rad_changed(bool)));
|
||||
connect(bnrow[i].cmb_action, SIGNAL(currentIndexChanged(int)), this, SLOT(combo_idx_changed(int)));
|
||||
connect(bnrow[i].rad_mapkey, SIGNAL(toggled(bool)), this, SLOT(rad_changed(bool)));
|
||||
connect(bnrow[i].cmb_mapkey, SIGNAL(currentTextChanged(const QString&)), this, SLOT(combo_str_changed(const QString&)));
|
||||
}
|
||||
|
||||
mask_events = false;
|
||||
|
@ -467,13 +470,12 @@ void MainWin::rad_changed(bool active)
|
|||
return;
|
||||
}
|
||||
if(src == bnrow[i].rad_mapkey) {
|
||||
// TODO
|
||||
if(active) {
|
||||
static bool warned;
|
||||
if(!warned) {
|
||||
errorbox("Sorry, Keyboard mapping from the UI not implemented yet.");
|
||||
warned = true;
|
||||
if(cfg.kbmap[i]) {
|
||||
spnav_cfg_set_kbmap(i, cfg.kbmap[i]);
|
||||
}
|
||||
} else {
|
||||
spnav_cfg_set_kbmap(i, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -542,6 +544,31 @@ void MainWin::combo_idx_changed(int sel)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWin::combo_str_changed(const QString &qstr)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
if(mask_events) return;
|
||||
|
||||
QObject *src = QObject::sender();
|
||||
for(int i=0; i<bnrow_count; i++) {
|
||||
if(src == bnrow[i].cmb_mapkey) {
|
||||
str = qstr.toLatin1().data();
|
||||
if(!str || !*str) return;
|
||||
|
||||
KeySym sym = XStringToKeysym(str);
|
||||
if(sym == NoSymbol) {
|
||||
errorboxf("Unknown keysym: \"%s\"", str);
|
||||
return;
|
||||
}
|
||||
|
||||
cfg.kbmap[i] = sym;
|
||||
spnav_cfg_set_kbmap(i, cfg.kbmap[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWin::serpath_changed()
|
||||
{
|
||||
free(cfg.serdev);
|
||||
|
@ -562,3 +589,15 @@ extern "C" void errorbox(const char *msg)
|
|||
{
|
||||
QMessageBox::critical(mainwin, "Error", msg, QMessageBox::Ok);
|
||||
}
|
||||
|
||||
extern "C" void errorboxf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
static char buf[512];
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof buf, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
errorbox(buf);
|
||||
}
|
||||
|
|
2
src/ui.h
2
src/ui.h
|
@ -31,6 +31,7 @@ public slots:
|
|||
void chk_changed(int checked);
|
||||
void rad_changed(bool active);
|
||||
void combo_idx_changed(int sel);
|
||||
void combo_str_changed(const QString &qstr);
|
||||
void serpath_changed();
|
||||
};
|
||||
|
||||
|
@ -41,6 +42,7 @@ extern "C" {
|
|||
|
||||
void update_ui(void);
|
||||
void errorbox(const char *msg);
|
||||
void errorboxf(const char *fmt, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue