mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-23 04:45:54 +02:00
Rewrote the whole input system.
Gmenu2X will no longer eat 100% CPU ;)
This commit is contained in:
parent
c6c3dfe8e0
commit
563cb34a89
@ -68,26 +68,40 @@ bool BrowseDialog::exec()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowseDialog::Action BrowseDialog::getAction()
|
BrowseDialog::Action BrowseDialog::getAction(bevent_t *event)
|
||||||
{
|
{
|
||||||
BrowseDialog::Action action = BrowseDialog::ACT_NONE;
|
BrowseDialog::Action action;
|
||||||
|
|
||||||
if (gmenu2x->input[ACTION_SELECT])
|
switch(event->button) {
|
||||||
action = BrowseDialog::ACT_CLOSE;
|
case MENU:
|
||||||
else if (gmenu2x->input[ACTION_UP])
|
action = BrowseDialog::ACT_CLOSE;
|
||||||
action = BrowseDialog::ACT_UP;
|
break;
|
||||||
else if (gmenu2x->input[ACTION_L])
|
case UP:
|
||||||
action = BrowseDialog::ACT_SCROLLUP;
|
action = BrowseDialog::ACT_UP;
|
||||||
else if (gmenu2x->input[ACTION_DOWN])
|
break;
|
||||||
action = BrowseDialog::ACT_DOWN;
|
case DOWN:
|
||||||
else if (gmenu2x->input[ACTION_R])
|
action = BrowseDialog::ACT_DOWN;
|
||||||
action = BrowseDialog::ACT_SCROLLDOWN;
|
break;
|
||||||
else if (gmenu2x->input[ACTION_X] || gmenu2x->input[ACTION_LEFT])
|
case ALTLEFT:
|
||||||
action = BrowseDialog::ACT_GOUP;
|
action = BrowseDialog::ACT_SCROLLUP;
|
||||||
else if (gmenu2x->input[ACTION_B])
|
break;
|
||||||
action = BrowseDialog::ACT_SELECT;
|
case ALTRIGHT:
|
||||||
else if (gmenu2x->input[ACTION_START])
|
action = BrowseDialog::ACT_SCROLLDOWN;
|
||||||
action = BrowseDialog::ACT_CONFIRM;
|
break;
|
||||||
|
case LEFT:
|
||||||
|
case CLEAR:
|
||||||
|
action = BrowseDialog::ACT_GOUP;
|
||||||
|
break;
|
||||||
|
case ACCEPT:
|
||||||
|
action = BrowseDialog::ACT_SELECT;
|
||||||
|
break;
|
||||||
|
case SETTINGS:
|
||||||
|
action = BrowseDialog::ACT_CONFIRM;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
action = BrowseDialog::ACT_NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
@ -95,14 +109,22 @@ BrowseDialog::Action BrowseDialog::getAction()
|
|||||||
void BrowseDialog::handleInput()
|
void BrowseDialog::handleInput()
|
||||||
{
|
{
|
||||||
BrowseDialog::Action action;
|
BrowseDialog::Action action;
|
||||||
|
bevent_t event;
|
||||||
|
|
||||||
gmenu2x->input.update();
|
do {
|
||||||
|
gmenu2x->input.waitForEvent(&event);
|
||||||
|
} while (event.state != PRESSED);
|
||||||
|
|
||||||
|
/*
|
||||||
|
while(!gmenu2x->input.update())
|
||||||
|
usleep(LOOP_DELAY);
|
||||||
|
*/
|
||||||
|
|
||||||
if (ts_pressed && !gmenu2x->ts.pressed()) {
|
if (ts_pressed && !gmenu2x->ts.pressed()) {
|
||||||
action = BrowseDialog::ACT_SELECT;
|
action = BrowseDialog::ACT_SELECT;
|
||||||
ts_pressed = false;
|
ts_pressed = false;
|
||||||
} else {
|
} else {
|
||||||
action = getAction();
|
action = getAction(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gmenu2x->f200 && gmenu2x->ts.pressed() && !gmenu2x->ts.inRect(touchRect)) ts_pressed = false;
|
if (gmenu2x->f200 && gmenu2x->ts.pressed() && !gmenu2x->ts.inRect(touchRect)) ts_pressed = false;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "gmenu2x.h"
|
#include "gmenu2x.h"
|
||||||
#include "buttonbox.h"
|
#include "buttonbox.h"
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
|
#include "inputmanager.h"
|
||||||
|
|
||||||
class FileLister;
|
class FileLister;
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ private:
|
|||||||
|
|
||||||
ButtonBox buttonBox;
|
ButtonBox buttonBox;
|
||||||
|
|
||||||
Action getAction();
|
Action getAction(bevent_t *event);
|
||||||
void handleInput();
|
void handleInput();
|
||||||
|
|
||||||
void paint();
|
void paint();
|
||||||
|
189
src/gmenu2x.cpp
189
src/gmenu2x.cpp
@ -522,9 +522,9 @@ void GMenu2X::viewLog() {
|
|||||||
td.exec();
|
td.exec();
|
||||||
|
|
||||||
MessageBox mb(this, tr["Do you want to delete the log file?"], "icons/ebook.png");
|
MessageBox mb(this, tr["Do you want to delete the log file?"], "icons/ebook.png");
|
||||||
mb.setButton(ACTION_B, tr["Yes"]);
|
mb.setButton(ACCEPT, tr["Yes"]);
|
||||||
mb.setButton(ACTION_X, tr["No"]);
|
mb.setButton(CLEAR, tr["No"]);
|
||||||
if (mb.exec() == ACTION_B) {
|
if (mb.exec() == ACCEPT) {
|
||||||
ledOn();
|
ledOn();
|
||||||
unlink(logfile.c_str());
|
unlink(logfile.c_str());
|
||||||
sync();
|
sync();
|
||||||
@ -865,11 +865,13 @@ void GMenu2X::main() {
|
|||||||
|
|
||||||
drawScrollBar(linkRows,menu->sectionLinks()->size()/linkColumns + ((menu->sectionLinks()->size()%linkColumns==0) ? 0 : 1),menu->firstDispRow(),43,resY-81);
|
drawScrollBar(linkRows,menu->sectionLinks()->size()/linkColumns + ((menu->sectionLinks()->size()%linkColumns==0) ? 0 : 1),menu->firstDispRow(),43,resY-81);
|
||||||
|
|
||||||
|
/*
|
||||||
switch(volumeMode) {
|
switch(volumeMode) {
|
||||||
case VOLUME_MODE_MUTE: sc.skinRes("imgs/mute.png")->blit(s,279,bottomBarIconY); break;
|
case VOLUME_MODE_MUTE: sc.skinRes("imgs/mute.png")->blit(s,279,bottomBarIconY); break;
|
||||||
case VOLUME_MODE_PHONES: sc.skinRes("imgs/phones.png")->blit(s,279,bottomBarIconY); break;
|
case VOLUME_MODE_PHONES: sc.skinRes("imgs/phones.png")->blit(s,279,bottomBarIconY); break;
|
||||||
default: sc.skinRes("imgs/volume.png")->blit(s,279,bottomBarIconY); break;
|
default: sc.skinRes("imgs/volume.png")->blit(s,279,bottomBarIconY); break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (menu->selLink()!=NULL) {
|
if (menu->selLink()!=NULL) {
|
||||||
s->write ( font, menu->selLink()->getDescription(), halfX, resY-19, SFontHAlignCenter, SFontVAlignBottom );
|
s->write ( font, menu->selLink()->getDescription(), halfX, resY-19, SFontHAlignCenter, SFontVAlignBottom );
|
||||||
@ -902,8 +904,6 @@ void GMenu2X::main() {
|
|||||||
//s->write( font, tr[batstr.c_str()], 20, 170 );
|
//s->write( font, tr[batstr.c_str()], 20, 170 );
|
||||||
//On Screen Help
|
//On Screen Help
|
||||||
|
|
||||||
if(input[ACTION_A] )
|
|
||||||
helpDisplayed = ! helpDisplayed;
|
|
||||||
|
|
||||||
if (helpDisplayed) {
|
if (helpDisplayed) {
|
||||||
s->box(10,50,300,143, skinConfColors[COLOR_MESSAGE_BOX_BG]);
|
s->box(10,50,300,143, skinConfColors[COLOR_MESSAGE_BOX_BG]);
|
||||||
@ -965,13 +965,55 @@ void GMenu2X::main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//#ifdef TARGET_GP2X
|
//#ifdef TARGET_GP2X
|
||||||
|
|
||||||
|
switch (input.waitForPressedButton()) {
|
||||||
|
case ACCEPT:
|
||||||
|
if (menu->selLink() != NULL) menu->selLink()->run();
|
||||||
|
break;
|
||||||
|
case CANCEL:
|
||||||
|
helpDisplayed = ! helpDisplayed;
|
||||||
|
break;
|
||||||
|
case SETTINGS:
|
||||||
|
options();
|
||||||
|
break;
|
||||||
|
case MENU:
|
||||||
|
contextMenu();
|
||||||
|
break;
|
||||||
|
case UP:
|
||||||
|
menu->linkUp();
|
||||||
|
break;
|
||||||
|
case DOWN:
|
||||||
|
menu->linkDown();
|
||||||
|
break;
|
||||||
|
case LEFT:
|
||||||
|
menu->linkLeft();
|
||||||
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
menu->linkRight();
|
||||||
|
break;
|
||||||
|
case MANUAL:
|
||||||
|
menu->selLinkApp()->showManual();
|
||||||
|
break;
|
||||||
|
case ALTLEFT:
|
||||||
|
menu->decSectionIndex();
|
||||||
|
offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6;
|
||||||
|
break;
|
||||||
|
case ALTRIGHT:
|
||||||
|
menu->incSectionIndex();
|
||||||
|
offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
while (!input.update())
|
while (!input.update())
|
||||||
usleep(LOOP_DELAY);
|
usleep(LOOP_DELAY);
|
||||||
if ( input[ACTION_B] && menu->selLink()!=NULL ) menu->selLink()->run();
|
if ( input[ACCEPT] && menu->selLink()!=NULL ) menu->selLink()->run();
|
||||||
else if ( input[ACTION_START] ) options();
|
else if ( input[SETTINGS] ) options();
|
||||||
else if ( input[ACTION_SELECT] ) contextMenu();
|
else if ( input[MENU] ) contextMenu();
|
||||||
// VOLUME SCALE MODIFIER
|
// VOLUME SCALE MODIFIER
|
||||||
else if ( fwType=="open2x" && input[ACTION_X] ) {
|
else if ( fwType=="open2x" && input[CLEAR] ) {
|
||||||
volumeMode = constrain(volumeMode-1, -VOLUME_MODE_MUTE-1, VOLUME_MODE_NORMAL);
|
volumeMode = constrain(volumeMode-1, -VOLUME_MODE_MUTE-1, VOLUME_MODE_NORMAL);
|
||||||
if(volumeMode < VOLUME_MODE_MUTE)
|
if(volumeMode < VOLUME_MODE_MUTE)
|
||||||
volumeMode = VOLUME_MODE_NORMAL;
|
volumeMode = VOLUME_MODE_NORMAL;
|
||||||
@ -983,42 +1025,43 @@ void GMenu2X::main() {
|
|||||||
setVolume(confInt["globalVolume"]);
|
setVolume(confInt["globalVolume"]);
|
||||||
}
|
}
|
||||||
// LINK NAVIGATION
|
// LINK NAVIGATION
|
||||||
else if ( input[ACTION_LEFT ] ) menu->linkLeft();
|
else if ( input[ALTLEFTEFT ] ) menu->linkLeft();
|
||||||
else if ( input[ACTION_RIGHT] ) menu->linkRight();
|
else if ( input[ALTRIGHTIGHT] ) menu->linkRight();
|
||||||
else if ( input[ACTION_UP ] ) menu->linkUp();
|
else if ( input[UP ] ) menu->linkUp();
|
||||||
else if ( input[ACTION_DOWN ] ) menu->linkDown();
|
else if ( input[DOWN ] ) menu->linkDown();
|
||||||
// SELLINKAPP SELECTED
|
// SELLINKAPP SELECTED
|
||||||
else if (menu->selLinkApp()!=NULL) {
|
else if (menu->selLinkApp()!=NULL) {
|
||||||
if ( input[ACTION_Y] ) menu->selLinkApp()->showManual();
|
if ( input[MANUAL] ) menu->selLinkApp()->showManual();
|
||||||
else if ( input.isActive(ACTION_A) ) {
|
else if ( input.isActive(CANCEL) ) {
|
||||||
// VOLUME
|
// VOLUME
|
||||||
if ( input[ACTION_VOLDOWN] && !input.isActive(ACTION_VOLUP) )
|
if ( input[VOLDOWN] && !input.isActive(VOLUP) )
|
||||||
menu->selLinkApp()->setVolume( constrain(menu->selLinkApp()->volume()-1,0,100) );
|
menu->selLinkApp()->setVolume( constrain(menu->selLinkApp()->volume()-1,0,100) );
|
||||||
if ( input[ACTION_VOLUP] && !input.isActive(ACTION_VOLDOWN) )
|
if ( input[VOLUP] && !input.isActive(VOLDOWN) )
|
||||||
menu->selLinkApp()->setVolume( constrain(menu->selLinkApp()->volume()+1,0,100) );;
|
menu->selLinkApp()->setVolume( constrain(menu->selLinkApp()->volume()+1,0,100) );;
|
||||||
if ( input.isActive(ACTION_VOLUP) && input.isActive(ACTION_VOLDOWN) ) menu->selLinkApp()->setVolume(-1);
|
if ( input.isActive(VOLUP) && input.isActive(VOLDOWN) ) menu->selLinkApp()->setVolume(-1);
|
||||||
} else {
|
} else {
|
||||||
// CLOCK
|
// CLOCK
|
||||||
if ( input[ACTION_VOLDOWN] && !input.isActive(ACTION_VOLUP) )
|
if ( input[VOLDOWN] && !input.isActive(VOLUP) )
|
||||||
menu->selLinkApp()->setClock( constrain(menu->selLinkApp()->clock()-1,200,confInt["maxClock"]) );
|
menu->selLinkApp()->setClock( constrain(menu->selLinkApp()->clock()-1,200,confInt["maxClock"]) );
|
||||||
if ( input[ACTION_VOLUP] && !input.isActive(ACTION_VOLDOWN) )
|
if ( input[VOLUP] && !input.isActive(VOLDOWN) )
|
||||||
menu->selLinkApp()->setClock( constrain(menu->selLinkApp()->clock()+1,200,confInt["maxClock"]) );
|
menu->selLinkApp()->setClock( constrain(menu->selLinkApp()->clock()+1,200,confInt["maxClock"]) );
|
||||||
if ( input.isActive(ACTION_VOLUP) && input.isActive(ACTION_VOLDOWN) ) menu->selLinkApp()->setClock(336);
|
if ( input.isActive(VOLUP) && input.isActive(VOLDOWN) ) menu->selLinkApp()->setClock(336);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( input.isActive(ACTION_A) ) {
|
if ( input.isActive(CANCEL) ) {
|
||||||
if (input.isActive(ACTION_L) && input.isActive(ACTION_R))
|
if (input.isActive(ALTLEFT) && input.isActive(ALTRIGHT))
|
||||||
saveScreenshot();
|
saveScreenshot();
|
||||||
} else {
|
} else {
|
||||||
// SECTIONS
|
// SECTIONS
|
||||||
if ( input[ACTION_L ] ) {
|
if ( input[ALTLEFT ] ) {
|
||||||
menu->decSectionIndex();
|
menu->decSectionIndex();
|
||||||
offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6;
|
offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6;
|
||||||
} else if ( input[ACTION_R ] ) {
|
} else if ( input[ALTRIGHT ] ) {
|
||||||
menu->incSectionIndex();
|
menu->incSectionIndex();
|
||||||
offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6;
|
offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1213,6 +1256,7 @@ void GMenu2X::setSkin(const string &skin, bool setWallpaper) {
|
|||||||
initFont();
|
initFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void GMenu2X::activateSdUsb() {
|
void GMenu2X::activateSdUsb() {
|
||||||
if (usbnet) {
|
if (usbnet) {
|
||||||
MessageBox mb(this,tr["Operation not permitted."]+"\n"+tr["You should disable Usb Networking to do this."]);
|
MessageBox mb(this,tr["Operation not permitted."]+"\n"+tr["You should disable Usb Networking to do this."]);
|
||||||
@ -1220,7 +1264,7 @@ void GMenu2X::activateSdUsb() {
|
|||||||
} else {
|
} else {
|
||||||
system("scripts/usbon.sh sd");
|
system("scripts/usbon.sh sd");
|
||||||
MessageBox mb(this,tr["USB Enabled (SD)"],"icons/usb.png");
|
MessageBox mb(this,tr["USB Enabled (SD)"],"icons/usb.png");
|
||||||
mb.setButton(ACTION_B, tr["Turn off"]);
|
mb.setButton(ACCEPT, tr["Turn off"]);
|
||||||
mb.exec();
|
mb.exec();
|
||||||
system("scripts/usboff.sh sd");
|
system("scripts/usboff.sh sd");
|
||||||
}
|
}
|
||||||
@ -1233,7 +1277,7 @@ void GMenu2X::activateNandUsb() {
|
|||||||
} else {
|
} else {
|
||||||
system("scripts/usbon.sh nand");
|
system("scripts/usbon.sh nand");
|
||||||
MessageBox mb(this,tr["USB Enabled (Nand)"],"icons/usb.png");
|
MessageBox mb(this,tr["USB Enabled (Nand)"],"icons/usb.png");
|
||||||
mb.setButton(ACTION_B, tr["Turn off"]);
|
mb.setButton(ACCEPT, tr["Turn off"]);
|
||||||
mb.exec();
|
mb.exec();
|
||||||
system("scripts/usboff.sh nand");
|
system("scripts/usboff.sh nand");
|
||||||
}
|
}
|
||||||
@ -1246,12 +1290,12 @@ void GMenu2X::activateRootUsb() {
|
|||||||
} else {
|
} else {
|
||||||
system("scripts/usbon.sh root");
|
system("scripts/usbon.sh root");
|
||||||
MessageBox mb(this,tr["USB Enabled (Root)"],"icons/usb.png");
|
MessageBox mb(this,tr["USB Enabled (Root)"],"icons/usb.png");
|
||||||
mb.setButton(ACTION_B, tr["Turn off"]);
|
mb.setButton(ACCEPT, tr["Turn off"]);
|
||||||
mb.exec();
|
mb.exec();
|
||||||
system("scripts/usboff.sh root");
|
system("scripts/usboff.sh root");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
void GMenu2X::contextMenu() {
|
void GMenu2X::contextMenu() {
|
||||||
vector<MenuOption> voices;
|
vector<MenuOption> voices;
|
||||||
{
|
{
|
||||||
@ -1307,6 +1351,8 @@ void GMenu2X::contextMenu() {
|
|||||||
bg.box(0, 0, resX, resY, 0,0,0,150);
|
bg.box(0, 0, resX, resY, 0,0,0,150);
|
||||||
bg.box(box.x, box.y, box.w, box.h, skinConfColors["messageBoxBg"]);
|
bg.box(box.x, box.y, box.w, box.h, skinConfColors["messageBoxBg"]);
|
||||||
bg.rectangle( box.x+2, box.y+2, box.w-4, box.h-4, skinConfColors["messageBoxBorder"] );*/
|
bg.rectangle( box.x+2, box.y+2, box.w-4, box.h-4, skinConfColors["messageBoxBorder"] );*/
|
||||||
|
|
||||||
|
bevent_t event;
|
||||||
while (!close) {
|
while (!close) {
|
||||||
tickNow = SDL_GetTicks();
|
tickNow = SDL_GetTicks();
|
||||||
|
|
||||||
@ -1354,11 +1400,30 @@ void GMenu2X::contextMenu() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
input.update();
|
|
||||||
if ( input[ACTION_SELECT] ) close = true;
|
if (fadeAlpha < 200) {
|
||||||
if ( input[ACTION_UP ] ) sel = max(0, sel-1);
|
if (!input.pollEvent(&event) || event.state != PRESSED) continue;
|
||||||
if ( input[ACTION_DOWN ] ) sel = min((int)voices.size()-1, sel+1);
|
} else {
|
||||||
if ( input[ACTION_B] ) { voices[sel].action(); close = true; }
|
event.button = input.waitForPressedButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(event.button) {
|
||||||
|
case MENU:
|
||||||
|
close = true;
|
||||||
|
break;
|
||||||
|
case UP:
|
||||||
|
sel = max(0, sel-1);
|
||||||
|
break;
|
||||||
|
case DOWN:
|
||||||
|
sel = min((int)voices.size()-1, sel+1);
|
||||||
|
break;
|
||||||
|
case ACCEPT:
|
||||||
|
voices[sel].action();
|
||||||
|
close = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1499,9 +1564,9 @@ void GMenu2X::editLink() {
|
|||||||
void GMenu2X::deleteLink() {
|
void GMenu2X::deleteLink() {
|
||||||
if (menu->selLinkApp()!=NULL) {
|
if (menu->selLinkApp()!=NULL) {
|
||||||
MessageBox mb(this, tr.translate("Deleting $1",menu->selLink()->getTitle().c_str(),NULL)+"\n"+tr["Are you sure?"], menu->selLink()->getIconPath());
|
MessageBox mb(this, tr.translate("Deleting $1",menu->selLink()->getTitle().c_str(),NULL)+"\n"+tr["Are you sure?"], menu->selLink()->getIconPath());
|
||||||
mb.setButton(ACTION_B, tr["Yes"]);
|
mb.setButton(ACCEPT, tr["Yes"]);
|
||||||
mb.setButton(ACTION_X, tr["No"]);
|
mb.setButton(CLEAR, tr["No"]);
|
||||||
if (mb.exec() == ACTION_B) {
|
if (mb.exec() == ACCEPT) {
|
||||||
ledOn();
|
ledOn();
|
||||||
menu->deleteSelectedLink();
|
menu->deleteSelectedLink();
|
||||||
sync();
|
sync();
|
||||||
@ -1561,9 +1626,9 @@ void GMenu2X::renameSection() {
|
|||||||
|
|
||||||
void GMenu2X::deleteSection() {
|
void GMenu2X::deleteSection() {
|
||||||
MessageBox mb(this,tr["You will lose all the links in this section."]+"\n"+tr["Are you sure?"]);
|
MessageBox mb(this,tr["You will lose all the links in this section."]+"\n"+tr["Are you sure?"]);
|
||||||
mb.setButton(ACTION_B, tr["Yes"]);
|
mb.setButton(ACCEPT, tr["Yes"]);
|
||||||
mb.setButton(ACTION_X, tr["No"]);
|
mb.setButton(CLEAR, tr["No"]);
|
||||||
if (mb.exec() == ACTION_B) {
|
if (mb.exec() == ACCEPT) {
|
||||||
ledOn();
|
ledOn();
|
||||||
if (rmtree(path+"sections/"+menu->selSection())) {
|
if (rmtree(path+"sections/"+menu->selSection())) {
|
||||||
menu->deleteSelectedSection();
|
menu->deleteSelectedSection();
|
||||||
@ -1655,12 +1720,22 @@ void GMenu2X::scanner() {
|
|||||||
ledOff();
|
ledOff();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool close = false;
|
buttontype_t button;
|
||||||
while (!close) {
|
do {
|
||||||
input.update();
|
button = input.waitForPressedButton();
|
||||||
if (input[ACTION_START] || input[ACTION_B] || input[ACTION_X]) close = true;
|
} while ((button != SETTINGS)
|
||||||
usleep(30000);
|
&& (button != ACCEPT)
|
||||||
}
|
&& (button != CLEAR));
|
||||||
|
|
||||||
|
/*
|
||||||
|
bevent_t event;
|
||||||
|
do {
|
||||||
|
input.getEvent(&event, true);
|
||||||
|
} while ((event.state != PRESSED) ||
|
||||||
|
( (event.button != SETTINGS)
|
||||||
|
&& (event.button != ACCEPT)
|
||||||
|
&& (event.button != CLEAR)));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::scanPath(string path, vector<string> *files) {
|
void GMenu2X::scanPath(string path, vector<string> *files) {
|
||||||
@ -1754,18 +1829,20 @@ unsigned short GMenu2X::getBatteryLevel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::setInputSpeed() {
|
void GMenu2X::setInputSpeed() {
|
||||||
|
/*
|
||||||
input.setInterval(150);
|
input.setInterval(150);
|
||||||
input.setInterval(30, ACTION_VOLDOWN);
|
input.setInterval(30, VOLDOWN);
|
||||||
input.setInterval(30, ACTION_VOLUP );
|
input.setInterval(30, VOLUP );
|
||||||
input.setInterval(30, ACTION_A );
|
input.setInterval(30, CANCEL );
|
||||||
input.setInterval(500, ACTION_START );
|
input.setInterval(500, SETTINGS );
|
||||||
input.setInterval(500, ACTION_SELECT );
|
input.setInterval(500, MENU );
|
||||||
input.setInterval(300, ACTION_X );
|
input.setInterval(300, CLEAR );
|
||||||
input.setInterval(300, ACTION_Y );
|
input.setInterval(300, MANUAL );
|
||||||
input.setInterval(1000,ACTION_B );
|
input.setInterval(1000,ACCEPT );
|
||||||
//joy.setInterval(1000,ACTION_CLICK );
|
//joy.setInterval(1000,ACTION_CLICK );
|
||||||
input.setInterval(300, ACTION_L );
|
input.setInterval(300, ALTLEFT );
|
||||||
input.setInterval(300, ACTION_R );
|
input.setInterval(300, ALTRIGHT );
|
||||||
|
*/
|
||||||
SDL_EnableKeyRepeat(1,150);
|
SDL_EnableKeyRepeat(1,150);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +164,43 @@ bool InputDialog::exec() {
|
|||||||
action = drawVirtualKeyboard();
|
action = drawVirtualKeyboard();
|
||||||
gmenu2x->s->flip();
|
gmenu2x->s->flip();
|
||||||
|
|
||||||
|
switch (inputMgr.waitForPressedButton()) {
|
||||||
|
case SETTINGS:
|
||||||
|
ok = false;
|
||||||
|
close = true;
|
||||||
|
break;
|
||||||
|
case UP:
|
||||||
|
selRow--;
|
||||||
|
break;
|
||||||
|
case DOWN:
|
||||||
|
selRow++;
|
||||||
|
if (selRow==(int)kb->size()) selCol = selCol<8 ? 0 : 1;
|
||||||
|
break;
|
||||||
|
case LEFT:
|
||||||
|
selCol--;
|
||||||
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
selCol++;
|
||||||
|
break;
|
||||||
|
case ACCEPT:
|
||||||
|
confirm();
|
||||||
|
break;
|
||||||
|
case MANUAL:
|
||||||
|
changeKeys();
|
||||||
|
break;
|
||||||
|
case CLEAR:
|
||||||
|
case ALTLEFT:
|
||||||
|
backspace();
|
||||||
|
break;
|
||||||
|
case ALTRIGHT:
|
||||||
|
space();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
inputMgr.update();
|
inputMgr.update();
|
||||||
if ( inputMgr[ACTION_START] ) action = ID_ACTION_CLOSE;
|
if ( inputMgr[ACTION_START] ) action = ID_ACTION_CLOSE;
|
||||||
if ( inputMgr[ACTION_UP ] ) action = ID_ACTION_UP;
|
if ( inputMgr[ACTION_UP ] ) action = ID_ACTION_UP;
|
||||||
@ -198,6 +235,7 @@ bool InputDialog::exec() {
|
|||||||
case ID_ACTION_KB_CHANGE: changeKeys(); break;
|
case ID_ACTION_KB_CHANGE: changeKeys(); break;
|
||||||
case ID_ACTION_SELECT: confirm(); break;
|
case ID_ACTION_SELECT: confirm(); break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
|
@ -18,186 +18,167 @@
|
|||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <iostream>
|
#include "debug.h"
|
||||||
#include <sstream>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include "inputmanager.h"
|
#include "inputmanager.h"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
using namespace std;
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
InputManager::InputManager() {}
|
static SDL_Joystick *joystick;
|
||||||
|
|
||||||
InputManager::~InputManager() {
|
|
||||||
for (uint x=0; x<joysticks.size(); x++)
|
|
||||||
if(SDL_JoystickOpened(x))
|
|
||||||
SDL_JoystickClose(joysticks[x]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputManager::init(const string &conffile) {
|
void InputManager::init(const string &conffile) {
|
||||||
SDL_JoystickEventState(SDL_IGNORE);
|
if (!readConfFile(conffile))
|
||||||
|
ERROR("InputManager initialization from config file failed.\n");
|
||||||
int numJoy = SDL_NumJoysticks();
|
|
||||||
for (int x=0; x<numJoy; x++) {
|
|
||||||
SDL_Joystick *joy = SDL_JoystickOpen(x);
|
|
||||||
if (joy) {
|
|
||||||
|
|
||||||
INFO("Initialized joystick: '%s'\n", SDL_JoystickName(x));
|
|
||||||
|
|
||||||
joysticks.push_back(joy);
|
|
||||||
}
|
|
||||||
|
|
||||||
else WARNING("Failed to initialize joystick: %i\n", x);
|
|
||||||
}
|
|
||||||
|
|
||||||
setActionsCount(14);
|
|
||||||
|
|
||||||
if (fileExists(conffile)) {
|
|
||||||
ifstream inf(conffile.c_str(), ios_base::in);
|
|
||||||
if (inf.is_open()) {
|
|
||||||
string line, name, value;
|
|
||||||
stringstream ss;
|
|
||||||
string::size_type pos;
|
|
||||||
vector<string> values;
|
|
||||||
|
|
||||||
while (getline(inf, line, '\n')) {
|
|
||||||
pos = line.find("=");
|
|
||||||
name = trim(line.substr(0,pos));
|
|
||||||
value = trim(line.substr(pos+1,line.length()));
|
|
||||||
int action = -1;
|
|
||||||
|
|
||||||
if (name=="up") action = ACTION_UP;
|
|
||||||
else if (name=="down") action = ACTION_DOWN;
|
|
||||||
else if (name=="left") action = ACTION_LEFT;
|
|
||||||
else if (name=="right") action = ACTION_RIGHT;
|
|
||||||
else if (name=="a") action = ACTION_A;
|
|
||||||
else if (name=="b") action = ACTION_B;
|
|
||||||
else if (name=="x") action = ACTION_X;
|
|
||||||
else if (name=="y") action = ACTION_Y;
|
|
||||||
else if (name=="l") action = ACTION_L;
|
|
||||||
else if (name=="r") action = ACTION_R;
|
|
||||||
else if (name=="start") action = ACTION_START;
|
|
||||||
else if (name=="select") action = ACTION_SELECT;
|
|
||||||
else if (name=="volup") action = ACTION_VOLUP;
|
|
||||||
else if (name=="voldown") action = ACTION_VOLDOWN;
|
|
||||||
|
|
||||||
if (action >= 0) {
|
|
||||||
split(values, value, ",");
|
|
||||||
if (values.size() >= 2) {
|
|
||||||
|
|
||||||
if (values[0] == "joystickbutton" && values.size()==3) {
|
|
||||||
InputMap map;
|
|
||||||
map.type = InputManager::MAPPING_TYPE_BUTTON;
|
|
||||||
map.num = atoi(values[1].c_str());
|
|
||||||
map.value = atoi(values[2].c_str());
|
|
||||||
map.treshold = 0;
|
|
||||||
mappings[action].push_back(map);
|
|
||||||
} else if (values[0] == "joystickaxys" && values.size()==4) {
|
|
||||||
InputMap map;
|
|
||||||
map.type = InputManager::MAPPING_TYPE_AXYS;
|
|
||||||
map.num = atoi(values[1].c_str());
|
|
||||||
map.value = atoi(values[2].c_str());
|
|
||||||
map.treshold = atoi(values[3].c_str());
|
|
||||||
mappings[action].push_back(map);
|
|
||||||
} else if (values[0] == "keyboard") {
|
|
||||||
InputMap map;
|
|
||||||
map.type = InputManager::MAPPING_TYPE_KEYPRESS;
|
|
||||||
map.value = atoi(values[1].c_str());
|
|
||||||
mappings[action].push_back(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inf.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputManager::setActionsCount(int count) {
|
|
||||||
actions.clear();
|
InputManager::InputManager() {
|
||||||
actionTick.clear();
|
initJoystick();
|
||||||
interval.clear();
|
|
||||||
for (int x=0; x<count; x++) {
|
|
||||||
actions.push_back(false);
|
|
||||||
actionTick.push_back(0);
|
|
||||||
interval.push_back(0);
|
|
||||||
MappingList maplist;
|
|
||||||
mappings.push_back(maplist);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputManager::update() {
|
|
||||||
bool anyactions = false;
|
|
||||||
SDL_JoystickUpdate();
|
|
||||||
|
|
||||||
events.clear();
|
InputManager::~InputManager() {
|
||||||
SDL_Event event;
|
if (SDL_NumJoysticks > 0)
|
||||||
while (SDL_PollEvent(&event)) {
|
SDL_JoystickClose(joystick);
|
||||||
SDL_Event evcopy = event;
|
|
||||||
events.push_back(evcopy);
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint32 tick = SDL_GetTicks();
|
|
||||||
for (uint x=0; x<actions.size(); x++) {
|
|
||||||
actions[x] = false;
|
|
||||||
if (isActive(x)) {
|
|
||||||
if (tick-actionTick[x]>interval[x]) {
|
|
||||||
actions[x] = true;
|
|
||||||
actionTick[x] = tick;
|
|
||||||
anyactions = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
actionTick[x] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return anyactions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int InputManager::count() {
|
|
||||||
return actions.size();
|
void InputManager::initJoystick() {
|
||||||
|
if (SDL_NumJoysticks > 0)
|
||||||
|
joystick = SDL_JoystickOpen(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputManager::setInterval(int ms, int action) {
|
|
||||||
if (action<0)
|
bool InputManager::readConfFile(const string &conffile) {
|
||||||
for (uint x=0; x<interval.size(); x++)
|
if (!fileExists(conffile)) return false;
|
||||||
interval[x] = ms;
|
|
||||||
else if ((uint)action < interval.size())
|
ifstream inf(conffile.c_str(), ios_base::in);
|
||||||
interval[action] = ms;
|
if (!(inf.is_open()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
string line, name, source;
|
||||||
|
string::size_type pos;
|
||||||
|
buttontype_t button;
|
||||||
|
|
||||||
|
while(getline(inf, line, '\n')) {
|
||||||
|
pos = line.find("=");
|
||||||
|
name = trim(line.substr(0,pos));
|
||||||
|
line = trim(line.substr(pos+1,line.length()));
|
||||||
|
|
||||||
|
if (name == "up") button = UP;
|
||||||
|
else if (name == "down") button = DOWN;
|
||||||
|
else if (name == "left") button = LEFT;
|
||||||
|
else if (name == "right") button = RIGHT;
|
||||||
|
else if (name == "accept") button = ACCEPT;
|
||||||
|
else if (name == "cancel") button = CANCEL;
|
||||||
|
else if (name == "clear") button = CLEAR;
|
||||||
|
else if (name == "manual") button = MANUAL;
|
||||||
|
else if (name == "altleft") button = ALTLEFT;
|
||||||
|
else if (name == "altright") button = ALTRIGHT;
|
||||||
|
else if (name == "menu") button = MENU;
|
||||||
|
else if (name == "settings") button = SETTINGS;
|
||||||
|
else if (name == "volup") button = VOLUP;
|
||||||
|
else if (name == "voldown") button = VOLDOWN;
|
||||||
|
else if (name == "power") button = POWER;
|
||||||
|
else if (name == "lock") button = LOCK;
|
||||||
|
else return false;
|
||||||
|
|
||||||
|
pos = line.find(",");
|
||||||
|
source = trim(line.substr(0,pos));
|
||||||
|
line = trim(line.substr(pos+1, line.length()));
|
||||||
|
|
||||||
|
if (source == "keyboard") ButtonMap[button].source = KEYBOARD;
|
||||||
|
else if (source == "joystick") ButtonMap[button].source = JOYSTICK;
|
||||||
|
else return false;
|
||||||
|
|
||||||
|
ButtonMap[button].code = atoi(line.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
inf.close();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputManager::operator[](int action) {
|
|
||||||
if (action<0 || (uint)action>=actions.size()) return false;
|
buttontype_t InputManager::waitForPressedButton() {
|
||||||
return actions[action];
|
return waitForButton(PRESSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputManager::isActive(int action) {
|
|
||||||
MappingList mapList = mappings[action];
|
|
||||||
for (MappingList::const_iterator it = mapList.begin(); it !=mapList.end(); ++it) {
|
|
||||||
InputMap map = *it;
|
|
||||||
|
|
||||||
switch (map.type) {
|
buttontype_t InputManager::waitForReleasedButton() {
|
||||||
case InputManager::MAPPING_TYPE_BUTTON:
|
return waitForButton(RELEASED);
|
||||||
if (map.num < joysticks.size() && SDL_JoystickGetButton(joysticks[map.num], map.value))
|
}
|
||||||
return true;
|
|
||||||
break;
|
buttontype_t InputManager::waitForButton(enum state_e state) {
|
||||||
case InputManager::MAPPING_TYPE_AXYS:
|
bevent_t event;
|
||||||
if (map.num < joysticks.size()) {
|
do {
|
||||||
int axyspos = SDL_JoystickGetAxis(joysticks[map.num], map.value);
|
waitForEvent(&event);
|
||||||
if (map.treshold<0 && axyspos < map.treshold) return true;
|
} while(event.state != state);
|
||||||
if (map.treshold>0 && axyspos > map.treshold) return true;
|
return event.button;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case InputManager::MAPPING_TYPE_KEYPRESS:
|
|
||||||
for (uint ex=0; ex<events.size(); ex++) {
|
void InputManager::waitForEvent(bevent_t *event) {
|
||||||
if (events[ex].type == SDL_KEYDOWN && events[ex].key.keysym.sym == map.value)
|
getEvent(event, true);
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
bool InputManager::pollEvent(bevent_t *event) {
|
||||||
}
|
return getEvent(event, false);
|
||||||
|
}
|
||||||
return false;
|
|
||||||
|
|
||||||
|
bool InputManager::getEvent(bevent_t *bevent, bool wait) {
|
||||||
|
//TODO: when an event is processed, program a new event
|
||||||
|
//in some time, and when it occurs, do a key repeat
|
||||||
|
|
||||||
|
SDL_JoystickUpdate();
|
||||||
|
SDL_Event event;
|
||||||
|
|
||||||
|
if (wait)
|
||||||
|
SDL_WaitEvent(&event);
|
||||||
|
else {
|
||||||
|
bevent->state = RELEASED;
|
||||||
|
if (!SDL_PollEvent(&event)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum source_type_e source;
|
||||||
|
|
||||||
|
switch(event.type) {
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
bevent->state = PRESSED;
|
||||||
|
source = KEYBOARD;
|
||||||
|
break;
|
||||||
|
case SDL_KEYUP:
|
||||||
|
bevent->state = RELEASED;
|
||||||
|
source = KEYBOARD;
|
||||||
|
break;
|
||||||
|
case SDL_JOYBUTTONDOWN:
|
||||||
|
bevent->state = PRESSED;
|
||||||
|
source = JOYSTICK;
|
||||||
|
break;
|
||||||
|
case SDL_JOYBUTTONUP:
|
||||||
|
bevent->state = RELEASED;
|
||||||
|
source = JOYSTICK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source == KEYBOARD) {
|
||||||
|
for (int i=0; i<BUTTONTYPE_T_SIZE; i++)
|
||||||
|
if (ButtonMap[i].source == KEYBOARD && (unsigned int)event.key.keysym.sym == ButtonMap[i].code) {
|
||||||
|
bevent->button = (buttontype_t)i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i=0; i<BUTTONTYPE_T_SIZE; i++)
|
||||||
|
if (ButtonMap[i].source == JOYSTICK && (unsigned int)event.jbutton.button == ButtonMap[i].code) {
|
||||||
|
bevent->button = (buttontype_t)i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -17,73 +17,57 @@
|
|||||||
* Free Software Foundation, Inc., *
|
* Free Software Foundation, Inc., *
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#ifndef INPUTMANAGER_H
|
#ifndef NEWINPUT_H
|
||||||
#define INPUTMANAGER_H
|
#define NEWINPUT_H
|
||||||
|
|
||||||
#define ACTION_UP 0
|
#include <SDL/SDL.h>
|
||||||
#define ACTION_DOWN 1
|
#include <sstream>
|
||||||
#define ACTION_LEFT 2
|
|
||||||
#define ACTION_RIGHT 3
|
|
||||||
#define ACTION_A 4
|
|
||||||
#define ACTION_B 5
|
|
||||||
#define ACTION_X 6
|
|
||||||
#define ACTION_Y 7
|
|
||||||
#define ACTION_L 8
|
|
||||||
#define ACTION_R 9
|
|
||||||
#define ACTION_START 10
|
|
||||||
#define ACTION_SELECT 11
|
|
||||||
#define ACTION_VOLUP 12
|
|
||||||
#define ACTION_VOLDOWN 13
|
|
||||||
|
|
||||||
#include <SDL.h>
|
using namespace std;
|
||||||
#include <SDL_image.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
using std::vector;
|
typedef enum buttontype_e {
|
||||||
using std::string;
|
UP, DOWN, LEFT, RIGHT,
|
||||||
|
ACCEPT, CANCEL,
|
||||||
|
CLEAR, MANUAL,
|
||||||
|
ALTLEFT, ALTRIGHT,
|
||||||
|
MENU, SETTINGS,
|
||||||
|
VOLUP, VOLDOWN,
|
||||||
|
POWER, LOCK
|
||||||
|
} buttontype_t;
|
||||||
|
#define BUTTONTYPE_T_SIZE 16
|
||||||
|
|
||||||
|
enum source_type_e {KEYBOARD, JOYSTICK};
|
||||||
|
enum state_e {PRESSED, RELEASED};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int type;
|
source_type_e source;
|
||||||
uint num;
|
Uint32 code;
|
||||||
int value;
|
} input_t;
|
||||||
int treshold;
|
|
||||||
} InputMap;
|
typedef struct {
|
||||||
|
buttontype_t button;
|
||||||
|
state_e state;
|
||||||
|
} bevent_t;
|
||||||
|
|
||||||
typedef vector<InputMap> MappingList;
|
|
||||||
typedef vector<SDL_Event> SDLEventList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Manages all input peripherals
|
|
||||||
@author Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
|
|
||||||
*/
|
|
||||||
class InputManager {
|
class InputManager {
|
||||||
private:
|
private:
|
||||||
InputMap getInputMapping(int action);
|
input_t ButtonMap[BUTTONTYPE_T_SIZE];
|
||||||
vector<Uint32> actionTick;
|
|
||||||
vector<Uint32> interval;
|
|
||||||
SDLEventList events;
|
|
||||||
|
|
||||||
vector <SDL_Joystick*> joysticks;
|
bool readConfFile(const string &conffile);
|
||||||
vector<bool> actions;
|
void initJoystick();
|
||||||
vector<MappingList> mappings;
|
bool getEvent(bevent_t *bevent, bool wait);
|
||||||
|
buttontype_t waitForButton(enum state_e state);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int MAPPING_TYPE_UNDEFINED = -1;
|
InputManager();
|
||||||
static const int MAPPING_TYPE_BUTTON = 0;
|
~InputManager();
|
||||||
static const int MAPPING_TYPE_AXYS = 1;
|
|
||||||
static const int MAPPING_TYPE_KEYPRESS = 2;
|
|
||||||
|
|
||||||
InputManager();
|
void init(const string &conffile);
|
||||||
~InputManager();
|
void waitForEvent(bevent_t *event);
|
||||||
void init(const string &conffile = "input.conf");
|
buttontype_t waitForPressedButton();
|
||||||
|
buttontype_t waitForReleasedButton();
|
||||||
bool update();
|
bool pollEvent(bevent_t *event);
|
||||||
int count();
|
|
||||||
void setActionsCount(int count);
|
|
||||||
void setInterval(int ms, int action = -1);
|
|
||||||
bool operator[](int action);
|
|
||||||
bool isActive(int action);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -333,11 +333,28 @@ void LinkApp::showManual() {
|
|||||||
repaint = false;
|
repaint = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inputMgr.update();
|
switch(inputMgr.waitForPressedButton()) {
|
||||||
if ( inputMgr[ACTION_Y] || inputMgr[ACTION_X] || inputMgr[ACTION_START] ) close = true;
|
case MANUAL:
|
||||||
if ( inputMgr[ACTION_LEFT] && page>0 ) { page--; repaint=true; }
|
case CLEAR:
|
||||||
if ( inputMgr[ACTION_RIGHT] && page<pagecount-1 ) { page++; repaint=true; }
|
case SETTINGS:
|
||||||
}
|
close = true;
|
||||||
|
break;
|
||||||
|
case LEFT:
|
||||||
|
if (page > 0) {
|
||||||
|
page--;
|
||||||
|
repaint = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
if (page < pagecount-1) {
|
||||||
|
page++;
|
||||||
|
repaint=true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define MENUSETTING_H
|
#define MENUSETTING_H
|
||||||
|
|
||||||
#include "buttonbox.h"
|
#include "buttonbox.h"
|
||||||
|
#include "inputmanager.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ public:
|
|||||||
virtual void draw(int y);
|
virtual void draw(int y);
|
||||||
virtual void handleTS();
|
virtual void handleTS();
|
||||||
|
|
||||||
virtual void manageInput() = 0;
|
virtual void manageInput(bevent_t *event) = 0;
|
||||||
virtual void adjustInput();
|
virtual void adjustInput();
|
||||||
virtual void drawSelected(int y);
|
virtual void drawSelected(int y);
|
||||||
virtual bool edited() = 0;
|
virtual bool edited() = 0;
|
||||||
|
@ -64,10 +64,10 @@ void MenuSettingBool::draw(int y)
|
|||||||
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingBool::manageInput()
|
void MenuSettingBool::manageInput(bevent_t *event)
|
||||||
{
|
{
|
||||||
if (gmenu2x->input[ACTION_B])
|
if (event->button == ACCEPT && event->state == PRESSED)
|
||||||
toggle();
|
toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingBool::toggle()
|
void MenuSettingBool::toggle()
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define MENUSETTINGBOOL_H
|
#define MENUSETTINGBOOL_H
|
||||||
|
|
||||||
#include "menusetting.h"
|
#include "menusetting.h"
|
||||||
|
#include "inputmanager.h"
|
||||||
|
|
||||||
class GMenu2X;
|
class GMenu2X;
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ public:
|
|||||||
virtual ~MenuSettingBool() {}
|
virtual ~MenuSettingBool() {}
|
||||||
|
|
||||||
virtual void draw(int y);
|
virtual void draw(int y);
|
||||||
virtual void manageInput();
|
virtual void manageInput(bevent_t *event);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
|
||||||
void setValue(int value);
|
void setValue(int value);
|
||||||
|
@ -65,12 +65,18 @@ void MenuSettingInt::draw(int y)
|
|||||||
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y+gmenu2x->font->getHalfHeight(), SFontHAlignLeft, SFontVAlignMiddle );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingInt::manageInput()
|
void MenuSettingInt::manageInput(bevent_t *event)
|
||||||
{
|
{
|
||||||
if (gmenu2x->input[ACTION_LEFT ] || gmenu2x->input[ACTION_X])
|
switch (event->button) {
|
||||||
dec();
|
case LEFT:
|
||||||
if (gmenu2x->input[ACTION_RIGHT] || gmenu2x->input[ACTION_Y])
|
dec();
|
||||||
inc();
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
inc();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingInt::inc()
|
void MenuSettingInt::inc()
|
||||||
@ -100,8 +106,8 @@ int MenuSettingInt::value()
|
|||||||
void MenuSettingInt::adjustInput()
|
void MenuSettingInt::adjustInput()
|
||||||
{
|
{
|
||||||
#ifdef TARGET_GP2X
|
#ifdef TARGET_GP2X
|
||||||
gmenu2x->input.setInterval(30, ACTION_LEFT );
|
// gmenu2x->input.setInterval(30, ACTION_LEFT );
|
||||||
gmenu2x->input.setInterval(30, ACTION_RIGHT);
|
// gmenu2x->input.setInterval(30, ACTION_RIGHT);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define MENUSETTINGINT_H
|
#define MENUSETTINGINT_H
|
||||||
|
|
||||||
#include "menusetting.h"
|
#include "menusetting.h"
|
||||||
|
#include "inputmanager.h"
|
||||||
|
|
||||||
class MenuSettingInt : public MenuSetting {
|
class MenuSettingInt : public MenuSetting {
|
||||||
private:
|
private:
|
||||||
@ -38,7 +39,7 @@ public:
|
|||||||
const std::string &description, int *value, int min, int max);
|
const std::string &description, int *value, int min, int max);
|
||||||
virtual ~MenuSettingInt() {}
|
virtual ~MenuSettingInt() {}
|
||||||
|
|
||||||
virtual void manageInput();
|
virtual void manageInput(bevent_t *event);
|
||||||
virtual void adjustInput();
|
virtual void adjustInput();
|
||||||
virtual void draw(int);
|
virtual void draw(int);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
@ -49,10 +49,18 @@ MenuSettingMultiString::MenuSettingMultiString(
|
|||||||
buttonBox.add(btn);
|
buttonBox.add(btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingMultiString::manageInput()
|
void MenuSettingMultiString::manageInput(bevent_t *event)
|
||||||
{
|
{
|
||||||
if (gmenu2x->input[ACTION_LEFT ]) decSel();
|
switch(event->button) {
|
||||||
if (gmenu2x->input[ACTION_RIGHT]) incSel();
|
case LEFT:
|
||||||
|
decSel();
|
||||||
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
incSel();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingMultiString::incSel()
|
void MenuSettingMultiString::incSel()
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define MENUSETTINGMULTISTRING_H
|
#define MENUSETTINGMULTISTRING_H
|
||||||
|
|
||||||
#include "menusettingstringbase.h"
|
#include "menusettingstringbase.h"
|
||||||
|
#include "inputmanager.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ public:
|
|||||||
const std::vector<std::string> *choices);
|
const std::vector<std::string> *choices);
|
||||||
virtual ~MenuSettingMultiString() {};
|
virtual ~MenuSettingMultiString() {};
|
||||||
|
|
||||||
virtual void manageInput();
|
virtual void manageInput(bevent_t *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,15 +82,23 @@ void MenuSettingRGBA::handleTS() {
|
|||||||
MenuSetting::handleTS();
|
MenuSetting::handleTS();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingRGBA::manageInput() {
|
void MenuSettingRGBA::manageInput(bevent_t *event) {
|
||||||
if (gmenu2x->input[ACTION_Y])
|
switch(event->button) {
|
||||||
inc();
|
case MANUAL:
|
||||||
if (gmenu2x->input[ACTION_X])
|
inc();
|
||||||
dec();
|
break;
|
||||||
if (gmenu2x->input[ACTION_LEFT])
|
case CLEAR:
|
||||||
leftComponent();
|
dec();
|
||||||
if (gmenu2x->input[ACTION_RIGHT])
|
break;
|
||||||
rightComponent();
|
case LEFT:
|
||||||
|
leftComponent();
|
||||||
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
rightComponent();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingRGBA::dec()
|
void MenuSettingRGBA::dec()
|
||||||
@ -173,9 +181,11 @@ unsigned short MenuSettingRGBA::getSelPart()
|
|||||||
void MenuSettingRGBA::adjustInput()
|
void MenuSettingRGBA::adjustInput()
|
||||||
{
|
{
|
||||||
#ifdef TARGET_GP2X
|
#ifdef TARGET_GP2X
|
||||||
|
/*
|
||||||
gmenu2x->input.setInterval(30, ACTION_Y );
|
gmenu2x->input.setInterval(30, ACTION_Y );
|
||||||
gmenu2x->input.setInterval(30, ACTION_X );
|
gmenu2x->input.setInterval(30, ACTION_X );
|
||||||
gmenu2x->input.setInterval(30, ACTION_L );
|
gmenu2x->input.setInterval(30, ACTION_L );
|
||||||
|
*/
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "menusetting.h"
|
#include "menusetting.h"
|
||||||
#include "surface.h"
|
#include "surface.h"
|
||||||
|
#include "inputmanager.h"
|
||||||
|
|
||||||
class GMenu2X;
|
class GMenu2X;
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ public:
|
|||||||
|
|
||||||
virtual void draw(int y);
|
virtual void draw(int y);
|
||||||
virtual void handleTS();
|
virtual void handleTS();
|
||||||
virtual void manageInput();
|
virtual void manageInput(bevent_t *event);
|
||||||
virtual void adjustInput();
|
virtual void adjustInput();
|
||||||
virtual void drawSelected(int y);
|
virtual void drawSelected(int y);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
@ -44,10 +44,18 @@ void MenuSettingStringBase::draw(int y)
|
|||||||
SFontHAlignLeft, SFontVAlignMiddle);
|
SFontHAlignLeft, SFontVAlignMiddle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingStringBase::manageInput()
|
void MenuSettingStringBase::manageInput(bevent_t *event)
|
||||||
{
|
{
|
||||||
if (gmenu2x->input[ACTION_X]) clear();
|
switch (event->button) {
|
||||||
if (gmenu2x->input[ACTION_B]) edit();
|
case CLEAR:
|
||||||
|
clear();
|
||||||
|
break;
|
||||||
|
case ACCEPT:
|
||||||
|
edit();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingStringBase::clear()
|
void MenuSettingStringBase::clear()
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define MENUSETTINGSTRINGBASE_H
|
#define MENUSETTINGSTRINGBASE_H
|
||||||
|
|
||||||
#include "menusetting.h"
|
#include "menusetting.h"
|
||||||
|
#include "inputmanager.h"
|
||||||
|
|
||||||
class MenuSettingStringBase : public MenuSetting {
|
class MenuSettingStringBase : public MenuSetting {
|
||||||
protected:
|
protected:
|
||||||
@ -37,7 +38,7 @@ public:
|
|||||||
virtual ~MenuSettingStringBase();
|
virtual ~MenuSettingStringBase();
|
||||||
|
|
||||||
virtual void draw(int y);
|
virtual void draw(int y);
|
||||||
virtual void manageInput();
|
virtual void manageInput(bevent_t *event);
|
||||||
virtual bool edited();
|
virtual bool edited();
|
||||||
|
|
||||||
void setValue(const std::string &value) { *_value = value; }
|
void setValue(const std::string &value) { *_value = value; }
|
||||||
|
@ -40,23 +40,23 @@ MessageBox::MessageBox(GMenu2X *gmenu2x, const string &text, const string &icon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Default enabled button
|
//Default enabled button
|
||||||
buttons[ACTION_B] = "OK";
|
buttons[ACCEPT] = "OK";
|
||||||
|
|
||||||
//Default labels
|
//Default labels
|
||||||
buttonLabels[ACTION_UP] = "up";
|
buttonLabels[UP] = "up";
|
||||||
buttonLabels[ACTION_DOWN] = "down";
|
buttonLabels[DOWN] = "down";
|
||||||
buttonLabels[ACTION_LEFT] = "left";
|
buttonLabels[LEFT] = "left";
|
||||||
buttonLabels[ACTION_RIGHT] = "right";
|
buttonLabels[RIGHT] = "right";
|
||||||
buttonLabels[ACTION_A] = "a";
|
buttonLabels[CANCEL] = "a";
|
||||||
buttonLabels[ACTION_B] = "b";
|
buttonLabels[ACCEPT] = "b";
|
||||||
buttonLabels[ACTION_X] = "x";
|
buttonLabels[CLEAR] = "x";
|
||||||
buttonLabels[ACTION_Y] = "y";
|
buttonLabels[MANUAL] = "y";
|
||||||
buttonLabels[ACTION_L] = "l";
|
buttonLabels[ALTLEFT] = "l";
|
||||||
buttonLabels[ACTION_R] = "r";
|
buttonLabels[ALTRIGHT] = "r";
|
||||||
buttonLabels[ACTION_START] = "start";
|
buttonLabels[SETTINGS] = "start";
|
||||||
buttonLabels[ACTION_SELECT] = "select";
|
buttonLabels[MENU] = "select";
|
||||||
buttonLabels[ACTION_VOLUP] = "vol+";
|
buttonLabels[VOLUP] = "vol+";
|
||||||
buttonLabels[ACTION_VOLDOWN] = "vol-";
|
buttonLabels[VOLDOWN] = "vol-";
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageBox::setButton(int action, const string &btn) {
|
void MessageBox::setButton(int action, const string &btn) {
|
||||||
@ -102,6 +102,7 @@ int MessageBox::exec() {
|
|||||||
bg.blit(gmenu2x->s,0,0);
|
bg.blit(gmenu2x->s,0,0);
|
||||||
gmenu2x->s->flip();
|
gmenu2x->s->flip();
|
||||||
|
|
||||||
|
bevent_t event;
|
||||||
while (result<0) {
|
while (result<0) {
|
||||||
//touchscreen
|
//touchscreen
|
||||||
if (gmenu2x->f200) {
|
if (gmenu2x->f200) {
|
||||||
@ -113,11 +114,15 @@ int MessageBox::exec() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
gmenu2x->input.update();
|
gmenu2x->input.update();
|
||||||
for (uint i=0; i<buttons.size(); i++)
|
for (uint i=0; i<buttons.size(); i++)
|
||||||
if (buttons[i]!="" && gmenu2x->input[i]) result = i;
|
if (buttons[i]!="" && gmenu2x->input[i]) result = i;
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (gmenu2x->input.pollEvent(&event) && (event.state == PRESSED) && (buttons[event.button] != "")) result = event.button;
|
||||||
|
|
||||||
usleep(LOOP_DELAY);
|
usleep(LOOP_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,65 @@ int Selector::exec(int startSelection) {
|
|||||||
gmenu2x->drawScrollBar(SELECTOR_ELEMENTS,fl.size(),firstElement,42,175);
|
gmenu2x->drawScrollBar(SELECTOR_ELEMENTS,fl.size(),firstElement,42,175);
|
||||||
gmenu2x->s->flip();
|
gmenu2x->s->flip();
|
||||||
|
|
||||||
|
switch (gmenu2x->input.waitForPressedButton()) {
|
||||||
|
case SETTINGS:
|
||||||
|
close = true;
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
case UP:
|
||||||
|
if (selected == 0) selected = fl.size() -1;
|
||||||
|
else selected -= 1;
|
||||||
|
selTick = SDL_GetTicks();
|
||||||
|
break;
|
||||||
|
case ALTLEFT:
|
||||||
|
if ((int)(selected-SELECTOR_ELEMENTS+1)<0) selected = 0;
|
||||||
|
else selected -= SELECTOR_ELEMENTS-1;
|
||||||
|
selTick = SDL_GetTicks();
|
||||||
|
break;
|
||||||
|
case DOWN:
|
||||||
|
if (selected+1>=fl.size()) selected = 0;
|
||||||
|
else selected += 1;
|
||||||
|
selTick = SDL_GetTicks();
|
||||||
|
break;
|
||||||
|
case ALTRIGHT:
|
||||||
|
if (selected+SELECTOR_ELEMENTS-1>=fl.size()) selected = fl.size()-1;
|
||||||
|
else selected += SELECTOR_ELEMENTS-1;
|
||||||
|
selTick = SDL_GetTicks();
|
||||||
|
break;
|
||||||
|
case CLEAR:
|
||||||
|
if (link->getSelectorBrowser()) {
|
||||||
|
string::size_type p = dir.rfind("/", dir.size()-2);
|
||||||
|
if (p==string::npos || dir.compare(0, 1, "/") != 0 || dir.length() < 2) {
|
||||||
|
close = true;
|
||||||
|
result = false;
|
||||||
|
} else {
|
||||||
|
dir = dir.substr(0,p+1);
|
||||||
|
INFO("%s\n", dir.c_str());
|
||||||
|
selected = 0;
|
||||||
|
firstElement = 0;
|
||||||
|
prepare(&fl,&screens,&titles);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
close = true;
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ACCEPT:
|
||||||
|
if (fl.isFile(selected)) {
|
||||||
|
file = fl[selected];
|
||||||
|
close = true;
|
||||||
|
} else {
|
||||||
|
dir = dir+fl[selected]+"/";
|
||||||
|
selected = 0;
|
||||||
|
firstElement = 0;
|
||||||
|
prepare(&fl,&screens,&titles);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
gmenu2x->input.update();
|
gmenu2x->input.update();
|
||||||
if ( gmenu2x->input[ACTION_START] ) { close = true; result = false; }
|
if ( gmenu2x->input[ACTION_START] ) { close = true; result = false; }
|
||||||
if ( gmenu2x->input[ACTION_UP] ) {
|
if ( gmenu2x->input[ACTION_UP] ) {
|
||||||
@ -179,6 +237,7 @@ int Selector::exec(int startSelection) {
|
|||||||
prepare(&fl,&screens,&titles);
|
prepare(&fl,&screens,&titles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
gmenu2x->sc.defaultAlpha = true;
|
gmenu2x->sc.defaultAlpha = true;
|
||||||
freeScreenshots(&screens);
|
freeScreenshots(&screens);
|
||||||
|
@ -105,11 +105,39 @@ bool SettingsDialog::exec() {
|
|||||||
gmenu2x->s->flip();
|
gmenu2x->s->flip();
|
||||||
voices[sel]->handleTS();
|
voices[sel]->handleTS();
|
||||||
|
|
||||||
|
bevent_t event;
|
||||||
|
do {
|
||||||
|
inputMgr.waitForEvent(&event);
|
||||||
|
} while (event.state != PRESSED);
|
||||||
|
|
||||||
|
switch (event.button) {
|
||||||
|
case SETTINGS:
|
||||||
|
close = true;
|
||||||
|
break;
|
||||||
|
case UP:
|
||||||
|
if (sel==0)
|
||||||
|
sel = voices.size()-1;
|
||||||
|
else
|
||||||
|
sel -= 1;
|
||||||
|
gmenu2x->setInputSpeed();
|
||||||
|
voices[sel]->adjustInput();
|
||||||
|
break;
|
||||||
|
case DOWN:
|
||||||
|
sel += 1;
|
||||||
|
if (sel>=voices.size()) sel = 0;
|
||||||
|
gmenu2x->setInputSpeed();
|
||||||
|
voices[sel]->adjustInput();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
voices[sel]->manageInput(&event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
inputMgr.update();
|
inputMgr.update();
|
||||||
if ( inputMgr[ACTION_START] ) action = SD_ACTION_CLOSE;
|
if ( inputMgr[ACTION_START] ) action = SD_ACTION_CLOSE;
|
||||||
if ( inputMgr[ACTION_UP ] ) action = SD_ACTION_UP;
|
if ( inputMgr[ACTION_UP ] ) action = SD_ACTION_UP;
|
||||||
if ( inputMgr[ACTION_DOWN ] ) action = SD_ACTION_DOWN;
|
if ( inputMgr[ACTION_DOWN ] ) action = SD_ACTION_DOWN;
|
||||||
voices[sel]->manageInput();
|
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case SD_ACTION_CLOSE: close = true; break;
|
case SD_ACTION_CLOSE: close = true; break;
|
||||||
@ -128,6 +156,7 @@ bool SettingsDialog::exec() {
|
|||||||
voices[sel]->adjustInput();
|
voices[sel]->adjustInput();
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
gmenu2x->setInputSpeed();
|
gmenu2x->setInputSpeed();
|
||||||
|
@ -116,7 +116,30 @@ void TextDialog::exec() {
|
|||||||
drawText(text, firstRow, rowsPerPage);
|
drawText(text, firstRow, rowsPerPage);
|
||||||
gmenu2x->s->flip();
|
gmenu2x->s->flip();
|
||||||
|
|
||||||
|
switch(gmenu2x->input.waitForPressedButton()) {
|
||||||
|
case UP:
|
||||||
|
if (firstRow > 0) firstRow--;
|
||||||
|
break;
|
||||||
|
case DOWN:
|
||||||
|
if (firstRow + rowsPerPage < text->size()) firstRow++;
|
||||||
|
break;
|
||||||
|
case ALTLEFT:
|
||||||
|
if (firstRow >= rowsPerPage-1) firstRow -= rowsPerPage-1;
|
||||||
|
else firstRow = 0;
|
||||||
|
break;
|
||||||
|
case ALTRIGHT:
|
||||||
|
if (firstRow + rowsPerPage*2 -1 < text->size()) firstRow += rowsPerPage-1;
|
||||||
|
else firstRow = max(0, text->size() - rowsPerPage);
|
||||||
|
break;
|
||||||
|
case SETTINGS:
|
||||||
|
case CLEAR:
|
||||||
|
close = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
gmenu2x->input.update();
|
gmenu2x->input.update();
|
||||||
if ( gmenu2x->input[ACTION_UP ] && firstRow>0 ) firstRow--;
|
if ( gmenu2x->input[ACTION_UP ] && firstRow>0 ) firstRow--;
|
||||||
if ( gmenu2x->input[ACTION_DOWN] && firstRow+rowsPerPage<text->size() ) firstRow++;
|
if ( gmenu2x->input[ACTION_DOWN] && firstRow+rowsPerPage<text->size() ) firstRow++;
|
||||||
@ -133,5 +156,6 @@ void TextDialog::exec() {
|
|||||||
firstRow = max(0,text->size()-rowsPerPage);
|
firstRow = max(0,text->size()-rowsPerPage);
|
||||||
}
|
}
|
||||||
if ( gmenu2x->input[ACTION_START] || gmenu2x->input[ACTION_X] ) close = true;
|
if ( gmenu2x->input[ACTION_START] || gmenu2x->input[ACTION_X] ) close = true;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,7 @@ void TextManualDialog::exec() {
|
|||||||
string spagecount;
|
string spagecount;
|
||||||
ss >> spagecount;
|
ss >> spagecount;
|
||||||
string pageStatus;
|
string pageStatus;
|
||||||
|
|
||||||
while (!close) {
|
while (!close) {
|
||||||
bg.blit(gmenu2x->s,0,0);
|
bg.blit(gmenu2x->s,0,0);
|
||||||
writeSubTitle(pages[page].title);
|
writeSubTitle(pages[page].title);
|
||||||
@ -99,6 +100,42 @@ void TextManualDialog::exec() {
|
|||||||
|
|
||||||
gmenu2x->s->flip();
|
gmenu2x->s->flip();
|
||||||
|
|
||||||
|
switch(gmenu2x->input.waitForPressedButton()) {
|
||||||
|
case UP:
|
||||||
|
if (firstRow > 0) firstRow--;
|
||||||
|
break;
|
||||||
|
case DOWN:
|
||||||
|
if (firstRow + rowsPerPage < pages[page].text.size()) firstRow++;
|
||||||
|
break;
|
||||||
|
case LEFT:
|
||||||
|
if (page > 0) {
|
||||||
|
page--;
|
||||||
|
firstRow = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
if (page < pages.size() -1) {
|
||||||
|
page++;
|
||||||
|
firstRow = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ALTLEFT:
|
||||||
|
if (firstRow >= rowsPerPage-1) firstRow -= rowsPerPage-1;
|
||||||
|
else firstRow = 0;
|
||||||
|
break;
|
||||||
|
case ALTRIGHT:
|
||||||
|
if (firstRow + rowsPerPage*2 -1 < pages[page].text.size()) firstRow += rowsPerPage-1;
|
||||||
|
else firstRow = max(0, pages[page].text.size() - rowsPerPage);
|
||||||
|
break;
|
||||||
|
case SETTINGS:
|
||||||
|
case CLEAR:
|
||||||
|
close = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
gmenu2x->input.update();
|
gmenu2x->input.update();
|
||||||
if ( gmenu2x->input[ACTION_UP ] && firstRow>0 ) firstRow--;
|
if ( gmenu2x->input[ACTION_UP ] && firstRow>0 ) firstRow--;
|
||||||
if ( gmenu2x->input[ACTION_DOWN ] && firstRow+rowsPerPage<pages[page].text.size() ) firstRow++;
|
if ( gmenu2x->input[ACTION_DOWN ] && firstRow+rowsPerPage<pages[page].text.size() ) firstRow++;
|
||||||
@ -117,5 +154,6 @@ void TextManualDialog::exec() {
|
|||||||
firstRow = max(0,pages[page].text.size()-rowsPerPage);
|
firstRow = max(0,pages[page].text.size()-rowsPerPage);
|
||||||
}
|
}
|
||||||
if ( gmenu2x->input[ACTION_START] || gmenu2x->input[ACTION_X] ) close = true;
|
if ( gmenu2x->input[ACTION_START] || gmenu2x->input[ACTION_X] ) close = true;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ bool WallpaperDialog::exec()
|
|||||||
DEBUG("Wallpapers: %i\n", wallpapers.size());
|
DEBUG("Wallpapers: %i\n", wallpapers.size());
|
||||||
|
|
||||||
uint i, selected = 0, firstElement = 0, iY;
|
uint i, selected = 0, firstElement = 0, iY;
|
||||||
|
|
||||||
while (!close) {
|
while (!close) {
|
||||||
if (selected>firstElement+9) firstElement=selected-9;
|
if (selected>firstElement+9) firstElement=selected-9;
|
||||||
if (selected<firstElement) firstElement=selected;
|
if (selected<firstElement) firstElement=selected;
|
||||||
@ -86,48 +87,39 @@ bool WallpaperDialog::exec()
|
|||||||
gmenu2x->drawScrollBar(10,wallpapers.size(),firstElement,44,170);
|
gmenu2x->drawScrollBar(10,wallpapers.size(),firstElement,44,170);
|
||||||
gmenu2x->s->flip();
|
gmenu2x->s->flip();
|
||||||
|
|
||||||
|
switch(gmenu2x->input.waitForPressedButton()) {
|
||||||
gmenu2x->input.update();
|
case MENU:
|
||||||
if ( gmenu2x->input[ACTION_SELECT] ) { close = true; result = false; }
|
case CLEAR:
|
||||||
if ( gmenu2x->input[ACTION_UP ] ) {
|
close = true;
|
||||||
if (selected==0)
|
result = false;
|
||||||
selected = wallpapers.size()-1;
|
break;
|
||||||
else
|
case UP:
|
||||||
selected -= 1;
|
if (selected == 0) selected = wallpapers.size()-1;
|
||||||
}
|
else selected -= 1;
|
||||||
if ( gmenu2x->input[ACTION_L ] ) {
|
break;
|
||||||
if ((int)(selected-9)<0) {
|
case ALTLEFT:
|
||||||
selected = 0;
|
if ((int)(selected-9) < 0) selected = 0;
|
||||||
} else {
|
else selected -= 9;
|
||||||
selected -= 9;
|
break;
|
||||||
}
|
case DOWN:
|
||||||
}
|
if (selected+1 >= wallpapers.size()) selected = 0;
|
||||||
if ( gmenu2x->input[ACTION_DOWN ] ) {
|
else selected += 1;
|
||||||
if (selected+1>=wallpapers.size())
|
break;
|
||||||
selected = 0;
|
case ALTRIGHT:
|
||||||
else
|
if (selected+9 >= wallpapers.size()) selected = wallpapers.size()-1;
|
||||||
selected += 1;
|
else selected += 9;
|
||||||
}
|
break;
|
||||||
if ( gmenu2x->input[ACTION_R ] ) {
|
case ACCEPT:
|
||||||
if (selected+9>=wallpapers.size()) {
|
close = true;
|
||||||
selected = wallpapers.size()-1;
|
if (wallpapers.size() > 0) {
|
||||||
} else {
|
if (selected < wallpapers.size() - fl.getFiles().size())
|
||||||
selected += 9;
|
wallpaper = "skins/" + gmenu2x->confStr["skin"] + "/wallpapers/" + wallpapers[selected];
|
||||||
}
|
else
|
||||||
}
|
wallpaper = "skins/Default/wallpapers/" + wallpapers[selected];
|
||||||
if ( gmenu2x->input[ACTION_X] ) {
|
} else result = false;
|
||||||
close = true;
|
default:
|
||||||
result = false;
|
break;
|
||||||
}
|
}
|
||||||
if ( gmenu2x->input[ACTION_B] ) {
|
|
||||||
close = true;
|
|
||||||
if (wallpapers.size()>0) {
|
|
||||||
if (selected<wallpapers.size()-fl.getFiles().size())
|
|
||||||
wallpaper = "skins/"+gmenu2x->confStr["skin"]+"/wallpapers/"+wallpapers[selected];
|
|
||||||
else
|
|
||||||
wallpaper = "skins/Default/wallpapers/"+wallpapers[selected];
|
|
||||||
} else result = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint i=0; i<wallpapers.size(); i++)
|
for (uint i=0; i<wallpapers.size(); i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user