Re: PureBasic 6.30 beta 2 is ready !
Posted: Mon Sep 15, 2025 1:40 pm
Did you run it as root ? You need admin right on Linux or you need an hid.rules file as described here: https://github.com/libusb/hidapi?tab=readme-ov-file
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
;------------------------------------------------------------------------------
; PureBasic 6.30 + backend C
;------------------------------------------------------------------------------
EnableExplicit
CompilerIf #PB_Compiler_Backend = #PB_Backend_C
;ldconfig -p | grep mongoc
ImportC "-lmongoc-1.0 -lbson-1.0" : EndImport
CompilerElse
CompilerError "Use #PB_Backend_C"
CompilerEndIf
;------------------------------------------------------------------------------
; Header C
;------------------------------------------------------------------------------
HeaderSection
#include <mongoc/mongoc.h>
EndHeaderSection
;------------------------------------------------------------------------------
; Prototypes
;------------------------------------------------------------------------------
PrototypeC mongoc_init_proto()
PrototypeC mongoc_cleanup_proto()
PrototypeC.i mongoc_client_new_proto(uri.p-ascii)
PrototypeC mongoc_client_destroy_proto(client.i)
PrototypeC.i mongoc_client_get_database_proto(client.i, name.p-ascii)
PrototypeC mongoc_database_destroy_proto(db.i)
Global mongoc_init.mongoc_init_proto
Global mongoc_cleanup.mongoc_cleanup_proto
Global mongoc_client_new.mongoc_client_new_proto
Global mongoc_client_destroy.mongoc_client_destroy_proto
Global mongoc_client_get_database.mongoc_client_get_database_proto
Global mongoc_database_destroy.mongoc_database_destroy_proto
!g_mongoc_init = &mongoc_init;
!g_mongoc_cleanup = &mongoc_cleanup;
!g_mongoc_client_new = &mongoc_client_new;
!g_mongoc_client_destroy = &mongoc_client_destroy;
!g_mongoc_client_get_database = &mongoc_client_get_database;
!g_mongoc_database_destroy = &mongoc_database_destroy;
;------------------------------------------------------------------------------
Procedure Main()
Protected client.i=0, db.i=0
Protected uri$="", dbname$=""
uri$ = "mongodb://localhost/"
dbname$ = "test"
OpenConsole()
PrintN( "Init driver...: mongodb://localhost/")
mongoc_init()
PrintN( "create client...")
client = mongoc_client_new(uri$)
If client = 0
PrintN( "ERROR: not create client")
ProcedureReturn
EndIf
PrintN( "Open database '" + dbname$ + "'...")
db = mongoc_client_get_database(client, dbname$)
If db = 0
PrintN( "ERROR: not open database")
ProcedureReturn
EndIf
PrintN( "Database open with success.")
mongoc_database_destroy(db)
mongoc_client_destroy(client)
PrintN( "Finish driver...")
mongoc_cleanup()
PrintN( "End.")
EndProcedure
If #PB_Compiler_IsMainFile
Main()
EndIf
On Linux, either the hidraw or the libusb back-end can be used. There are tradeoffs, and the functionality supported is slightly different. Both are built by default. It is up to the application linking to hidapi to choose the backend at link time by linking to either libhidapi-libusb or libhidapi-hidraw.
Code: Select all
- Added: New ScreenGadget library to create easily UI on a game screen (for 2D and 3D)