equal
deleted
inserted
replaced
26 extern char sdlkeys[1024][2][128]; |
26 extern char sdlkeys[1024][2][128]; |
27 extern char xb360buttons[][128]; |
27 extern char xb360buttons[][128]; |
28 extern char xb360dpad[128]; |
28 extern char xb360dpad[128]; |
29 extern char xbox360axes[][128]; |
29 extern char xbox360axes[][128]; |
30 |
30 |
|
31 #ifdef _WIN32 |
31 bool hardware; |
32 bool hardware; |
|
33 #endif |
32 extern char *programname; |
34 extern char *programname; |
33 |
35 |
34 SDLInteraction::SDLInteraction() |
36 SDLInteraction::SDLInteraction() |
35 { |
37 { |
36 music = -1; |
38 music = -1; |
|
39 #ifdef _WIN32 |
37 hardware = false; |
40 hardware = false; |
|
41 #endif |
38 SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); |
42 SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); |
39 |
43 |
40 |
44 |
41 if(SDL_NumJoysticks()) |
45 if(SDL_NumJoysticks()) |
42 addGameControllerKeys(); |
46 addGameControllerKeys(); |
44 } |
48 } |
45 |
49 |
46 SDLInteraction::~SDLInteraction() |
50 SDLInteraction::~SDLInteraction() |
47 { |
51 { |
48 SDL_Quit(); |
52 SDL_Quit(); |
49 openal_close(); |
53 oalb_close(); |
50 } |
54 } |
51 |
55 |
|
56 #ifdef _WIN32 |
52 void SDLInteraction::setHardwareSound(bool hardware_snd) |
57 void SDLInteraction::setHardwareSound(bool hardware_snd) |
53 { |
58 { |
54 hardware = hardware_snd; |
59 hardware = hardware_snd; |
55 } |
60 } |
|
61 #endif |
56 |
62 |
57 QStringList SDLInteraction::getResolutions() const |
63 QStringList SDLInteraction::getResolutions() const |
58 { |
64 { |
59 QStringList result; |
65 QStringList result; |
60 |
66 |
66 { |
72 { |
67 result << "640x480"; |
73 result << "640x480"; |
68 } else |
74 } else |
69 { |
75 { |
70 for(int i = 0; modes[i]; ++i) |
76 for(int i = 0; modes[i]; ++i) |
71 if ((modes[i]->w >= 640) && (modes[i]->h >= 480)) |
77 if ((modes[i]->w >= 640) && (modes[i]->h >= 480) && (modes[i]->h <= 1200)) |
72 result << QString("%1x%2").arg(modes[i]->w).arg(modes[i]->h); |
78 result << QString("%1x%2").arg(modes[i]->w).arg(modes[i]->h); |
73 } |
79 } |
74 |
80 |
75 return result; |
81 return result; |
76 } |
82 } |
158 |
164 |
159 void SDLInteraction::StartMusic() |
165 void SDLInteraction::StartMusic() |
160 { |
166 { |
161 OpenAL_Init(); |
167 OpenAL_Init(); |
162 if (music < 0) { |
168 if (music < 0) { |
163 music = openal_loadfile(QString(datadir->absolutePath() + "/Music/main theme.ogg").toLocal8Bit().constData()); |
169 music = oalb_loadfile(QString(datadir->absolutePath() + "/Music/main theme.ogg").toLocal8Bit().constData()); |
164 openal_toggleloop(music); |
|
165 |
170 |
166 } |
171 } |
167 openal_setvolume(music, 60); |
172 oalb_playsound(music, 1); |
168 openal_fadein(music, 30); |
173 oalb_setvolume(music, 60); |
169 } |
174 } |
170 |
175 |
171 void SDLInteraction::StopMusic() |
176 void SDLInteraction::StopMusic() |
172 { |
177 { |
173 if (music >= 0) openal_fadeout(music, 40); |
178 // if (music >= 0) openal_fadeout(music, 40); |
|
179 oalb_stopsound(music); |
174 } |
180 } |
175 |
181 |
176 //we need thjs wrapper because of some issues with windows drivers |
182 //we need thjs wrapper because of some issues with windows drivers |
177 //beware that this cause a slight delay when playing the first sound |
183 //beware that this cause a slight delay when playing the first sound |
178 void OpenAL_Init() |
184 void OpenAL_Init() |
179 { |
185 { |
180 if (!openal_ready()) |
186 if (!oalb_ready()) |
181 openal_init(programname, hardware ? 1 : 0, 5); |
187 #ifdef _WIN32 |
|
188 oalb_init(programname, hardware ? 1 : 0); |
|
189 #else |
|
190 oalb_init(programname, 0); |
|
191 #endif |
182 } |
192 } |
183 |
193 |