-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathsteamworks_unix.go
560 lines (487 loc) · 16.7 KB
/
steamworks_unix.go
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
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2021 The go-steamworks Authors
//go:build !windows
package steamworks
import (
_ "embed"
"fmt"
"os"
"path/filepath"
"runtime"
"unsafe"
)
// #cgo LDFLAGS: -ldl
//
// #include <stdbool.h>
// #include <stdint.h>
// #include <stdlib.h>
// #include <dlfcn.h>
//
// static uintptr_t dlsym_(uintptr_t handle, const char* name) {
// return (uintptr_t)dlsym((void*)handle, name);
// }
//
// static const char* uintptrToChar(uintptr_t str) {
// return (const char*)str;
// }
//
// static uint8_t callFunc_Bool(uintptr_t f) {
// return ((bool (*)())(f))();
// }
//
// static uint8_t callFunc_Bool_Ptr(uintptr_t f, uintptr_t arg0) {
// return ((bool (*)(void*))(f))((void*)arg0);
// }
//
// static uint8_t callFunc_Bool_Ptr_Bool(uintptr_t f, uintptr_t arg0, uint8_t arg1) {
// return ((bool (*)(void*, bool))(f))((void*)arg0, (bool)arg1);
// }
//
// static uint8_t callFunc_Bool_Ptr_Int32(uintptr_t f, uintptr_t arg0, int32_t arg1) {
// return ((bool (*)(void*, int32_t))(f))((void*)arg0, arg1);
// }
//
// static uint8_t callFunc_Bool_Ptr_Int32_Int32_Int32_Int32_Int32(uintptr_t f, uintptr_t arg0, int32_t arg1, int32_t arg2, int32_t arg3, int32_t arg4, int32_t arg5) {
// return ((bool (*)(void*, int32_t, int32_t, int32_t, int32_t, int32_t))(f))((void*)arg0, arg1, arg2, arg3, arg4, arg5);
// }
//
// static uint8_t callFunc_Bool_Ptr_Ptr(uintptr_t f, uintptr_t arg0, uintptr_t arg1) {
// return ((bool (*)(void*, void*))(f))((void*)arg0, (void*)arg1);
// }
//
// static uint8_t callFunc_Bool_Ptr_Ptr_Ptr(uintptr_t f, uintptr_t arg0, uintptr_t arg1, uintptr_t arg2) {
// return ((bool (*)(void*, void*, void*))(f))((void*)arg0, (void*)arg1, (void*)arg2);
// }
//
// static uint8_t callFunc_Bool_Ptr_Ptr_Ptr_Int32(uintptr_t f, uintptr_t arg0, uintptr_t arg1, uintptr_t arg2, int32_t arg3) {
// return ((bool (*)(void*, void*, void*, int32_t))(f))((void*)arg0, (void*)arg1, (void*)arg2, arg3);
// }
//
// static uint8_t callFunc_Bool_Int32(uintptr_t f, uint32_t arg0) {
// return ((bool (*)(uint32_t))(f))(arg0);
// }
//
// static int32_t callFunc_Int32_Ptr(uintptr_t f, uintptr_t arg0) {
// return ((int32_t (*)(void*))(f))((void*)arg0);
// }
//
// static int32_t callFunc_Int32_Ptr_Int32_Ptr_Int32(uintptr_t f, uintptr_t arg0, int32_t arg1, uintptr_t arg2, int32_t arg3) {
// return ((int32_t (*)(void*, int32_t, void*, int32_t))(f))((void*)arg0, arg1, (void*)arg2, arg3);
// }
//
// static int32_t callFunc_Int32_Ptr_Int32_Ptr_Ptr_Ptr_Int32(uintptr_t f, uintptr_t arg0, int32_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, int32_t arg5) {
// return ((int32_t (*)(void*, int32_t, void*, void*, void*, int32_t))(f))((void*)arg0, arg1, (void*)arg2, (void*)arg3, (void*)arg4, arg5);
// }
//
// static int32_t callFunc_Int32_Ptr_Int64(uintptr_t f, uintptr_t arg0, int64_t arg1) {
// return ((int32_t (*)(void*, int64_t))(f))((void*)arg0, arg1);
// }
//
// static int32_t callFunc_Int32_Ptr_Ptr(uintptr_t f, uintptr_t arg0, uintptr_t arg1) {
// return ((int32_t (*)(void*, void*))(f))((void*)arg0, (void*)arg1);
// }
//
// static int32_t callFunc_Int32_Ptr_Ptr_Ptr_Int32(uintptr_t f, uintptr_t arg0, uintptr_t arg1, uintptr_t arg2, int32_t arg3) {
// return ((int32_t (*)(void*, void*, void*, int32_t))(f))((void*)arg0, (void*)arg1, (void*)arg2, arg3);
// }
//
// static int64_t callFunc_Int64_Ptr(uintptr_t f, uintptr_t arg0) {
// return ((int64_t (*)(void*))(f))((void*)arg0);
// }
//
// static uintptr_t callFunc_Ptr(uintptr_t f) {
// return (uintptr_t)((void* (*)())(f))();
// }
//
// static uintptr_t callFunc_Ptr_Ptr(uintptr_t f, uintptr_t arg0) {
// return (uintptr_t)((void* (*)(void*))(f))((void*)arg0);
// }
//
// static void callFunc_Void(uintptr_t f) {
// ((void (*)())(f))();
// }
//
// static void callFunc_Void_Ptr_Bool(uintptr_t f, uintptr_t arg0, uint8_t arg1) {
// ((void (*)(void*, bool))(f))((void*)arg0, (bool)arg1);
// }
import "C"
type lib struct {
lib C.uintptr_t
procs map[string]C.uintptr_t
}
type funcType int
const (
funcType_Bool funcType = iota
funcType_Bool_Ptr
funcType_Bool_Ptr_Bool
funcType_Bool_Ptr_Int32
funcType_Bool_Ptr_Int32_Int32_Int32_Int32_Int32
funcType_Bool_Ptr_Ptr
funcType_Bool_Ptr_Ptr_Ptr
funcType_Bool_Ptr_Ptr_Ptr_Int32
funcType_Bool_Int32
funcType_Int32_Int64
funcType_Int32_Ptr
funcType_Int32_Ptr_Int32_Ptr_Int32
funcType_Int32_Ptr_Int32_Ptr_Ptr_Ptr_Int32
funcType_Int32_Ptr_Int64
funcType_Int32_Ptr_Ptr
funcType_Int32_Ptr_Ptr_Ptr_Int32
funcType_Int64_Ptr
funcType_Ptr
funcType_Ptr_Ptr
funcType_Void
funcType_Void_Ptr_Bool
)
func (l *lib) call(ftype funcType, name string, args ...uintptr) (C.uint64_t, error) {
if l.procs == nil {
l.procs = map[string]C.uintptr_t{}
}
if _, ok := l.procs[name]; !ok {
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
l.procs[name] = C.dlsym_(l.lib, cname)
}
f := l.procs[name]
switch ftype {
case funcType_Bool:
return C.uint64_t(C.callFunc_Bool(f)), nil
case funcType_Bool_Ptr:
return C.uint64_t(C.callFunc_Bool_Ptr(f, C.uintptr_t(args[0]))), nil
case funcType_Bool_Ptr_Bool:
return C.uint64_t(C.callFunc_Bool_Ptr_Bool(f, C.uintptr_t(args[0]), C.uint8_t(args[1]))), nil
case funcType_Bool_Ptr_Int32:
return C.uint64_t(C.callFunc_Bool_Ptr_Int32(f, C.uintptr_t(args[0]), C.int32_t(args[1]))), nil
case funcType_Bool_Ptr_Int32_Int32_Int32_Int32_Int32:
return C.uint64_t(C.callFunc_Bool_Ptr_Int32_Int32_Int32_Int32_Int32(f, C.uintptr_t(args[0]), C.int32_t(args[1]), C.int32_t(args[2]), C.int32_t(args[3]), C.int32_t(args[4]), C.int32_t(args[5]))), nil
case funcType_Bool_Ptr_Ptr:
return C.uint64_t(C.callFunc_Bool_Ptr_Ptr(f, C.uintptr_t(args[0]), C.uintptr_t(args[1]))), nil
case funcType_Bool_Ptr_Ptr_Ptr:
return C.uint64_t(C.callFunc_Bool_Ptr_Ptr_Ptr(f, C.uintptr_t(args[0]), C.uintptr_t(args[1]), C.uintptr_t(args[2]))), nil
case funcType_Bool_Ptr_Ptr_Ptr_Int32:
return C.uint64_t(C.callFunc_Bool_Ptr_Ptr_Ptr_Int32(f, C.uintptr_t(args[0]), C.uintptr_t(args[1]), C.uintptr_t(args[2]), C.int32_t(args[3]))), nil
case funcType_Bool_Int32:
return C.uint64_t(C.callFunc_Bool_Int32(f, C.uint32_t(args[0]))), nil
case funcType_Int32_Ptr:
return C.uint64_t(C.callFunc_Int32_Ptr(f, C.uintptr_t(args[0]))), nil
case funcType_Int32_Ptr_Int32_Ptr_Int32:
return C.uint64_t(C.callFunc_Int32_Ptr_Int32_Ptr_Int32(f, C.uintptr_t(args[0]), C.int32_t(args[1]), C.uintptr_t(args[2]), C.int32_t(args[3]))), nil
case funcType_Int32_Ptr_Int32_Ptr_Ptr_Ptr_Int32:
return C.uint64_t(C.callFunc_Int32_Ptr_Int32_Ptr_Ptr_Ptr_Int32(f, C.uintptr_t(args[0]), C.int32_t(args[1]), C.uintptr_t(args[2]), C.uintptr_t(args[3]), C.uintptr_t(args[4]), C.int32_t(args[5]))), nil
case funcType_Int32_Ptr_Int64:
return C.uint64_t(C.callFunc_Int32_Ptr_Int64(f, C.uintptr_t(args[0]), C.int64_t(args[1]))), nil
case funcType_Int32_Ptr_Ptr:
return C.uint64_t(C.callFunc_Int32_Ptr_Ptr(f, C.uintptr_t(args[0]), C.uintptr_t(args[1]))), nil
case funcType_Int32_Ptr_Ptr_Ptr_Int32:
return C.uint64_t(C.callFunc_Int32_Ptr_Ptr_Ptr_Int32(f, C.uintptr_t(args[0]), C.uintptr_t(args[1]), C.uintptr_t(args[2]), C.int32_t(args[3]))), nil
case funcType_Int64_Ptr:
return C.uint64_t(C.callFunc_Int64_Ptr(f, C.uintptr_t(args[0]))), nil
case funcType_Ptr:
return C.uint64_t(C.callFunc_Ptr(f)), nil
case funcType_Ptr_Ptr:
return C.uint64_t(C.callFunc_Ptr_Ptr(f, C.uintptr_t(args[0]))), nil
case funcType_Void:
C.callFunc_Void(f)
return 0, nil
case funcType_Void_Ptr_Bool:
C.callFunc_Void_Ptr_Bool(f, C.uintptr_t(args[0]), C.uint8_t(args[1]))
return 0, nil
}
return 0, fmt.Errorf("steamworks: function %s not implemented", name)
}
func loadLib() (C.uintptr_t, error) {
dir, err := os.MkdirTemp("", "")
if err != nil {
return 0, err
}
ext := ".so"
if runtime.GOOS == "darwin" {
ext = ".dylib"
}
path := filepath.Join(dir, "libsteam_api"+ext)
if err := os.WriteFile(path, libSteamAPI, 0644); err != nil {
return 0, err
}
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))
lib := C.uintptr_t(uintptr(C.dlopen(cpath, C.RTLD_LAZY)))
if lib == 0 {
return 0, fmt.Errorf("steamworks: dlopen failed: %s", C.GoString(C.dlerror()))
}
return lib, nil
}
var theLib *lib
func init() {
l, err := loadLib()
if err != nil {
panic(err)
}
theLib = &lib{
lib: l,
}
}
func cBool(x bool) uintptr {
if x {
return 1
}
return 0
}
func RestartAppIfNecessary(appID uint32) bool {
v, err := theLib.call(funcType_Bool_Int32, flatAPI_RestartAppIfNecessary, uintptr(appID))
if err != nil {
panic(err)
}
return byte(v) != 0
}
func Init() error {
var msg steamErrMsg
v, err := theLib.call(funcType_Bool_Ptr, flatAPI_InitFlat, uintptr(unsafe.Pointer(&msg)))
if err != nil {
panic(err)
}
if ESteamAPIInitResult(v) != ESteamAPIInitResult_OK {
return fmt.Errorf("steamworks: InitFlat failed: %d, %s", ESteamAPIInitResult(v), msg.String())
}
return nil
}
func RunCallbacks() {
if _, err := theLib.call(funcType_Void, flatAPI_RunCallbacks); err != nil {
panic(err)
}
}
func SteamApps() ISteamApps {
v, err := theLib.call(funcType_Ptr, flatAPI_SteamApps)
if err != nil {
panic(err)
}
return steamApps(v)
}
type steamApps C.uintptr_t
func (s steamApps) BGetDLCDataByIndex(iDLC int) (appID AppId_t, available bool, pchName string, success bool) {
var name [4096]byte
v, err := theLib.call(funcType_Int32_Ptr_Int32_Ptr_Ptr_Ptr_Int32, flatAPI_ISteamApps_BGetDLCDataByIndex, uintptr(s), uintptr(iDLC), uintptr(unsafe.Pointer(&appID)), uintptr(unsafe.Pointer(&available)), uintptr(unsafe.Pointer(&name[0])), uintptr(len(name)))
if err != nil {
panic(err)
}
return appID, available, C.GoString((*C.char)(unsafe.Pointer(&name[0]))), byte(v) != 0
}
func (s steamApps) BIsDlcInstalled(appID AppId_t) bool {
v, err := theLib.call(funcType_Bool_Ptr_Int32, flatAPI_ISteamApps_BIsDlcInstalled, uintptr(s), uintptr(appID))
if err != nil {
panic(err)
}
return byte(v) != 0
}
func (s steamApps) GetAppInstallDir(appID AppId_t) string {
var path [4096]byte
v, err := theLib.call(funcType_Int32_Ptr_Int32_Ptr_Int32, flatAPI_ISteamApps_GetAppInstallDir, uintptr(s), uintptr(appID), uintptr(unsafe.Pointer(&path[0])), uintptr(len(path)))
if err != nil {
panic(err)
}
return string(path[:uint32(v)-1])
}
func (s steamApps) GetCurrentGameLanguage() string {
v, err := theLib.call(funcType_Ptr_Ptr, flatAPI_ISteamApps_GetCurrentGameLanguage, uintptr(s))
if err != nil {
panic(err)
}
return C.GoString(C.uintptrToChar(C.uintptr_t(v)))
}
func (s steamApps) GetDLCCount() int32 {
v, err := theLib.call(funcType_Int32_Ptr, flatAPI_ISteamApps_GetDLCCount, uintptr(s))
if err != nil {
panic(err)
}
return int32(v)
}
func SteamFriends() ISteamFriends {
v, err := theLib.call(funcType_Ptr, flagAPI_SteamFriends)
if err != nil {
panic(err)
}
return steamFriends(v)
}
type steamFriends C.uintptr_t
func (s steamFriends) GetPersonaName() string {
v, err := theLib.call(funcType_Ptr_Ptr, flatAPI_ISteamFriends_GetPersonaName, uintptr(s))
if err != nil {
panic(err)
}
return C.GoString(C.uintptrToChar(C.uintptr_t(v)))
}
func (s steamFriends) SetRichPresence(key, value string) bool {
ckey := C.CString(key)
defer C.free(unsafe.Pointer(ckey))
cvalue := C.CString(value)
defer C.free(unsafe.Pointer(cvalue))
v, err := theLib.call(funcType_Bool_Ptr_Ptr_Ptr, flatAPI_ISteamFriends_SetRichPresence, uintptr(s), uintptr(unsafe.Pointer(ckey)), uintptr(unsafe.Pointer(cvalue)))
if err != nil {
panic(err)
}
return byte(v) != 0
}
func SteamInput() ISteamInput {
v, err := theLib.call(funcType_Ptr, flatAPI_SteamInput)
if err != nil {
panic(err)
}
return steamInput(v)
}
type steamInput C.uintptr_t
func (s steamInput) GetConnectedControllers() []InputHandle_t {
var handles [_STEAM_INPUT_MAX_COUNT]InputHandle_t
v, err := theLib.call(funcType_Int32_Ptr_Ptr, flatAPI_ISteamInput_GetConnectedControllers, uintptr(s), uintptr(unsafe.Pointer(&handles[0])))
if err != nil {
panic(err)
}
return handles[:int(v)]
}
func (s steamInput) GetInputTypeForHandle(inputHandle InputHandle_t) ESteamInputType {
v, err := theLib.call(funcType_Int32_Ptr_Int64, flatAPI_ISteamInput_GetInputTypeForHandle, uintptr(s), uintptr(inputHandle))
if err != nil {
panic(err)
}
return ESteamInputType(v)
}
func (s steamInput) Init(bExplicitlyCallRunFrame bool) bool {
var callRunFrame uintptr
if bExplicitlyCallRunFrame {
callRunFrame = 1
}
v, err := theLib.call(funcType_Bool_Ptr_Bool, flatAPI_ISteamInput_Init, uintptr(s), callRunFrame)
if err != nil {
panic(err)
}
return byte(v) != 0
}
func (s steamInput) RunFrame() {
if _, err := theLib.call(funcType_Void_Ptr_Bool, flatAPI_ISteamInput_RunFrame, uintptr(s), 0); err != nil {
panic(err)
}
}
func SteamRemoteStorage() ISteamRemoteStorage {
v, err := theLib.call(funcType_Ptr, flatAPI_SteamRemoteStorage)
if err != nil {
panic(err)
}
return steamRemoteStorage(v)
}
type steamRemoteStorage C.uintptr_t
func (s steamRemoteStorage) FileWrite(file string, data []byte) bool {
cfile := C.CString(file)
defer C.free(unsafe.Pointer(cfile))
defer runtime.KeepAlive(data)
v, err := theLib.call(funcType_Bool_Ptr_Ptr_Ptr_Int32, flatAPI_ISteamRemoteStorage_FileWrite, uintptr(s), uintptr(unsafe.Pointer(cfile)), uintptr(unsafe.Pointer(&data[0])), uintptr(len(data)))
if err != nil {
panic(err)
}
return byte(v) != 0
}
func (s steamRemoteStorage) FileRead(file string, data []byte) int32 {
cfile := C.CString(file)
defer C.free(unsafe.Pointer(cfile))
defer runtime.KeepAlive(data)
v, err := theLib.call(funcType_Int32_Ptr_Ptr_Ptr_Int32, flatAPI_ISteamRemoteStorage_FileRead, uintptr(s), uintptr(unsafe.Pointer(cfile)), uintptr(unsafe.Pointer(&data[0])), uintptr(len(data)))
if err != nil {
panic(err)
}
return int32(v)
}
func (s steamRemoteStorage) FileDelete(file string) bool {
cfile := C.CString(file)
defer C.free(unsafe.Pointer(cfile))
v, err := theLib.call(funcType_Bool_Ptr_Ptr, flatAPI_ISteamRemoteStorage_FileDelete, uintptr(s), uintptr(unsafe.Pointer(cfile)))
if err != nil {
panic(err)
}
return byte(v) != 0
}
func (s steamRemoteStorage) GetFileSize(file string) int32 {
cfile := C.CString(file)
defer C.free(unsafe.Pointer(cfile))
v, err := theLib.call(funcType_Int32_Ptr, flatAPI_ISteamRemoteStorage_GetFileSize, uintptr(s), uintptr(unsafe.Pointer(cfile)))
if err != nil {
panic(err)
}
return int32(v)
}
func SteamUser() ISteamUser {
v, err := theLib.call(funcType_Ptr, flatAPI_SteamUser)
if err != nil {
panic(err)
}
return steamUser(v)
}
type steamUser C.uintptr_t
func (s steamUser) GetSteamID() CSteamID {
v, err := theLib.call(funcType_Int64_Ptr, flatAPI_ISteamUser_GetSteamID, uintptr(s))
if err != nil {
panic(err)
}
return CSteamID(v)
}
func SteamUserStats() ISteamUserStats {
v, err := theLib.call(funcType_Ptr, flatAPI_SteamUserStats)
if err != nil {
panic(err)
}
return steamUserStats(v)
}
type steamUserStats C.uintptr_t
func (s steamUserStats) GetAchievement(name string) (achieved, success bool) {
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
v, err := theLib.call(funcType_Bool_Ptr_Ptr_Ptr, flatAPI_ISteamUserStats_GetAchievement, uintptr(s), uintptr(unsafe.Pointer(cname)), uintptr(unsafe.Pointer(&achieved)))
if err != nil {
panic(err)
}
success = byte(v) != 0
return
}
func (s steamUserStats) SetAchievement(name string) bool {
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
v, err := theLib.call(funcType_Bool_Ptr_Ptr, flatAPI_ISteamUserStats_SetAchievement, uintptr(s), uintptr(unsafe.Pointer(cname)))
if err != nil {
panic(err)
}
return byte(v) != 0
}
func (s steamUserStats) ClearAchievement(name string) bool {
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
v, err := theLib.call(funcType_Bool_Ptr_Ptr, flatAPI_ISteamUserStats_ClearAchievement, uintptr(s), uintptr(unsafe.Pointer(cname)))
if err != nil {
panic(err)
}
return byte(v) != 0
}
func (s steamUserStats) StoreStats() bool {
v, err := theLib.call(funcType_Bool_Ptr, flatAPI_ISteamUserStats_StoreStats, uintptr(s))
if err != nil {
panic(err)
}
return byte(v) != 0
}
func SteamUtils() ISteamUtils {
v, err := theLib.call(funcType_Ptr, flatAPI_SteamUtils)
if err != nil {
panic(err)
}
return steamUtils(v)
}
type steamUtils C.uintptr_t
func (s steamUtils) IsSteamRunningOnSteamDeck() bool {
v, err := theLib.call(funcType_Bool_Ptr, flatAPI_ISteamUtils_IsSteamRunningOnSteamDeck, uintptr(s))
if err != nil {
panic(err)
}
return byte(v) != 0
}
func (s steamUtils) ShowFloatingGamepadTextInput(keyboardMode EFloatingGamepadTextInputMode, textFieldXPosition, textFieldYPosition, textFieldWidth, textFieldHeight int32) bool {
v, err := theLib.call(funcType_Bool_Ptr_Int32_Int32_Int32_Int32_Int32, flatAPI_ISteamUtils_ShowFloatingGamepadTextInput, uintptr(s), uintptr(keyboardMode), uintptr(textFieldXPosition), uintptr(textFieldYPosition), uintptr(textFieldWidth), uintptr(textFieldHeight))
if err != nil {
panic(err)
}
return byte(v) != 0
}