@kmamal/sdl 0.11.5 → 0.11.7

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.
Files changed (38) hide show
  1. package/README.md +46 -7
  2. package/binding.gyp +1 -0
  3. package/package.json +1 -1
  4. package/src/javascript/audio/audio-instance.js +2 -3
  5. package/src/javascript/audio/device.js +1 -10
  6. package/src/javascript/audio/index.js +5 -7
  7. package/src/javascript/controller/controller-instance.js +2 -0
  8. package/src/javascript/controller/device.js +14 -3
  9. package/src/javascript/controller/index.js +5 -11
  10. package/src/javascript/events/index.js +56 -126
  11. package/src/javascript/events/reconcile-audio-devices.js +15 -0
  12. package/src/javascript/events/reconcile-displays.js +16 -0
  13. package/src/javascript/events/reconcile-joystick-and-controller-devices.js +37 -0
  14. package/src/javascript/events/reconcile.js +61 -0
  15. package/src/javascript/joystick/device.js +9 -3
  16. package/src/javascript/joystick/index.js +13 -5
  17. package/src/javascript/joystick/joystick-instance.js +2 -0
  18. package/src/javascript/sensor/sensor-instance.js +2 -0
  19. package/src/javascript/video/display.js +4 -0
  20. package/src/javascript/video/index.js +1 -0
  21. package/src/native/audio.cpp +10 -12
  22. package/src/native/audio.h +4 -0
  23. package/src/native/controller.cpp +72 -56
  24. package/src/native/controller.h +3 -0
  25. package/src/native/enums.cpp +315 -315
  26. package/src/native/events.cpp +156 -80
  27. package/src/native/events.h +1 -0
  28. package/src/native/global.cpp +46 -20
  29. package/src/native/joystick.cpp +87 -48
  30. package/src/native/joystick.h +3 -2
  31. package/src/native/keyboard.cpp +1 -1
  32. package/src/native/mouse.cpp +2 -2
  33. package/src/native/power.cpp +9 -3
  34. package/src/native/sensor.cpp +24 -13
  35. package/src/native/video.cpp +21 -13
  36. package/src/native/video.h +1 -0
  37. package/src/native/window.cpp +28 -22
  38. package/src/types/index.d.ts +57 -17
@@ -0,0 +1,61 @@
1
+
2
+ const reconcileDevices = (
3
+ emitter,
4
+ mainList,
5
+ currList,
6
+ compare,
7
+ prefix = 'device',
8
+ ) => {
9
+ const addEventType = `${prefix}Add`
10
+ const removeEventType = `${prefix}Remove`
11
+
12
+ currList.sort(compare)
13
+
14
+ let mainIndex = 0
15
+ let currIndex = 0
16
+ let mainDevice = mainList[mainIndex]
17
+ let currDevice = currList[currIndex]
18
+ while (mainIndex < mainList.length && currIndex < currList.length) {
19
+ const cmp = compare(mainDevice, currDevice)
20
+ if (cmp === 0) {
21
+ Object.assign(mainList[mainIndex], currList[currIndex])
22
+ mainDevice = mainList[++mainIndex]
23
+ currDevice = currList[++currIndex]
24
+ }
25
+ else if (cmp < 0) {
26
+ mainList.splice(mainIndex, 1)
27
+ const type = removeEventType
28
+ const event = { type, device: mainDevice }
29
+ emitter.emit(type, event)
30
+ mainDevice = mainList[mainIndex]
31
+ }
32
+ else {
33
+ mainList.splice(mainIndex, 0, currDevice)
34
+ mainDevice = mainList[++mainIndex]
35
+ const type = addEventType
36
+ const event = { type, device: currDevice }
37
+ emitter.emit(type, event)
38
+ currDevice = currList[++currIndex]
39
+ }
40
+ }
41
+
42
+ if (mainIndex < mainList.length) {
43
+ while (mainIndex < mainList.length) {
44
+ [ mainDevice ] = mainList.splice(mainIndex, 1)
45
+ const type = removeEventType
46
+ const event = { type, device: mainDevice }
47
+ emitter.emit(type, event)
48
+ }
49
+ }
50
+ else {
51
+ while (currIndex < currList.length) {
52
+ mainList.push(currDevice)
53
+ const type = addEventType
54
+ const event = { type, device: currDevice }
55
+ emitter.emit(type, event)
56
+ currDevice = currList[++currIndex]
57
+ }
58
+ }
59
+ }
60
+
61
+ module.exports = { reconcileDevices }
@@ -1,10 +1,16 @@
1
1
 
2
2
  const make = (device) => {
3
- delete device.isController
4
- delete device.mapping
3
+ const {
4
+ isController,
5
+ controllerMapping,
6
+ controllerName,
7
+ controllerType,
8
+ ...rest
9
+ } = device
10
+ return rest
5
11
  }
6
12
 
7
- const compare = (a, b) => a.id - b.id
13
+ const compare = (a, b) => a._index - b._index
8
14
 
9
15
  module.exports = {
10
16
  make,
@@ -1,13 +1,21 @@
1
1
  const Globals = require('../globals')
2
2
  const Bindings = require('../bindings')
3
- const { make: makeJoystickDevice } = require('./device')
4
3
  const { EventsViaPoll } = require('../events/events-via-poll')
5
4
  const { JoystickInstance } = require('./joystick-instance')
6
5
 
7
- Globals.joystickDevices = Bindings.joystick_getDevices()
8
- for (const joystickDevice of Globals.joystickDevices) {
9
- makeJoystickDevice(joystickDevice)
10
- }
6
+
7
+ const { make: makeJoystickDevice } = require('./device')
8
+ const {
9
+ make: makeControllerDevice,
10
+ filter: filterControllerDevice,
11
+ } = require('../controller/device')
12
+
13
+ const devices = Bindings.joystick_getDevices()
14
+ Globals.joystickDevices = devices
15
+ .map(makeJoystickDevice)
16
+ Globals.controllerDevices = devices
17
+ .filter(filterControllerDevice)
18
+ .map(makeControllerDevice)
11
19
 
12
20
 
13
21
  const validEvents = [ 'deviceAdd', 'deviceRemove' ]
@@ -15,6 +15,8 @@ class JoystickInstance extends EventsViaPoll {
15
15
  constructor (device) {
16
16
  super(validEvents)
17
17
 
18
+ if (!Globals.joystickDevices.includes(device)) { throw Object.assign(new Error("invalid device"), { device }) }
19
+
18
20
  const result = Bindings.joystick_open(device._index)
19
21
 
20
22
  this._firmwareVersion = result.firmwareVersion
@@ -11,6 +11,8 @@ class SensorInstance extends EventsViaPoll {
11
11
  constructor (device) {
12
12
  super(validEvents)
13
13
 
14
+ if (!Globals.sensorDevices.includes(device)) { throw Object.assign(new Error("invalid device"), { device }) }
15
+
14
16
  Bindings.sensor_open(device._index)
15
17
 
16
18
  this._device = device
@@ -0,0 +1,4 @@
1
+
2
+ const compare = (a, b) => a._index - b._index
3
+
4
+ module.exports = { compare }
@@ -3,6 +3,7 @@ const Bindings = require('../bindings')
3
3
  const { EventsViaPoll } = require('../events/events-via-poll')
4
4
  const { Window } = require('./window')
5
5
 
6
+
6
7
  Globals.displays = Bindings.video_getDisplays()
7
8
 
8
9
 
@@ -5,16 +5,16 @@
5
5
  #include <sstream>
6
6
 
7
7
 
8
+ std::map<bool, std::string> audio::device_types;
9
+
10
+
8
11
  Napi::Array
9
12
  audio::_getDevices(Napi::Env &env, bool is_capture)
10
13
  {
11
- const char *error = SDL_GetError();
12
- if (error != global::no_error) { fprintf(stderr, "SDL silent error: %s\n", error); }
13
- SDL_ClearError();
14
-
15
14
  int num_devices = SDL_GetNumAudioDevices(is_capture ? 1 : 0);
16
15
  if (num_devices == -1) {
17
- error = SDL_GetError();
16
+ // SDL_GetNumAudioDevices can return -1 even if there is no error
17
+ const char *error = SDL_GetError();
18
18
  if (error != global::no_error) {
19
19
  std::ostringstream message;
20
20
  message << "SDL_GetNumAudioDevices(" << is_capture << ") error: " << error;
@@ -26,6 +26,8 @@ audio::_getDevices(Napi::Env &env, bool is_capture)
26
26
 
27
27
  Napi::Array devices = Napi::Array::New(env, num_devices);
28
28
 
29
+ std::string device_type = audio::device_types[is_capture];
30
+
29
31
  for (int i = 0; i < num_devices; i++) {
30
32
  const char *name = SDL_GetAudioDeviceName(i, is_capture);
31
33
  if (name == nullptr) {
@@ -36,8 +38,8 @@ audio::_getDevices(Napi::Env &env, bool is_capture)
36
38
  }
37
39
 
38
40
  Napi::Object device = Napi::Object::New(env);
39
- device.Set("isRecorder", Napi::Boolean::New(env, is_capture));
40
- device.Set("name", Napi::String::New(env, name));
41
+ device.Set("name", name);
42
+ device.Set("type", device_type);
41
43
 
42
44
  devices.Set(i, device);
43
45
  }
@@ -155,12 +157,8 @@ audio::dequeue (const Napi::CallbackInfo &info)
155
157
  void *dst = info[1].As<Napi::Buffer<char>>().Data();
156
158
  int size = info[2].As<Napi::Number>().Int32Value();
157
159
 
158
- const char *error = SDL_GetError();
159
- if (error != global::no_error) { fprintf(stderr, "SDL silent error: %s\n", error); }
160
- SDL_ClearError();
161
-
162
160
  int num = SDL_DequeueAudio(audio_id, dst, size);
163
- error = SDL_GetError();
161
+ const char *error = SDL_GetError();
164
162
  if (error != global::no_error) {
165
163
  std::ostringstream message;
166
164
  message << "SDL_DequeueAudio(" << audio_id << ") error: " << error;
@@ -2,9 +2,13 @@
2
2
  #define _AUDIO_H_
3
3
 
4
4
  #include <napi.h>
5
+ #include <map>
6
+ #include <string>
5
7
 
6
8
  namespace audio {
7
9
 
10
+ extern std::map<bool, std::string> device_types;
11
+
8
12
  Napi::Array _getDevices(Napi::Env &env, bool is_capture);
9
13
 
10
14
  Napi::Value getDevices(const Napi::CallbackInfo &info);
@@ -7,24 +7,40 @@
7
7
  #include <sstream>
8
8
 
9
9
 
10
+ std::map<SDL_GameControllerType, std::string> controller::types;
10
11
  std::map<SDL_GameControllerAxis, std::string> controller::axes;
11
12
  std::map<SDL_GameControllerButton, std::string> controller::buttons;
12
13
 
13
14
 
15
+ double
16
+ controller::mapAxis (SDL_GameController *controller, SDL_GameControllerAxis axis) {
17
+ return mapAxisValue(controller, axis, SDL_GameControllerGetAxis(controller, axis));
18
+ }
19
+
20
+ double
21
+ controller::mapAxisValue (SDL_GameController *controller, SDL_GameControllerAxis axis, int value) {
22
+ SDL_GameControllerButtonBind bind = SDL_GameControllerGetBindForAxis(controller, axis);
23
+ if (bind.bindType == SDL_CONTROLLER_BINDTYPE_AXIS) {
24
+ SDL_Joystick *joystick = SDL_GameControllerGetJoystick(controller);
25
+ return joystick::mapAxisValue(joystick, bind.value.axis, value);
26
+ }
27
+
28
+ double range = value < 0 ? -SDL_JOYSTICK_AXIS_MIN : SDL_JOYSTICK_AXIS_MAX;
29
+ return value / range;
30
+ }
31
+
14
32
  void
15
33
  controller::getState (Napi::Env &env, SDL_GameController *controller, Napi::Object dst)
16
34
  {
17
- const char *error = SDL_GetError();
18
- if (error != global::no_error) { fprintf(stderr, "SDL silent error: %s\n", error); }
19
- SDL_ClearError();
20
-
21
35
  Napi::Object axes = Napi::Object::New(env);
22
- axes.Set("leftStickX", Napi::Number::New(env, joystick::mapAxis(SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_LEFTX))));
23
- axes.Set("leftStickY", Napi::Number::New(env, joystick::mapAxis(SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_LEFTY))));
24
- axes.Set("rightStickX", Napi::Number::New(env, joystick::mapAxis(SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX))));
25
- axes.Set("rightStickY", Napi::Number::New(env, joystick::mapAxis(SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY))));
26
- axes.Set("leftTrigger", Napi::Number::New(env, joystick::mapAxis(SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_TRIGGERLEFT))));
27
- axes.Set("rightTrigger", Napi::Number::New(env, joystick::mapAxis(SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_TRIGGERRIGHT))));
36
+ axes.Set("leftStickX", controller::mapAxis(controller, SDL_CONTROLLER_AXIS_LEFTX));
37
+ axes.Set("leftStickY", controller::mapAxis(controller, SDL_CONTROLLER_AXIS_LEFTY));
38
+ axes.Set("rightStickX", controller::mapAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX));
39
+ axes.Set("rightStickY", controller::mapAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY));
40
+ axes.Set("leftTrigger", controller::mapAxis(controller, SDL_CONTROLLER_AXIS_TRIGGERLEFT));
41
+ axes.Set("rightTrigger", controller::mapAxis(controller, SDL_CONTROLLER_AXIS_TRIGGERRIGHT));
42
+
43
+ const char *error;
28
44
 
29
45
  error = SDL_GetError();
30
46
  if (error != global::no_error) {
@@ -35,25 +51,25 @@ controller::getState (Napi::Env &env, SDL_GameController *controller, Napi::Obje
35
51
  }
36
52
 
37
53
  Napi::Object buttons = Napi::Object::New(env);
38
- buttons.Set("dpadLeft", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_LEFT)));
39
- buttons.Set("dpadRight", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_RIGHT)));
40
- buttons.Set("dpadUp", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_UP)));
41
- buttons.Set("dpadDown", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_DOWN)));
42
- buttons.Set("a", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_A)));
43
- buttons.Set("b", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_B)));
44
- buttons.Set("x", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_X)));
45
- buttons.Set("y", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_Y)));
46
- buttons.Set("guide", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_GUIDE)));
47
- buttons.Set("back", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_BACK)));
48
- buttons.Set("start", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_START)));
49
- buttons.Set("leftStick", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_LEFTSTICK)));
50
- buttons.Set("rightStick", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_RIGHTSTICK)));
51
- buttons.Set("leftShoulder", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_LEFTSHOULDER)));
52
- buttons.Set("rightShoulder", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)));
53
- buttons.Set("paddle1", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_PADDLE1)));
54
- buttons.Set("paddle2", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_PADDLE2)));
55
- buttons.Set("paddle3", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_PADDLE3)));
56
- buttons.Set("paddle4", Napi::Boolean::New(env, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_PADDLE4)));
54
+ buttons.Set("dpadLeft", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_LEFT));
55
+ buttons.Set("dpadRight", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_RIGHT));
56
+ buttons.Set("dpadUp", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_UP));
57
+ buttons.Set("dpadDown", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_DOWN));
58
+ buttons.Set("a", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_A));
59
+ buttons.Set("b", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_B));
60
+ buttons.Set("x", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_X));
61
+ buttons.Set("y", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_Y));
62
+ buttons.Set("guide", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_GUIDE));
63
+ buttons.Set("back", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_BACK));
64
+ buttons.Set("start", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_START));
65
+ buttons.Set("leftStick", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_LEFTSTICK));
66
+ buttons.Set("rightStick", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_RIGHTSTICK));
67
+ buttons.Set("leftShoulder", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_LEFTSHOULDER));
68
+ buttons.Set("rightShoulder", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER));
69
+ buttons.Set("paddle1", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_PADDLE1));
70
+ buttons.Set("paddle2", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_PADDLE2));
71
+ buttons.Set("paddle3", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_PADDLE3));
72
+ buttons.Set("paddle4", !!SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_PADDLE4));
57
73
 
58
74
  error = SDL_GetError();
59
75
  if (error != global::no_error) {
@@ -83,7 +99,13 @@ controller::addMappings (const Napi::CallbackInfo &info)
83
99
  SDL_ClearError();
84
100
  throw Napi::Error::New(env, message.str());
85
101
  }
102
+
103
+ // SDL_GameControllerAddMapping produces errors even though it succeeds
104
+ const char *error = SDL_GetError();
105
+ if (error != global::no_error) { fprintf(stderr, "SDL silent error: %s\n", error); }
106
+ SDL_ClearError();
86
107
  }
108
+
87
109
  return env.Undefined();
88
110
  }
89
111
 
@@ -102,42 +124,36 @@ controller::open (const Napi::CallbackInfo &info)
102
124
  throw Napi::Error::New(env, message.str());
103
125
  }
104
126
 
105
- SDL_Joystick *joystick = SDL_GameControllerGetJoystick(controller);
106
- if (joystick == nullptr) {
107
- std::ostringstream message;
108
- message << "SDL_GameControllerGetJoystick(" << index << ") error: " << SDL_GetError();
109
- SDL_ClearError();
110
- throw Napi::Error::New(env, message.str());
111
- }
112
-
113
- SDL_JoystickID joystick_id = SDL_JoystickInstanceID(joystick);
114
- if (joystick_id < 0) {
115
- std::ostringstream message;
116
- message << "SDL_JoystickInstanceID(" << index << ") error: " << SDL_GetError();
117
- SDL_ClearError();
118
- throw Napi::Error::New(env, message.str());
119
- }
127
+ // SDL_GameControllerOpen produces errors even though it succeeds
128
+ const char *error = SDL_GetError();
129
+ if (error != global::no_error) { fprintf(stderr, "SDL silent error: %s\n", error); }
130
+ SDL_ClearError();
120
131
 
121
- int _firmware_version = SDL_JoystickGetFirmwareVersion(joystick);
122
- Napi::Value firmware_version = _firmware_version == 0 ? env.Null() : Napi::Number::New(env, _firmware_version);
132
+ int _firmware_version = SDL_GameControllerGetFirmwareVersion(controller);
133
+ Napi::Value firmware_version = _firmware_version != 0
134
+ ? Napi::Number::New(env, _firmware_version)
135
+ : env.Null() ;
123
136
 
124
- const char *_serial_number = SDL_JoystickGetSerial(joystick);
125
- Napi::Value serial_number = _serial_number == 0 ? env.Null() : Napi::String::New(env, _serial_number);
137
+ const char *_serial_number = SDL_GameControllerGetSerial(controller);
138
+ Napi::Value serial_number = _serial_number != 0
139
+ ? Napi::String::New(env, _serial_number)
140
+ : env.Null();
126
141
 
127
- bool has_led = SDL_JoystickHasLED(joystick);
128
- bool has_rumble = SDL_JoystickHasRumble(joystick);
129
- bool has_rumble_triggers = SDL_JoystickHasRumbleTriggers(joystick);
142
+ bool has_led = SDL_GameControllerHasLED(controller);
143
+ bool has_rumble = SDL_GameControllerHasRumble(controller);
144
+ bool has_rumble_triggers = SDL_GameControllerHasRumbleTriggers(controller);
130
145
 
131
146
  Uint64 _steam_handle = SDL_GameControllerGetSteamHandle(controller);
132
- Napi::Value steam_handle = _steam_handle == 0 ? env.Null() : Napi::Buffer<Uint64>::Copy(env, &_steam_handle, 1);
147
+ Napi::Value steam_handle = _steam_handle != 0
148
+ ? Napi::Buffer<Uint64>::Copy(env, &_steam_handle, 1)
149
+ : env.Null();
133
150
 
134
151
  Napi::Object result = Napi::Object::New(env);
135
- // result.Set("id", Napi::Number::New(env, joystick_id)); // NOTE: Unused. Same as the device id
136
152
  result.Set("firmwareVersion", firmware_version);
137
153
  result.Set("serialNumber", serial_number);
138
- result.Set("hasLed", Napi::Boolean::New(env, has_led));
139
- result.Set("hasRumble", Napi::Boolean::New(env, has_rumble));
140
- result.Set("hasRumbleTriggers", Napi::Boolean::New(env, has_rumble_triggers));
154
+ result.Set("hasLed", has_led);
155
+ result.Set("hasRumble", has_rumble);
156
+ result.Set("hasRumbleTriggers", has_rumble_triggers);
141
157
  result.Set("steamHandle", steam_handle);
142
158
 
143
159
  controller::getState(env, controller, result);
@@ -8,9 +8,12 @@
8
8
 
9
9
  namespace controller {
10
10
 
11
+ extern std::map<SDL_GameControllerType, std::string> types;
11
12
  extern std::map<SDL_GameControllerAxis, std::string> axes;
12
13
  extern std::map<SDL_GameControllerButton, std::string> buttons;
13
14
 
15
+ double mapAxis (SDL_GameController *controller, SDL_GameControllerAxis axis);
16
+ double mapAxisValue (SDL_GameController *controller, SDL_GameControllerAxis axis, int value);
14
17
  void getState (Napi::Env &env, SDL_GameController *controller, Napi::Object dst);
15
18
 
16
19
  Napi::Value addMappings(const Napi::CallbackInfo &info);