add the mouse absolute coordinate option
This commit is contained in:
@ -414,7 +414,7 @@ void Axis::move( bool press ) {
|
||||
//if not gradient, always go full speed.
|
||||
else dist = maxSpeed;
|
||||
|
||||
e.type = FakeEvent::MouseMove;
|
||||
e.type = absolute ? FakeEvent::MouseMoveAbsolute : FakeEvent::MouseMove;
|
||||
if (mode == MousePosVert) {
|
||||
e.move.x = 0;
|
||||
e.move.y = dist;
|
||||
|
@ -22,6 +22,7 @@ class Axis : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
//each axis can create a key press or move the mouse in one of four directions.
|
||||
enum Interpretation { ZeroOne, Gradient, Absolute };
|
||||
enum Mode {Keyboard, MousePosVert, MouseNegVert, MousePosHor, MouseNegHor};
|
||||
enum TransferCurve {Linear, Quadratic, Cubic, QuadraticExtreme,
|
||||
PowerFunction};
|
||||
@ -76,7 +77,9 @@ class Axis : public QObject {
|
||||
float inverseRange;
|
||||
|
||||
//actual axis settings:
|
||||
Interpretation interpretation;
|
||||
bool gradient;
|
||||
bool absolute;
|
||||
int maxSpeed; //0..MAXMOUSESPEED
|
||||
unsigned int transferCurve;
|
||||
float sensitivity;
|
||||
|
@ -23,9 +23,12 @@ AxisEdit::AxisEdit( Axis* ax )
|
||||
QVBoxLayout* v2 = new QVBoxLayout();
|
||||
v2->setMargin(5);
|
||||
v2->setSpacing(5);
|
||||
chkGradient = new QCheckBox(tr("&Gradient"), this);
|
||||
chkGradient->setChecked(axis->gradient);
|
||||
connect(chkGradient, SIGNAL(toggled(bool)), this, SLOT( gradientChanged( bool )));
|
||||
chkGradient = new QComboBox(this);
|
||||
chkGradient->insertItem((int) Axis::ZeroOne, tr("Use 0 or max always"), Qt::DisplayRole);
|
||||
chkGradient->insertItem((int) Axis::Gradient, tr("Relative movement (previously gradient)"), Qt::DisplayRole);
|
||||
chkGradient->insertItem((int) Axis::Absolute, tr("Absolute movement (direct position)"), Qt::DisplayRole);
|
||||
chkGradient->setCurrentIndex( axis->interpretation );
|
||||
connect(chkGradient, SIGNAL(activated(int)), this, SLOT( gradientChanged( int )));
|
||||
v2->addWidget(chkGradient);
|
||||
|
||||
cmbMode = new QComboBox(this);
|
||||
@ -103,6 +106,7 @@ AxisEdit::AxisEdit( Axis* ax )
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
v->addWidget(buttonBox);
|
||||
|
||||
gradientChanged( axis->interpretation );
|
||||
modeChanged( axis->mode );
|
||||
transferCurveChanged( axis->transferCurve );
|
||||
throttleChanged( axis->throttle + 1 );
|
||||
@ -116,9 +120,10 @@ void AxisEdit::show() {
|
||||
void AxisEdit::setState( int val ) {
|
||||
slider->setValue( val );
|
||||
}
|
||||
void AxisEdit::gradientChanged( bool on ) {
|
||||
cmbTransferCurve->setEnabled(on);
|
||||
if (on) {
|
||||
void AxisEdit::gradientChanged( int index ) {
|
||||
bool gradient = index != Axis::ZeroOne;
|
||||
cmbTransferCurve->setEnabled(gradient);
|
||||
if (gradient) {
|
||||
transferCurveChanged( axis->transferCurve );
|
||||
}
|
||||
else {
|
||||
@ -135,7 +140,7 @@ void AxisEdit::modeChanged( int index ) {
|
||||
else {
|
||||
mouseBox->setEnabled(true);
|
||||
keyBox->setEnabled(false);
|
||||
if (chkGradient->isChecked()) {
|
||||
if ((Axis::Interpretation)chkGradient->currentIndex() != Axis::ZeroOne) {
|
||||
cmbTransferCurve->setEnabled(true);
|
||||
transferCurveChanged( axis->transferCurve );
|
||||
}
|
||||
@ -172,7 +177,9 @@ void AxisEdit::throttleChanged( int index ) {
|
||||
}
|
||||
|
||||
void AxisEdit::accept() {
|
||||
axis->gradient = chkGradient->isChecked();
|
||||
axis->interpretation = (Axis::Interpretation)chkGradient->currentIndex();
|
||||
axis->gradient = axis->interpretation != Axis::ZeroOne;
|
||||
axis->absolute = axis->interpretation == Axis::Absolute;
|
||||
axis->maxSpeed = spinSpeed->value();
|
||||
axis->transferCurve = (Axis::TransferCurve)cmbTransferCurve->currentIndex();
|
||||
axis->sensitivity = spinSensitivity->value();
|
||||
|
@ -24,7 +24,7 @@ class AxisEdit : public QDialog {
|
||||
void setState( int val );
|
||||
protected slots:
|
||||
//slots for GUI events
|
||||
void gradientChanged( bool on );
|
||||
void gradientChanged( int index );
|
||||
void modeChanged( int index );
|
||||
void transferCurveChanged( int index );
|
||||
void throttleChanged( int index );
|
||||
@ -33,8 +33,7 @@ class AxisEdit : public QDialog {
|
||||
//the associated Axis that needs to be set.
|
||||
Axis *axis;
|
||||
//the important parts of the dialog:
|
||||
QCheckBox *chkGradient;
|
||||
QComboBox *cmbMode, *cmbThrottle, *cmbTransferCurve;
|
||||
QComboBox *chkGradient, *cmbMode, *cmbThrottle, *cmbTransferCurve;
|
||||
QFrame *mouseBox, *keyBox;
|
||||
QSpinBox *spinSpeed;
|
||||
QLabel *lblSensitivity;
|
||||
|
@ -11,6 +11,19 @@ void sendevent(const FakeEvent &e) {
|
||||
XTestFakeRelativeMotionEvent(display, e.move.x, e.move.y, 0);
|
||||
break;
|
||||
|
||||
case FakeEvent::MouseMoveAbsolute:
|
||||
{
|
||||
Screen* screen = XDefaultScreenOfDisplay(display);
|
||||
static int rememberX = 0, rememberY = 0;
|
||||
if (e.move.x) rememberX = e.move.x;
|
||||
if (e.move.y) rememberY = e.move.y;
|
||||
const int scaledX100 = rememberX * (XWidthOfScreen(screen)/2) / 100;
|
||||
const int scaledY100 = rememberY * (XHeightOfScreen(screen)/2) / 100;
|
||||
XTestFakeMotionEvent(display, DefaultScreen(display),
|
||||
XWidthOfScreen(screen)/2 + scaledX100,
|
||||
XHeightOfScreen(screen)/2 + scaledY100, 0);
|
||||
break;
|
||||
}
|
||||
case FakeEvent::KeyUp:
|
||||
if (e.keycode == 0) return;
|
||||
XTestFakeKeyEvent(display, e.keycode, false, 0);
|
||||
|
@ -8,7 +8,7 @@
|
||||
struct FakeEvent {
|
||||
//types of events QJoyPad can create.
|
||||
//KeyRelease, KeyPress, ButtonRelease, ButtonPress, and MouseMove
|
||||
enum EventType {KeyUp, KeyDown, MouseUp, MouseDown, MouseMove};
|
||||
enum EventType {KeyUp, KeyDown, MouseUp, MouseDown, MouseMove, MouseMoveAbsolute};
|
||||
|
||||
EventType type;
|
||||
union {
|
||||
|
Reference in New Issue
Block a user