1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2025-04-21 12:27:27 +03:00

Cleanup of touch screen code.

Initialize in constructor and clean up in destructor instead of having separate init() and deinit() methods.
Don't close file descriptor if open failed (ts_fd == -1).
Renamed initialized() to available(), since it tests whether the touch screen was found, not whether an initialization was attempted.
Improved code layout and minor other cleanups.
This commit is contained in:
Maarten ter Huurne
2011-12-23 12:30:15 +01:00
parent c7af4b1aea
commit 944ab86f9c
7 changed files with 53 additions and 66 deletions

View File

@@ -61,7 +61,7 @@ bool SettingsDialog::exec() {
uint numRows = (gmenu2x->resY-gmenu2x->skinConfInt["topBarHeight"]-20)/rowHeight;
while (!close) {
if (ts.initialized()) ts.poll();
if (ts.available()) ts.poll();
bg.blit(gmenu2x->s,0,0);
@@ -88,11 +88,11 @@ bool SettingsDialog::exec() {
gmenu2x->s->setClipRect(clipRect);
if (ts_pressed && !ts.pressed()) ts_pressed = false;
if (ts.initialized() && ts.pressed() && !ts.inRect(touchRect)) ts_pressed = false;
if (ts.available() && ts.pressed() && !ts.inRect(touchRect)) ts_pressed = false;
for (i=firstElement; i<voices.size() && i<firstElement+numRows; i++) {
iY = i-firstElement;
voices[i]->draw(iY*rowHeight+gmenu2x->skinConfInt["topBarHeight"]+2);
if (ts.initialized() && ts.pressed() && ts.inRect(touchRect.x, touchRect.y+(iY*rowHeight), touchRect.w, rowHeight)) {
if (ts.available() && ts.pressed() && ts.inRect(touchRect.x, touchRect.y+(iY*rowHeight), touchRect.w, rowHeight)) {
ts_pressed = true;
sel = i;
}