finishing up repo migration

git-svn-id: svn://svn.code.sf.net/p/qjoypad/code/trunk@80 c05e91a0-76c8-4ec0-b377-ef19ce7cc080
This commit is contained in:
John Toman
2009-05-26 00:45:05 +00:00
committed by virtuoussin13
commit 1cc6e9087e
59 changed files with 6563 additions and 0 deletions

57
src/quickset.cpp Normal file
View File

@ -0,0 +1,57 @@
#include "quickset.h"
#include "getkey.h"
//build the dialog
QuickSet::QuickSet( JoyPad* jp)
: QDialog() {
setting = false;
joypad = jp;
setWindowTitle("Set " + jp->getName());
QVBoxLayout* LMain = new QVBoxLayout(this);
LMain->setMargin(5);
LMain->setSpacing(5);
//LMain->setAutoAdd(true);
new QLabel("Press any button or axis and\nyou will be prompted for a key.",this);
QPushButton* button = new QPushButton("Done",this);
connect( button, SIGNAL(clicked()), this, SLOT(accept()));
}
void QuickSet::jsevent( js_event msg ) {
//ignore any joystick events if we're waiting for a keypress
if (setting) return;
//if a button was pressed on the joystick
if (msg.type == JS_EVENT_BUTTON) {
//capture that button.
Button* button = joypad->Buttons[msg.number];
//go into setting mode and request a key/mousebutton
setting = true;
int code = GetKey(button->getName(), true).exec();
setting = false;
//if a mouse button was used,
if (code > MOUSE_OFFSET)
//then tell it to the Button a mouse button
button->setKey(true, code - MOUSE_OFFSET);
else
//otherwise, tell it to use a keycode.
button->setKey(false, code);
}
else {
//require a signal strength of at least 5000 to consider an axis moved.
if (abs(msg.value) < 5000) return;
//capture the axis that moved
Axis* axis = joypad->Axes[msg.number];
//grab a keycode for that axis and that direction
setting = true;
int code = GetKey(axis->getName() + ", " + QString((msg.value > 0)?"positive":"negative"), false).exec();
setting = false;
//assign the key to the axis.
axis->setKey((msg.value > 0),code);
}
}