Root/
Source at commit ba9af53 created 13 years 7 months ago. By bartbes, Changed the file browser to use / as root and added ability to see extensionless files (i.e. executables) | |
---|---|
1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * |
3 | * massimiliano.torromeo@gmail.com * |
4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * |
6 | * it under the terms of the GNU General Public License as published by * |
7 | * the Free Software Foundation; either version 2 of the License, or * |
8 | * (at your option) any later version. * |
9 | * * |
10 | * This program is distributed in the hope that it will be useful, * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 | * GNU General Public License for more details. * |
14 | * * |
15 | * You should have received a copy of the GNU General Public License * |
16 | * along with this program; if not, write to the * |
17 | * Free Software Foundation, Inc., * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | ***************************************************************************/ |
20 | |
21 | #ifndef GMENU2X_H |
22 | #define GMENU2X_H |
23 | |
24 | #include "surfacecollection.h" |
25 | #include "iconbutton.h" |
26 | #include "translator.h" |
27 | #include "FastDelegate.h" |
28 | #include "utilities.h" |
29 | #include "touchscreen.h" |
30 | #include "inputmanager.h" |
31 | #include "asfont.h" |
32 | #include "surface.h" |
33 | |
34 | #include <iostream> |
35 | #include <string> |
36 | #include <vector> |
37 | #include <tr1/unordered_map> |
38 | |
39 | const int MAX_VOLUME_SCALE_FACTOR = 200; |
40 | // Default values - going to add settings adjustment, saving, loading and such |
41 | const int VOLUME_SCALER_MUTE = 0; |
42 | const int VOLUME_SCALER_PHONES = 65; |
43 | const int VOLUME_SCALER_NORMAL = 100; |
44 | const int VOLUME_MODE_MUTE = 0; |
45 | const int VOLUME_MODE_PHONES = 1; |
46 | const int VOLUME_MODE_NORMAL = 2; |
47 | const int BATTERY_READS = 10; |
48 | |
49 | const int LOOP_DELAY=30000; |
50 | |
51 | extern const char *CARD_ROOT; |
52 | extern const int CARD_ROOT_LEN; |
53 | |
54 | extern void jz_cpuspeed(unsigned clockspeed); |
55 | |
56 | // Note: Keep this in sync with colorNames! |
57 | enum color { |
58 | COLOR_TOP_BAR_BG, |
59 | COLOR_BOTTOM_BAR_BG, |
60 | COLOR_SELECTION_BG, |
61 | COLOR_MESSAGE_BOX_BG, |
62 | COLOR_MESSAGE_BOX_BORDER, |
63 | COLOR_MESSAGE_BOX_SELECTION, |
64 | |
65 | NUM_COLORS, |
66 | }; |
67 | |
68 | using std::string; |
69 | using std::vector; |
70 | using fastdelegate::FastDelegate0; |
71 | |
72 | typedef FastDelegate0<> MenuAction; |
73 | typedef unordered_map<string, string, hash<string> > ConfStrHash; |
74 | typedef unordered_map<string, int, hash<string> > ConfIntHash; |
75 | |
76 | typedef struct { |
77 | unsigned short batt; |
78 | unsigned short remocon; |
79 | } MMSP2ADC; |
80 | |
81 | struct MenuOption { |
82 | string text; |
83 | MenuAction action; |
84 | }; |
85 | |
86 | class Menu; |
87 | |
88 | class GMenu2X { |
89 | private: |
90 | string path; //!< Contains the working directory of GMenu2X |
91 | /*! |
92 | Retrieves the free disk space on the sd |
93 | @return String containing a human readable representation of the free disk space |
94 | */ |
95 | string getDiskFree(); |
96 | unsigned short cpuX; //!< Offset for displaying cpu clock information |
97 | unsigned short volumeX; //!< Offset for displaying volume level |
98 | unsigned short manualX; //!< Offset for displaying the manual indicator in the taskbar |
99 | /*! |
100 | Reads the current battery state and returns a number representing it's level of charge |
101 | @return A number representing battery charge. 0 means fully discharged. 5 means fully charged. 6 represents a gp2x using AC power. |
102 | */ |
103 | unsigned short getBatteryLevel(); |
104 | FILE* batteryHandle, *backlightHandle, *usbHandle, *acHandle; |
105 | void browsePath(const string &path, vector<string>* directories, vector<string>* files); |
106 | /*! |
107 | Starts the scanning of the nand and sd filesystems, searching for dge and gpu files and creating the links in 2 dedicated sections. |
108 | */ |
109 | void scanner(); |
110 | /*! |
111 | Performs the actual scan in the given path and populates the files vector with the results. The creation of the links is not performed here. |
112 | @see scanner |
113 | */ |
114 | void scanPath(string path, vector<string> *files); |
115 | |
116 | /*! |
117 | Displays a selector and launches the specified executable file |
118 | */ |
119 | void explorer(); |
120 | |
121 | bool inet, //!< Represents the configuration of the basic network services. @see readCommonIni @see usbnet @see samba @see web |
122 | usbnet, |
123 | samba, |
124 | web; |
125 | string ip, defaultgw, lastSelectorDir; |
126 | int lastSelectorElement; |
127 | void readConfig(); |
128 | void readConfigOpen2x(); |
129 | void readTmp(); |
130 | void readCommonIni(); |
131 | void writeCommonIni(); |
132 | |
133 | void initServices(); |
134 | void initFont(); |
135 | void initMenu(); |
136 | |
137 | #ifdef TARGET_GP2X |
138 | unsigned long gp2x_mem; |
139 | unsigned short *gp2x_memregs; |
140 | volatile unsigned short *MEM_REG; |
141 | int cx25874; //tv-out |
142 | #endif |
143 | void gp2x_tvout_on(bool pal); |
144 | void gp2x_tvout_off(); |
145 | void gp2x_init(); |
146 | void gp2x_deinit(); |
147 | void toggleTvOut(); |
148 | |
149 | public: |
150 | GMenu2X(); |
151 | ~GMenu2X(); |
152 | void quit(); |
153 | |
154 | /* |
155 | * Variables needed for elements disposition |
156 | */ |
157 | uint resX, resY, halfX, halfY; |
158 | uint bottomBarIconY, bottomBarTextY, linkColumns, linkRows; |
159 | |
160 | /*! |
161 | Retrieves the parent directory of GMenu2X. |
162 | This functions is used to initialize the "path" variable. |
163 | @see path |
164 | @return String containing the parent directory |
165 | */ |
166 | const string &getExePath(); |
167 | |
168 | InputManager input; |
169 | Touchscreen ts; |
170 | |
171 | //Configuration hashes |
172 | ConfStrHash confStr, skinConfStr; |
173 | ConfIntHash confInt, skinConfInt; |
174 | RGBAColor skinConfColors[NUM_COLORS]; |
175 | |
176 | //Configuration settings |
177 | bool useSelectionPng; |
178 | void setSkin(const string &skin, bool setWallpaper = true); |
179 | //firmware type and version |
180 | string fwType, fwVersion; |
181 | //gp2x type |
182 | bool f200; |
183 | |
184 | // Open2x settings --------------------------------------------------------- |
185 | bool o2x_usb_net_on_boot, o2x_ftp_on_boot, o2x_telnet_on_boot, o2x_gp2xjoy_on_boot, o2x_usb_host_on_boot, o2x_usb_hid_on_boot, o2x_usb_storage_on_boot; |
186 | string o2x_usb_net_ip; |
187 | int volumeMode, savedVolumeMode; // just use the const int scale values at top of source |
188 | |
189 | // Volume scaling values to store from config files |
190 | int volumeScalerPhones; |
191 | int volumeScalerNormal; |
192 | //-------------------------------------------------------------------------- |
193 | |
194 | SurfaceCollection sc; |
195 | Translator tr; |
196 | Surface *s, *bg; |
197 | ASFont *font; |
198 | |
199 | //Status functions |
200 | void main(); |
201 | void options(); |
202 | void settingsOpen2x(); |
203 | void skinMenu(); |
204 | void activateSdUsb(); |
205 | void activateNandUsb(); |
206 | void activateRootUsb(); |
207 | void about(); |
208 | void viewLog(); |
209 | void contextMenu(); |
210 | void changeWallpaper(); |
211 | void saveScreenshot(); |
212 | |
213 | void applyRamTimings(); |
214 | void applyDefaultTimings(); |
215 | |
216 | void setClock(unsigned mhz); |
217 | void setGamma(int gamma); |
218 | |
219 | void setVolume(int vol); |
220 | int getVolume(); |
221 | void setVolumeScaler(int scaler); |
222 | int getVolumeScaler(); |
223 | |
224 | void setBacklight(int val); |
225 | int getBackLight(); |
226 | |
227 | void setInputSpeed(); |
228 | |
229 | void writeConfig(); |
230 | void writeConfigOpen2x(); |
231 | void writeSkinConfig(); |
232 | void writeTmp(int selelem=-1, const string &selectordir=""); |
233 | |
234 | void ledOn(); |
235 | void ledOff(); |
236 | |
237 | void addLink(); |
238 | void editLink(); |
239 | void deleteLink(); |
240 | void addSection(); |
241 | void renameSection(); |
242 | void deleteSection(); |
243 | |
244 | void initBG(); |
245 | int drawButton(Button *btn, int x=5, int y=-10); |
246 | int drawButton(Surface *s, const string &btn, const string &text, int x=5, int y=-10); |
247 | int drawButtonRight(Surface *s, const string &btn, const string &text, int x=5, int y=-10); |
248 | void drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height); |
249 | |
250 | void drawTopBar(Surface *s=NULL); |
251 | void drawBottomBar(Surface *s=NULL); |
252 | |
253 | Menu* menu; |
254 | }; |
255 | |
256 | #endif |
257 |
Branches:
install_locations
master
opkrun
packages