gosu 0.7.46 → 0.7.47.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA512:
3
+ metadata.gz: 46f962dcbee435df36c0b90f2c9a7f0eb0697affd20202a9b3f0b74438cef81715a549d4f40922ee0fc6f54472d80a43dbb220610092b17bb16b79674f93d657
4
+ data.tar.gz: 65c994b275f5c0c3cbb131f5c9071ffa51f62a63123efa78cc945b90c5a4305135e77776caf29a63e822909bff6048b2ec333db5c68ff5f032be69395e0cb9c8
5
+ SHA1:
6
+ metadata.gz: 5717d9bb26797d0752706336725a51bb7d1569a0
7
+ data.tar.gz: 1ace5dbeaf66ffa54ae91e4767edf113d84035a3
@@ -1,5 +1,19 @@
1
- #ifndef GOSU_BUTTONSWIN_HPP
2
- #define GOSU_BUTTONSWIN_HPP
1
+ #ifndef GOSU_BUTTONS_HPP
2
+ #define GOSU_BUTTONS_HPP
3
+
4
+ #include <Gosu/Platform.hpp>
5
+
6
+ #ifdef GOSU_IS_MAC
7
+ #define GOSU_SCANCODE(mac, windows_or_linux) mac
8
+ #define GOSU_SPECIAL_SCANCODE(mac, windows, linux) mac
9
+ #else
10
+ #define GOSU_SCANCODE(mac, linux_or_windows) linux_or_windows
11
+ #ifdef GOSU_IS_WIN
12
+ #define GOSU_SPECIAL_SCANCODE(mac, windows, linux) windows
13
+ #else
14
+ #define GOSU_SPECIAL_SCANCODE(mac, windows, linux) linux
15
+ #endif
16
+ #endif
3
17
 
4
18
  namespace Gosu
5
19
  {
@@ -8,93 +22,104 @@ namespace Gosu
8
22
  //! mouse buttons and mouse wheel (ms*) and gamepad buttons (gp*).
9
23
  enum ButtonName
10
24
  {
11
- kbRangeBegin = 0x00,
12
- kbEscape = 0x01,
13
- kbF1 = 0x3b,
14
- kbF2 = 0x3c,
15
- kbF3 = 0x3d,
16
- kbF4 = 0x3e,
17
- kbF5 = 0x3f,
18
- kbF6 = 0x40,
19
- kbF7 = 0x41,
20
- kbF8 = 0x42,
21
- kbF9 = 0x43,
22
- kbF10 = 0x44,
23
- kbF11 = 0x57,
24
- kbF12 = 0x58,
25
- kb0 = 0x0b,
26
- kb1 = 0x02,
27
- kb2 = 0x03,
28
- kb3 = 0x04,
29
- kb4 = 0x05,
30
- kb5 = 0x06,
31
- kb6 = 0x07,
32
- kb7 = 0x08,
33
- kb8 = 0x09,
34
- kb9 = 0x0a,
35
- kbTab = 0x0f,
36
- kbReturn = 0x1c,
37
- kbSpace = 0x39,
38
- kbLeftShift = 0x2a,
39
- kbRightShift = 0x36,
40
- kbLeftControl = 0x1d,
41
- kbRightControl = 0x9d,
42
- kbLeftAlt = 0x38,
43
- kbRightAlt = 0xb8,
44
- kbLeftMeta = 0xdb,
45
- kbRightMeta = 0xdc,
46
- kbBackspace = 0x0e,
47
- kbLeft = 0xcb,
48
- kbRight = 0xcd,
49
- kbUp = 0xc8,
50
- kbDown = 0xd0,
51
- kbHome = 0xc7,
52
- kbEnd = 0xcf,
53
- kbInsert = 0xd2,
54
- kbDelete = 0xd3,
55
- kbPageUp = 0xc9,
56
- kbPageDown = 0xd1,
57
- kbEnter = 0x9c,
58
- kbA = 0x1e,
59
- kbB = 0x30,
60
- kbC = 0x2e,
61
- kbD = 0x20,
62
- kbE = 0x12,
63
- kbF = 0x21,
64
- kbG = 0x22,
65
- kbH = 0x23,
66
- kbI = 0x17,
67
- kbJ = 0x24,
68
- kbK = 0x25,
69
- kbL = 0x26,
70
- kbM = 0x32,
71
- kbN = 0x31,
72
- kbO = 0x18,
73
- kbP = 0x19,
74
- kbQ = 0x10,
75
- kbR = 0x13,
76
- kbS = 0x1f,
77
- kbT = 0x14,
78
- kbU = 0x16,
79
- kbV = 0x2f,
80
- kbW = 0x11,
81
- kbX = 0x2d,
82
- kbY = 0x15,
83
- kbZ = 0x2c,
84
- kbNumpad0 = 0x52,
85
- kbNumpad1 = 0x4f,
86
- kbNumpad2 = 0x50,
87
- kbNumpad3 = 0x51,
88
- kbNumpad4 = 0x4b,
89
- kbNumpad5 = 0x4c,
90
- kbNumpad6 = 0x4d,
91
- kbNumpad7 = 0x47,
92
- kbNumpad8 = 0x48,
93
- kbNumpad9 = 0x49,
94
- kbNumpadAdd = 0x4e,
95
- kbNumpadSubtract = 0x4a,
96
- kbNumpadMultiply = 0x37,
97
- kbNumpadDivide = 0xb5,
25
+ kbRangeBegin,
26
+ kbEscape = GOSU_SCANCODE(0x35, 0x01),
27
+ kbF1 = GOSU_SCANCODE(0x7a, 0x3b),
28
+ kbF2 = GOSU_SCANCODE(0x78, 0x3c),
29
+ kbF3 = GOSU_SCANCODE(0x63, 0x3d),
30
+ kbF4 = GOSU_SCANCODE(0x76, 0x3e),
31
+ kbF5 = GOSU_SCANCODE(0x60, 0x3f),
32
+ kbF6 = GOSU_SCANCODE(0x61, 0x40),
33
+ kbF7 = GOSU_SCANCODE(0x62, 0x41),
34
+ kbF8 = GOSU_SCANCODE(0x64, 0x42),
35
+ kbF9 = GOSU_SCANCODE(0x65, 0x43),
36
+ kbF10 = GOSU_SCANCODE(0x6d, 0x44),
37
+ kbF11 = GOSU_SCANCODE(0x67, 0x57),
38
+ kbF12 = GOSU_SCANCODE(0x6f, 0x58),
39
+ kb0 = GOSU_SCANCODE(0x1d, 0x0b),
40
+ kb1 = GOSU_SCANCODE(0x12, 0x02),
41
+ kb2 = GOSU_SCANCODE(0x13, 0x03),
42
+ kb3 = GOSU_SCANCODE(0x14, 0x04),
43
+ kb4 = GOSU_SCANCODE(0x15, 0x05),
44
+ kb5 = GOSU_SCANCODE(0x17, 0x06),
45
+ kb6 = GOSU_SCANCODE(0x16, 0x07),
46
+ kb7 = GOSU_SCANCODE(0x1a, 0x08),
47
+ kb8 = GOSU_SCANCODE(0x1c, 0x09),
48
+ kb9 = GOSU_SCANCODE(0x19, 0x0a),
49
+ kbTab = GOSU_SCANCODE(0x30, 0x0f),
50
+ kbReturn = GOSU_SCANCODE(0x24, 0x1c),
51
+ kbSpace = GOSU_SCANCODE(0x31, 0x39),
52
+ kbLeftShift = GOSU_SCANCODE(0x38, 0x2a),
53
+ kbRightShift = GOSU_SCANCODE(0x3c, 0x36),
54
+ kbLeftControl = GOSU_SCANCODE(0x3b, 0x1d),
55
+ kbRightControl = GOSU_SPECIAL_SCANCODE(0x3e, 0x9d, 0x61),
56
+ kbLeftAlt = GOSU_SCANCODE(0x3a, 0x38),
57
+ kbRightAlt = GOSU_SPECIAL_SCANCODE(0x3d, 0xb8, 0x64),
58
+ kbLeftMeta = GOSU_SPECIAL_SCANCODE(0x37, 0xdb, 0x7d),
59
+ kbRightMeta = GOSU_SPECIAL_SCANCODE(0x36, 0xdc, 0x7e),
60
+ kbBackspace = GOSU_SCANCODE(0x33, 0x0e),
61
+ kbLeft = GOSU_SPECIAL_SCANCODE(0x7b, 0xcb, 0x69),
62
+ kbRight = GOSU_SPECIAL_SCANCODE(0x7c, 0xcd, 0x6a),
63
+ kbUp = GOSU_SPECIAL_SCANCODE(0x7e, 0xc8, 0x67),
64
+ kbDown = GOSU_SPECIAL_SCANCODE(0x7d, 0xd0, 0x6c),
65
+ kbHome = GOSU_SPECIAL_SCANCODE(0x73, 0xc7, 0x66),
66
+ kbEnd = GOSU_SPECIAL_SCANCODE(0x77, 0xcf, 0x6b),
67
+ kbInsert = GOSU_SPECIAL_SCANCODE(0x72, 0xd2, 0x6e),
68
+ kbDelete = GOSU_SPECIAL_SCANCODE(0x75, 0xd3, 0x6f),
69
+ kbPageUp = GOSU_SPECIAL_SCANCODE(0x74, 0xc9, 0x68),
70
+ kbPageDown = GOSU_SPECIAL_SCANCODE(0x79, 0xd1, 0x6d),
71
+ kbEnter = GOSU_SPECIAL_SCANCODE(0x4c, 0x9c, 0x60),
72
+ kbBacktick = GOSU_SCANCODE(0x32, 0x29),
73
+ kbMinus = GOSU_SCANCODE(0x1b, 0x0c),
74
+ kbEqual = GOSU_SCANCODE(0x18, 0x0d),
75
+ kbBracketLeft = GOSU_SCANCODE(0x21, 0x1a),
76
+ kbBracketRight = GOSU_SCANCODE(0x1e, 0x1b),
77
+ kbBackslash = GOSU_SCANCODE(0x2a, 0x2b),
78
+ kbSemicolon = GOSU_SCANCODE(0x29, 0x27),
79
+ kbApostrophe = GOSU_SCANCODE(0x27, 0x28),
80
+ kbComma = GOSU_SCANCODE(0x2b, 0x33),
81
+ kbPeriod = GOSU_SCANCODE(0x2f, 0x34),
82
+ kbSlash = GOSU_SCANCODE(0x2c, 0x35),
83
+ kbA = GOSU_SCANCODE(0x00, 0x1e),
84
+ kbB = GOSU_SCANCODE(0x0b, 0x30),
85
+ kbC = GOSU_SCANCODE(0x08, 0x2e),
86
+ kbD = GOSU_SCANCODE(0x02, 0x20),
87
+ kbE = GOSU_SCANCODE(0x0e, 0x12),
88
+ kbF = GOSU_SCANCODE(0x03, 0x21),
89
+ kbG = GOSU_SCANCODE(0x05, 0x22),
90
+ kbH = GOSU_SCANCODE(0x04, 0x23),
91
+ kbI = GOSU_SCANCODE(0x22, 0x17),
92
+ kbJ = GOSU_SCANCODE(0x26, 0x24),
93
+ kbK = GOSU_SCANCODE(0x28, 0x25),
94
+ kbL = GOSU_SCANCODE(0x25, 0x26),
95
+ kbM = GOSU_SCANCODE(0x2e, 0x32),
96
+ kbN = GOSU_SCANCODE(0x2d, 0x31),
97
+ kbO = GOSU_SCANCODE(0x1f, 0x18),
98
+ kbP = GOSU_SCANCODE(0x23, 0x19),
99
+ kbQ = GOSU_SCANCODE(0x0c, 0x10),
100
+ kbR = GOSU_SCANCODE(0x0f, 0x13),
101
+ kbS = GOSU_SCANCODE(0x01, 0x1f),
102
+ kbT = GOSU_SCANCODE(0x11, 0x14),
103
+ kbU = GOSU_SCANCODE(0x20, 0x16),
104
+ kbV = GOSU_SCANCODE(0x09, 0x2f),
105
+ kbW = GOSU_SCANCODE(0x0d, 0x11),
106
+ kbX = GOSU_SCANCODE(0x07, 0x2d),
107
+ kbY = GOSU_SCANCODE(0x10, 0x15),
108
+ kbZ = GOSU_SCANCODE(0x06, 0x2c),
109
+ kbNumpad0 = GOSU_SCANCODE(0x52, 0x52),
110
+ kbNumpad1 = GOSU_SCANCODE(0x53, 0x4f),
111
+ kbNumpad2 = GOSU_SCANCODE(0x54, 0x50),
112
+ kbNumpad3 = GOSU_SCANCODE(0x55, 0x51),
113
+ kbNumpad4 = GOSU_SCANCODE(0x56, 0x4b),
114
+ kbNumpad5 = GOSU_SCANCODE(0x57, 0x4c),
115
+ kbNumpad6 = GOSU_SCANCODE(0x58, 0x4d),
116
+ kbNumpad7 = GOSU_SCANCODE(0x59, 0x47),
117
+ kbNumpad8 = GOSU_SCANCODE(0x5b, 0x48),
118
+ kbNumpad9 = GOSU_SCANCODE(0x5c, 0x49),
119
+ kbNumpadAdd = GOSU_SCANCODE(0x45, 0x4e),
120
+ kbNumpadSubtract = GOSU_SCANCODE(0x4e, 0x4a),
121
+ kbNumpadMultiply = GOSU_SCANCODE(0x43, 0x37),
122
+ kbNumpadDivide = GOSU_SCANCODE(0x4b, 0xb5),
98
123
  kbRangeEnd = 0xff,
99
124
 
100
125
  msRangeBegin,
@@ -103,7 +128,15 @@ namespace Gosu
103
128
  msMiddle,
104
129
  msWheelUp,
105
130
  msWheelDown,
106
- msRangeEnd,
131
+ msOther0,
132
+ msOther1,
133
+ msOther2,
134
+ msOther3,
135
+ msOther4,
136
+ msOther5,
137
+ msOther6,
138
+ msOther7,
139
+ msRangeEnd = 0x110,
107
140
 
108
141
  gpRangeBegin,
109
142
  gpLeft = gpRangeBegin,
@@ -224,4 +257,7 @@ namespace Gosu
224
257
  };
225
258
  }
226
259
 
260
+ #undef GOSU_SCANCODE
261
+ #undef GOSU_SPECIAL_SCANCODE
262
+
227
263
  #endif
@@ -24,6 +24,10 @@ namespace Gosu
24
24
  unsigned const MAX_TEXTURE_SIZE = 1024;
25
25
 
26
26
  #ifdef GOSU_IS_MAC
27
+ // TODO: Without this gigantic hack, Gosu crashes in the "scale" function,
28
+ // but _only_ when used from Ruby 1.9. It is unclear what might cause this -
29
+ // maybe a compiler bug that tries to use SSE functions with the wrong
30
+ // alignment. Adding __attribute__((aligned(16))) does not help, though.
27
31
  struct Transform
28
32
  {
29
33
  double value[16];
@@ -6,28 +6,21 @@
6
6
 
7
7
  #include <Gosu/Fwd.hpp>
8
8
  #include <Gosu/Platform.hpp>
9
+ #include <Gosu/Buttons.hpp>
10
+ #include <Gosu/TR1.hpp>
9
11
 
10
12
  #ifdef GOSU_IS_WIN
11
- #include <Gosu/Buttons.hpp>
12
13
  #ifndef NOMINMAX
13
14
  #define NOMINMAX
14
15
  #endif
15
16
  #include <windows.h>
16
17
  #endif
17
18
 
18
- #ifdef GOSU_IS_MAC
19
- #include <Gosu/ButtonsMac.hpp>
20
- #endif
21
-
22
19
  #ifdef GOSU_IS_X
23
- #include <Gosu/Buttons.hpp>
24
20
  #include <X11/Xlib.h>
25
21
  #include <X11/Xutil.h>
26
22
  #endif
27
23
 
28
- #include <Gosu/Platform.hpp>
29
- #include <Gosu/Fwd.hpp>
30
- #include <Gosu/TR1.hpp>
31
24
  #include <vector>
32
25
 
33
26
  namespace Gosu
@@ -3,8 +3,8 @@
3
3
 
4
4
  #define GOSU_MAJOR_VERSION 0
5
5
  #define GOSU_MINOR_VERSION 7
6
- #define GOSU_POINT_VERSION 46
7
- #define GOSU_VERSION "0.7.46"
6
+ #define GOSU_POINT_VERSION 47
7
+ #define GOSU_VERSION "0.7.47.1"
8
8
 
9
9
  #define GOSU_COPYRIGHT_NOTICE \
10
10
  " " \
@@ -74,7 +74,7 @@ namespace Gosu
74
74
  }
75
75
  ++currentToken;
76
76
  currentTokens[i] = currentToken;
77
- return std::make_pair<int, int>(i, currentToken);
77
+ return std::make_pair(i, int(currentToken));
78
78
  }
79
79
 
80
80
  int sourceIfStillPlaying(int channel, int token) const
@@ -379,7 +379,7 @@ void Gosu::registerEntity(const wstring& name, const Gosu::Bitmap& replacement)
379
379
 
380
380
  bool Gosu::isEntity(const wstring& name)
381
381
  {
382
- return entities[name];
382
+ return entities[name].get();
383
383
  }
384
384
 
385
385
  const Gosu::Bitmap& Gosu::entityBitmap(const wstring& name)
@@ -63,6 +63,7 @@ namespace {
63
63
  char buf[256];
64
64
  CFStringRef str =
65
65
  (CFStringRef)CFDictionaryGetValue(dict, key);
66
+ // TODO - make sure that this uses UTF8!
66
67
  checkTrue(str && CFStringGetCString(str, buf, sizeof buf, CFStringGetSystemEncoding()),
67
68
  what);
68
69
  return buf;
@@ -114,9 +115,9 @@ namespace {
114
115
  "a min value");
115
116
  SInt32 max = getDictSInt32(dict, CFSTR(kIOHIDElementMaxKey),
116
117
  "a max value");
117
- if ((max - min) == 3)
118
+ if ((max - min) + 1 == 4)
118
119
  kind = fourWay;
119
- else if ((max - min) == 7)
120
+ else if ((max - min) + 1 == 8)
120
121
  kind = eightWay;
121
122
  else
122
123
  kind = unknown;
@@ -160,10 +161,9 @@ namespace {
160
161
  for (unsigned i = 0; i < self.devices.size(); ++i)
161
162
  if (self.devices[i].interface.get() == refcon)
162
163
  {
163
- self.devices.erase(self.devices.begin() + i);
164
+ self.devices[i] = Device();
164
165
  return;
165
166
  }
166
- assert(false);
167
167
  }
168
168
 
169
169
  bool isDeviceInteresting(CFMutableDictionaryRef properties)
@@ -316,32 +316,27 @@ namespace {
316
316
  }
317
317
  }
318
318
 
319
- unsigned countDevices() const
320
- {
321
- return devices.size();
322
- }
323
-
324
- const Device& getDevice(unsigned i) const
325
- {
326
- return devices.at(i);
327
- }
328
-
329
319
  std::tr1::array<bool, gpNum> poll()
330
320
  {
331
321
  std::tr1::array<bool, gpNum> result = { false };
332
322
 
333
323
  IOHIDEventStruct event;
334
- for (int dev = 0; dev < devices.size(); ++dev)
324
+ for (int dev = 0; dev < devices.size() && dev < numGamepads; ++dev)
335
325
  {
336
- int rangeOffset = (dev + 1) * gpNumPerGamepad - gpRangeBegin;
326
+ if (! devices[dev].interface)
327
+ // Device has been disconnected.
328
+ continue;
337
329
 
330
+ int rangeOffset = (dev + 1) * gpNumPerGamepad - gpRangeBegin;
331
+
338
332
  // Axis
339
333
  for (int ax = 0; ax < devices[dev].axis.size(); ++ax)
340
334
  {
341
- checkIO((*devices[dev].interface)->getElementValue(
335
+ if ((*devices[dev].interface)->getElementValue(
342
336
  devices[dev].interface.get(),
343
- devices[dev].axis[ax].cookie, &event));
344
-
337
+ devices[dev].axis[ax].cookie, &event) != kIOReturnSuccess)
338
+ break;
339
+
345
340
  Axis& a = devices[dev].axis[ax];
346
341
  if (event.value < (3 * a.min + 1 * a.max) / 4.0)
347
342
  {
@@ -360,20 +355,20 @@ namespace {
360
355
  // Hats (merge into axis)
361
356
  for (int hat = 0; hat < devices[dev].hats.size(); ++hat)
362
357
  {
363
- checkIO((*devices[dev].interface)->getElementValue(
358
+ if ((*devices[dev].interface)->getElementValue(
364
359
  devices[dev].interface.get(),
365
- devices[dev].hats[hat].cookie, &event));
366
-
360
+ devices[dev].hats[hat].cookie, &event) != kIOReturnSuccess)
361
+ break;
362
+
367
363
  // In case device does not start at 0 as expected.
368
364
  event.value -= devices[dev].hats[hat].min;
369
-
365
+
370
366
  // Treat all hats as being 8-way.
371
367
  if (devices[dev].hats[hat].kind == Hat::fourWay)
372
368
  event.value *= 2;
373
369
 
374
370
  switch (event.value)
375
371
  {
376
- // Must...resist...doing...crappy...fallthrough...magic...
377
372
  case 0:
378
373
  result[gpUp + rangeOffset] = true;
379
374
  break;
@@ -408,19 +403,18 @@ namespace {
408
403
  // Buttons
409
404
  for (int btn = 0; btn < devices[dev].buttons.size() && btn < 16; ++btn)
410
405
  {
411
- checkIO((*devices[dev].interface)->getElementValue(
406
+ if ((*devices[dev].interface)->getElementValue(
412
407
  devices[dev].interface.get(),
413
- devices[dev].buttons[btn].cookie, &event));
414
-
408
+ devices[dev].buttons[btn].cookie, &event) != kIOReturnSuccess)
409
+ break;
410
+
415
411
  if (event.value >= 1)
416
412
  result[gpButton0 + btn + rangeOffset] = true;
417
413
  }
418
- }
419
-
420
- for (int dev = 0; dev < numGamepads && dev < devices.size(); ++dev) {
421
- for (int index = 0; index < gpNumPerGamepad; ++index) {
422
- result[index] = result[index] || result[index + dev * gpNumPerGamepad];
423
- }
414
+
415
+ // Merge these results into the area for "all gamepads OR'ed together"
416
+ for (int index = 0; index < gpNumPerGamepad; ++index)
417
+ result[index] = (result[index] || result[index + (dev + 1) * gpNumPerGamepad]);
424
418
  }
425
419
 
426
420
  return result;
@@ -428,12 +422,6 @@ namespace {
428
422
  };
429
423
  }
430
424
 
431
- // Needed for char translation.
432
- namespace Gosu
433
- {
434
- std::wstring macRomanToWstring(const std::string& s);
435
- }
436
-
437
425
  namespace {
438
426
  const unsigned numScancodes = 128;
439
427
 
@@ -590,6 +578,16 @@ bool Gosu::Input::feedNSEvent(void* event)
590
578
  case NSRightMouseUp:
591
579
  pimpl->enqueue(msRight, false);
592
580
  return true;
581
+ case NSOtherMouseDown:
582
+ if ([ev buttonNumber] >= 10)
583
+ return false;
584
+ pimpl->enqueue(msOther0 + [ev buttonNumber] - 2, true);
585
+ return true;
586
+ case NSOtherMouseUp:
587
+ if ([ev buttonNumber] >= 10)
588
+ return false;
589
+ pimpl->enqueue(msOther0 + [ev buttonNumber] - 2, false);
590
+ return true;
593
591
  case NSScrollWheel:
594
592
  if ([ev deltaY] > 0)
595
593
  {
@@ -607,7 +605,7 @@ bool Gosu::Input::feedNSEvent(void* event)
607
605
  }
608
606
 
609
607
  // Handle other keys.
610
- if (type == NSKeyDown || type == NSKeyUp)
608
+ if ((type == NSKeyDown || type == NSKeyUp) && [ev keyCode] <= kbRangeEnd)
611
609
  {
612
610
  pimpl->enqueue([ev keyCode], type == NSKeyDown);
613
611
  return true;
@@ -637,7 +635,7 @@ bool Gosu::Input::down(Gosu::Button btn) const
637
635
  if (btn == noButton || btn.id() >= numButtons)
638
636
  return false;
639
637
 
640
- return buttonStates.at(btn.id());
638
+ return buttonStates[btn.id()];
641
639
  }
642
640
 
643
641
  double Gosu::Input::mouseX() const
@@ -700,7 +698,7 @@ void Gosu::Input::update()
700
698
  for (unsigned i = 0; i < pimpl->queue.size(); ++i)
701
699
  {
702
700
  Impl::WaitingButton& wb = pimpl->queue[i];
703
- buttonStates.at(wb.btn.id()) = wb.down;
701
+ buttonStates[wb.btn.id()] = wb.down;
704
702
  if (wb.down && onButtonDown)
705
703
  onButtonDown(wb.btn);
706
704
  else if (!wb.down && onButtonUp)
@@ -201,15 +201,13 @@ struct Gosu::Input::Impl
201
201
  case DIERR_INPUTLOST:
202
202
  {
203
203
  // Cannot fetch new events: Release all buttons.
204
- for (unsigned id = msRangeBegin; id < msRangeEnd; ++id)
204
+ for (unsigned id = msRangeBegin; id <= msRangeEnd; ++id)
205
205
  setButton(id, false, collectEvents);
206
206
  mouse->Acquire();
207
207
  break;
208
208
  }
209
209
  }
210
210
 
211
- keyboard:
212
-
213
211
  inOut = inputBufferSize;
214
212
  hr = keyboard->GetDeviceData(sizeof data[0], data, &inOut, 0);
215
213
  switch (hr)
@@ -225,7 +223,7 @@ struct Gosu::Input::Impl
225
223
  case DIERR_NOTACQUIRED:
226
224
  case DIERR_INPUTLOST:
227
225
  {
228
- for (unsigned id = kbRangeBegin; id < kbRangeEnd; ++id)
226
+ for (unsigned id = kbRangeBegin; id <= kbRangeEnd; ++id)
229
227
  setButton(id, false, collectEvents);
230
228
  keyboard->Acquire();
231
229
  break;
@@ -233,10 +231,12 @@ struct Gosu::Input::Impl
233
231
  }
234
232
 
235
233
  std::tr1::array<bool, gpNum> gpBuffer = { false };
236
- for (unsigned gp = 0; gp < gamepads.size(); ++gp)
234
+ for (unsigned gp = 0; gp < gamepads.size() && gp < numGamepads; ++gp)
237
235
  {
238
236
  gamepads[gp]->Poll();
239
237
 
238
+ int rangeOffset = (gp + 1) * gpNumPerGamepad - gpRangeBegin;
239
+
240
240
  DIJOYSTATE joy;
241
241
  hr = gamepads[gp]->GetDeviceState(sizeof joy, &joy);
242
242
  switch (hr)
@@ -244,18 +244,18 @@ struct Gosu::Input::Impl
244
244
  case DI_OK:
245
245
  {
246
246
  if (joy.lX < -stickThreshold)
247
- gpBuffer[gpLeft - gpRangeBegin] = true;
247
+ gpBuffer[gpLeft + rangeOffset] = true;
248
248
  else if (joy.lX > stickThreshold)
249
- gpBuffer[gpRight - gpRangeBegin] = true;
249
+ gpBuffer[gpRight + rangeOffset] = true;
250
250
 
251
251
  if (joy.lY < -stickThreshold)
252
- gpBuffer[gpUp - gpRangeBegin] = true;
252
+ gpBuffer[gpUp + rangeOffset] = true;
253
253
  else if (joy.lY > stickThreshold)
254
- gpBuffer[gpDown - gpRangeBegin] = true;
254
+ gpBuffer[gpDown + rangeOffset] = true;
255
255
 
256
- for (unsigned id = gpButton0; id < gpRangeEnd; ++id)
256
+ for (unsigned id = gpButton0; id <= gpButton15; ++id)
257
257
  if (joy.rgbButtons[id - gpButton0])
258
- gpBuffer[id - gpRangeBegin] = true;
258
+ gpBuffer[id + rangeOffset] = true;
259
259
 
260
260
  break;
261
261
  }
@@ -268,8 +268,13 @@ struct Gosu::Input::Impl
268
268
  break;
269
269
  }
270
270
  }
271
+
272
+ // Merge these results into the area for "all gamepads OR'ed together"
273
+ for (int index = 0; index < gpNumPerGamepad; ++index)
274
+ gpBuffer[index] = (gpBuffer[index] || gpBuffer[index + (gp + 1) * gpNumPerGamepad]);
271
275
  }
272
- for (unsigned id = gpRangeBegin; id < gpRangeEnd; ++id)
276
+
277
+ for (unsigned id = gpRangeBegin; id <= gpRangeEnd; ++id)
273
278
  setButton(id, gpBuffer[id - gpRangeBegin], collectEvents);
274
279
  }
275
280
  };
@@ -169,14 +169,19 @@ void Gosu::Input::update()
169
169
  case Button3: id = msRight; break;
170
170
  case Button4: id = msWheelUp; break;
171
171
  case Button5: id = msWheelDown; break;
172
+ case 6: id = msOther0; break;
173
+ case 7: id = msOther1; break;
174
+ case 8: id = msOther2; break;
175
+ case 9: id = msOther3; break;
176
+ case 10: id = msOther4; break;
177
+ case 11: id = msOther5; break;
178
+ case 12: id = msOther6; break;
179
+ case 13: id = msOther7; break;
172
180
  default: continue;
173
181
  }
174
182
  pimpl->keyMap[id] = true;
175
- // TODO: Here, above, below, who came up with that cast? Uh :)
176
183
  if (onButtonDown)
177
184
  onButtonDown(Button(id));
178
- if (onButtonUp and id == msWheelUp or id == msWheelDown)
179
- onButtonUp(Button(id));
180
185
  }
181
186
  else if (event.type == ButtonRelease)
182
187
  {
@@ -186,11 +191,21 @@ void Gosu::Input::update()
186
191
  case Button1: id = msLeft; break;
187
192
  case Button2: id = msMiddle; break;
188
193
  case Button3: id = msRight; break;
194
+ case Button4: id = msWheelUp; break;
195
+ case Button5: id = msWheelDown; break;
196
+ case 6: id = msOther0; break;
197
+ case 7: id = msOther1; break;
198
+ case 8: id = msOther2; break;
199
+ case 9: id = msOther3; break;
200
+ case 10: id = msOther4; break;
201
+ case 11: id = msOther5; break;
202
+ case 12: id = msOther6; break;
203
+ case 13: id = msOther7; break;
189
204
  default: continue;
190
205
  }
191
206
  pimpl->keyMap[id] = false;
192
207
  if (onButtonUp)
193
- onButtonUp(*reinterpret_cast<Button*>(&id));
208
+ onButtonUp(Button(id));
194
209
  }
195
210
  else if (event.type == MotionNotify)
196
211
  {
@@ -618,7 +618,6 @@ namespace Gosu {
618
618
  // Input and Window:
619
619
 
620
620
  // Button ID constants
621
- // Does not matter that it's the Mac file, %include only analyses symbols to export, not their values.
622
621
  %ignore Gosu::kbRangeBegin;
623
622
  %ignore Gosu::kbRangeEnd;
624
623
  %ignore Gosu::msRangeBegin;
@@ -628,9 +627,11 @@ namespace Gosu {
628
627
  %ignore Gosu::kbNum;
629
628
  %ignore Gosu::msNum;
630
629
  %ignore Gosu::gpNum;
630
+ %ignore Gosu::gpNumPerGamepad;
631
631
  %ignore Gosu::numButtons;
632
+ %ignore Gosu::numGamepads;
632
633
  %ignore Gosu::noButton;
633
- %include "../Gosu/ButtonsMac.hpp"
634
+ %include "../Gosu/Buttons.hpp"
634
635
  %init %{
635
636
  GosusDarkSide::oncePerTick = GosusDarkSide::yieldToOtherRubyThreads;
636
637
  // While we are at it, to some healthy srand() - otherwise unavailable to Ruby people
@@ -11245,8 +11245,8 @@ SWIGEXPORT void Init_gosu(void) {
11245
11245
  SWIG_RubyInitializeTrackings();
11246
11246
  rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(0)));
11247
11247
  rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(7)));
11248
- rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(45)));
11249
- rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.45"));
11248
+ rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(47)));
11249
+ rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.7.47"));
11250
11250
  rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
11251
11251
  rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
11252
11252
  rb_define_module_function(mGosu, "degrees_to_radians", VALUEFUNC(_wrap_degrees_to_radians), -1);
@@ -11430,6 +11430,7 @@ SWIGEXPORT void Init_gosu(void) {
11430
11430
  rb_define_const(mGosu, "KbF10", SWIG_From_int(static_cast< int >(Gosu::kbF10)));
11431
11431
  rb_define_const(mGosu, "KbF11", SWIG_From_int(static_cast< int >(Gosu::kbF11)));
11432
11432
  rb_define_const(mGosu, "KbF12", SWIG_From_int(static_cast< int >(Gosu::kbF12)));
11433
+ rb_define_const(mGosu, "Kb0", SWIG_From_int(static_cast< int >(Gosu::kb0)));
11433
11434
  rb_define_const(mGosu, "Kb1", SWIG_From_int(static_cast< int >(Gosu::kb1)));
11434
11435
  rb_define_const(mGosu, "Kb2", SWIG_From_int(static_cast< int >(Gosu::kb2)));
11435
11436
  rb_define_const(mGosu, "Kb3", SWIG_From_int(static_cast< int >(Gosu::kb3)));
@@ -11439,7 +11440,40 @@ SWIGEXPORT void Init_gosu(void) {
11439
11440
  rb_define_const(mGosu, "Kb7", SWIG_From_int(static_cast< int >(Gosu::kb7)));
11440
11441
  rb_define_const(mGosu, "Kb8", SWIG_From_int(static_cast< int >(Gosu::kb8)));
11441
11442
  rb_define_const(mGosu, "Kb9", SWIG_From_int(static_cast< int >(Gosu::kb9)));
11442
- rb_define_const(mGosu, "Kb0", SWIG_From_int(static_cast< int >(Gosu::kb0)));
11443
+ rb_define_const(mGosu, "KbTab", SWIG_From_int(static_cast< int >(Gosu::kbTab)));
11444
+ rb_define_const(mGosu, "KbReturn", SWIG_From_int(static_cast< int >(Gosu::kbReturn)));
11445
+ rb_define_const(mGosu, "KbSpace", SWIG_From_int(static_cast< int >(Gosu::kbSpace)));
11446
+ rb_define_const(mGosu, "KbLeftShift", SWIG_From_int(static_cast< int >(Gosu::kbLeftShift)));
11447
+ rb_define_const(mGosu, "KbRightShift", SWIG_From_int(static_cast< int >(Gosu::kbRightShift)));
11448
+ rb_define_const(mGosu, "KbLeftControl", SWIG_From_int(static_cast< int >(Gosu::kbLeftControl)));
11449
+ rb_define_const(mGosu, "KbRightControl", SWIG_From_int(static_cast< int >(Gosu::kbRightControl)));
11450
+ rb_define_const(mGosu, "KbLeftAlt", SWIG_From_int(static_cast< int >(Gosu::kbLeftAlt)));
11451
+ rb_define_const(mGosu, "KbRightAlt", SWIG_From_int(static_cast< int >(Gosu::kbRightAlt)));
11452
+ rb_define_const(mGosu, "KbLeftMeta", SWIG_From_int(static_cast< int >(Gosu::kbLeftMeta)));
11453
+ rb_define_const(mGosu, "KbRightMeta", SWIG_From_int(static_cast< int >(Gosu::kbRightMeta)));
11454
+ rb_define_const(mGosu, "KbBackspace", SWIG_From_int(static_cast< int >(Gosu::kbBackspace)));
11455
+ rb_define_const(mGosu, "KbLeft", SWIG_From_int(static_cast< int >(Gosu::kbLeft)));
11456
+ rb_define_const(mGosu, "KbRight", SWIG_From_int(static_cast< int >(Gosu::kbRight)));
11457
+ rb_define_const(mGosu, "KbUp", SWIG_From_int(static_cast< int >(Gosu::kbUp)));
11458
+ rb_define_const(mGosu, "KbDown", SWIG_From_int(static_cast< int >(Gosu::kbDown)));
11459
+ rb_define_const(mGosu, "KbHome", SWIG_From_int(static_cast< int >(Gosu::kbHome)));
11460
+ rb_define_const(mGosu, "KbEnd", SWIG_From_int(static_cast< int >(Gosu::kbEnd)));
11461
+ rb_define_const(mGosu, "KbInsert", SWIG_From_int(static_cast< int >(Gosu::kbInsert)));
11462
+ rb_define_const(mGosu, "KbDelete", SWIG_From_int(static_cast< int >(Gosu::kbDelete)));
11463
+ rb_define_const(mGosu, "KbPageUp", SWIG_From_int(static_cast< int >(Gosu::kbPageUp)));
11464
+ rb_define_const(mGosu, "KbPageDown", SWIG_From_int(static_cast< int >(Gosu::kbPageDown)));
11465
+ rb_define_const(mGosu, "KbEnter", SWIG_From_int(static_cast< int >(Gosu::kbEnter)));
11466
+ rb_define_const(mGosu, "KbBacktick", SWIG_From_int(static_cast< int >(Gosu::kbBacktick)));
11467
+ rb_define_const(mGosu, "KbMinus", SWIG_From_int(static_cast< int >(Gosu::kbMinus)));
11468
+ rb_define_const(mGosu, "KbEqual", SWIG_From_int(static_cast< int >(Gosu::kbEqual)));
11469
+ rb_define_const(mGosu, "KbBracketLeft", SWIG_From_int(static_cast< int >(Gosu::kbBracketLeft)));
11470
+ rb_define_const(mGosu, "KbBracketRight", SWIG_From_int(static_cast< int >(Gosu::kbBracketRight)));
11471
+ rb_define_const(mGosu, "KbBackslash", SWIG_From_int(static_cast< int >(Gosu::kbBackslash)));
11472
+ rb_define_const(mGosu, "KbSemicolon", SWIG_From_int(static_cast< int >(Gosu::kbSemicolon)));
11473
+ rb_define_const(mGosu, "KbApostrophe", SWIG_From_int(static_cast< int >(Gosu::kbApostrophe)));
11474
+ rb_define_const(mGosu, "KbComma", SWIG_From_int(static_cast< int >(Gosu::kbComma)));
11475
+ rb_define_const(mGosu, "KbPeriod", SWIG_From_int(static_cast< int >(Gosu::kbPeriod)));
11476
+ rb_define_const(mGosu, "KbSlash", SWIG_From_int(static_cast< int >(Gosu::kbSlash)));
11443
11477
  rb_define_const(mGosu, "KbA", SWIG_From_int(static_cast< int >(Gosu::kbA)));
11444
11478
  rb_define_const(mGosu, "KbB", SWIG_From_int(static_cast< int >(Gosu::kbB)));
11445
11479
  rb_define_const(mGosu, "KbC", SWIG_From_int(static_cast< int >(Gosu::kbC)));
@@ -11466,29 +11500,7 @@ SWIGEXPORT void Init_gosu(void) {
11466
11500
  rb_define_const(mGosu, "KbX", SWIG_From_int(static_cast< int >(Gosu::kbX)));
11467
11501
  rb_define_const(mGosu, "KbY", SWIG_From_int(static_cast< int >(Gosu::kbY)));
11468
11502
  rb_define_const(mGosu, "KbZ", SWIG_From_int(static_cast< int >(Gosu::kbZ)));
11469
- rb_define_const(mGosu, "KbTab", SWIG_From_int(static_cast< int >(Gosu::kbTab)));
11470
- rb_define_const(mGosu, "KbReturn", SWIG_From_int(static_cast< int >(Gosu::kbReturn)));
11471
- rb_define_const(mGosu, "KbSpace", SWIG_From_int(static_cast< int >(Gosu::kbSpace)));
11472
- rb_define_const(mGosu, "KbLeftShift", SWIG_From_int(static_cast< int >(Gosu::kbLeftShift)));
11473
- rb_define_const(mGosu, "KbRightShift", SWIG_From_int(static_cast< int >(Gosu::kbRightShift)));
11474
- rb_define_const(mGosu, "KbLeftControl", SWIG_From_int(static_cast< int >(Gosu::kbLeftControl)));
11475
- rb_define_const(mGosu, "KbRightControl", SWIG_From_int(static_cast< int >(Gosu::kbRightControl)));
11476
- rb_define_const(mGosu, "KbLeftAlt", SWIG_From_int(static_cast< int >(Gosu::kbLeftAlt)));
11477
- rb_define_const(mGosu, "KbRightAlt", SWIG_From_int(static_cast< int >(Gosu::kbRightAlt)));
11478
- rb_define_const(mGosu, "KbLeftMeta", SWIG_From_int(static_cast< int >(Gosu::kbLeftMeta)));
11479
- rb_define_const(mGosu, "KbRightMeta", SWIG_From_int(static_cast< int >(Gosu::kbRightMeta)));
11480
- rb_define_const(mGosu, "KbBackspace", SWIG_From_int(static_cast< int >(Gosu::kbBackspace)));
11481
- rb_define_const(mGosu, "KbLeft", SWIG_From_int(static_cast< int >(Gosu::kbLeft)));
11482
- rb_define_const(mGosu, "KbRight", SWIG_From_int(static_cast< int >(Gosu::kbRight)));
11483
- rb_define_const(mGosu, "KbUp", SWIG_From_int(static_cast< int >(Gosu::kbUp)));
11484
- rb_define_const(mGosu, "KbDown", SWIG_From_int(static_cast< int >(Gosu::kbDown)));
11485
- rb_define_const(mGosu, "KbHome", SWIG_From_int(static_cast< int >(Gosu::kbHome)));
11486
- rb_define_const(mGosu, "KbEnd", SWIG_From_int(static_cast< int >(Gosu::kbEnd)));
11487
- rb_define_const(mGosu, "KbInsert", SWIG_From_int(static_cast< int >(Gosu::kbInsert)));
11488
- rb_define_const(mGosu, "KbDelete", SWIG_From_int(static_cast< int >(Gosu::kbDelete)));
11489
- rb_define_const(mGosu, "KbPageUp", SWIG_From_int(static_cast< int >(Gosu::kbPageUp)));
11490
- rb_define_const(mGosu, "KbPageDown", SWIG_From_int(static_cast< int >(Gosu::kbPageDown)));
11491
- rb_define_const(mGosu, "KbEnter", SWIG_From_int(static_cast< int >(Gosu::kbEnter)));
11503
+ rb_define_const(mGosu, "KbNumpad0", SWIG_From_int(static_cast< int >(Gosu::kbNumpad0)));
11492
11504
  rb_define_const(mGosu, "KbNumpad1", SWIG_From_int(static_cast< int >(Gosu::kbNumpad1)));
11493
11505
  rb_define_const(mGosu, "KbNumpad2", SWIG_From_int(static_cast< int >(Gosu::kbNumpad2)));
11494
11506
  rb_define_const(mGosu, "KbNumpad3", SWIG_From_int(static_cast< int >(Gosu::kbNumpad3)));
@@ -11498,7 +11510,6 @@ SWIGEXPORT void Init_gosu(void) {
11498
11510
  rb_define_const(mGosu, "KbNumpad7", SWIG_From_int(static_cast< int >(Gosu::kbNumpad7)));
11499
11511
  rb_define_const(mGosu, "KbNumpad8", SWIG_From_int(static_cast< int >(Gosu::kbNumpad8)));
11500
11512
  rb_define_const(mGosu, "KbNumpad9", SWIG_From_int(static_cast< int >(Gosu::kbNumpad9)));
11501
- rb_define_const(mGosu, "KbNumpad0", SWIG_From_int(static_cast< int >(Gosu::kbNumpad0)));
11502
11513
  rb_define_const(mGosu, "KbNumpadAdd", SWIG_From_int(static_cast< int >(Gosu::kbNumpadAdd)));
11503
11514
  rb_define_const(mGosu, "KbNumpadSubtract", SWIG_From_int(static_cast< int >(Gosu::kbNumpadSubtract)));
11504
11515
  rb_define_const(mGosu, "KbNumpadMultiply", SWIG_From_int(static_cast< int >(Gosu::kbNumpadMultiply)));
@@ -11508,6 +11519,14 @@ SWIGEXPORT void Init_gosu(void) {
11508
11519
  rb_define_const(mGosu, "MsMiddle", SWIG_From_int(static_cast< int >(Gosu::msMiddle)));
11509
11520
  rb_define_const(mGosu, "MsWheelUp", SWIG_From_int(static_cast< int >(Gosu::msWheelUp)));
11510
11521
  rb_define_const(mGosu, "MsWheelDown", SWIG_From_int(static_cast< int >(Gosu::msWheelDown)));
11522
+ rb_define_const(mGosu, "MsOther0", SWIG_From_int(static_cast< int >(Gosu::msOther0)));
11523
+ rb_define_const(mGosu, "MsOther1", SWIG_From_int(static_cast< int >(Gosu::msOther1)));
11524
+ rb_define_const(mGosu, "MsOther2", SWIG_From_int(static_cast< int >(Gosu::msOther2)));
11525
+ rb_define_const(mGosu, "MsOther3", SWIG_From_int(static_cast< int >(Gosu::msOther3)));
11526
+ rb_define_const(mGosu, "MsOther4", SWIG_From_int(static_cast< int >(Gosu::msOther4)));
11527
+ rb_define_const(mGosu, "MsOther5", SWIG_From_int(static_cast< int >(Gosu::msOther5)));
11528
+ rb_define_const(mGosu, "MsOther6", SWIG_From_int(static_cast< int >(Gosu::msOther6)));
11529
+ rb_define_const(mGosu, "MsOther7", SWIG_From_int(static_cast< int >(Gosu::msOther7)));
11511
11530
  rb_define_const(mGosu, "GpLeft", SWIG_From_int(static_cast< int >(Gosu::gpLeft)));
11512
11531
  rb_define_const(mGosu, "GpRight", SWIG_From_int(static_cast< int >(Gosu::gpRight)));
11513
11532
  rb_define_const(mGosu, "GpUp", SWIG_From_int(static_cast< int >(Gosu::gpUp)));
@@ -11608,8 +11627,6 @@ SWIGEXPORT void Init_gosu(void) {
11608
11627
  rb_define_const(mGosu, "Gp3Button13", SWIG_From_int(static_cast< int >(Gosu::gp3Button13)));
11609
11628
  rb_define_const(mGosu, "Gp3Button14", SWIG_From_int(static_cast< int >(Gosu::gp3Button14)));
11610
11629
  rb_define_const(mGosu, "Gp3Button15", SWIG_From_int(static_cast< int >(Gosu::gp3Button15)));
11611
- rb_define_const(mGosu, "NumGamepads", SWIG_From_int(static_cast< int >(Gosu::numGamepads)));
11612
- rb_define_const(mGosu, "GpNumPerGamepad", SWIG_From_int(static_cast< int >(Gosu::gpNumPerGamepad)));
11613
11630
 
11614
11631
  GosusDarkSide::oncePerTick = GosusDarkSide::yieldToOtherRubyThreads;
11615
11632
  // While we are at it, to some healthy srand() - otherwise unavailable to Ruby people
@@ -1,5 +1,5 @@
1
1
  #include <Gosu/TextInput.hpp>
2
- #include <Gosu/ButtonsMac.hpp>
2
+ #include <Gosu/Buttons.hpp>
3
3
  #include <GosuImpl/MacUtility.hpp>
4
4
  #include <algorithm>
5
5
  #include <vector>
@@ -66,7 +66,7 @@ bool Gosu::TextInput::feedXEvent(void* display, void* event)
66
66
 
67
67
  KeySym lower, upper;
68
68
  int keysyms_per_keycode_return;
69
- KeySym keysym = (KeySym)XGetKeyboardMapping((Display*)display, ev->xkey.keycode, 0, &keysyms_per_keycode_return);
69
+ KeySym keysym = *XGetKeyboardMapping((Display*)display, ev->xkey.keycode, 1, &keysyms_per_keycode_return);
70
70
  XConvertCase(keysym, &lower, &upper);
71
71
 
72
72
  wchar_t ch = static_cast<wchar_t>(shiftDown ? upper : lower);
@@ -90,8 +90,10 @@ bool Gosu::TextInput::feedXEvent(void* display, void* event)
90
90
  return true;
91
91
  }
92
92
 
93
+ Button btn(ev->xkey.keycode-8);
94
+
93
95
  // Char left
94
- if (ch == kbLeft && !ctrlDown)
96
+ if (btn == kbLeft && !ctrlDown)
95
97
  {
96
98
  if (CARET_POS > 0)
97
99
  CARET_POS -= 1;
@@ -103,7 +105,7 @@ bool Gosu::TextInput::feedXEvent(void* display, void* event)
103
105
  }
104
106
 
105
107
  // Char right
106
- if (ch == kbRight && !ctrlDown)
108
+ if (btn == kbRight && !ctrlDown)
107
109
  {
108
110
  if (CARET_POS < pimpl->text.length())
109
111
  CARET_POS += 1;
@@ -115,7 +117,7 @@ bool Gosu::TextInput::feedXEvent(void* display, void* event)
115
117
  }
116
118
 
117
119
  // Home
118
- if (ch == kbHome)
120
+ if (btn == kbHome)
119
121
  {
120
122
  CARET_POS = 0;
121
123
 
@@ -126,7 +128,7 @@ bool Gosu::TextInput::feedXEvent(void* display, void* event)
126
128
  }
127
129
 
128
130
  // End
129
- if (ch == kbEnd)
131
+ if (btn == kbEnd)
130
132
  {
131
133
  CARET_POS = pimpl->text.length();
132
134
 
@@ -137,7 +139,7 @@ bool Gosu::TextInput::feedXEvent(void* display, void* event)
137
139
  }
138
140
 
139
141
  // Word left
140
- if (ch == kbLeft && ctrlDown)
142
+ if (btn == kbLeft && ctrlDown)
141
143
  {
142
144
  if (CARET_POS == pimpl->text.length())
143
145
  --CARET_POS;
@@ -155,7 +157,7 @@ bool Gosu::TextInput::feedXEvent(void* display, void* event)
155
157
  }
156
158
 
157
159
  // Word right
158
- if (ch == kbRight && ctrlDown)
160
+ if (btn == kbRight && ctrlDown)
159
161
  {
160
162
  while (CARET_POS < pimpl->text.length() && iswspace(pimpl->text.at(CARET_POS)))
161
163
  ++CARET_POS;
@@ -170,7 +172,7 @@ bool Gosu::TextInput::feedXEvent(void* display, void* event)
170
172
  }
171
173
 
172
174
  // Delete existant selection
173
- if (ch == kbBackspace)
175
+ if (btn == kbBackspace)
174
176
  {
175
177
  if (SEL_START != CARET_POS)
176
178
  {
@@ -191,7 +193,7 @@ bool Gosu::TextInput::feedXEvent(void* display, void* event)
191
193
  }
192
194
 
193
195
  // Delete existant selection
194
- if (ch == kbDelete)
196
+ if (btn == kbDelete)
195
197
  {
196
198
  if (SEL_START != CARET_POS)
197
199
  {
@@ -40,15 +40,10 @@ string Gosu::wstringToUTF8(const std::wstring& ws)
40
40
  // from this file.
41
41
 
42
42
  namespace {
43
- extern const char MACROMAN[] = "MacRoman";
44
43
  extern const char UCS_2_INTERNAL[] = "UCS-2-INTERNAL";
45
44
  }
46
45
 
47
46
  namespace Gosu {
48
- wstring macRomanToWstring(const string& s)
49
- {
50
- return iconvert<wstring, UCS_4_INTERNAL, MACROMAN>(s);
51
- }
52
47
  vector<unsigned short> wstringToUniChars(const wstring& ws)
53
48
  {
54
49
  return iconvert<vector<unsigned short>, UCS_2_INTERNAL, UCS_4_INTERNAL>(ws);
@@ -81,6 +81,8 @@ namespace Gosu
81
81
  case NSLeftMouseUp:
82
82
  case NSRightMouseDown:
83
83
  case NSRightMouseUp:
84
+ case NSOtherMouseDown:
85
+ case NSOtherMouseUp:
84
86
  case NSScrollWheel:
85
87
  case NSKeyUp:
86
88
  case NSKeyDown:
@@ -108,7 +110,10 @@ namespace
108
110
 
109
111
  typedef void (*WindowProc)(Gosu::Window&);
110
112
 
111
- @interface GosuForwarder : NSObject<NSWindowDelegate>
113
+ @interface GosuForwarder : NSObject
114
+ #ifdef __LP64__
115
+ <NSWindowDelegate>
116
+ #endif
112
117
  {
113
118
  Gosu::Window* win;
114
119
  WindowProc pr;
@@ -164,6 +169,8 @@ OVERRIDE_METHOD(mouseDown);
164
169
  OVERRIDE_METHOD(mouseUp);
165
170
  OVERRIDE_METHOD(rightMouseDown);
166
171
  OVERRIDE_METHOD(rightMouseUp);
172
+ OVERRIDE_METHOD(otherMouseDown);
173
+ OVERRIDE_METHOD(otherMouseUp);
167
174
  OVERRIDE_METHOD(scrollWheel);
168
175
  @end
169
176
 
@@ -75,4 +75,7 @@ class Gosu::Window
75
75
  end
76
76
 
77
77
  # Release OpenAL resources during Ruby's shutdown, not Gosu's.
78
- at_exit { Gosu::_release_all_openal_resources }
78
+ at_exit do
79
+ Gosu::Song.current_song.stop if Gosu::Song.current_song
80
+ Gosu::_release_all_openal_resources
81
+ end
@@ -82,7 +82,13 @@ if `uname`.chomp == 'Darwin' then
82
82
  $INCFLAGS << " -I../dependencies/libvorbis/lib"
83
83
  # To make everything work with the Objective C runtime
84
84
  $CFLAGS << " -x objective-c -fobjc-gc -DNDEBUG"
85
- CONFIG['CXXFLAGS'] = "#{CONFIG['CXXFLAGS']} -x objective-c++" # cheat a little here
85
+ # Compile all C++ files as Objective C++ on OS X since mkmf does not support .mm
86
+ # files.
87
+ # Also undefine two debug flags that cause exceptions to randomly crash
88
+ # otherwise; see:
89
+ # https://trac.macports.org/ticket/27237#comment:21
90
+ # http://newartisans.com/2009/10/a-c-gotcha-on-snow-leopard/#comment-893
91
+ CONFIG['CXXFLAGS'] = "#{CONFIG['CXXFLAGS']} -x objective-c++ -U_GLIBCXX_DEBUG -U_GLIBCXX_DEBUG_PEDANTIC"
86
92
  $LDFLAGS << " -L/usr/X11/lib -liconv"
87
93
  %w(AudioToolbox IOKit OpenAL OpenGL AppKit ApplicationServices Foundation Carbon).each do |f|
88
94
  $LDFLAGS << " -framework #{f}"
metadata CHANGED
@@ -1,13 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 95
5
- prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 46
10
- version: 0.7.46
4
+ version: 0.7.47.1
11
5
  platform: ruby
12
6
  authors:
13
7
  - Julian Raschke
@@ -15,7 +9,7 @@ autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
11
 
18
- date: 2013-03-31 00:00:00 Z
12
+ date: 2013-04-01 00:00:00 Z
19
13
  dependencies: []
20
14
 
21
15
  description: " 2D game development library.\n\n Gosu features easy to use and game-friendly interfaces to 2D graphics\n and text (accelerated by 3D hardware), sound samples and music as well as\n keyboard, mouse and gamepad/joystick input.\n\n Also includes demos for integration with RMagick, Chipmunk and OpenGL.\n"
@@ -35,7 +29,6 @@ files:
35
29
  - Gosu/AutoLink.hpp
36
30
  - Gosu/Bitmap.hpp
37
31
  - Gosu/Buttons.hpp
38
- - Gosu/ButtonsMac.hpp
39
32
  - Gosu/Color.hpp
40
33
  - Gosu/Directories.hpp
41
34
  - Gosu/Font.hpp
@@ -160,7 +153,6 @@ files:
160
153
  - GosuImpl/RubyGosuStub.mm
161
154
  - GosuImpl/RubyGosu_SWIG_GC_PATCH.patch
162
155
  - GosuImpl/RubyGosu_SWIG_RENAME_PATCH.patch
163
- - GosuImpl/RubyGosu_SWIG_TYPE_PATCH.patch
164
156
  - GosuImpl/RubyGosu_wrap.cxx
165
157
  - GosuImpl/RubyGosu_wrap.h
166
158
  - GosuImpl/Sockets/CommSocket.cpp
@@ -269,6 +261,8 @@ files:
269
261
  homepage: http://www.libgosu.org/
270
262
  licenses: []
271
263
 
264
+ metadata: {}
265
+
272
266
  post_install_message:
273
267
  rdoc_options:
274
268
  - README.txt
@@ -285,31 +279,21 @@ rdoc_options:
285
279
  require_paths:
286
280
  - lib
287
281
  required_ruby_version: !ruby/object:Gem::Requirement
288
- none: false
289
282
  requirements:
290
283
  - - ">="
291
284
  - !ruby/object:Gem::Version
292
- hash: 51
293
- segments:
294
- - 1
295
- - 8
296
- - 2
297
285
  version: 1.8.2
298
286
  required_rubygems_version: !ruby/object:Gem::Requirement
299
- none: false
300
287
  requirements:
301
288
  - - ">="
302
289
  - !ruby/object:Gem::Version
303
- hash: 3
304
- segments:
305
- - 0
306
290
  version: "0"
307
291
  requirements:
308
292
  - See https://github.com/jlnr/gosu/wiki/Getting-Started-on-Linux
309
293
  rubyforge_project:
310
- rubygems_version: 1.8.24
294
+ rubygems_version: 2.0.3
311
295
  signing_key:
312
- specification_version: 3
296
+ specification_version: 4
313
297
  summary: 2D game development library.
314
298
  test_files: []
315
299
 
@@ -1,227 +0,0 @@
1
- #ifndef GOSU_BUTTONSMAC_HPP
2
- #define GOSU_BUTTONSMAC_HPP
3
-
4
- namespace Gosu
5
- {
6
- //! List of button ids that can be used with Gosu::Input.
7
- //! This enumeration contains ids for keyboard keys (kb*),
8
- //! mouse buttons and mouse wheel (ms*) and gamepad buttons (gp*).
9
- enum ButtonName
10
- {
11
- kbRangeBegin = 0x00,
12
- kbEscape = 0x35,
13
- kbF1 = 0x7a,
14
- kbF2 = 0x78,
15
- kbF3 = 0x63,
16
- kbF4 = 0x76,
17
- kbF5 = 0x60,
18
- kbF6 = 0x61,
19
- kbF7 = 0x62,
20
- kbF8 = 0x64,
21
- kbF9 = 0x65,
22
- kbF10 = 0x6d,
23
- kbF11 = 0x67,
24
- kbF12 = 0x6f,
25
- kb1 = 0x12,
26
- kb2 = 0x13,
27
- kb3 = 0x14,
28
- kb4 = 0x15,
29
- kb5 = 0x17,
30
- kb6 = 0x16,
31
- kb7 = 0x1a,
32
- kb8 = 0x1c,
33
- kb9 = 0x19,
34
- kb0 = 0x1d,
35
- kbA = 0x00,
36
- kbB = 0x0b,
37
- kbC = 0x08,
38
- kbD = 0x02,
39
- kbE = 0x0e,
40
- kbF = 0x03,
41
- kbG = 0x05,
42
- kbH = 0x04,
43
- kbI = 0x22,
44
- kbJ = 0x26,
45
- kbK = 0x28,
46
- kbL = 0x25,
47
- kbM = 0x2e,
48
- kbN = 0x2d,
49
- kbO = 0x1f,
50
- kbP = 0x23,
51
- kbQ = 0x0c,
52
- kbR = 0x0f,
53
- kbS = 0x01,
54
- kbT = 0x11,
55
- kbU = 0x20,
56
- kbV = 0x09,
57
- kbW = 0x0d,
58
- kbX = 0x07,
59
- kbY = 0x10,
60
- kbZ = 0x06,
61
- kbTab = 0x30,
62
- kbReturn = 0x24,
63
- kbSpace = 0x31,
64
- kbLeftShift = 0x38,
65
- kbRightShift = 0x3c,
66
- kbLeftControl = 0x3b,
67
- kbRightControl = 0x3e,
68
- kbLeftAlt = 0x3a,
69
- kbRightAlt = 0x3d,
70
- kbLeftMeta = 0x37,
71
- kbRightMeta = 0x36,
72
- kbBackspace = 0x33,
73
- kbLeft = 0x7b,
74
- kbRight = 0x7c,
75
- kbUp = 0x7e,
76
- kbDown = 0x7d,
77
- kbHome = 0x73,
78
- kbEnd = 0x77,
79
- kbInsert = 0x72,
80
- kbDelete = 0x75,
81
- kbPageUp = 0x74,
82
- kbPageDown = 0x79,
83
- kbEnter = 0x4c,
84
- kbNumpad1 = 0x53,
85
- kbNumpad2 = 0x54,
86
- kbNumpad3 = 0x55,
87
- kbNumpad4 = 0x56,
88
- kbNumpad5 = 0x57,
89
- kbNumpad6 = 0x58,
90
- kbNumpad7 = 0x59,
91
- kbNumpad8 = 0x5b,
92
- kbNumpad9 = 0x5c,
93
- kbNumpad0 = 0x52,
94
- kbNumpadAdd = 0x45,
95
- kbNumpadSubtract = 0x4e,
96
- kbNumpadMultiply = 0x43,
97
- kbNumpadDivide = 0x4b,
98
- kbRangeEnd = 0xffff,
99
-
100
- msRangeBegin,
101
- msLeft = msRangeBegin,
102
- msRight,
103
- msMiddle,
104
- msWheelUp,
105
- msWheelDown,
106
- msRangeEnd,
107
-
108
- gpRangeBegin,
109
- gpLeft = gpRangeBegin,
110
- gpRight,
111
- gpUp,
112
- gpDown,
113
- gpButton0,
114
- gpButton1,
115
- gpButton2,
116
- gpButton3,
117
- gpButton4,
118
- gpButton5,
119
- gpButton6,
120
- gpButton7,
121
- gpButton8,
122
- gpButton9,
123
- gpButton10,
124
- gpButton11,
125
- gpButton12,
126
- gpButton13,
127
- gpButton14,
128
- gpButton15,
129
-
130
- gp0Left,
131
- gp0Right,
132
- gp0Up,
133
- gp0Down,
134
- gp0Button0,
135
- gp0Button1,
136
- gp0Button2,
137
- gp0Button3,
138
- gp0Button4,
139
- gp0Button5,
140
- gp0Button6,
141
- gp0Button7,
142
- gp0Button8,
143
- gp0Button9,
144
- gp0Button10,
145
- gp0Button11,
146
- gp0Button12,
147
- gp0Button13,
148
- gp0Button14,
149
- gp0Button15,
150
-
151
- gp1Left,
152
- gp1Right,
153
- gp1Up,
154
- gp1Down,
155
- gp1Button0,
156
- gp1Button1,
157
- gp1Button2,
158
- gp1Button3,
159
- gp1Button4,
160
- gp1Button5,
161
- gp1Button6,
162
- gp1Button7,
163
- gp1Button8,
164
- gp1Button9,
165
- gp1Button10,
166
- gp1Button11,
167
- gp1Button12,
168
- gp1Button13,
169
- gp1Button14,
170
- gp1Button15,
171
-
172
- gp2Left,
173
- gp2Right,
174
- gp2Up,
175
- gp2Down,
176
- gp2Button0,
177
- gp2Button1,
178
- gp2Button2,
179
- gp2Button3,
180
- gp2Button4,
181
- gp2Button5,
182
- gp2Button6,
183
- gp2Button7,
184
- gp2Button8,
185
- gp2Button9,
186
- gp2Button10,
187
- gp2Button11,
188
- gp2Button12,
189
- gp2Button13,
190
- gp2Button14,
191
- gp2Button15,
192
-
193
- gp3Left,
194
- gp3Right,
195
- gp3Up,
196
- gp3Down,
197
- gp3Button0,
198
- gp3Button1,
199
- gp3Button2,
200
- gp3Button3,
201
- gp3Button4,
202
- gp3Button5,
203
- gp3Button6,
204
- gp3Button7,
205
- gp3Button8,
206
- gp3Button9,
207
- gp3Button10,
208
- gp3Button11,
209
- gp3Button12,
210
- gp3Button13,
211
- gp3Button14,
212
- gp3Button15,
213
-
214
- gpRangeEnd = gp3Button15,
215
-
216
- numButtons = gpRangeEnd + 1,
217
- numGamepads = 4,
218
- noButton = 0xffffffff,
219
-
220
- kbNum = kbRangeEnd - kbRangeBegin + 1,
221
- msNum = msRangeEnd - msRangeBegin + 1,
222
- gpNum = gpRangeEnd - gpRangeBegin + 1,
223
- gpNumPerGamepad = gpNum / (numGamepads + 1),
224
- };
225
- }
226
-
227
- #endif
@@ -1,11 +0,0 @@
1
- --- GosuImpl/RubyGosu_wrap.cxx 2011-04-06 14:42:00.000000000 +0800
2
- +++ GosuImpl/RubyGosu_wrap_.cxx 2011-04-06 14:49:55.000000000 +0800
3
- @@ -1514,7 +1514,7 @@
4
- downcast methods. */
5
- if (obj != Qnil) {
6
- VALUE value = rb_iv_get(obj, "@__swigtype__");
7
- - char* type_name = RSTRING_PTR(value);
8
- + const char* type_name = RSTRING_PTR(value);
9
-
10
- if (strcmp(type->name, type_name) == 0) {
11
- return obj;