slifer 0.1.3 → 0.1.4
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/LICENSE +21 -21
- package/README.md +66 -66
- package/bun.lockb +0 -0
- package/index.ts +3 -3
- package/libs/libSDL2.so +0 -0
- package/libs/libSDL2_image.so +0 -0
- package/libs/libSDL2_ttf.so +0 -0
- package/package.json +17 -14
- package/src/ffi.ts +230 -227
- package/src/global.ts +10 -9
- package/src/modules/graphics.ts +157 -155
- package/src/modules/keyboard.ts +79 -77
- package/src/modules/mouse.ts +101 -99
- package/src/slifer.ts +132 -126
- package/tsconfig.json +28 -27
package/src/ffi.ts
CHANGED
|
@@ -1,227 +1,230 @@
|
|
|
1
|
-
import { dlopen, FFIType, suffix } from "bun:ffi";
|
|
2
|
-
|
|
3
|
-
let libSDLImport;
|
|
4
|
-
let libImageImport;
|
|
5
|
-
let libTTFImport;
|
|
6
|
-
let libGFXImport;
|
|
7
|
-
|
|
8
|
-
if (process.platform == "win32") {
|
|
9
|
-
//@ts-expect-error
|
|
10
|
-
libSDLImport = await import("../libs/libSDL2.dll");
|
|
11
|
-
//@ts-expect-error
|
|
12
|
-
libImageImport = await import("../libs/libSDL2_image.dll");
|
|
13
|
-
//@ts-expect-error
|
|
14
|
-
libTTFImport = await import("../libs/libSDL2_ttf.dll");
|
|
15
|
-
} else if (process.platform == "darwin") {
|
|
16
|
-
//@ts-expect-error
|
|
17
|
-
libSDLImport = await import("../libs/libSDL2.dylib");
|
|
18
|
-
//@ts-expect-error
|
|
19
|
-
libImageImport = await import("../libs/libSDL2_image.dylib");
|
|
20
|
-
//@ts-expect-error
|
|
21
|
-
libTTFImport = await import("../libs/libSDL2_ttf.dylib");
|
|
22
|
-
} else if (process.platform == "linux") {
|
|
23
|
-
//@ts-expect-error
|
|
24
|
-
libSDLImport = await import("../libs/libSDL2.so");
|
|
25
|
-
//@ts-expect-error
|
|
26
|
-
libImageImport = await import("../libs/libSDL2_image.so");
|
|
27
|
-
//@ts-expect-error
|
|
28
|
-
libTTFImport = await import("../libs/libSDL2_ttf.so");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
"pointer",
|
|
183
|
-
"pointer",
|
|
184
|
-
"pointer",
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
returns: "
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
1
|
+
import { dlopen, FFIType, suffix } from "bun:ffi";
|
|
2
|
+
|
|
3
|
+
let libSDLImport;
|
|
4
|
+
let libImageImport;
|
|
5
|
+
let libTTFImport;
|
|
6
|
+
let libGFXImport;
|
|
7
|
+
|
|
8
|
+
if (process.platform == "win32") {
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
libSDLImport = await import("../libs/libSDL2.dll");
|
|
11
|
+
//@ts-expect-error
|
|
12
|
+
libImageImport = await import("../libs/libSDL2_image.dll");
|
|
13
|
+
//@ts-expect-error
|
|
14
|
+
libTTFImport = await import("../libs/libSDL2_ttf.dll");
|
|
15
|
+
} else if (process.platform == "darwin") {
|
|
16
|
+
//@ts-expect-error
|
|
17
|
+
libSDLImport = await import("../libs/libSDL2.dylib");
|
|
18
|
+
//@ts-expect-error
|
|
19
|
+
libImageImport = await import("../libs/libSDL2_image.dylib");
|
|
20
|
+
//@ts-expect-error
|
|
21
|
+
libTTFImport = await import("../libs/libSDL2_ttf.dylib");
|
|
22
|
+
} else if (process.platform == "linux") {
|
|
23
|
+
//@ts-expect-error
|
|
24
|
+
libSDLImport = await import("../libs/libSDL2.so");
|
|
25
|
+
//@ts-expect-error
|
|
26
|
+
libImageImport = await import("../libs/libSDL2_image.so");
|
|
27
|
+
//@ts-expect-error
|
|
28
|
+
libTTFImport = await import("../libs/libSDL2_ttf.so");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @internal */
|
|
32
|
+
export const libsdl = dlopen(libSDLImport.default, {
|
|
33
|
+
SDL_Init: {
|
|
34
|
+
args: [FFIType.int],
|
|
35
|
+
returns: FFIType.int,
|
|
36
|
+
},
|
|
37
|
+
SDL_GetRevision: {
|
|
38
|
+
returns: "cstring",
|
|
39
|
+
},
|
|
40
|
+
SDL_CreateWindow: {
|
|
41
|
+
args: ["cstring", "int", "int", "int", "int", "u32"],
|
|
42
|
+
returns: "pointer",
|
|
43
|
+
},
|
|
44
|
+
SDL_CreateRenderer: {
|
|
45
|
+
args: ["pointer", "int", "u32"],
|
|
46
|
+
returns: "pointer",
|
|
47
|
+
},
|
|
48
|
+
SDL_GetDesktopDisplayMode: {
|
|
49
|
+
args: ["int", "pointer"],
|
|
50
|
+
returns: "int",
|
|
51
|
+
},
|
|
52
|
+
SDL_GetDisplayOrientation: {
|
|
53
|
+
args: ["int"],
|
|
54
|
+
returns: "int",
|
|
55
|
+
},
|
|
56
|
+
SDL_SetWindowFullscreen: {
|
|
57
|
+
args: ["pointer", "u32"],
|
|
58
|
+
returns: "int",
|
|
59
|
+
},
|
|
60
|
+
SDL_PollEvent: {
|
|
61
|
+
args: ["pointer"],
|
|
62
|
+
returns: "int",
|
|
63
|
+
},
|
|
64
|
+
SDL_RenderClear: {
|
|
65
|
+
args: ["pointer"],
|
|
66
|
+
returns: "int",
|
|
67
|
+
},
|
|
68
|
+
SDL_RenderCopy: {
|
|
69
|
+
args: ["pointer", "pointer", "pointer", "pointer"],
|
|
70
|
+
returns: "int",
|
|
71
|
+
},
|
|
72
|
+
SDL_RenderPresent: {
|
|
73
|
+
args: ["pointer"],
|
|
74
|
+
returns: "void",
|
|
75
|
+
},
|
|
76
|
+
SDL_CreateTextureFromSurface: {
|
|
77
|
+
args: ["pointer", "pointer"],
|
|
78
|
+
returns: "pointer",
|
|
79
|
+
},
|
|
80
|
+
SDL_DestroyRenderer: {
|
|
81
|
+
args: ["pointer"],
|
|
82
|
+
returns: "void",
|
|
83
|
+
},
|
|
84
|
+
SDL_DestroyWindow: {
|
|
85
|
+
args: ["pointer"],
|
|
86
|
+
returns: "void",
|
|
87
|
+
},
|
|
88
|
+
SDL_Quit: {
|
|
89
|
+
returns: "void",
|
|
90
|
+
},
|
|
91
|
+
SDL_GetKeyName: {
|
|
92
|
+
args: ["int"],
|
|
93
|
+
returns: "cstring",
|
|
94
|
+
},
|
|
95
|
+
SDL_GetKeyFromScancode: {
|
|
96
|
+
args: ["int"],
|
|
97
|
+
returns: "int",
|
|
98
|
+
},
|
|
99
|
+
SDL_GetPerformanceCounter: {
|
|
100
|
+
returns: "u64",
|
|
101
|
+
},
|
|
102
|
+
SDL_GetPerformanceFrequency: {
|
|
103
|
+
returns: "u64",
|
|
104
|
+
},
|
|
105
|
+
SDL_QueryTexture: {
|
|
106
|
+
args: ["pointer", "pointer", "pointer", "pointer", "pointer"],
|
|
107
|
+
returns: "int",
|
|
108
|
+
},
|
|
109
|
+
SDL_GetMouseState: {
|
|
110
|
+
args: ["pointer", "pointer"],
|
|
111
|
+
returns: "u32",
|
|
112
|
+
},
|
|
113
|
+
SDL_CreateColorCursor: {
|
|
114
|
+
args: ["pointer", "int", "int"],
|
|
115
|
+
returns: "pointer",
|
|
116
|
+
},
|
|
117
|
+
SDL_SetCursor: {
|
|
118
|
+
args: ["pointer"],
|
|
119
|
+
returns: "void",
|
|
120
|
+
},
|
|
121
|
+
SDL_SetRenderDrawColor: {
|
|
122
|
+
args: ["pointer", "int", "int", "int", "int"],
|
|
123
|
+
returns: "void",
|
|
124
|
+
},
|
|
125
|
+
SDL_RenderFillRect: {
|
|
126
|
+
args: ["pointer", "pointer"],
|
|
127
|
+
returns: "bool",
|
|
128
|
+
},
|
|
129
|
+
SDL_GetWindowPosition: {
|
|
130
|
+
args: ["pointer", "pointer", "pointer"],
|
|
131
|
+
returns: "void",
|
|
132
|
+
},
|
|
133
|
+
SDL_SetWindowPosition: {
|
|
134
|
+
args: ["pointer", "int", "int"],
|
|
135
|
+
returns: "void",
|
|
136
|
+
},
|
|
137
|
+
SDL_SetWindowHitTest: {
|
|
138
|
+
args: ["pointer", FFIType.function, "pointer"],
|
|
139
|
+
returns: "int",
|
|
140
|
+
},
|
|
141
|
+
SDL_GetWindowSize: {
|
|
142
|
+
args: ["pointer", "pointer", "pointer"],
|
|
143
|
+
returns: "void",
|
|
144
|
+
},
|
|
145
|
+
SDL_CreateSystemCursor: {
|
|
146
|
+
args: ["int"],
|
|
147
|
+
returns: "pointer",
|
|
148
|
+
},
|
|
149
|
+
SDL_GetError: {
|
|
150
|
+
returns: "cstring",
|
|
151
|
+
},
|
|
152
|
+
SDL_SetHint: {
|
|
153
|
+
args: ["cstring", "cstring"],
|
|
154
|
+
returns: "bool",
|
|
155
|
+
},
|
|
156
|
+
SDL_MinimizeWindow: {
|
|
157
|
+
args: ["pointer"],
|
|
158
|
+
returns: "void",
|
|
159
|
+
},
|
|
160
|
+
SDL_GetShapedWindowMode: {
|
|
161
|
+
args: ["pointer", "pointer"],
|
|
162
|
+
returns: "int",
|
|
163
|
+
},
|
|
164
|
+
SDL_CreateShapedWindow: {
|
|
165
|
+
args: ["cstring", "int", "int", "int", "int", "u32"],
|
|
166
|
+
returns: "pointer",
|
|
167
|
+
},
|
|
168
|
+
SDL_SetWindowShape: {
|
|
169
|
+
args: ["pointer", "pointer", "pointer"],
|
|
170
|
+
returns: "int",
|
|
171
|
+
},
|
|
172
|
+
SDL_SetWindowIcon: {
|
|
173
|
+
args: ["pointer", "pointer"],
|
|
174
|
+
returns: "void",
|
|
175
|
+
},
|
|
176
|
+
SDL_RaiseWindow: {
|
|
177
|
+
args: ["pointer"],
|
|
178
|
+
returns: "void",
|
|
179
|
+
},
|
|
180
|
+
SDL_RenderCopyEx: {
|
|
181
|
+
args: [
|
|
182
|
+
"pointer",
|
|
183
|
+
"pointer",
|
|
184
|
+
"pointer",
|
|
185
|
+
"pointer",
|
|
186
|
+
"double",
|
|
187
|
+
"pointer",
|
|
188
|
+
"int",
|
|
189
|
+
],
|
|
190
|
+
returns: "int",
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
/** @internal */
|
|
195
|
+
export const libimage = dlopen(libImageImport.default, {
|
|
196
|
+
IMG_Init: {
|
|
197
|
+
args: ["int"],
|
|
198
|
+
returns: "int",
|
|
199
|
+
},
|
|
200
|
+
IMG_Load: {
|
|
201
|
+
args: ["cstring"],
|
|
202
|
+
returns: "pointer",
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
/** @internal */
|
|
207
|
+
export const libttf = dlopen(libTTFImport.default, {
|
|
208
|
+
TTF_Init: {
|
|
209
|
+
returns: "int",
|
|
210
|
+
},
|
|
211
|
+
TTF_OpenFont: {
|
|
212
|
+
args: ["cstring", "int"],
|
|
213
|
+
returns: "pointer",
|
|
214
|
+
},
|
|
215
|
+
TTF_RenderText_Solid: {
|
|
216
|
+
args: ["pointer", "cstring", "u32"],
|
|
217
|
+
returns: "pointer",
|
|
218
|
+
},
|
|
219
|
+
TTF_SizeText: {
|
|
220
|
+
args: ["pointer", "cstring", "pointer", "pointer"],
|
|
221
|
+
returns: "int",
|
|
222
|
+
},
|
|
223
|
+
TTF_Quit: {
|
|
224
|
+
returns: "void",
|
|
225
|
+
},
|
|
226
|
+
TTF_CloseFont: {
|
|
227
|
+
args: ["pointer"],
|
|
228
|
+
returns: "void",
|
|
229
|
+
},
|
|
230
|
+
});
|
package/src/global.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { type Pointer } from 'bun:ffi';
|
|
2
|
-
|
|
3
|
-
class Global {
|
|
4
|
-
|
|
5
|
-
static ptrWindow : Pointer;
|
|
6
|
-
static ptrRenderer : Pointer;
|
|
7
|
-
static ptrFont : Pointer;
|
|
8
|
-
}
|
|
9
|
-
|
|
1
|
+
import { type Pointer } from 'bun:ffi';
|
|
2
|
+
|
|
3
|
+
class Global {
|
|
4
|
+
|
|
5
|
+
static ptrWindow : Pointer;
|
|
6
|
+
static ptrRenderer : Pointer;
|
|
7
|
+
static ptrFont : Pointer;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** @internal */
|
|
10
11
|
export default Global;
|