Author Topic: Spriggsy's API Collection  (Read 7291 times)

0 Members and 1 Guest are viewing this topic.

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #60 on: November 01, 2020, 05:50:00 PM »
Updated 11/01/2020 at 5:49 PM

Updated pipecom library code with WinAPI calls to simulate popen without a console window appearing.
If you're API and you know it clap your hands
My GitHub

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #61 on: November 03, 2020, 04:17:30 PM »
Updated 04:17 PM on 11/03/2020

Fixed bug in pipecom which caused duplication of data between calls in Windows due to the buffer not being cleared.
If you're API and you know it clap your hands
My GitHub

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #62 on: November 05, 2020, 11:17:12 AM »
Updated 11:15 AM on 11/05/2020

Updated pipecom library and added CryptBinaryToString and CryptStringToBinary from Crypt32 WinAPI DLL. The code is found in "Base64 Multiplatform.bas". The code also contains usage for the built-in base64 command for Mac and Linux.

See here for a dedicated post on the library: https://www.qb64.org/forum/index.php?topic=3214.0
« Last Edit: November 05, 2020, 11:27:13 AM by SpriggsySpriggs »
If you're API and you know it clap your hands
My GitHub

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #63 on: November 17, 2020, 06:20:31 PM »
Updated 06:17 PM on 11/17/2020

Added a huge FTP library using WinAPI's Wininet DLL. Took me several days to make it this complete. Probably one of my most complex and certainly my largest library so far. This library has functions for downloading, uploading, directory listing, changing directory, deleting files, deleting directories, and making directories. It's a big one and one that will be updated as time goes on. Since this one uses functions from a previous FTP example in my 7-zip folder I have removed the previous example and replaced it with this. The file is named "FTP WinAPI.bas". Below are some screenshots showing an example FTP listing generated with the library:

 
 
« Last Edit: November 17, 2020, 06:25:38 PM by SpriggsySpriggs »
If you're API and you know it clap your hands
My GitHub

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #64 on: November 18, 2020, 02:50:27 AM »
Updated the "dir" style listing as well as added a new function. Both accept a file extension filter.

Screenshot of the filtered listing:

 
If you're API and you know it clap your hands
My GitHub

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #65 on: November 28, 2020, 08:24:10 AM »
08:23 AM 11/28/2020

Updated the XInput library to show pressure on the triggers of the gamepad.

See video for demonstration:

« Last Edit: November 28, 2020, 08:57:58 AM by SpriggsySpriggs »
If you're API and you know it clap your hands
My GitHub

Online FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 3044
  • Let it go, this too shall pass.
    • QB64.org
Re: Spriggsy's API Collection
« Reply #66 on: November 28, 2020, 08:25:34 AM »
❤️

Online SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3492
    • Steve’s QB64 Archive Forum
Re: Spriggsy's API Collection
« Reply #67 on: November 28, 2020, 10:16:12 AM »
Is there some requirement for XINPUT to work properly for us?  I ran the test code in your API bundle last night, and the program would never detect my joystick at all.  I even went in and swapped it to check for all 4 of the available channels (0 to 3), wondering if perhaps mine was on something other than the default 0, but it was all no good.  _DEVICES found and identified the gamepad properly, but the XINPUT application didn't.

Does this require DirectX9?  DirectX11?  Some other version?  As this PC is new, I don't think it has anything except DirectX12 installed on it.  Are older packages required for this to work properly?

Edit:  Reading on the XInput information gives this info:

Quote
XInput Limitations
XInput only supports "next generation" controllers. This limits it basically to controllers for the Xbox 360 that also have Windows drivers. Legacy Windows controllers, joysticks and generalized haptic feedback devices are not supported.

I'm guessing that my poor old gamepad is probably not one of the "next generation" models.  Looks like testing this code will have to wait as well, for me to get a new controller. 

« Last Edit: November 28, 2020, 10:33:38 AM by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #68 on: November 28, 2020, 01:13:30 PM »
@SMcNeill
Yeah, I wasn't sure what sort of drivers your controller used so I couldn't be sure if it would work or not. It would be neat if your new one did!
If you're API and you know it clap your hands
My GitHub

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #69 on: November 29, 2020, 01:05:57 AM »
1:01 AM 11/29/2020

Updated UUID Creation library by making it cleaner; e.g., getting rid of unnecessary CONST values, breaking some repetitive actions into new functions and subs, and adding the ability to compare two GUID/UUID values to check if they are greater, less, or equal using UuidCompare. If UUID1 is greater than UUID2 then the return is -1. 0 for equal and 1 for UUID1 less than UUID2.
« Last Edit: November 29, 2020, 01:44:07 AM by SpriggsySpriggs »
If you're API and you know it clap your hands
My GitHub

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #70 on: November 29, 2020, 02:07:01 AM »
2:05 AM 11/29/2020

Fixed bug in the FTP library that would cause print statements after FTPUpload and FTPDownload to not appear because of the usage of _DISPLAY in the download loop. _AUTODISPLAY has been added after the loop execution so that printing can resume normally.
If you're API and you know it clap your hands
My GitHub

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #71 on: December 07, 2020, 03:19:21 PM »
Updated 03:15 PM on 12/07/2020

Added hidapi; a library that is a wrapper for WinAPI HID functions. The source code included is a test program designed to interface with a Nintendo Switch Pro Controller over Bluetooth HID using an InForm-based application that is similar to the XInput tester. The DLL included is for 64 bit only (see original post for clarification) but anyone can retrieve the 32 bit version themselves by following this link (https://github.com/libusb/hidapi/releases) and downloading the hidapi-win.zip file.

A video demonstrating the test program:
« Last Edit: December 08, 2020, 09:29:47 AM by SpriggsySpriggs »
If you're API and you know it clap your hands
My GitHub

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #72 on: December 18, 2020, 10:07:55 AM »
Fixed bug in my Base 64 code that Steve (@SMcNeill) pointed out. A trailing null character was left behind due to my habit of null-terminated strings in WinAPI functions.

 
If you're API and you know it clap your hands
My GitHub

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #73 on: December 20, 2020, 09:19:33 PM »
Updated 12/20/2020 @ 9:17 PM

Added mappedvar, a header file I wrote (Windows, Mac, and Linux), which allows you to create and assign values to named variables on the fly rather than creating the variables beforehand in the source. This allows you to have generic variables (strings only. Can be modified quite easily for other types) and works quite nicely. It's a small file but I believe it will lead to much power in future QB64 programs. Enjoy having generics!

Updated 12/20/2020 @ 9:48 PM

Added some trim functions to the library in order to verify that the name for the variable would not begin, end, or solely contain, whitespace.
« Last Edit: December 21, 2020, 08:19:43 AM by SpriggsySpriggs »
If you're API and you know it clap your hands
My GitHub

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1100
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #74 on: December 21, 2020, 01:22:46 PM »
Updated 12/21/2020 @ 1:19 PM

Added two new SUBs to my mappedvar header library: freemappedvar and freemap. freemappedvar erases the referenced mapped variable from the map. freemap erases the map entirely, freeing that portion of memory.

Updated 12/21/2020 @ 4:33 PM

Fixed problem of freemappedvar not actually being freed from memory due to wrong function being used. The code is now fixed and updated in the zip.

Code: QB64: [Select]
  1.  
  2. $IF WIN THEN
  3.     DECLARE LIBRARY ".\mappedvar"
  4.     $ELSE
  5.     DECLARE LIBRARY "./mappedvar"
  6.     $END IF
  7.     FUNCTION mapvar% (name AS STRING, value AS STRING)
  8.     FUNCTION getmappedvalue$ (name AS STRING)
  9.     SUB freemappedvar (name AS STRING)
  10.     SUB freemap ()
  11.     FUNCTION mapsize%& ()
  12.  
  13.  
  14. a = mapvar("test1", "this is a test")
  15. a = mapvar("test2", "this is also a test")
  16. PRINT getmappedvalue("test1"), getmappedvalue("test2")
  17. PRINT "Map is currently"; mapsize; "elements"
  18. freemappedvar "test1"
  19. PRINT "Map is currently"; mapsize; "elements"
  20. a = mapvar("test3", "not sure how big it is now")
  21. PRINT "Map is currently"; mapsize; "elements"
  22. freemap
  23. PRINT "Map is currently"; mapsize; "elements"
« Last Edit: December 21, 2020, 04:34:21 PM by SpriggsySpriggs »
If you're API and you know it clap your hands
My GitHub