malc-game-engine 1.0.0 → 1.0.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.
- package/malc.js +50 -40
- package/package.json +1 -1
package/malc.js
CHANGED
|
@@ -2126,24 +2126,24 @@ class GameController {
|
|
|
2126
2126
|
this.id = "";
|
|
2127
2127
|
|
|
2128
2128
|
this.binds = {
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2129
|
+
select: null,
|
|
2130
|
+
back: null,
|
|
2131
|
+
primary: null,
|
|
2132
|
+
secondary: null,
|
|
2133
|
+
leftbumber: null, // Fixed: changed from leftBumber
|
|
2134
|
+
rightbumber: null, // Fixed: changed from rightBumber
|
|
2135
|
+
lefttrigger: null, // Fixed: changed from leftTrigger
|
|
2136
|
+
righttrigger: null, // Fixed: changed from rightTrigger
|
|
2137
|
+
view: null,
|
|
2138
|
+
menu: null,
|
|
2139
|
+
leftstick: null, // Fixed: changed from leftStick
|
|
2140
|
+
rightstick: null, // Fixed: changed from rightStick
|
|
2141
|
+
up: null,
|
|
2142
|
+
down: null,
|
|
2143
|
+
left: null,
|
|
2144
|
+
right: null,
|
|
2145
|
+
home: null,
|
|
2146
|
+
};
|
|
2147
2147
|
|
|
2148
2148
|
this.setupListeners();
|
|
2149
2149
|
}
|
|
@@ -2208,28 +2208,38 @@ class GameController {
|
|
|
2208
2208
|
|
|
2209
2209
|
getButton(name){
|
|
2210
2210
|
name = name.toLowerCase();
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
secondary: 3,
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2211
|
+
|
|
2212
|
+
// Handle common variations
|
|
2213
|
+
const buttonMap = {
|
|
2214
|
+
// Primary button names
|
|
2215
|
+
'select': 0, 'back': 1, 'primary': 2, 'secondary': 3,
|
|
2216
|
+
'home': 16,
|
|
2217
|
+
|
|
2218
|
+
// Bumpers (with common variations)
|
|
2219
|
+
'leftbumper': 4, 'leftbumber': 4, 'lb': 4,
|
|
2220
|
+
'rightbumper': 5, 'rightbumber': 5, 'rb': 5,
|
|
2221
|
+
|
|
2222
|
+
// Triggers
|
|
2223
|
+
'lefttrigger': 6, 'lt': 6,
|
|
2224
|
+
'righttrigger': 7, 'rt': 7,
|
|
2225
|
+
|
|
2226
|
+
// System buttons
|
|
2227
|
+
'view': 8, 'menu': 9,
|
|
2228
|
+
|
|
2229
|
+
// Stick clicks
|
|
2230
|
+
'leftstick': 10, 'l3': 10,
|
|
2231
|
+
'rightstick': 11, 'r3': 11,
|
|
2232
|
+
|
|
2233
|
+
// D-Pad
|
|
2234
|
+
'up': 12, 'down': 13, 'left': 14, 'right': 15
|
|
2235
|
+
};
|
|
2236
|
+
|
|
2237
|
+
const btn = buttonMap[name];
|
|
2238
|
+
|
|
2239
|
+
if(btn == undefined) {
|
|
2240
|
+
throw new Error(`Controller|TypeError: "${name}" isn't a valid button mapping getter!`);
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2233
2243
|
return this.buttons[btn]?.pressed || false;
|
|
2234
2244
|
}
|
|
2235
2245
|
}
|