Skip to content

Commit

Permalink
Loading halfway thru
Browse files Browse the repository at this point in the history
  • Loading branch information
manugupt1 committed Jul 7, 2011
1 parent 2f2b852 commit 818de2e
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 10 deletions.
110 changes: 100 additions & 10 deletions src/mouse.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,26 @@ class Mouse{
string InvX;
string InvY;
string AngleOffset;
string Emulate3Buttons;
string Emulate3Timeout;
string ChordMiddle;
string EmulateWheel;
string EmulateWheelTimeout;
int Emulate3Buttons;
int Emulate3Timeout;
int EmulateWheel;
int EmulateWheelTimeout;
public:
void setProduct(string);
void setVendor(string);
void setName(string);
void setDevice(string);
void setEmulate3Buttons(string);
void setEmulateWheel(string);
void setEmulate3(int);
void setEmulate3Timeout(int);
void setEmulateWheel(int);
void setEmulateWheelTimeout(int);
string getName();
string getVendor();
string getProduct();
int getEmulate3();
int getEmulate3Timeout();
int getEmulateWheel();
int getEmulateWheelTimeout();
Details();
};

Expand All @@ -62,6 +67,8 @@ class Mouse{
void getName();
void fillUpMouseList();
bool writeConf(string &line,bool newNode,string parameter,bool isLastParameter,string extraParam,string value);
void loadState();
void saveState();
public:
void autodetect();
void initUI();
Expand All @@ -70,6 +77,38 @@ class Mouse{
Mouse();
};

void Mouse::Details::setEmulateWheel(int v){
EmulateWheel = v;
}

int Mouse::Details::getEmulateWheel(){
return EmulateWheelTimeout;
}

void Mouse::Details::setEmulateWheelTimeout(int v){
EmulateWheelTimeout = v;
}

int Mouse::Details::getEmulateWheelTimeout(){
return EmulateWheelTimeout;
}

void Mouse::Details::setEmulate3(int v){
Emulate3Buttons = v;
}

int Mouse::Details::getEmulate3(){
return Emulate3Buttons;
}

void Mouse::Details::setEmulate3Timeout(int v){
Emulate3Timeout = v;
}

int Mouse::Details::getEmulate3Timeout(){
return Emulate3Timeout;
}

string Mouse::Details::getProduct(){
return product;
}
Expand Down Expand Up @@ -97,6 +136,7 @@ void Mouse::Details::setVendor(string v){

void Mouse::Details::setName(string n){
name = n;
Emulate3Buttons = 0;
}

void Mouse::Details::setDevice(string d){
Expand All @@ -107,6 +147,41 @@ Mouse::Details::Details(){
protocol = "Auto";
}

void Mouse::loadState(){
int i;
for(i=0;i<d.size();i++)
if(d[i]->getName()==mouseList->value())
break;
int b3 = d[i]->getEmulate3();
if(b3==0){
button3->setValue(0,0);
button3->setValue(1,1);
timeout->setDisabled();
}else{
button3->setValue(1,0);
button3->setValue(0,1);
timeout->setEnabled();
}
}

void Mouse::saveState(){
int i;
for(i=0;i<d.size();i++)
if(d[i]->getName()==mouseList->value())
break;
string b3 = button3->selectedLabel();

b3 = b3.erase(b3.find('&'),b3.find('&')+1);
cout<<b3<<endl;
if(!b3.compare("Yes")){
d[i]->setEmulate3(1);
}else{
d[i]->setEmulate3(0);
}
d[i]->setEmulate3Timeout(timeout->value());


}
void Mouse::getProductVendor(){
string pv = line.substr(line.find_first_of('/')+1,line.find_last_of('/'));
string v = pv.substr(0,pv.find_first_of('/'));
Expand Down Expand Up @@ -154,23 +229,22 @@ void Mouse::initUI(){
hl1 = factory->createHLayout(vl1);

mouseList = factory->createComboBox(vl1,"Auto Detected Mouse");
mouseList->addItem("Generic Mouse");
fillUpMouseList();
button3Label = factory->createLabel(vl1,"3 button Emulation Options");
enableButton3Layout = factory->createHLayout(vl1);
enableButton3Label = factory->createLabel(enableButton3Layout,"Enable 3 Buttons");
button3 = factory->createRadioButtonGroup(enableButton3Layout);
button3->addButton("Yes");
button3->addButton("No");
timeout = factory->createIntField(vl1,"3 Button Timeout Time",0,1000,50);
timeout = factory->createIntField(vl1,"3 Button Timeout",0,1000,50);
timeout->setDisabled();
wheelLabel = factory->createLabel(vl1,"Wheel Emulation Options");
enableWheelLayout = factory->createHLayout(vl1);
enableWheelLabel = factory->createLabel(enableWheelLayout,"Enable Wheel Emulation");
wheel = factory->createRadioButtonGroup(enableWheelLayout);
wheel->addButton("Yes");
wheel->addButton("No");
wheeltimeout = factory->createIntField(vl1,"3 Button Timeout Time",0,1000,200);
wheeltimeout = factory->createIntField(vl1,"Wheel Button Timeout",0,1000,200);
wheeltimeout->setDisabled();
InvX = factory->createCheckBox(vl1,"Invert X Axis",false);
InvY = factory->createCheckBox(vl1,"Invert Y Axis",false);
Expand Down Expand Up @@ -210,6 +284,22 @@ bool Mouse::respondToEvent(){
if(okButton->getElement()==dialog->eventWidget()){
saveConf();
}
if(button3->isButton(0,dialog->eventWidget())){
timeout->setEnabled();
}
if(button3->isButton(1,dialog->eventWidget())){
timeout->setDisabled();
}
if(wheel->isButton(0,dialog->eventWidget())){
wheeltimeout->setEnabled();
}
if(wheel->isButton(1,dialog->eventWidget())){
wheeltimeout->setDisabled();
}
if(mouseList->getElement()==dialog->eventWidget()){
loadState();
}
saveState();
};
return true;
}
Expand Down
9 changes: 9 additions & 0 deletions src/ui/yui.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,15 @@ namespace UI{
string yRadioButtonGroup::selectedLabel(){
return group->currentButton()->label();
}
bool yRadioButtonGroup::isButton(int index,YWidget* w){
if(w==buttonList[index])
return true;
else
return false;
}
void yRadioButtonGroup::setValue(int index,int value){
buttonList[index]->setValue(value);
}

yIntField::yIntField(yDialog* parent,string text,int min,int max,int value){
field = YUI::widgetFactory()->createIntField(parent->getElement(),text,min,max,value);
Expand Down
2 changes: 2 additions & 0 deletions src/ui/yui.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ namespace UI{
yRadioButtonGroup(yVLayout*);
string selectedLabel();
void addButton(std::string);
bool isButton(int,YWidget*);
void setValue(int,int);
};

//YINTFIELD
Expand Down

0 comments on commit 818de2e

Please sign in to comment.