-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
EuWin2.ew
470 lines (266 loc) · 14 KB
/
EuWin2.ew
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
183
184
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
without warning
without type_check
include std/dll.e
include std/machine.e
include sfFlags.e
--Context functions
atom win = open_dll("csfml-window-2.dll")
if win = -1 then
puts(1,"Failed to open csfml-window-2.dll!\n")
abort(0)
end if
--Context functions
public constant xsfContext_create = define_c_func(win,"+sfContext_create",{},C_POINTER),
xsfContext_destroy = define_c_proc(win,"+sfContext_destroy",{C_POINTER}),
xsfContext_setActive = define_c_proc(win,"+sfContext_setActive",{C_POINTER,C_BOOL}),
xsfContext_getSettings = define_c_func(win,"+sfContext_getSettings",{C_POINTER},C_UINT),
xsfContext_getActiveContextId = define_c_func(win,"+sfContext_getActiveContextId",{},C_UINT)
public function sfContext_create()
return c_func(xsfContext_create,{})
end function
public procedure sfContext_destroy(atom context)
c_proc(xsfContext_destroy,{context})
end procedure
public procedure sfContext_setActive(atom context,integer active)
c_proc(xsfContext_setActive,{context,active})
end procedure
public function sfContext_getSettings(atom ctx)
return c_func(xsfContext_getSettings,{ctx})
end function
public function sfContext_getActiveContextId()
return c_func(xsfContext_getActiveContextId,{})
end function
--Joystick functions
public constant xsfJoystick_isConnected = define_c_func(win,"+sfJoystick_isConnected",{C_UINT},C_BOOL),
xsfJoystick_getButtonCount = define_c_func(win,"+sfJoystick_getButtonCount",{C_UINT},C_UINT),
xsfJoystick_hasAxis = define_c_func(win,"+sfJoystick_hasAxis",{C_UINT,C_POINTER},C_BOOL),
xsfJoystick_isButtonPressed = define_c_func(win,"+sfJoystick_isButtonPressed",{C_UINT,C_UINT},C_BOOL),
xsfJoystick_getAxisPosition = define_c_func(win,"+sfJoystick_getAxisPosition",{C_UINT,C_POINTER},C_FLOAT),
xsfJoystick_getIdentification = define_c_func(win,"+sfJoystick_getIdentification",{C_UINT},C_POINTER),
xsfJoystick_update = define_c_proc(win,"+sfJoystick_update",{})
public function sfJoystick_isConnected(atom joy)
return c_func(xsfJoystick_isConnected,{joy})
end function
public function sfJoystick_getButtonCount(atom joy)
return c_func(xsfJoystick_getButtonCount,{joy})
end function
public function sfJoystick_hasAxis(atom joy,atom axis)
return c_func(xsfJoystick_hasAxis,{joy,axis})
end function
public function sfJoystick_isButtonPressed(atom joy,atom btn)
return c_func(xsfJoystick_isButtonPressed,{joy,btn})
end function
public function sfJoystick_getAxisPosition(atom joy,atom axis)
return c_func(xsfJoystick_getAxisPosition,{joy,axis})
end function
public function sfJoystick_getIdentification(atom joy)
return c_func(xsfJoystick_getIdentification,{joy})
end function
public procedure sfJoystick_update()
c_proc(xsfJoystick_update,{})
end procedure
--Keyboard function
public constant xsfKeyboard_isKeyPressed = define_c_func(win,"+sfKeyboard_isKeyPressed",{C_POINTER},C_BOOL),
xsfKeyboard_setVirtualKeyboardVisible = define_c_proc(win,"+sfKeyboard_setVirtualKeyboardVisible",{C_BOOL})
public function sfKeyboard_isKeyPressed(sfKeyCode key)
return c_func(xsfKeyboard_isKeyPressed,{key})
end function
public procedure sfKeyboard_setVirtualKeyboardVisible(atom vis)
c_proc(xsfKeyboard_setVirtualKeyboardVisible,{vis})
end procedure
--Mouse functions
public constant xsfMouse_isButtonPressed = define_c_func(win,"+sfMouse_isButtonPressed",{C_POINTER},C_BOOL),
xsfMouse_getPosition = define_c_func(win,"+sfMouse_getPosition",{C_POINTER},C_INT),
xsfMouse_setPosition = define_c_proc(win,"+sfMouse_setPosition",{C_INT,C_INT,C_POINTER})
public function sfMouse_isButtonPressed(atom btn)
return c_func(xsfMouse_isButtonPressed,{btn})
end function
public function sfMouse_getPosition(atom relativeTo)
return c_func(xsfMouse_getPosition,{relativeTo})
end function
public procedure sfMouse_setPosition(integer x,integer y,atom relativeTo)
c_proc(xsfMouse_setPosition,{x,y,relativeTo})
end procedure
--Sensor functions
public constant xsfSensor_isAvailable = define_c_func(win,"+sfSensor_isAvailable",{C_POINTER},C_BOOL),
xsfSensor_setEnabled = define_c_proc(win,"+sfSensor_setEnabled",{C_POINTER,C_BOOL}),
xsfSensor_getValue = define_c_func(win,"+sfSensor_getValue",{C_POINTER},C_FLOAT)
public function sfSensor_isAvailable(atom sensor)
return c_func(xsfSensor_isAvailable,{sensor})
end function
public procedure sfSensor_setEnabled(atom sensor,integer enabled)
c_proc(xsfSensor_setEnabled,{sensor,enabled})
end procedure
public function sfSensor_getValue(atom sensor)
return c_func(xsfSensor_getValue,{sensor})
end function
--Touch functions
public constant xsfTouch_isDown = define_c_func(win,"+sfTouch_isDown",{C_UINT},C_BOOL),
xsfTouch_getPosition = define_c_func(win,"+sfTouch_getPosition",{C_UINT,C_POINTER},C_INT)
public function sfTouch_isDown(atom finger)
return c_func(xsfTouch_isDown,{finger})
end function
public function sfTouch_getPosition(atom finger,atom relativeTo)
return c_func(xsfTouch_getPosition,{finger,relativeTo})
end function
--Video mode functions
public constant xsfVideoMode_getDesktopMode = define_c_func(win,"+sfVideoMode_getDesktopMode",{},C_POINTER),
xsfVideoMode_getFullscreenModes = define_c_func(win,"+sfVideoMode_getFullscreenModes",{C_POINTER},C_POINTER),
xsfVideoMode_isValid = define_c_func(win,"+sfVideoMode_isValid",{C_INT,C_INT,C_INT},C_BOOL)
public function sfVideoMode_getDesktopMode()
return c_func(xsfVideoMode_getDesktopMode,{})
end function
public function sfVideoMode_getFullscreenModes(atom count)
return c_func(xsfVideoMode_getFullscreenModes,{count})
end function
public function sfVideoMode_isValid(integer w,integer h,integer bpp)
return c_func(xsfVideoMode_isValid,{w,h,bpp})
end function
--Window functions
public constant xsfWindow_create = define_c_func(win,"+sfWindow_create",{C_INT,C_INT,C_INT,C_POINTER,C_UINT,C_POINTER},C_POINTER),
xsfWindow_createUnicode = define_c_func(win,"+sfWindow_createUnicode",{C_INT,C_INT,C_INT,C_POINTER,C_UINT,C_POINTER},C_POINTER),
xsfWindow_createFromHandle = define_c_func(win,"+sfWindow_createFromHandle",{C_POINTER,C_POINTER},C_POINTER),
xsfWindow_destroy = define_c_proc(win,"+sfWindow_destroy",{C_POINTER}),
xsfWindow_close = define_c_proc(win,"+sfWindow_close",{C_POINTER}),
xsfWindow_isOpen = define_c_func(win,"+sfWindow_isOpen",{C_POINTER},C_BOOL),
xsfWindow_getSettings = define_c_func(win,"+sfWindow_getSettings",{C_POINTER},C_POINTER),
xsfWindow_pollEvent = define_c_func(win,"+sfWindow_pollEvent",{C_POINTER,C_POINTER},C_BOOL),
xsfWindow_waitEvent = define_c_func(win,"+sfWindow_waitEvent",{C_POINTER,C_POINTER},C_BOOL),
xsfWindow_getPosition = define_c_func(win,"+sfWindow_getPosition",{C_POINTER},C_INT),
xsfWindow_setPosition = define_c_proc(win,"+sfWindow_setPosition",{C_POINTER,C_INT,C_INT}),
xsfWindow_getSize = define_c_func(win,"+sfWindow_getSize",{C_POINTER},C_INT),
xsfWindow_setSize = define_c_proc(win,"+sfWindow_setSize",{C_POINTER,C_INT,C_INT}),
xsfWindow_setTitle = define_c_proc(win,"+sfWindow_setTitle",{C_POINTER,C_POINTER}),
xsfWindow_setUnicodeTitle = define_c_proc(win,"+sfWindow_setUnicodeTitle",{C_POINTER,C_POINTER}),
xsfWindow_setIcon = define_c_proc(win,"+sfWindow_setIcon",{C_POINTER,C_UINT,C_UINT,C_POINTER}),
xsfWindow_setVisible = define_c_proc(win,"+sfWindow_setVisible",{C_POINTER,C_BOOL}),
xsfWindow_setMouseCursorVisible = define_c_proc(win,"+sfWindow_setMouseCursorVisible",{C_POINTER,C_BOOL}),
xsfWindow_setVerticalSyncEnabled = define_c_proc(win,"+sfWindow_setVerticalSyncEnabled",{C_POINTER,C_BOOL}),
xsfWindow_setKeyRepeatEnabled = define_c_proc(win,"+sfWindow_setKeyRepeatEnabled",{C_POINTER,C_BOOL}),
xsfWindow_setActive = define_c_func(win,"+sfWindow_setActive",{C_POINTER,C_BOOL},C_BOOL),
xsfWindow_requestFocus = define_c_proc(win,"+sfWindow_requestFocus",{C_POINTER}),
xsfWindow_hasFocus = define_c_func(win,"+sfWindow_hasFocus",{C_POINTER},C_BOOL),
xsfWindow_display = define_c_proc(win,"+sfWindow_display",{C_POINTER}),
xsfWindow_setFramerateLimit = define_c_proc(win,"+sfWindow_setFramerateLimit",{C_POINTER,C_UINT}),
xsfWindow_setJoystickThreshold = define_c_proc(win,"+sfWindow_setJoystickThreshold",{C_POINTER,C_FLOAT}),
xsfWindow_getSystemHandle = define_c_func(win,"+sfWindow_getSystemHandle",{C_POINTER},C_POINTER)
public function sfWindow_create(integer w,integer h,integer bpp,sequence title,atom style,atom settings)
atom str = allocate_string(title)
atom ret = c_func(xsfWindow_create,{w,h,bpp,str,style,settings})
return ret
end function
public function sfWindow_createUnicode(integer w,integer h,integer bpp,sequence title,atom style,atom settings)
atom str = allocate_string(title)
atom ret = c_func(xsfWindow_createUnicode,{w,h,bpp,str,style,settings})
return ret
end function
public function sfWindow_createFromHandle(atom handle,atom settings)
return c_func(xsfWindow_createFromHandle,{handle,settings})
end function
public procedure sfWindow_destroy(atom window)
c_proc(xsfWindow_destroy,{window})
end procedure
public procedure sfWindow_close(atom window)
c_proc(xsfWindow_close,{window})
end procedure
public function sfWindow_isOpen(atom window)
return c_func(xsfWindow_isOpen,{window})
end function
public function sfWindow_getSettings(atom window)
return c_func(xsfWindow_getSettings,{window})
end function
public function sfWindow_pollEvent(atom window,atom event)
return c_func(xsfWindow_pollEvent,{window,event})
end function
public function sfWindow_waitEvent(atom window,atom event)
return c_func(xsfWindow_waitEvent,{window,event})
end function
public function sfWindow_getPosition(atom window)
return c_func(xsfWindow_getPosition,{window})
end function
public procedure sfWindow_setPosition(atom window,integer x,integer y)
c_proc(xsfWindow_setPosition,{window,x,y})
end procedure
public function sfWindow_getSize(atom window)
return c_func(xsfWindow_getSize,{window})
end function
public procedure sfWindow_setSize(atom window,integer x,integer y)
c_proc(xsfWindow_setSize,{window,x,y})
end procedure
public procedure sfWindow_setTitle(atom window,sequence title)
atom str = allocate_string(title)
c_proc(xsfWindow_setTitle,{window,str})
end procedure
public procedure sfWindow_setUnicodeTitle(atom window,sequence title)
atom str = allocate_string(title)
c_proc(xsfWindow_setUnicodeTitle,{window,str})
end procedure
public procedure sfWindow_setIcon(atom window,integer w,integer h,atom pixels)
c_proc(xsfWindow_setIcon,{window,w,h,pixels})
end procedure
public procedure sfWindow_setVisible(atom window,integer visible)
c_proc(xsfWindow_setVisible,{window,visible})
end procedure
public procedure sfWindow_setMouseCursorVisible(atom window,integer visible)
c_proc(xsfWindow_setMouseCursorVisible,{window,visible})
end procedure
public procedure sfWindow_setVerticalSyncEnabled(atom window,integer enabled)
c_proc(xsfWindow_setVerticalSyncEnabled,{window,enabled})
end procedure
public procedure sfWindow_setKeyRepeatEnabled(atom window,integer enabled)
c_proc(xsfWindow_setKeyRepeatEnabled,{window,enabled})
end procedure
public function sfWindow_setActive(atom window,integer active)
return c_func(xsfWindow_setActive,{window,active})
end function
public procedure sfWindow_requestFocus(atom window)
c_proc(xsfWindow_requestFocus,{window})
end procedure
public function sfWindow_hasFocus(atom window)
return c_func(xsfWindow_hasFocus,{window})
end function
public procedure sfWindow_display(atom window)
c_proc(xsfWindow_display,{window})
end procedure
public procedure sfWindow_setFramerateLimit(atom window,integer limit)
c_proc(xsfWindow_setFramerateLimit,{window,limit})
end procedure
public procedure sfWindow_setJoystickThreshold(atom window,atom threshold)
c_proc(xsfWindow_setJoystickThreshold,{window,threshold})
end procedure
public function sfWindow_getSystemHandle(atom window)
return c_func(xsfWindow_getSystemHandle,{window})
end function
--Cursor functions
public constant xsfCursor_createFromPixels = define_c_func(win,"+sfCursor_createFromPixels",{C_POINTER,C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT},C_POINTER),
xsfCursor_createFromSystem = define_c_func(win,"+sfCursor_createFromSystem",{C_POINTER},C_POINTER),
xsfCursor_destroy = define_c_proc(win,"+sfCursor_destroy",{C_POINTER})
public function sfCursor_createFromPixels(atom pix,atom x,atom y,atom x2,atom y2)
return c_func(xsfCursor_createFromPixels,{pix,x,y,x2,y2})
end function
public function sfCursor_createFromSystem(sfCursorType xtype)
return c_func(xsfCursor_createFromSystem,{xtype})
end function
public procedure sfCursor_destroy(atom cur)
c_proc(xsfCursor_destroy,{cur})
end procedure
--Clipboard Functions
public constant xsfClipboard_getString = define_c_func(win,"+sfClipboard_getString",{},C_POINTER),
xsfClipboard_getUnicodeString = define_c_func(win,"+sfClipboard_getUnicodeString",{},C_POINTER),
xsfClipboard_setString = define_c_proc(win,"+sfClipboard_setString",{C_POINTER}),
xsfClipboard_setUnicodeString = define_c_proc(win,"+sfClipboard_setUnicodeString",{C_POINTER})
public function sfClipboard_getString()
return c_func(xsfClipboard_getString,{})
end function
public function sfClipboard_getUnicodeString()
return c_func(xsfClipboard_getUnicodeString,{})
end function
public procedure sfClipboard_setString(sequence text)
atom str = allocate_string(text,1)
c_proc(xsfClipboard_setString,{str})
end procedure
public procedure sfClipboard_setUnicodeString(sequence text)
atom str = allocate_string(text,1)
c_proc(xsfClipboard_setUnicodeString,{str})
end procedure
121.52