gosu 0.7.33 → 0.7.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gosu/Async.hpp +10 -8
- data/Gosu/Audio.hpp +6 -4
- data/Gosu/AutoLink.hpp +0 -0
- data/Gosu/Bitmap.hpp +4 -5
- data/Gosu/ButtonsX.hpp +1 -1
- data/Gosu/Color.hpp +8 -8
- data/Gosu/Font.hpp +2 -2
- data/Gosu/Graphics.hpp +4 -6
- data/Gosu/IO.hpp +11 -4
- data/Gosu/Image.hpp +9 -7
- data/Gosu/ImageData.hpp +10 -4
- data/Gosu/Input.hpp +4 -5
- data/Gosu/Sockets.hpp +10 -12
- data/Gosu/TR1.hpp +44 -0
- data/Gosu/TextInput.hpp +2 -2
- data/Gosu/Version.hpp +2 -2
- data/Gosu/WinUtility.hpp +5 -6
- data/Gosu/Window.hpp +5 -6
- data/GosuImpl/Async.cpp +4 -3
- data/GosuImpl/Audio/ALChannelManagement.hpp +23 -11
- data/GosuImpl/Audio/AudioFile.hpp +11 -3
- data/GosuImpl/Audio/AudioOpenAL.cpp +613 -0
- data/GosuImpl/Audio/AudioOpenAL.mm +1 -605
- data/GosuImpl/Audio/AudioSDL.cpp +12 -14
- data/GosuImpl/Audio/AudioToolboxFile.hpp +0 -1
- data/GosuImpl/Audio/OggFile.hpp +2 -0
- data/GosuImpl/Audio/SndFile.hpp +158 -0
- data/GosuImpl/DirectoriesWin.cpp +18 -18
- data/GosuImpl/Graphics/BitmapApple.mm +17 -19
- data/GosuImpl/Graphics/BitmapBMP.cpp +7 -2
- data/GosuImpl/Graphics/BitmapFreeImage.cpp +11 -12
- data/GosuImpl/Graphics/BitmapGDIplus.cpp +35 -31
- data/GosuImpl/Graphics/BitmapUtils.cpp +1 -1
- data/GosuImpl/Graphics/BlockAllocator.cpp +7 -8
- data/GosuImpl/Graphics/BlockAllocator.hpp +3 -4
- data/GosuImpl/Graphics/Common.hpp +3 -2
- data/GosuImpl/Graphics/DrawOp.hpp +2 -3
- data/GosuImpl/Graphics/DrawOpQueue.hpp +28 -20
- data/GosuImpl/Graphics/Font.cpp +13 -13
- data/GosuImpl/Graphics/FormattedString.hpp +93 -86
- data/GosuImpl/Graphics/Graphics.cpp +16 -14
- data/GosuImpl/Graphics/Image.cpp +7 -3
- data/GosuImpl/Graphics/LargeImageData.hpp +4 -5
- data/GosuImpl/Graphics/Macro.hpp +11 -11
- data/GosuImpl/Graphics/RenderState.hpp +5 -4
- data/GosuImpl/Graphics/TexChunk.cpp +3 -3
- data/GosuImpl/Graphics/TexChunk.hpp +4 -4
- data/GosuImpl/Graphics/Text.cpp +29 -30
- data/GosuImpl/Graphics/TextMac.cpp +9 -7
- data/GosuImpl/Graphics/TextTTFWin.cpp +3 -1
- data/GosuImpl/Graphics/TextTouch.mm +0 -1
- data/GosuImpl/Graphics/TextUnix.cpp +12 -4
- data/GosuImpl/Graphics/TextWin.cpp +4 -2
- data/GosuImpl/Graphics/Texture.cpp +7 -6
- data/GosuImpl/Graphics/Texture.hpp +3 -4
- data/GosuImpl/InputMac.mm +12 -15
- data/GosuImpl/InputTouch.mm +3 -3
- data/GosuImpl/InputWin.cpp +149 -159
- data/GosuImpl/InputX.cpp +0 -0
- data/GosuImpl/MacUtility.hpp +9 -4
- data/GosuImpl/RubyGosu.swg +38 -43
- data/GosuImpl/RubyGosu_wrap.cxx +89 -96
- data/GosuImpl/Sockets/CommSocket.cpp +5 -5
- data/GosuImpl/Sockets/Sockets.hpp +4 -4
- data/GosuImpl/TimingApple.cpp +2 -3
- data/GosuImpl/Utility.cpp +18 -0
- data/GosuImpl/WinMain.cpp +0 -1
- data/GosuImpl/WinUtility.cpp +2 -2
- data/GosuImpl/WindowMac.mm +20 -17
- data/GosuImpl/WindowTouch.mm +8 -7
- data/GosuImpl/WindowWin.cpp +12 -7
- data/GosuImpl/WindowX.cpp +67 -18
- data/lib/gosu.rb +14 -12
- data/linux/extconf.rb +11 -6
- metadata +8 -7
- data/GosuImpl/Audio/AudioAudiere.cpp +0 -448
- 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,
|
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
|
-
|
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
|
74
|
-
block
|
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
|
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,
|
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
|
};
|
data/GosuImpl/InputMac.mm
CHANGED
@@ -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
|
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
|
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
|
-
|
329
|
+
std::tr1::array<bool, gpNum> poll()
|
329
330
|
{
|
330
|
-
|
331
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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])
|
data/GosuImpl/InputTouch.mm
CHANGED
@@ -20,7 +20,7 @@ struct Gosu::Input::Impl {
|
|
20
20
|
float updateInterval;
|
21
21
|
|
22
22
|
ObjRef<NSMutableSet> currentTouchesSet;
|
23
|
-
|
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
|
-
|
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())
|
data/GosuImpl/InputWin.cpp
CHANGED
@@ -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
|
-
|
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
|
-
|
26
|
+
std::tr1::shared_ptr<IDirectInput8> input;
|
28
27
|
|
29
|
-
typedef
|
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
|
-
|
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
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
134
|
+
void updateMousePos()
|
135
|
+
{
|
136
|
+
POINT pos;
|
137
|
+
if (!::GetCursorPos(&pos))
|
138
|
+
return;
|
140
139
|
|
141
|
-
|
140
|
+
Win::check(::ScreenToClient(window, &pos));
|
142
141
|
|
143
|
-
|
144
|
-
|
145
|
-
|
142
|
+
mouseX = pos.x;
|
143
|
+
mouseY = pos.y;
|
144
|
+
}
|
146
145
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
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
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
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
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
408
|
-
|
409
|
-
|
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
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
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
|
-
|
435
|
-
|
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
|
-
|
453
|
+
Impl::Events events;
|
464
454
|
events.swap(pimpl->events);
|
465
455
|
for (unsigned i = 0; i < events.size(); ++i)
|
466
456
|
{
|