sfml.js 0.0.1-preview.32 → 0.0.1-preview.33

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/lib/keyboard.d.ts CHANGED
@@ -1,2 +1,106 @@
1
1
  export function isKeyPressed(key: number | string): boolean;
2
2
  export function setVirtualKeyboardVisible(visible: boolean): void;
3
+ export enum Keys {
4
+ A = 0,
5
+ Add = 67,
6
+ B = 1,
7
+ Backslash = 53,
8
+ Backspace = 59,
9
+ C = 2,
10
+ Comma = 49,
11
+ D = 3,
12
+ Delete = 66,
13
+ Divide = 70,
14
+ Down = 74,
15
+ E = 4,
16
+ End = 63,
17
+ Enter = 58,
18
+ Equal = 55,
19
+ Escape = 36,
20
+ F = 5,
21
+ F1 = 85,
22
+ F10 = 94,
23
+ F11 = 95,
24
+ F12 = 96,
25
+ F13 = 97,
26
+ F14 = 98,
27
+ F15 = 99,
28
+ F2 = 86,
29
+ F3 = 87,
30
+ F4 = 88,
31
+ F5 = 89,
32
+ F6 = 90,
33
+ F7 = 91,
34
+ F8 = 92,
35
+ F9 = 93,
36
+ G = 6,
37
+ H = 7,
38
+ Home = 64,
39
+ Hyphen = 56,
40
+ I = 8,
41
+ Insert = 65,
42
+ J = 9,
43
+ K = 10,
44
+ L = 11,
45
+ LAlt = 39,
46
+ LBracket = 46,
47
+ LControl = 37,
48
+ LShift = 38,
49
+ LSystem = 40,
50
+ Left = 71,
51
+ M = 12,
52
+ Menu = 45,
53
+ Multiply = 69,
54
+ N = 13,
55
+ Num0 = 26,
56
+ Num1 = 27,
57
+ Num2 = 28,
58
+ Num3 = 29,
59
+ Num4 = 30,
60
+ Num5 = 31,
61
+ Num6 = 32,
62
+ Num7 = 33,
63
+ Num8 = 34,
64
+ Num9 = 35,
65
+ Numpad0 = 75,
66
+ Numpad1 = 76,
67
+ Numpad2 = 77,
68
+ Numpad3 = 78,
69
+ Numpad4 = 79,
70
+ Numpad5 = 80,
71
+ Numpad6 = 81,
72
+ Numpad7 = 82,
73
+ Numpad8 = 83,
74
+ Numpad9 = 84,
75
+ O = 14,
76
+ P = 15,
77
+ PageDown = 62,
78
+ PageUp = 61,
79
+ Pause = 100,
80
+ Period = 50,
81
+ Q = 16,
82
+ Quote = 51,
83
+ R = 17,
84
+ RAlt = 43,
85
+ RBracket = 47,
86
+ RControl = 41,
87
+ RShift = 42,
88
+ RSystem = 44,
89
+ Right = 72,
90
+ S = 18,
91
+ Semicolon = 48,
92
+ Slash = 52,
93
+ Space = 57,
94
+ Subtract = 68,
95
+ T = 19,
96
+ Tab = 60,
97
+ Tilde = 54,
98
+ U = 20,
99
+ Unknown = -1,
100
+ Up = 73,
101
+ V = 21,
102
+ W = 22,
103
+ X = 23,
104
+ Y = 24,
105
+ Z = 25,
106
+ }
package/lib/keyboard.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const {
4
4
  isKeyPressed: _isKeyPressed,
5
5
  setVirtualKeyboardVisible: _setVirtualKeyboardVisible,
6
+ Keys,
6
7
  } = require('../build/Release/binding.node');
7
8
 
8
9
  exports.setVirtualKeyboardVisible = function setVirtualKeyboardVisible(visible) {
@@ -10,3 +11,5 @@ exports.setVirtualKeyboardVisible = function setVirtualKeyboardVisible(visible)
10
11
  };
11
12
 
12
13
  exports.isKeyPressed = _isKeyPressed;
14
+
15
+ exports.Keys = Keys;
@@ -26,6 +26,8 @@ export class RenderWindow {
26
26
  setActive(active?: boolean): void;
27
27
 
28
28
  getSize(): Vector2U;
29
+
30
+ hasFocus(): boolean;
29
31
  }
30
32
  export namespace RenderWindow {
31
33
  enum Style {
@@ -107,6 +107,10 @@ class RenderWindow {
107
107
  getSize() {
108
108
  return this[RAW_RENDER_WINDOW].getSize();
109
109
  }
110
+
111
+ hasFocus() {
112
+ return this[RAW_RENDER_WINDOW].hasFocus();
113
+ }
110
114
  }
111
115
 
112
116
  RenderWindow.Style = _RenderWindow.Style;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfml.js",
3
- "version": "0.0.1-preview.32",
3
+ "version": "0.0.1-preview.33",
4
4
  "description": "SFML's Node.js binding.",
5
5
  "main": "lib/sfml.js",
6
6
  "scripts": {
package/src/keyboard.cc CHANGED
@@ -10,6 +10,7 @@ namespace keyboard {
10
10
  using std::map;
11
11
  using std::string;
12
12
  using v8::Local;
13
+ using v8::Object;
13
14
  using v8::String;
14
15
 
15
16
  NAN_MODULE_INIT(Init) {
@@ -18,6 +19,16 @@ NAN_MODULE_INIT(Init) {
18
19
  Nan::SetMethod(target, "isKeyPressed", IsKeyPressed);
19
20
  Nan::SetMethod(
20
21
  target, "setVirtualKeyboardVisible", SetVirtualKeyboardVisible);
22
+
23
+ Local<Object> key_codes = Nan::New<Object>();
24
+ for (auto it = gen::keycode_atoi.begin(); it != gen::keycode_atoi.end();
25
+ it++) {
26
+ Nan::Set(key_codes,
27
+ Nan::New<String>(it->first).ToLocalChecked(),
28
+ Nan::New(it->second));
29
+ }
30
+
31
+ Nan::Set(target, Nan::New<String>("Keys").ToLocalChecked(), key_codes);
21
32
  }
22
33
 
23
34
  NAN_METHOD(IsKeyPressed) {
@@ -32,6 +32,7 @@ NAN_MODULE_INIT(RenderWindow::Init) {
32
32
  Nan::SetPrototypeMethod(tpl, "isOpen", IsOpen);
33
33
  Nan::SetPrototypeMethod(tpl, "pollEvent", PollEvent);
34
34
  Nan::SetPrototypeMethod(tpl, "getSize", GetSize);
35
+ Nan::SetPrototypeMethod(tpl, "hasFocus", HasFocus);
35
36
 
36
37
  #define PRIMITIVE_VALUE_PROTOTYPE_METHOD(name, _) \
37
38
  Nan::SetPrototypeMethod(tpl, "set" #name, Set##name);
@@ -199,6 +200,11 @@ NAN_METHOD(RenderWindow::GetSize) {
199
200
  info.GetReturnValue().Set(maybe_vec.ToLocalChecked());
200
201
  }
201
202
 
203
+ NAN_METHOD(RenderWindow::HasFocus) {
204
+ RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
205
+ info.GetReturnValue().Set(window->_window->hasFocus());
206
+ }
207
+
202
208
  #define SET_PRIMITIVE_VALUE(name, type) \
203
209
  NAN_METHOD(RenderWindow::Set##name) { \
204
210
  RenderWindow* window = \
@@ -26,6 +26,7 @@ class RenderWindow : public Nan::ObjectWrap {
26
26
  static NAN_METHOD(IsOpen);
27
27
  static NAN_METHOD(PollEvent);
28
28
  static NAN_METHOD(GetSize);
29
+ static NAN_METHOD(HasFocus);
29
30
 
30
31
  #define PRIMITIVE_VALUES(V) \
31
32
  V(Visible, bool) \