-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcec_private.clj
88 lines (67 loc) · 3.93 KB
/
cec_private.clj
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
(ns chromex.app.cec-private
"Private API for HDMI CEC functionality.
* available since Chrome 68"
(:refer-clojure :only [defmacro defn apply declare meta let partial])
(:require [chromex.wrapgen :refer [gen-wrap-helper]]
[chromex.callgen :refer [gen-call-helper gen-tap-all-events-call]]))
(declare api-table)
(declare gen-call)
; -- functions --------------------------------------------------------------------------------------------------------------
(defmacro send-stand-by
"Attempt to put all HDMI CEC compatible devices in standby.This is not guaranteed to have any effect on the connected
displays. Displays that do not support HDMI CEC will not be affected.|callback| will be run as soon as all displays have
been requested to change their power state.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error."
([] (gen-call :function ::send-stand-by &form)))
(defmacro send-wake-up
"Attempt to announce this device as the active input source towards all HDMI CEC enabled displays connected, waking them
from standby if necessary.|callback| will be run as soon as all displays have been requested to change their power state.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error."
([] (gen-call :function ::send-wake-up &form)))
(defmacro query-display-cec-power-state
"Queries all HDMI CEC capable displays for their current power state.
This function returns a core.async channel of type `promise-chan` which eventually receives a result value.
Signature of the result value put on the channel is [power-states] where:
|power-states| - ?
In case of an error the channel closes without receiving any value and relevant error object can be obtained via
chromex.error/get-last-error."
([] (gen-call :function ::query-display-cec-power-state &form)))
; -- convenience ------------------------------------------------------------------------------------------------------------
(defmacro tap-all-events
"Taps all valid non-deprecated events in chromex.app.cec-private namespace."
[chan]
(gen-tap-all-events-call api-table (meta &form) chan))
; ---------------------------------------------------------------------------------------------------------------------------
; -- API TABLE --------------------------------------------------------------------------------------------------------------
; ---------------------------------------------------------------------------------------------------------------------------
(def api-table
{:namespace "chrome.cecPrivate",
:since "68",
:functions
[{:id ::send-stand-by,
:name "sendStandBy",
:callback? true,
:params [{:name "callback", :optional? true, :type :callback}]}
{:id ::send-wake-up,
:name "sendWakeUp",
:callback? true,
:params [{:name "callback", :optional? true, :type :callback}]}
{:id ::query-display-cec-power-state,
:name "queryDisplayCecPowerState",
:callback? true,
:params
[{:name "callback",
:type :callback,
:callback {:params [{:name "power-states", :type "[array-of-unknown-types]"}]}}]}]})
; -- helpers ----------------------------------------------------------------------------------------------------------------
; code generation for native API wrapper
(defmacro gen-wrap [kind item-id config & args]
(apply gen-wrap-helper api-table kind item-id config args))
; code generation for API call-site
(def gen-call (partial gen-call-helper api-table))