fyradevice 1.0.0
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.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +12 -0
- data/docs/API.md +16 -0
- data/docs/LICENSE.nlohmann-json +21 -0
- data/lib/fyradevice.rb +46 -0
- data/native/FyraDeviceJsonSDK.dll +0 -0
- metadata +68 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 343cf163eeda10f7c2491097061c2243a00e7f8f1f0b99d4de7d5a0c2019b30e
|
|
4
|
+
data.tar.gz: 903523d7e0863de6cf0bd25d356374f15991ef0f48bd30df0e168a6f2b930b8e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a1b6f0e9f97ac1b0d1b6c07563de875ea842633ab810487349837c23a68b4f5eceb2f66e56f7d5003ff5e54d8acce51433f1290755da98855016ddd24e1bb96b
|
|
7
|
+
data.tar.gz: 8823e8a9ec8dd2031c1bd9bb0b59d0cb3a3f6e23921f036111215da5177c9e9d4d5cb5b16fa843d666a2172d7c71505ed654c1502b8cb9eb950c3f530fba01f8
|
data/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TitanCSA
|
|
4
|
+
|
|
5
|
+
This license applies to the user-mode source code, examples, build scripts,
|
|
6
|
+
and documentation in this repository.
|
|
7
|
+
It does not apply to the prebuilt kernel
|
|
8
|
+
driver, driver catalogs, or INF files under InstallerUI/Package; those files are
|
|
9
|
+
covered by licenses/BINARY-LICENSE.txt. Third-party names and projects retain their own
|
|
10
|
+
licenses and trademarks.
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# FyraDevice Ruby SDK
|
|
2
|
+
|
|
3
|
+
`gem install fyradevice`
|
|
4
|
+
|
|
5
|
+
Windows x64 Ruby3.1+.
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
require "fyradevice"
|
|
9
|
+
FyraDeviceSDK::Client.open { |client| p client.call("status") }
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
[API and operation schema](docs/API.md). Matching driver installed separately.
|
data/docs/API.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Device operations
|
|
2
|
+
|
|
3
|
+
All operations take an argument object; absent arguments mean `{}`.
|
|
4
|
+
|
|
5
|
+
- `check` and `connect`: `{speed:2,input_depth:32,delegate_controls:false,descriptors:[{kind:1,index:0,language:0,interface_number:0,data:[...]}],rules:[{setup:[8 bytes],mask:[8 bytes],action:1,data:[]}]}`. Exact descriptors define USB identity; check validates offline. Connect returns opaque decimal `handle`, actual decimal `device_id`, and token.
|
|
6
|
+
- `status`: returns capabilities, licensing and devices/counters. All uint64 values use decimal strings.
|
|
7
|
+
- `send`: `{handle,endpoint:129,data:[0,1,255]}` uses the explicit native endpoint overload.
|
|
8
|
+
- `disconnect`: `{handle}`. Close also disconnects owned devices.
|
|
9
|
+
- `receive`: `{timeout:0}`; bounded 0..100 ms per call so close cannot wait indefinitely. Poll from a worker if necessary. Returns kind, endpoint, setup, data, IDs and timed_out. Control outputs include opaque reply_handle.
|
|
10
|
+
- `reply`: `{reply_handle,data:[],stall:false}`. Failed replies may be retried; successful handles become stale. Maximum 4096 outstanding control requests.
|
|
11
|
+
|
|
12
|
+
JSON requests are bounded to 1 MiB, byte arrays to4096, descriptors64, rules32, devices16. Original SDK applies additional semantic validation. Unknown/stale/foreign handles fail. Operations are serialized; concurrent operations return busy. Input capture/driver operations are performed only on explicit calls. Production tests only open/close and reject an invalid config offline. Synthetic tests cover the rest without real devices.
|
|
13
|
+
|
|
14
|
+
## Language client
|
|
15
|
+
|
|
16
|
+
The client calls the native SDK directly. Use the call method with an operation name and argument object. Receive is synchronous and bounded to100ms; use an application worker for responsive UI/event loops. Explicitly close the client after use. 64-bit identifiers and counters are decimal strings. Native errors expose their Windows code. Matching driver and licensing are separate requirements.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013-2025 Niels Lohmann
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/lib/fyradevice.rb
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'fiddle'
|
|
3
|
+
require 'thread'
|
|
4
|
+
module FyraDeviceSDK
|
|
5
|
+
class NativeError < StandardError
|
|
6
|
+
attr_reader :code
|
|
7
|
+
def initialize(code,message);@code=code;super(message);end
|
|
8
|
+
end
|
|
9
|
+
class Client
|
|
10
|
+
def self.open(library_path: nil)
|
|
11
|
+
client=new(library_path: library_path)
|
|
12
|
+
return client unless block_given?
|
|
13
|
+
begin;yield client;ensure;client.close;end
|
|
14
|
+
end
|
|
15
|
+
def initialize(library_path: nil)
|
|
16
|
+
raise 'Windows x64 required' unless Fiddle::SIZEOF_VOIDP==8 && RUBY_PLATFORM.match?(/mingw|mswin/)
|
|
17
|
+
@library=Fiddle::Handle.new(library_path || ENV['FYRADEVICE_SDK_NATIVE_PATH'] || File.expand_path('../native/FyraDeviceJsonSDK.dll',__dir__))
|
|
18
|
+
@mutex=Mutex.new
|
|
19
|
+
@open=Fiddle::Function.new(@library['fyradevice_json_open'],[Fiddle::TYPE_VOIDP],Fiddle::TYPE_INT)
|
|
20
|
+
@close=Fiddle::Function.new(@library['fyradevice_json_close'],[Fiddle::TYPE_LONG_LONG],Fiddle::TYPE_INT)
|
|
21
|
+
@call=Fiddle::Function.new(@library['fyradevice_json_call'],[Fiddle::TYPE_LONG_LONG,Fiddle::TYPE_VOIDP,Fiddle::TYPE_INT],Fiddle::TYPE_VOIDP)
|
|
22
|
+
@free=Fiddle::Function.new(@library['fyradevice_json_free'],[Fiddle::TYPE_VOIDP],Fiddle::TYPE_VOID)
|
|
23
|
+
out=Fiddle::Pointer.malloc(8,Fiddle::RUBY_FREE);out[0,8]=[0].pack('Q<');code=@open.call(out);raise NativeError.new(code,'Cannot open SDK') if code!=0
|
|
24
|
+
@session=out[0,8].unpack1('Q<')
|
|
25
|
+
end
|
|
26
|
+
def call(operation,arguments={})
|
|
27
|
+
payload=JSON.generate({operation:operation,arguments:arguments}).encode('UTF-8')
|
|
28
|
+
raise ArgumentError,'Request exceeds 1 MiB' if payload.bytesize>1024*1024
|
|
29
|
+
@mutex.synchronize do
|
|
30
|
+
raise 'SDK is closed' if @session==0
|
|
31
|
+
pointer=@call.call(@session,payload,payload.bytesize);raise NoMemoryError,'Native response allocation failed' if pointer.null?
|
|
32
|
+
begin;response=JSON.parse(pointer.to_s);ensure;@free.call(pointer);end
|
|
33
|
+
raise NativeError.new(response['code'],response['message']) unless response['ok']
|
|
34
|
+
response['result']
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
def close
|
|
38
|
+
@mutex.synchronize do
|
|
39
|
+
if @session!=0
|
|
40
|
+
code=@close.call(@session);raise NativeError.new(code,'Native close failed') if code!=0
|
|
41
|
+
@session=0
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: fyradevice
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- TitanCSA
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: fiddle
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '1.1'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '2'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '1.1'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '2'
|
|
32
|
+
description: Product native SDK operations through a UTF-8 JSON C ABI; driver installed
|
|
33
|
+
separately.
|
|
34
|
+
executables: []
|
|
35
|
+
extensions: []
|
|
36
|
+
extra_rdoc_files: []
|
|
37
|
+
files:
|
|
38
|
+
- LICENSE
|
|
39
|
+
- README.md
|
|
40
|
+
- docs/API.md
|
|
41
|
+
- docs/LICENSE.nlohmann-json
|
|
42
|
+
- lib/fyradevice.rb
|
|
43
|
+
- native/FyraDeviceJsonSDK.dll
|
|
44
|
+
homepage: https://github.com/TitanCSA/FyraDevice-SDK
|
|
45
|
+
licenses:
|
|
46
|
+
- MIT
|
|
47
|
+
metadata:
|
|
48
|
+
source_code_uri: https://github.com/TitanCSA/FyraDevice-SDK
|
|
49
|
+
documentation_uri: https://github.com/TitanCSA/FyraDevice-SDK/tree/main/FyraDevice-Ruby-rubygems/docs
|
|
50
|
+
allowed_push_host: https://rubygems.org
|
|
51
|
+
rdoc_options: []
|
|
52
|
+
require_paths:
|
|
53
|
+
- lib
|
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - ">="
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '3.1'
|
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '0'
|
|
64
|
+
requirements: []
|
|
65
|
+
rubygems_version: 4.0.20
|
|
66
|
+
specification_version: 4
|
|
67
|
+
summary: Windows x64 FyraDevice direct SDK
|
|
68
|
+
test_files: []
|