gosu 0.7.33 → 0.7.35

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/Gosu/Async.hpp +10 -8
  2. data/Gosu/Audio.hpp +6 -4
  3. data/Gosu/AutoLink.hpp +0 -0
  4. data/Gosu/Bitmap.hpp +4 -5
  5. data/Gosu/ButtonsX.hpp +1 -1
  6. data/Gosu/Color.hpp +8 -8
  7. data/Gosu/Font.hpp +2 -2
  8. data/Gosu/Graphics.hpp +4 -6
  9. data/Gosu/IO.hpp +11 -4
  10. data/Gosu/Image.hpp +9 -7
  11. data/Gosu/ImageData.hpp +10 -4
  12. data/Gosu/Input.hpp +4 -5
  13. data/Gosu/Sockets.hpp +10 -12
  14. data/Gosu/TR1.hpp +44 -0
  15. data/Gosu/TextInput.hpp +2 -2
  16. data/Gosu/Version.hpp +2 -2
  17. data/Gosu/WinUtility.hpp +5 -6
  18. data/Gosu/Window.hpp +5 -6
  19. data/GosuImpl/Async.cpp +4 -3
  20. data/GosuImpl/Audio/ALChannelManagement.hpp +23 -11
  21. data/GosuImpl/Audio/AudioFile.hpp +11 -3
  22. data/GosuImpl/Audio/AudioOpenAL.cpp +613 -0
  23. data/GosuImpl/Audio/AudioOpenAL.mm +1 -605
  24. data/GosuImpl/Audio/AudioSDL.cpp +12 -14
  25. data/GosuImpl/Audio/AudioToolboxFile.hpp +0 -1
  26. data/GosuImpl/Audio/OggFile.hpp +2 -0
  27. data/GosuImpl/Audio/SndFile.hpp +158 -0
  28. data/GosuImpl/DirectoriesWin.cpp +18 -18
  29. data/GosuImpl/Graphics/BitmapApple.mm +17 -19
  30. data/GosuImpl/Graphics/BitmapBMP.cpp +7 -2
  31. data/GosuImpl/Graphics/BitmapFreeImage.cpp +11 -12
  32. data/GosuImpl/Graphics/BitmapGDIplus.cpp +35 -31
  33. data/GosuImpl/Graphics/BitmapUtils.cpp +1 -1
  34. data/GosuImpl/Graphics/BlockAllocator.cpp +7 -8
  35. data/GosuImpl/Graphics/BlockAllocator.hpp +3 -4
  36. data/GosuImpl/Graphics/Common.hpp +3 -2
  37. data/GosuImpl/Graphics/DrawOp.hpp +2 -3
  38. data/GosuImpl/Graphics/DrawOpQueue.hpp +28 -20
  39. data/GosuImpl/Graphics/Font.cpp +13 -13
  40. data/GosuImpl/Graphics/FormattedString.hpp +93 -86
  41. data/GosuImpl/Graphics/Graphics.cpp +16 -14
  42. data/GosuImpl/Graphics/Image.cpp +7 -3
  43. data/GosuImpl/Graphics/LargeImageData.hpp +4 -5
  44. data/GosuImpl/Graphics/Macro.hpp +11 -11
  45. data/GosuImpl/Graphics/RenderState.hpp +5 -4
  46. data/GosuImpl/Graphics/TexChunk.cpp +3 -3
  47. data/GosuImpl/Graphics/TexChunk.hpp +4 -4
  48. data/GosuImpl/Graphics/Text.cpp +29 -30
  49. data/GosuImpl/Graphics/TextMac.cpp +9 -7
  50. data/GosuImpl/Graphics/TextTTFWin.cpp +3 -1
  51. data/GosuImpl/Graphics/TextTouch.mm +0 -1
  52. data/GosuImpl/Graphics/TextUnix.cpp +12 -4
  53. data/GosuImpl/Graphics/TextWin.cpp +4 -2
  54. data/GosuImpl/Graphics/Texture.cpp +7 -6
  55. data/GosuImpl/Graphics/Texture.hpp +3 -4
  56. data/GosuImpl/InputMac.mm +12 -15
  57. data/GosuImpl/InputTouch.mm +3 -3
  58. data/GosuImpl/InputWin.cpp +149 -159
  59. data/GosuImpl/InputX.cpp +0 -0
  60. data/GosuImpl/MacUtility.hpp +9 -4
  61. data/GosuImpl/RubyGosu.swg +38 -43
  62. data/GosuImpl/RubyGosu_wrap.cxx +89 -96
  63. data/GosuImpl/Sockets/CommSocket.cpp +5 -5
  64. data/GosuImpl/Sockets/Sockets.hpp +4 -4
  65. data/GosuImpl/TimingApple.cpp +2 -3
  66. data/GosuImpl/Utility.cpp +18 -0
  67. data/GosuImpl/WinMain.cpp +0 -1
  68. data/GosuImpl/WinUtility.cpp +2 -2
  69. data/GosuImpl/WindowMac.mm +20 -17
  70. data/GosuImpl/WindowTouch.mm +8 -7
  71. data/GosuImpl/WindowWin.cpp +12 -7
  72. data/GosuImpl/WindowX.cpp +67 -18
  73. data/lib/gosu.rb +14 -12
  74. data/linux/extconf.rb +11 -6
  75. metadata +8 -7
  76. data/GosuImpl/Audio/AudioAudiere.cpp +0 -448
  77. data/GosuImpl/RubyGosu_DllMain.cxx +0 -31
@@ -62,19 +62,20 @@ GLuint Gosu::Texture::texName() const
62
62
 
63
63
  std::auto_ptr<Gosu::TexChunk>
64
64
  Gosu::Texture::tryAlloc(Graphics& graphics, Transforms& transforms,
65
- DrawOpQueueStack& queues, boost::shared_ptr<Texture> ptr, const Bitmap& bmp, unsigned padding)
65
+ DrawOpQueueStack& queues, std::tr1::shared_ptr<Texture> ptr,
66
+ const Bitmap& bmp, unsigned padding)
66
67
  {
67
68
  std::auto_ptr<Gosu::TexChunk> result;
68
69
 
69
- boost::optional<BlockAllocator::Block> block = allocator.alloc(bmp.width(), bmp.height());
70
- if (!block)
70
+ BlockAllocator::Block block;
71
+ if (!allocator.alloc(bmp.width(), bmp.height(), block))
71
72
  return result;
72
73
 
73
- result.reset(new TexChunk(graphics, transforms, queues, ptr, block->left + padding, block->top + padding,
74
- block->width - 2 * padding, block->height - 2 * padding, padding));
74
+ result.reset(new TexChunk(graphics, transforms, queues, ptr, block.left + padding, block.top + padding,
75
+ block.width - 2 * padding, block.height - 2 * padding, padding));
75
76
 
76
77
  glBindTexture(GL_TEXTURE_2D, name);
77
- glTexSubImage2D(GL_TEXTURE_2D, 0, block->left, block->top, block->width, block->height,
78
+ glTexSubImage2D(GL_TEXTURE_2D, 0, block.left, block.top, block.width, block.height,
78
79
  Color::GL_FORMAT, GL_UNSIGNED_BYTE, bmp.data());
79
80
 
80
81
  num += 1;
@@ -3,11 +3,10 @@
3
3
 
4
4
  #include <Gosu/Fwd.hpp>
5
5
  #include <Gosu/Bitmap.hpp>
6
+ #include <Gosu/TR1.hpp>
6
7
  #include <GosuImpl/Graphics/Common.hpp>
7
8
  #include <GosuImpl/Graphics/TexChunk.hpp>
8
9
  #include <GosuImpl/Graphics/BlockAllocator.hpp>
9
- #include <boost/cstdint.hpp>
10
- #include <boost/shared_ptr.hpp>
11
10
  #include <vector>
12
11
 
13
12
  namespace Gosu
@@ -24,8 +23,8 @@ namespace Gosu
24
23
  unsigned size() const;
25
24
  GLuint texName() const;
26
25
  std::auto_ptr<TexChunk>
27
- tryAlloc(Graphics& graphics, Transforms& transforms, DrawOpQueueStack& queues, boost::shared_ptr<Texture> ptr,
28
- const Bitmap& bmp, unsigned padding);
26
+ tryAlloc(Graphics& graphics, Transforms& transforms, DrawOpQueueStack& queues,
27
+ std::tr1::shared_ptr<Texture> ptr, const Bitmap& bmp, unsigned padding);
29
28
  void free(unsigned x, unsigned y);
30
29
  Gosu::Bitmap toBitmap(unsigned x, unsigned y, unsigned width, unsigned height) const;
31
30
  };
@@ -3,10 +3,9 @@
3
3
  #include <Gosu/Input.hpp>
4
4
  #include <Gosu/TextInput.hpp>
5
5
  #include <GosuImpl/MacUtility.hpp>
6
+ #include <Gosu/TR1.hpp>
6
7
  #include <Gosu/Utility.hpp>
7
8
  #include <IOKit/hidsystem/IOLLEvent.h>
8
- #include <boost/array.hpp>
9
- #include <boost/cstdint.hpp>
10
9
  #include <map>
11
10
  #include <string>
12
11
  #include <vector>
@@ -21,14 +20,13 @@
21
20
  #include <IOKit/IOCFPlugIn.h>
22
21
  #include <stdexcept>
23
22
  #include <vector>
24
- #include <boost/shared_ptr.hpp>
25
23
 
26
24
  // USB Gamepad code, likely to be moved somewhere else later.
27
25
  // This is Frankencode until the Input redesign happens.
28
26
  namespace {
29
27
  using namespace std;
30
28
  using namespace Gosu;
31
- using boost::shared_ptr;
29
+ using tr1::shared_ptr;
32
30
 
33
31
  template<typename Negatable>
34
32
  void checkTrue(Negatable cond, const char* message = "work")
@@ -42,9 +40,12 @@ namespace {
42
40
  checkTrue(val == kIOReturnSuccess, message);
43
41
  }
44
42
 
45
- class IOScope : boost::noncopyable
43
+ class IOScope
46
44
  {
47
45
  io_object_t ref;
46
+
47
+ IOScope(const IOScope&);
48
+ IOScope& operator=(const IOScope&);
48
49
  public:
49
50
  IOScope(io_object_t ref)
50
51
  : ref(ref)
@@ -325,11 +326,10 @@ namespace {
325
326
  return devices.at(i);
326
327
  }
327
328
 
328
- boost::array<bool, gpNum> poll()
329
+ std::tr1::array<bool, gpNum> poll()
329
330
  {
330
- boost::array<bool, gpNum> result;
331
- result.assign(false);
332
-
331
+ std::tr1::array<bool, gpNum> result = { false };
332
+
333
333
  IOHIDEventStruct event;
334
334
  for (int dev = 0; dev < devices.size(); ++dev)
335
335
  {
@@ -429,7 +429,7 @@ namespace Gosu
429
429
  namespace {
430
430
  const unsigned numScancodes = 128;
431
431
 
432
- boost::array<wchar_t, numScancodes> idChars;
432
+ std::tr1::array<wchar_t, numScancodes> idChars = { 0 };
433
433
  std::map<wchar_t, unsigned> charIds;
434
434
 
435
435
  void initCharTranslation()
@@ -439,8 +439,6 @@ namespace {
439
439
  return;
440
440
  initializedCharData = true;
441
441
 
442
- idChars.assign(0);
443
-
444
442
  #ifdef __LP64__
445
443
  CFRef<TISInputSourceRef> is(TISCopyCurrentKeyboardLayoutInputSource());
446
444
  CFRef<CFDataRef> UCHR(
@@ -507,7 +505,7 @@ namespace {
507
505
  #endif
508
506
  }
509
507
 
510
- boost::array<bool, Gosu::numButtons> buttonStates;
508
+ std::tr1::array<bool, Gosu::numButtons> buttonStates = { false };
511
509
  }
512
510
 
513
511
  struct Gosu::Input::Impl
@@ -575,7 +573,6 @@ Gosu::Input::Input(void* window)
575
573
  : pimpl(new Impl(*this))
576
574
  {
577
575
  pimpl->window = static_cast<NSWindow*>(window);
578
- buttonStates.assign(false);
579
576
  initCharTranslation();
580
577
  }
581
578
 
@@ -733,7 +730,7 @@ void Gosu::Input::update()
733
730
  pimpl->queue.clear();
734
731
 
735
732
  static System sys;
736
- boost::array<bool, gpNum> gpState = sys.poll();
733
+ std::tr1::array<bool, gpNum> gpState = sys.poll();
737
734
  for (unsigned i = 0; i < gpNum; ++i)
738
735
  {
739
736
  if (buttonStates[i + gpRangeBegin] != gpState[i])
@@ -20,7 +20,7 @@ struct Gosu::Input::Impl {
20
20
  float updateInterval;
21
21
 
22
22
  ObjRef<NSMutableSet> currentTouchesSet;
23
- boost::scoped_ptr<Gosu::Touches> currentTouchesVector;
23
+ std::auto_ptr<Gosu::Touches> currentTouchesVector;
24
24
 
25
25
  Touch translateTouch(UITouch* uiTouch)
26
26
  {
@@ -66,7 +66,7 @@ void Gosu::Input::feedTouchEvent(int type, void* touches)
66
66
  NSSet* uiTouches = (NSSet*)touches;
67
67
 
68
68
  pimpl->currentTouchesVector.reset();
69
- boost::function<void (Touch)>* f = &onTouchMoved;
69
+ std::tr1::function<void (Touch)>* f = &onTouchMoved;
70
70
  if (type == 0)
71
71
  [pimpl->currentTouchesSet.get() unionSet: uiTouches], f = &onTouchBegan;
72
72
  else if (type == 2)
@@ -106,7 +106,7 @@ void Gosu::Input::setMouseFactors(double factorX, double factorY) {
106
106
 
107
107
  const Gosu::Touches& Gosu::Input::currentTouches() const
108
108
  {
109
- if (!pimpl->currentTouchesVector)
109
+ if (!pimpl->currentTouchesVector.get())
110
110
  {
111
111
  pimpl->currentTouchesVector.reset(new Gosu::Touches);
112
112
  for (UITouch* uiTouch in pimpl->currentTouchesSet.obj())
@@ -1,8 +1,7 @@
1
1
  #include <Gosu/Input.hpp>
2
2
  #include <Gosu/Platform.hpp>
3
+ #include <Gosu/TR1.hpp>
3
4
  #include <Gosu/WinUtility.hpp>
4
- #include <boost/array.hpp>
5
- #include <boost/shared_ptr.hpp>
6
5
  #include <cwchar>
7
6
  #include <iomanip>
8
7
  #include <sstream>
@@ -15,7 +14,7 @@
15
14
  #include <dinput.h>
16
15
 
17
16
  namespace {
18
- boost::array<bool, Gosu::numButtons> buttons;
17
+ std::tr1::array<bool, Gosu::numButtons> buttons;
19
18
  }
20
19
 
21
20
  struct Gosu::Input::Impl
@@ -24,14 +23,14 @@ struct Gosu::Input::Impl
24
23
  Impl() : textInput(0) {}
25
24
 
26
25
  HWND window;
27
- boost::shared_ptr<IDirectInput8> input;
26
+ std::tr1::shared_ptr<IDirectInput8> input;
28
27
 
29
- typedef boost::shared_ptr<IDirectInputDevice8> Device;
28
+ typedef std::tr1::shared_ptr<IDirectInputDevice8> Device;
30
29
  Device keyboard, mouse;
31
30
  std::vector<Device> gamepads;
32
31
 
33
32
  double mouseX, mouseY;
34
- double mouseFactorX, mouseFactorY;
33
+ double mouseFactorX, mouseFactorY;
35
34
  bool swapMouse;
36
35
 
37
36
  struct EventInfo
@@ -132,156 +131,147 @@ struct Gosu::Input::Impl
132
131
  return DIENUM_CONTINUE;
133
132
  }
134
133
 
135
- void updateMousePos()
136
- {
137
- POINT pos;
138
- if (!::GetCursorPos(&pos))
139
- return;
134
+ void updateMousePos()
135
+ {
136
+ POINT pos;
137
+ if (!::GetCursorPos(&pos))
138
+ return;
140
139
 
141
- Win::check(::ScreenToClient(window, &pos));
140
+ Win::check(::ScreenToClient(window, &pos));
142
141
 
143
- mouseX = pos.x;
144
- mouseY = pos.y;
145
- }
142
+ mouseX = pos.x;
143
+ mouseY = pos.y;
144
+ }
146
145
 
147
- void updateButtons(bool collectEvents)
148
- {
149
- DIDEVICEOBJECTDATA data[inputBufferSize];
150
- DWORD inOut;
151
- HRESULT hr;
146
+ void updateButtons(bool collectEvents)
147
+ {
148
+ DIDEVICEOBJECTDATA data[inputBufferSize];
149
+ DWORD inOut;
150
+ HRESULT hr;
152
151
 
153
152
  RECT rect;
154
153
  ::GetClientRect(window, &rect);
155
154
  bool ignoreClicks = mouseX < 0 || mouseX > rect.right || mouseY < 0 || mouseY > rect.bottom;
156
155
 
157
- inOut = inputBufferSize;
158
- hr = mouse->GetDeviceData(sizeof data[0], data, &inOut, 0);
159
- switch(hr)
160
- {
161
- case DI_OK:
162
- case DI_BUFFEROVERFLOW:
163
- {
164
- // Everything's ok: Update buttons and fire events.
165
- for (unsigned i = 0; i < inOut; ++i)
166
- {
167
- bool down = (data[i].dwData & 0x80) != 0 && !ignoreClicks;
168
-
169
- switch (data[i].dwOfs)
170
- {
171
- case DIMOFS_BUTTON0:
172
- {
173
- unsigned id = swapMouse ? msRight : msLeft;
174
- setButton(id, down, collectEvents);
175
- break;
176
- }
177
- case DIMOFS_BUTTON1:
178
- {
179
- unsigned id = swapMouse ? msLeft : msRight;
180
- setButton(id, down, collectEvents);
181
- break;
182
- }
183
- case DIMOFS_BUTTON2:
184
- {
185
- setButton(msMiddle, down, collectEvents);
186
- break;
187
- }
188
- case DIMOFS_Z:
189
- {
190
- if (!collectEvents || data[i].dwData == 0)
191
- break;
192
-
193
- EventInfo event;
194
- event.action = EventInfo::buttonDown;
195
- if (int(data[i].dwData) < 0)
196
- event.id = msWheelDown;
197
- else
198
- event.id = msWheelUp;
199
- events.push_back(event);
200
- event.action = EventInfo::buttonUp;
201
- events.push_back(event);
202
- break;
203
- }
204
- }
205
- }
206
- break;
207
- }
208
-
209
- case DIERR_NOTACQUIRED:
210
- case DIERR_INPUTLOST:
211
- {
212
- // Cannot fetch new events: Release all buttons.
213
- for (unsigned id = msRangeBegin; id < msRangeEnd; ++id)
214
- setButton(id, false, collectEvents);
215
- mouse->Acquire();
216
- break;
217
- }
218
- }
156
+ inOut = inputBufferSize;
157
+ hr = mouse->GetDeviceData(sizeof data[0], data, &inOut, 0);
158
+ switch(hr)
159
+ {
160
+ case DI_OK:
161
+ case DI_BUFFEROVERFLOW:
162
+ {
163
+ // Everything's ok: Update buttons and fire events.
164
+ for (unsigned i = 0; i < inOut; ++i)
165
+ {
166
+ bool down = (data[i].dwData & 0x80) != 0 && !ignoreClicks;
167
+
168
+ // No switch statement here because it breaks compilation with MinGW.
169
+ if (data[i].dwOfs == DIMOFS_BUTTON0)
170
+ {
171
+ unsigned id = swapMouse ? msRight : msLeft;
172
+ setButton(id, down, collectEvents);
173
+ }
174
+ else if (data[i].dwOfs == DIMOFS_BUTTON1)
175
+ {
176
+ unsigned id = swapMouse ? msLeft : msRight;
177
+ setButton(id, down, collectEvents);
178
+ }
179
+ else if (data[i].dwOfs == DIMOFS_BUTTON2)
180
+ {
181
+ setButton(msMiddle, down, collectEvents);
182
+ }
183
+ else if (data[i].dwOfs == DIMOFS_Z &&
184
+ collectEvents && data[i].dwData)
185
+ {
186
+ EventInfo event;
187
+ event.action = EventInfo::buttonDown;
188
+ if (int(data[i].dwData) < 0)
189
+ event.id = msWheelDown;
190
+ else
191
+ event.id = msWheelUp;
192
+ events.push_back(event);
193
+ event.action = EventInfo::buttonUp;
194
+ events.push_back(event);
195
+ }
196
+ }
197
+ break;
198
+ }
199
+
200
+ case DIERR_NOTACQUIRED:
201
+ case DIERR_INPUTLOST:
202
+ {
203
+ // Cannot fetch new events: Release all buttons.
204
+ for (unsigned id = msRangeBegin; id < msRangeEnd; ++id)
205
+ setButton(id, false, collectEvents);
206
+ mouse->Acquire();
207
+ break;
208
+ }
209
+ }
219
210
 
220
211
  keyboard:
221
212
 
222
- inOut = inputBufferSize;
223
- hr = keyboard->GetDeviceData(sizeof data[0], data, &inOut, 0);
224
- switch (hr)
225
- {
226
- case DI_OK:
227
- case DI_BUFFEROVERFLOW:
228
- {
229
- for (unsigned i = 0; i < inOut; ++i)
230
- forceButton(data[i].dwOfs, (data[i].dwData & 0x80) != 0, collectEvents);
231
- break;
232
- }
233
-
234
- case DIERR_NOTACQUIRED:
235
- case DIERR_INPUTLOST:
236
- {
237
- for (unsigned id = kbRangeBegin; id < kbRangeEnd; ++id)
238
- setButton(id, false, collectEvents);
239
- keyboard->Acquire();
240
- break;
241
- }
242
- }
243
-
244
- boost::array<bool, gpNum> gpBuffer;
245
- gpBuffer.assign(false);
246
- for (unsigned gp = 0; gp < gamepads.size(); ++gp)
247
- {
248
- gamepads[gp]->Poll();
249
-
250
- DIJOYSTATE joy;
251
- hr = gamepads[gp]->GetDeviceState(sizeof joy, &joy);
252
- switch (hr)
253
- {
254
- case DI_OK:
255
- {
256
- if (joy.lX < -stickThreshold)
257
- gpBuffer[gpLeft - gpRangeBegin] = true;
258
- else if (joy.lX > stickThreshold)
259
- gpBuffer[gpRight - gpRangeBegin] = true;
260
-
261
- if (joy.lY < -stickThreshold)
262
- gpBuffer[gpUp - gpRangeBegin] = true;
263
- else if (joy.lY > stickThreshold)
264
- gpBuffer[gpDown - gpRangeBegin] = true;
265
-
266
- for (unsigned id = gpButton0; id < gpRangeEnd; ++id)
267
- if (joy.rgbButtons[id - gpButton0])
268
- gpBuffer[id - gpRangeBegin] = true;
269
-
270
- break;
271
- }
272
-
273
- case DIERR_NOTACQUIRED:
274
- case DIERR_INPUTLOST:
275
- {
276
- gamepads[gp]->Acquire();
277
-
278
- break;
279
- }
280
- }
281
- }
282
- for (unsigned id = gpRangeBegin; id < gpRangeEnd; ++id)
283
- setButton(id, gpBuffer[id - gpRangeBegin], collectEvents);
284
- }
213
+ inOut = inputBufferSize;
214
+ hr = keyboard->GetDeviceData(sizeof data[0], data, &inOut, 0);
215
+ switch (hr)
216
+ {
217
+ case DI_OK:
218
+ case DI_BUFFEROVERFLOW:
219
+ {
220
+ for (unsigned i = 0; i < inOut; ++i)
221
+ forceButton(data[i].dwOfs, (data[i].dwData & 0x80) != 0, collectEvents);
222
+ break;
223
+ }
224
+
225
+ case DIERR_NOTACQUIRED:
226
+ case DIERR_INPUTLOST:
227
+ {
228
+ for (unsigned id = kbRangeBegin; id < kbRangeEnd; ++id)
229
+ setButton(id, false, collectEvents);
230
+ keyboard->Acquire();
231
+ break;
232
+ }
233
+ }
234
+
235
+ std::tr1::array<bool, gpNum> gpBuffer = { false };
236
+ for (unsigned gp = 0; gp < gamepads.size(); ++gp)
237
+ {
238
+ gamepads[gp]->Poll();
239
+
240
+ DIJOYSTATE joy;
241
+ hr = gamepads[gp]->GetDeviceState(sizeof joy, &joy);
242
+ switch (hr)
243
+ {
244
+ case DI_OK:
245
+ {
246
+ if (joy.lX < -stickThreshold)
247
+ gpBuffer[gpLeft - gpRangeBegin] = true;
248
+ else if (joy.lX > stickThreshold)
249
+ gpBuffer[gpRight - gpRangeBegin] = true;
250
+
251
+ if (joy.lY < -stickThreshold)
252
+ gpBuffer[gpUp - gpRangeBegin] = true;
253
+ else if (joy.lY > stickThreshold)
254
+ gpBuffer[gpDown - gpRangeBegin] = true;
255
+
256
+ for (unsigned id = gpButton0; id < gpRangeEnd; ++id)
257
+ if (joy.rgbButtons[id - gpButton0])
258
+ gpBuffer[id - gpRangeBegin] = true;
259
+
260
+ break;
261
+ }
262
+
263
+ case DIERR_NOTACQUIRED:
264
+ case DIERR_INPUTLOST:
265
+ {
266
+ gamepads[gp]->Acquire();
267
+
268
+ break;
269
+ }
270
+ }
271
+ }
272
+ for (unsigned id = gpRangeBegin; id < gpRangeEnd; ++id)
273
+ setButton(id, gpBuffer[id - gpRangeBegin], collectEvents);
274
+ }
285
275
  };
286
276
 
287
277
  Gosu::Input::Input(HWND window)
@@ -355,7 +345,7 @@ Gosu::Input::Input(HWND window)
355
345
 
356
346
  // Get into a usable default state.
357
347
 
358
- pimpl->mouseX = pimpl->mouseY = 0;
348
+ pimpl->mouseX = pimpl->mouseY = 0;
359
349
  pimpl->updateMousePos();
360
350
  buttons.assign(false);
361
351
  }
@@ -372,7 +362,7 @@ Gosu::Button Gosu::Input::charToId(wchar_t ch)
372
362
  if (HIBYTE(vkey) == static_cast<unsigned char>(-1) &&
373
363
  LOBYTE(vkey) == static_cast<unsigned char>(-1))
374
364
  {
375
- return noButton;
365
+ return noButton;
376
366
  }
377
367
 
378
368
  // Key needs special modifier keys?
@@ -385,7 +375,7 @@ Gosu::Button Gosu::Input::charToId(wchar_t ch)
385
375
 
386
376
  wchar_t Gosu::Input::idToChar(Gosu::Button btn)
387
377
  {
388
- // Only translate keyboard ids.
378
+ // Only translate keyboard ids.
389
379
  if (btn.id() > 255)
390
380
  return 0;
391
381
 
@@ -397,16 +387,16 @@ wchar_t Gosu::Input::idToChar(Gosu::Button btn)
397
387
  // (Three elements so too-long names will make GKNT return 3 and we'll know.)
398
388
  wchar_t buf[3];
399
389
  if (::GetKeyNameText(btn.id() << 16, buf, 3) == 1)
400
- return /*std::*/towlower(buf[0]);
390
+ return /*std::*/towlower(buf[0]);
401
391
 
402
392
  return 0;
403
393
  }
404
394
 
405
395
  bool Gosu::Input::down(Button btn) const
406
396
  {
407
- // The invalid button is never pressed (but can be passed to this function).
408
- if (btn == noButton || btn.id() >= numButtons)
409
- return false;
397
+ // The invalid button is never pressed (but can be passed to this function).
398
+ if (btn == noButton || btn.id() >= numButtons)
399
+ return false;
410
400
 
411
401
  return buttons.at(btn.id());
412
402
  }
@@ -423,16 +413,16 @@ double Gosu::Input::mouseY() const
423
413
 
424
414
  void Gosu::Input::setMousePosition(double x, double y)
425
415
  {
426
- POINT pos = { x / pimpl->mouseFactorX, y / pimpl->mouseFactorY };
427
- ::ClientToScreen(pimpl->window, &pos);
428
- ::SetCursorPos(pos.x, pos.y);
429
- pimpl->updateMousePos();
416
+ POINT pos = { x / pimpl->mouseFactorX, y / pimpl->mouseFactorY };
417
+ ::ClientToScreen(pimpl->window, &pos);
418
+ ::SetCursorPos(pos.x, pos.y);
419
+ pimpl->updateMousePos();
430
420
  }
431
421
 
432
422
  void Gosu::Input::setMouseFactors(double factorX, double factorY)
433
423
  {
434
- pimpl->mouseFactorX = factorX;
435
- pimpl->mouseFactorY = factorY;
424
+ pimpl->mouseFactorX = factorX;
425
+ pimpl->mouseFactorY = factorY;
436
426
  }
437
427
 
438
428
  const Gosu::Touches& Gosu::Input::currentTouches() const
@@ -460,7 +450,7 @@ void Gosu::Input::update()
460
450
  {
461
451
  pimpl->updateMousePos();
462
452
  pimpl->updateButtons(true);
463
- Impl::Events events;
453
+ Impl::Events events;
464
454
  events.swap(pimpl->events);
465
455
  for (unsigned i = 0; i < events.size(); ++i)
466
456
  {