src/browsedialog.cpp |
73 | 73 | return result; |
74 | 74 | } |
75 | 75 | |
76 | | BrowseDialog::Action BrowseDialog::getAction(InputManager::ButtonEvent *event) |
| 76 | BrowseDialog::Action BrowseDialog::getAction(InputManager::Button button) |
77 | 77 | { |
78 | | BrowseDialog::Action action; |
79 | | |
80 | | switch(event->button) { |
81 | | case InputManager::MENU: |
82 | | action = BrowseDialog::ACT_CLOSE; |
83 | | break; |
84 | | case InputManager::UP: |
85 | | action = BrowseDialog::ACT_UP; |
86 | | break; |
87 | | case InputManager::DOWN: |
88 | | action = BrowseDialog::ACT_DOWN; |
89 | | break; |
90 | | case InputManager::ALTLEFT: |
91 | | action = BrowseDialog::ACT_SCROLLUP; |
92 | | break; |
93 | | case InputManager::ALTRIGHT: |
94 | | action = BrowseDialog::ACT_SCROLLDOWN; |
95 | | break; |
96 | | case InputManager::LEFT: |
97 | | case InputManager::CANCEL: |
98 | | action = BrowseDialog::ACT_GOUP; |
99 | | break; |
100 | | case InputManager::ACCEPT: |
101 | | action = BrowseDialog::ACT_SELECT; |
102 | | break; |
103 | | case InputManager::SETTINGS: |
104 | | action = BrowseDialog::ACT_CONFIRM; |
105 | | break; |
106 | | default: |
107 | | action = BrowseDialog::ACT_NONE; |
108 | | break; |
109 | | } |
110 | | |
111 | | return action; |
| 78 | switch (button) { |
| 79 | case InputManager::MENU: |
| 80 | return BrowseDialog::ACT_CLOSE; |
| 81 | case InputManager::UP: |
| 82 | return BrowseDialog::ACT_UP; |
| 83 | case InputManager::DOWN: |
| 84 | return BrowseDialog::ACT_DOWN; |
| 85 | case InputManager::ALTLEFT: |
| 86 | return BrowseDialog::ACT_SCROLLUP; |
| 87 | case InputManager::ALTRIGHT: |
| 88 | return BrowseDialog::ACT_SCROLLDOWN; |
| 89 | case InputManager::LEFT: |
| 90 | case InputManager::CANCEL: |
| 91 | return BrowseDialog::ACT_GOUP; |
| 92 | case InputManager::ACCEPT: |
| 93 | return BrowseDialog::ACT_SELECT; |
| 94 | case InputManager::SETTINGS: |
| 95 | return BrowseDialog::ACT_CONFIRM; |
| 96 | default: |
| 97 | return BrowseDialog::ACT_NONE; |
| 98 | } |
112 | 99 | } |
113 | 100 | |
114 | 101 | void BrowseDialog::handleInput() |
115 | 102 | { |
116 | | BrowseDialog::Action action; |
117 | | InputManager::ButtonEvent event; |
118 | | |
119 | | do { |
120 | | gmenu2x->input.waitForEvent(&event); |
121 | | } while (event.state != InputManager::PRESSED); |
| 103 | InputManager::Button button = gmenu2x->input.waitForPressedButton(); |
122 | 104 | |
| 105 | BrowseDialog::Action action; |
123 | 106 | if (ts_pressed && !gmenu2x->ts.pressed()) { |
124 | 107 | action = BrowseDialog::ACT_SELECT; |
125 | 108 | ts_pressed = false; |
126 | 109 | } else { |
127 | | action = getAction(&event); |
| 110 | action = getAction(button); |
128 | 111 | } |
129 | 112 | |
130 | 113 | if (gmenu2x->ts.initialized() && gmenu2x->ts.pressed() && !gmenu2x->ts.inRect(touchRect)) ts_pressed = false; |