├── README.md
├── pictures
├── Screenshot01.png
├── Screenshot02.png
├── Screenshot03.png
└── Screenshot04.png
└── script.video.fswitch
├── LICENSE.txt
├── addon.xml
├── changelog.txt
├── fswitch.py
├── fswitch_config.py
├── fswitch_configutil.py
├── fswitch_keylisten.py
├── fswitch_message.py
├── fswitch_player.py
├── fswitch_service.py
├── fswitch_util.py
├── fswitch_window.py
└── resources
└── language
└── English
└── strings.po
/README.md:
--------------------------------------------------------------------------------
1 | # Kodi.AmLogic.script.frequency.switcher
2 | Automatic refresh rate switcher for Kodi running under Android in AmLogic boards (S802 based, mainly)
3 |
4 | Based on the Minix Frequency Switcher:
5 | (http://www.minixforum.com/threads/autoframerate-detection-switching-output-in-xbmc.601/)
6 |
7 | - Modified to run on all AmLogic boards.
8 | - Modified to run on Kodi instead of XBMC.
9 |
10 | /sys/class/display/mode needs to be writable.
11 |
12 | With Kodi supporting automatic rate switching, this addon in useful mainly for S802 boards that can't perform HDMI handshake,
13 | resulting in "null edid" in /sys/class/amhdmitx/amhdmitx0/disp_cap
14 |
15 | Kodi uses information in that virtual file to determine valid resolutions/refresh rates.
16 | Submited PR to Kodi to support manual override of "disp_cap" to try to circumvent the issue: https://github.com/xbmc/xbmc/pull/7257
17 |
18 | ### Screenshot
19 |
20 |
--------------------------------------------------------------------------------
/pictures/Screenshot01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff2900/Kodi.AmLogic.script.frequency.switcher/928ebb3e9d7ac79553f298385706333c7861954e/pictures/Screenshot01.png
--------------------------------------------------------------------------------
/pictures/Screenshot02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff2900/Kodi.AmLogic.script.frequency.switcher/928ebb3e9d7ac79553f298385706333c7861954e/pictures/Screenshot02.png
--------------------------------------------------------------------------------
/pictures/Screenshot03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff2900/Kodi.AmLogic.script.frequency.switcher/928ebb3e9d7ac79553f298385706333c7861954e/pictures/Screenshot03.png
--------------------------------------------------------------------------------
/pictures/Screenshot04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jeff2900/Kodi.AmLogic.script.frequency.switcher/928ebb3e9d7ac79553f298385706333c7861954e/pictures/Screenshot04.png
--------------------------------------------------------------------------------
/script.video.fswitch/LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/script.video.fswitch/addon.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | video executable
17 |
18 |
19 |
20 | Frequency Switcher for AmLogic boards
21 | Supports 2160p, 1080p and 720p resolutions.[CR][CR]Please run Clean Up before you Uninstall or Disable.[CR][CR]Based on Minix Frequency Switcher.[CR][CR]Thanks MINIX-Ken, HardwareGuru, KenV99, Roman_V_M, takoi and Abbe
22 |
23 |
24 |
25 | GNU GENERAL PUBLIC LICENSE. Version 3, June 2007
26 |
27 | https://github.com/pmos69/Kodi.AmLogic.script.frequency.switcher
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/script.video.fswitch/changelog.txt:
--------------------------------------------------------------------------------
1 | v2.1.2
2 | - Add preliminary support Kodi 19.0
3 |
4 | v2.1.1
5 | - Fix for auto switching timeout
6 |
7 | v2.1.0
8 | - Add 25hz and 30hz modes. Need "Clean Up" before use.
9 |
10 | v2.0.6
11 | - Fix hdcp_mode blank screen
12 |
13 | v2.0.5
14 | - Improved code to detect host operating system
15 |
16 | v2.0.4
17 | - Fix auto switching SPMC 16.6.81
18 |
19 | v2.0.3
20 | - Fix keymaps compatibility with Kodi 17.0
21 | Skin Confluence must be installed to use keymaps
22 |
23 | v2.0.2
24 | - Add preliminary support Kodi 17.0
25 |
26 | v2.0.1
27 | - Added 4k
28 |
29 | v2
30 | - Runs on all AmLogic boards
31 | - Runs in Kodi
32 |
33 | v1.3.1
34 | - Fix for auto switching DVD-ISO and IMG files
35 | - Improved source frame rate detection
36 | - Reduced stand down period
37 |
38 | v1.3.0
39 | - Added Info mapped key
40 |
41 | v1.2.0
42 | - Added 50hz option for playback stop
43 | - Improved Clean Up
44 |
45 | v1.1.0
46 | - Settings shared between profiles
47 | - Added support for switching on end of playback
48 | - Prevented switching when playing audio files
49 | - Removed notification sound
50 | - Improved Automatic mapped key
51 |
52 | v1.0.0
53 | - Service optimization
54 | - Service startup changed from Login to XBMC Startup
55 | - Added Clean Up (for use before Uninstall and Disable)
56 |
57 | v0.0.3
58 | - Added support for key navigation (beta 3)
59 |
60 | v0.0.2
61 | - First published version (beta 2)
62 |
63 | v0.0.1
64 | - Unpublished dev version
--------------------------------------------------------------------------------
/script.video.fswitch/fswitch.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import xbmcgui
3 | import fswitch_window as fswin
4 | import fswitch_util as fsutil
5 | import fswitch_message as fsmsg
6 | import fswitch_configutil as fsconfigutil
7 | import fswitch_config as fsconfig
8 |
9 | class Main:
10 | 'main function - determine platform and process arguments'
11 |
12 | @staticmethod
13 | def run():
14 |
15 | scriptMode = None
16 |
17 | # if the only argument is script name then run in setup mode
18 | if len(sys.argv) == 1:
19 | scriptMode = 'Setup'
20 |
21 | # otherwise select mode based on the first argument
22 | else:
23 | scriptArg = sys.argv[1]
24 |
25 | if scriptArg == '4k2k-60hz':
26 | scriptMode = 'SetFreq'
27 | elif scriptArg == '4k2k-50hz':
28 | scriptMode = 'SetFreq'
29 | elif scriptArg == '4k2k-30hz':
30 | scriptMode = 'SetFreq'
31 | elif scriptArg == '4k2k-25hz':
32 | scriptMode = 'SetFreq'
33 | elif scriptArg == '4k2k-24hz':
34 | scriptMode = 'SetFreq'
35 | elif scriptArg == '1080p-60hz':
36 | scriptMode = 'SetFreq'
37 | elif scriptArg == '1080p-50hz':
38 | scriptMode = 'SetFreq'
39 | elif scriptArg == '1080p-30hz':
40 | scriptMode = 'SetFreq'
41 | elif scriptArg == '1080p-25hz':
42 | scriptMode = 'SetFreq'
43 | elif scriptArg == '1080p-24hz':
44 | scriptMode = 'SetFreq'
45 | elif scriptArg == '720p-60hz':
46 | scriptMode = 'SetFreq'
47 | elif scriptArg == '720p-50hz':
48 | scriptMode = 'SetFreq'
49 | elif scriptArg == 'auto':
50 | scriptMode = 'AutoSet'
51 | elif scriptArg == 'info':
52 | scriptMode = 'ShowInfo'
53 |
54 | # create default settings (if they don't already exist)
55 | fsconfigutil.createAllSettingsFiles()
56 |
57 | # load settings
58 | loadSettingsStatus = fsconfigutil.loadSettings()
59 |
60 | if scriptMode == 'Setup':
61 | # Create and show main configuration window
62 | fsMainWindow = fswin.MainWindow('Frequency Switcher configuration')
63 | fsMainWindow.doModal()
64 |
65 | elif scriptMode == 'SetFreq':
66 | # set the output mode
67 | setModeStatus, statusType = fsutil.setDisplayMode(scriptArg)
68 |
69 | # display notification
70 | if statusType == 'warn':
71 | fsmsg.notifyQuickWarn('Frequency Switcher', setModeStatus)
72 | else:
73 | fsmsg.notifyInfo('Frequency Switcher', setModeStatus)
74 |
75 | elif scriptMode == 'AutoSet':
76 | # set the output mode automatically
77 | setModeStatus, statusType = fsutil.setDisplayModeAuto()
78 |
79 | # display notification
80 | if statusType == 'warn':
81 | fsmsg.notifyQuickWarn('Frequency Switcher', setModeStatus)
82 | else:
83 | fsmsg.notifyInfo('Frequency Switcher', setModeStatus)
84 |
85 | elif scriptMode == 'ShowInfo':
86 | fsconfigutil.loadActiveInfoSetting()
87 |
88 | # disable info panel if currently active
89 | if fsconfig.activeInfo:
90 |
91 | # check that the active info panel flag file is not old (occurs if XBMC crashes)
92 | if fsconfigutil.activeInfoFlagIsOld():
93 | fswin.InfoPanel.showInfo()
94 |
95 | # flag file is new so deactivate panel
96 | else:
97 | fsconfig.activeInfo = False
98 | fsconfigutil.saveActiveInfoSetting()
99 |
100 | # show info panel if not currently active
101 | else:
102 | fswin.InfoPanel.showInfo()
103 |
104 | else:
105 | fsmsg.notifyInfo('Invalid script argument', scriptArg)
106 |
107 |
108 | # only run main function if module is running directly (i.e. not imported)
109 | if __name__ == '__main__':
110 | Main.run()
111 |
112 |
--------------------------------------------------------------------------------
/script.video.fswitch/fswitch_config.py:
--------------------------------------------------------------------------------
1 | # platform
2 | osPlatform = None
3 |
4 | # service config
5 | radioOnPlayStop60 = None
6 | radioOnPlayStop50 = None
7 | radioNotifyOn = None
8 |
9 | # service flags
10 | radioOnPlayStart = None
11 | activeService = None
12 |
13 | # active info flag
14 | activeInfo = None
15 |
16 | # key mapping
17 | radio60hz = None
18 | radio50hz = None
19 | radio30hz = None
20 | radio25hz = None
21 | radio24hz = None
22 | radioAuto = None
23 | radioInfo = None
24 |
25 | key60hz = None
26 | key50hz = None
27 | key30hz = None
28 | key25hz = None
29 | key24hz = None
30 | keyAuto = None
31 | keyInfo = None
32 |
33 | status60hz = None
34 | status50hz = None
35 | status30hz = None
36 | status25hz = None
37 | status24hz = None
38 | statusAuto = None
39 | statusInfo = None
40 |
41 | keymapRes = None
42 |
43 | # mode change
44 | lastFreqChange = None
45 |
46 | lastDetectedFps = None
47 | lastDetectedFile = None
48 |
49 | # auto-set configuration
50 | radioAuto60hz = None
51 | radioAuto50hz = None
52 | radioAuto30hz = None
53 | radioAuto25hz = None
54 | radioAuto24hz = None
55 |
56 | edit60hzFps1 = None
57 | edit60hzFps2 = None
58 | edit60hzFps3 = None
59 | edit60hzFps4 = None
60 |
61 | edit50hzFps1 = None
62 | edit50hzFps2 = None
63 | edit50hzFps3 = None
64 | edit50hzFps4 = None
65 |
66 | edit30hzFps1 = None
67 | edit30hzFps2 = None
68 | edit30hzFps3 = None
69 | edit30hzFps4 = None
70 |
71 | edit25hzFps1 = None
72 | edit25hzFps2 = None
73 | edit25hzFps3 = None
74 | edit25hzFps4 = None
75 |
76 | edit24hzFps1 = None
77 | edit24hzFps2 = None
78 | edit24hzFps3 = None
79 | edit24hzFps4 = None
80 |
81 |
82 | # temporary (global but not saved)
83 | lastPlayedMediaType = None
84 |
85 |
--------------------------------------------------------------------------------
/script.video.fswitch/fswitch_configutil.py:
--------------------------------------------------------------------------------
1 | import xbmc
2 | import xbmcaddon
3 | import os
4 | import calendar
5 | import time
6 |
7 | try: # Python 2
8 | import cPickle as pickle
9 |
10 | except ImportError: # Python 3
11 | import _pickle as pickle
12 |
13 | import fswitch_config as fsconfig
14 |
15 | def settingsFolder():
16 | # global settings folder
17 | globalSettingsFolder = xbmc.translatePath('special://userdata')
18 | globalSettingsFolder = os.path.join(globalSettingsFolder, 'addon_data')
19 | globalSettingsFolder = os.path.join(globalSettingsFolder, 'script.frequency.switcher')
20 | return globalSettingsFolder
21 |
22 |
23 | def settingsFile():
24 | # global settings file
25 | globalSettingsFolder = settingsFolder()
26 | globalSettingsFile = os.path.join(globalSettingsFolder, 'global_settings.p')
27 | return globalSettingsFile
28 |
29 | def settingsLastFpsFile():
30 | # last FPS settings file
31 | globalSettingsFolder = settingsFolder()
32 | globalLastFpsFile = os.path.join(globalSettingsFolder, 'global_lastfps.p')
33 | return globalLastFpsFile
34 |
35 | def settingsLastChangeFile():
36 | # last frequency change time file
37 | globalSettingsFolder = settingsFolder()
38 | globalLastChangeFile = os.path.join(globalSettingsFolder, 'global_lastchange.p')
39 | return globalLastChangeFile
40 |
41 | def settingsAutoSyncFile():
42 | # global auto sync file
43 | globalSettingsFolder = settingsFolder()
44 | globalAutoSyncFile = os.path.join(globalSettingsFolder, 'global_autosync.p')
45 | return globalAutoSyncFile
46 |
47 | def settingsServiceConfigFile():
48 | # global service config file
49 | globalSettingsFolder = settingsFolder()
50 | globalServiceConfigFile = os.path.join(globalSettingsFolder, 'global_serviceconfig.p')
51 | return globalServiceConfigFile
52 |
53 |
54 | def createAllSettingsFiles():
55 |
56 | # create settings folder if it doesn't already exist
57 | golbalSettingsFolder = settingsFolder()
58 | if not os.path.isdir(golbalSettingsFolder):
59 | os.makedirs(golbalSettingsFolder)
60 |
61 | # create settings files if they don't already exist
62 | globalSettingsFile = settingsFile()
63 | if not os.path.isfile(globalSettingsFile):
64 | resetSettingsFile()
65 |
66 | globalLastFps = settingsLastFpsFile()
67 | if not os.path.isfile(globalLastFps):
68 | resetLastDetectedFpsFile()
69 |
70 | globalLastChange = settingsLastChangeFile()
71 | if not os.path.isfile(globalLastChange):
72 | resetLastFreqChangeSettingFile()
73 |
74 | globalAutoSync = settingsAutoSyncFile()
75 | if not os.path.isfile(globalAutoSync):
76 | resetAutoSyncSettingsFile()
77 |
78 | globalServiceConfig = settingsServiceConfigFile()
79 | if not os.path.isfile(globalServiceConfig):
80 | resetServiceConfigFile()
81 |
82 | def deleteAllSettingsFiles():
83 |
84 | # delete settings files
85 | try:
86 | globalSettingsFile = settingsFile()
87 | if os.path.isfile(globalSettingsFile):
88 | os.remove(globalSettingsFile)
89 |
90 | globalLastFps = settingsLastFpsFile()
91 | if os.path.isfile(globalLastFps):
92 | os.remove(globalLastFps)
93 |
94 | globalLastChange = settingsLastChangeFile()
95 | if os.path.isfile(globalLastChange):
96 | os.remove(globalLastChange)
97 |
98 | globalAutoSync = settingsAutoSyncFile()
99 | if os.path.isfile(globalAutoSync):
100 | os.remove(globalAutoSync)
101 |
102 | globalServiceConfig = settingsServiceConfigFile()
103 | if os.path.isfile(globalServiceConfig):
104 | os.remove(globalServiceConfig)
105 |
106 | infoStateFlagFile = activeInfoFlagFile()
107 | if os.path.isfile(infoStateFlagFile):
108 | os.remove(infoStateFlagFile)
109 |
110 | # delete settings folder if empty
111 | golbalSettingsFolder = settingsFolder()
112 | if os.path.isdir(golbalSettingsFolder):
113 | os.rmdir(golbalSettingsFolder)
114 |
115 | settingsDeleted = True
116 | except Exception:
117 | settingsDeleted = False
118 |
119 |
120 | def resetSettingsFile():
121 |
122 | globalSettingsFile = settingsFile()
123 |
124 | # default settings
125 | fsSettings = {}
126 |
127 | # platform
128 | fsSettings['osPlatform'] = 'unknown'
129 |
130 | # key mapping
131 | fsSettings['radio60hz'] = False
132 | fsSettings['radio50hz'] = False
133 | fsSettings['radio30hz'] = False
134 | fsSettings['radio25hz'] = False
135 | fsSettings['radio24hz'] = False
136 | fsSettings['radioAuto'] = False
137 | fsSettings['radioInfo'] = False
138 |
139 | fsSettings['key60hz'] = ''
140 | fsSettings['key50hz'] = ''
141 | fsSettings['key30hz'] = ''
142 | fsSettings['key25hz'] = ''
143 | fsSettings['key24hz'] = ''
144 | fsSettings['keyAuto'] = ''
145 | fsSettings['keyInfo'] = ''
146 |
147 | fsSettings['status60hz'] = ''
148 | fsSettings['status50hz'] = ''
149 | fsSettings['status30hz'] = ''
150 | fsSettings['status25hz'] = ''
151 | fsSettings['status24hz'] = ''
152 | fsSettings['statusAuto'] = ''
153 | fsSettings['statusInfo'] = ''
154 |
155 | fsSettings['keymapRes'] = ''
156 |
157 | # create or overwrite settings file
158 | try:
159 | with open(globalSettingsFile, 'wb') as settingsFileHandle:
160 | pickle.dump(fsSettings, settingsFileHandle)
161 |
162 | resetSettingsStatus = 'Reset settings'
163 | except Exception:
164 | resetSettingsStatus = 'Failed to reset settings'
165 |
166 | resetLastDetectedFpsFile()
167 |
168 | resetLastFreqChangeSettingFile()
169 |
170 | resetAutoSyncSettingsFile()
171 |
172 | resetServiceConfigFile()
173 |
174 | def resetLastDetectedFpsFile():
175 |
176 | globalLastFps = settingsLastFpsFile()
177 |
178 | # default settings
179 | fsSettings = {}
180 |
181 | fsSettings['lastDetectedFps'] = ''
182 | fsSettings['lastDetectedFile'] = ''
183 |
184 | # create or overwrite settings file
185 | try:
186 | with open(globalLastFps, 'wb') as settingsFileHandle:
187 | pickle.dump(fsSettings, settingsFileHandle)
188 |
189 | resetSettingsStatus = 'Reset last FPS settings'
190 | except Exception:
191 | resetSettingsStatus = 'Failed to reset last FPS settings'
192 |
193 | def resetLastFreqChangeSettingFile():
194 |
195 | globalLastChange = settingsLastChangeFile()
196 |
197 | # default settings
198 | fsSettings = {}
199 |
200 | fsSettings['lastFreqChange'] = 0
201 |
202 | # create or overwrite settings file
203 | try:
204 | with open(globalLastChange, 'wb') as settingsFileHandle:
205 | pickle.dump(fsSettings, settingsFileHandle)
206 |
207 | resetSettingsStatus = 'Reset last change time setting'
208 | except Exception:
209 | resetSettingsStatus = 'Failed to reset last change time setting'
210 |
211 | def resetAutoSyncSettingsFile():
212 |
213 | globalAutoSync = settingsAutoSyncFile()
214 |
215 | # default settings
216 | fsSettings = {}
217 |
218 | # auto-set configuration
219 | fsSettings['radioAuto60hz'] = True
220 | fsSettings['radioAuto50hz'] = True
221 | fsSettings['radioAuto30hz'] = False
222 | fsSettings['radioAuto25hz'] = False
223 | fsSettings['radioAuto24hz'] = True
224 |
225 | fsSettings['edit60hzFps1'] = '59.940'
226 | fsSettings['edit60hzFps2'] = '29.970'
227 | fsSettings['edit60hzFps3'] = ''
228 | fsSettings['edit60hzFps4'] = ''
229 |
230 | fsSettings['edit50hzFps1'] = '50.000'
231 | fsSettings['edit50hzFps2'] = '25.000'
232 | fsSettings['edit50hzFps3'] = ''
233 | fsSettings['edit50hzFps4'] = ''
234 |
235 | fsSettings['edit30hzFps1'] = ''
236 | fsSettings['edit30hzFps2'] = ''
237 | fsSettings['edit30hzFps3'] = ''
238 | fsSettings['edit30hzFps4'] = ''
239 |
240 | fsSettings['edit25hzFps1'] = ''
241 | fsSettings['edit25hzFps2'] = ''
242 | fsSettings['edit25hzFps3'] = ''
243 | fsSettings['edit25hzFps4'] = ''
244 |
245 | fsSettings['edit24hzFps1'] = '24.000'
246 | fsSettings['edit24hzFps2'] = '23.976'
247 | fsSettings['edit24hzFps3'] = ''
248 | fsSettings['edit24hzFps4'] = ''
249 |
250 | # create or overwrite settings file
251 | try:
252 | with open(globalAutoSync, 'wb') as settingsFileHandle:
253 | pickle.dump(fsSettings, settingsFileHandle)
254 |
255 | resetSettingsStatus = 'Reset auto sync settings'
256 | except Exception:
257 | resetSettingsStatus = 'Failed to reset auto sync settings'
258 |
259 | def resetServiceConfigFile():
260 |
261 | globalServiceConfig = settingsServiceConfigFile()
262 |
263 | # default settings
264 | fsSettings = {}
265 |
266 | # service config
267 | fsSettings['radioOnPlayStop60'] = False
268 | fsSettings['radioOnPlayStop50'] = False
269 | fsSettings['radioNotifyOn'] = True
270 |
271 | # create or overwrite settings file
272 | try:
273 | with open(globalServiceConfig, 'wb') as settingsFileHandle:
274 | pickle.dump(fsSettings, settingsFileHandle)
275 |
276 | resetSettingsStatus = 'Reset service configuration'
277 | except Exception:
278 | resetSettingsStatus = 'Failed to reset service configuration'
279 |
280 |
281 | def loadSettings():
282 |
283 | # load service configuration (first to allow for fsmsg debugging)
284 | loadServiceConfig()
285 |
286 | globalSettingsFile = settingsFile()
287 |
288 | # read settings file
289 | try:
290 | with open(globalSettingsFile, 'rb') as settingsFileHandle:
291 | fsSettings = pickle.load(settingsFileHandle)
292 |
293 | # platform
294 | fsconfig.osPlatform = fsSettings['osPlatform']
295 |
296 | # key mapping
297 | fsconfig.radio60hz = fsSettings['radio60hz']
298 | fsconfig.radio50hz = fsSettings['radio50hz']
299 | fsconfig.radio30hz = fsSettings['radio30hz']
300 | fsconfig.radio25hz = fsSettings['radio25hz']
301 | fsconfig.radio24hz = fsSettings['radio24hz']
302 | fsconfig.radioAuto = fsSettings['radioAuto']
303 | fsconfig.radioInfo = fsSettings['radioInfo']
304 |
305 | fsconfig.key60hz = fsSettings['key60hz']
306 | fsconfig.key50hz = fsSettings['key50hz']
307 | fsconfig.key30hz = fsSettings['key30hz']
308 | fsconfig.key25hz = fsSettings['key25hz']
309 | fsconfig.key24hz = fsSettings['key24hz']
310 | fsconfig.keyAuto = fsSettings['keyAuto']
311 | fsconfig.keyInfo = fsSettings['keyInfo']
312 |
313 | fsconfig.status60hz = fsSettings['status60hz']
314 | fsconfig.status50hz = fsSettings['status50hz']
315 | fsconfig.status30hz = fsSettings['status30hz']
316 | fsconfig.status25hz = fsSettings['status25hz']
317 | fsconfig.status24hz = fsSettings['status24hz']
318 | fsconfig.statusAuto = fsSettings['statusAuto']
319 | fsconfig.statusInfo = fsSettings['statusInfo']
320 |
321 | fsconfig.keymapRes = fsSettings['keymapRes']
322 |
323 | loadSettingsStatus = 'Loaded settings'
324 | except Exception:
325 | loadSettingsStatus = 'Failed to load settings'
326 |
327 | # load auto-set configuration
328 | loadAutoSyncSettings()
329 |
330 | # load use service flag
331 | fsconfig.radioOnPlayStart = useServiceFlagGet()
332 |
333 | return loadSettingsStatus
334 |
335 | def saveSettings():
336 |
337 | globalSettingsFile = settingsFile()
338 |
339 | fsSettings = {}
340 |
341 | # platform
342 | fsSettings['osPlatform'] = fsconfig.osPlatform
343 |
344 | # key mapping
345 | fsSettings['radio60hz'] = fsconfig.radio60hz
346 | fsSettings['radio50hz'] = fsconfig.radio50hz
347 | fsSettings['radio30hz'] = fsconfig.radio30hz
348 | fsSettings['radio25hz'] = fsconfig.radio25hz
349 | fsSettings['radio24hz'] = fsconfig.radio24hz
350 | fsSettings['radioAuto'] = fsconfig.radioAuto
351 | fsSettings['radioInfo'] = fsconfig.radioInfo
352 |
353 | fsSettings['key60hz'] = fsconfig.key60hz
354 | fsSettings['key50hz'] = fsconfig.key50hz
355 | fsSettings['key30hz'] = fsconfig.key30hz
356 | fsSettings['key25hz'] = fsconfig.key25hz
357 | fsSettings['key24hz'] = fsconfig.key24hz
358 | fsSettings['keyAuto'] = fsconfig.keyAuto
359 | fsSettings['keyInfo'] = fsconfig.keyInfo
360 |
361 | fsSettings['status60hz'] = fsconfig.status60hz
362 | fsSettings['status50hz'] = fsconfig.status50hz
363 | fsSettings['status30hz'] = fsconfig.status30hz
364 | fsSettings['status25hz'] = fsconfig.status25hz
365 | fsSettings['status24hz'] = fsconfig.status24hz
366 | fsSettings['statusAuto'] = fsconfig.statusAuto
367 | fsSettings['statusInfo'] = fsconfig.statusInfo
368 |
369 | fsSettings['keymapRes'] = fsconfig.keymapRes
370 |
371 | # create or overwrite settings file
372 | try:
373 | with open(globalSettingsFile, 'wb') as settingsFileHandle:
374 | pickle.dump(fsSettings, settingsFileHandle)
375 |
376 | saveSettingsStatus = 'Settings saved'
377 | except Exception:
378 | saveSettingsStatus = 'Failed to save settings'
379 |
380 | # save auto-set configuration
381 | saveAutoSyncSettings()
382 |
383 | # save service configuration
384 | saveServiceConfig()
385 |
386 | # save use service flag
387 | if fsconfig.radioOnPlayStart:
388 | useServiceFlagSet()
389 | else:
390 | useServiceFlagDel()
391 |
392 | return saveSettingsStatus
393 |
394 |
395 | def loadLastDetectedFps():
396 |
397 | globalLastFps = settingsLastFpsFile()
398 |
399 | # read settings file
400 | try:
401 | with open(globalLastFps, 'rb') as settingsFileHandle:
402 | fsSettings = pickle.load(settingsFileHandle)
403 |
404 | fsconfig.lastDetectedFps = fsSettings['lastDetectedFps']
405 | fsconfig.lastDetectedFile = fsSettings['lastDetectedFile']
406 |
407 | loadSettingsStatus = 'Loaded last FPS'
408 | except Exception:
409 | loadSettingsStatus = 'Failed to load last FPS'
410 |
411 | return loadSettingsStatus
412 |
413 | def saveLastDetectedFps():
414 |
415 | globalLastFps = settingsLastFpsFile()
416 |
417 | fsSettings = {}
418 | fsSettings['lastDetectedFps'] = fsconfig.lastDetectedFps
419 | fsSettings['lastDetectedFile'] = fsconfig.lastDetectedFile
420 |
421 | # create or overwrite settings file
422 | try:
423 | with open(globalLastFps, 'wb') as settingsFileHandle:
424 | pickle.dump(fsSettings, settingsFileHandle)
425 |
426 | saveSettingsStatus = 'Last FPS saved'
427 | except Exception:
428 | saveSettingsStatus = 'Failed to save last FPS'
429 |
430 | return saveSettingsStatus
431 |
432 |
433 | def loadLastFreqChangeSetting():
434 |
435 | globalLastChange = settingsLastChangeFile()
436 |
437 | # read settings file
438 | try:
439 | with open(globalLastChange, 'rb') as settingsFileHandle:
440 | fsSettings = pickle.load(settingsFileHandle)
441 |
442 | fsconfig.lastFreqChange = fsSettings['lastFreqChange']
443 |
444 | loadSettingsStatus = 'Loaded last change time'
445 | except Exception:
446 | loadSettingsStatus = 'Failed to load last change time'
447 |
448 | return loadSettingsStatus
449 |
450 | def saveLastFreqChangeSetting():
451 |
452 | globalLastChange = settingsLastChangeFile()
453 |
454 | fsSettings = {}
455 |
456 | fsSettings['lastFreqChange'] = fsconfig.lastFreqChange
457 |
458 | # create or overwrite settings file
459 | try:
460 | with open(globalLastChange, 'wb') as settingsFileHandle:
461 | pickle.dump(fsSettings, settingsFileHandle)
462 |
463 | saveSettingsStatus = 'Last change time saved'
464 | except Exception:
465 | saveSettingsStatus = 'Failed to save last change time'
466 |
467 | return saveSettingsStatus
468 |
469 |
470 | def loadAutoSyncSettings():
471 |
472 | globalAutoSync = settingsAutoSyncFile()
473 |
474 | # read settings file
475 | try:
476 | with open(globalAutoSync, 'rb') as settingsFileHandle:
477 | fsSettings = pickle.load(settingsFileHandle)
478 |
479 | # auto-set configuration
480 | fsconfig.radioAuto60hz = fsSettings['radioAuto60hz']
481 | fsconfig.radioAuto50hz = fsSettings['radioAuto50hz']
482 | fsconfig.radioAuto30hz = fsSettings['radioAuto30hz']
483 | fsconfig.radioAuto25hz = fsSettings['radioAuto25hz']
484 | fsconfig.radioAuto24hz = fsSettings['radioAuto24hz']
485 |
486 | fsconfig.edit60hzFps1 = fsSettings['edit60hzFps1']
487 | fsconfig.edit60hzFps2 = fsSettings['edit60hzFps2']
488 | fsconfig.edit60hzFps3 = fsSettings['edit60hzFps3']
489 | fsconfig.edit60hzFps4 = fsSettings['edit60hzFps4']
490 |
491 | fsconfig.edit50hzFps1 = fsSettings['edit50hzFps1']
492 | fsconfig.edit50hzFps2 = fsSettings['edit50hzFps2']
493 | fsconfig.edit50hzFps3 = fsSettings['edit50hzFps3']
494 | fsconfig.edit50hzFps4 = fsSettings['edit50hzFps4']
495 |
496 | fsconfig.edit30hzFps1 = fsSettings['edit30hzFps1']
497 | fsconfig.edit30hzFps2 = fsSettings['edit30hzFps2']
498 | fsconfig.edit30hzFps3 = fsSettings['edit30hzFps3']
499 | fsconfig.edit30hzFps4 = fsSettings['edit30hzFps4']
500 |
501 | fsconfig.edit25hzFps1 = fsSettings['edit25hzFps1']
502 | fsconfig.edit25hzFps2 = fsSettings['edit25hzFps2']
503 | fsconfig.edit25hzFps3 = fsSettings['edit25hzFps3']
504 | fsconfig.edit25hzFps4 = fsSettings['edit25hzFps4']
505 |
506 | fsconfig.edit24hzFps1 = fsSettings['edit24hzFps1']
507 | fsconfig.edit24hzFps2 = fsSettings['edit24hzFps2']
508 | fsconfig.edit24hzFps3 = fsSettings['edit24hzFps3']
509 | fsconfig.edit24hzFps4 = fsSettings['edit24hzFps4']
510 |
511 | loadSettingsStatus = 'Loaded auto sync settings'
512 | except Exception:
513 | loadSettingsStatus = 'Failed to load auto sync settings'
514 |
515 | return loadSettingsStatus
516 |
517 | def saveAutoSyncSettings():
518 |
519 | globalAutoSync = settingsAutoSyncFile()
520 |
521 | fsSettings = {}
522 |
523 | # auto-set configuration
524 | fsSettings['radioAuto60hz'] = fsconfig.radioAuto60hz
525 | fsSettings['radioAuto50hz'] = fsconfig.radioAuto50hz
526 | fsSettings['radioAuto30hz'] = fsconfig.radioAuto30hz
527 | fsSettings['radioAuto25hz'] = fsconfig.radioAuto25hz
528 | fsSettings['radioAuto24hz'] = fsconfig.radioAuto24hz
529 |
530 | fsSettings['edit60hzFps1'] = fsconfig.edit60hzFps1
531 | fsSettings['edit60hzFps2'] = fsconfig.edit60hzFps2
532 | fsSettings['edit60hzFps3'] = fsconfig.edit60hzFps3
533 | fsSettings['edit60hzFps4'] = fsconfig.edit60hzFps4
534 |
535 | fsSettings['edit50hzFps1'] = fsconfig.edit50hzFps1
536 | fsSettings['edit50hzFps2'] = fsconfig.edit50hzFps2
537 | fsSettings['edit50hzFps3'] = fsconfig.edit50hzFps3
538 | fsSettings['edit50hzFps4'] = fsconfig.edit50hzFps4
539 |
540 | fsSettings['edit30hzFps1'] = fsconfig.edit30hzFps1
541 | fsSettings['edit30hzFps2'] = fsconfig.edit30hzFps2
542 | fsSettings['edit30hzFps3'] = fsconfig.edit30hzFps3
543 | fsSettings['edit30hzFps4'] = fsconfig.edit30hzFps4
544 |
545 | fsSettings['edit25hzFps1'] = fsconfig.edit25hzFps1
546 | fsSettings['edit25hzFps2'] = fsconfig.edit25hzFps2
547 | fsSettings['edit25hzFps3'] = fsconfig.edit25hzFps3
548 | fsSettings['edit25hzFps4'] = fsconfig.edit25hzFps4
549 |
550 | fsSettings['edit24hzFps1'] = fsconfig.edit24hzFps1
551 | fsSettings['edit24hzFps2'] = fsconfig.edit24hzFps2
552 | fsSettings['edit24hzFps3'] = fsconfig.edit24hzFps3
553 | fsSettings['edit24hzFps4'] = fsconfig.edit24hzFps4
554 |
555 | # create or overwrite settings file
556 | try:
557 | with open(globalAutoSync, 'wb') as settingsFileHandle:
558 | pickle.dump(fsSettings, settingsFileHandle)
559 |
560 | saveSettingsStatus = 'Auto sync settings saved'
561 | except Exception:
562 | saveSettingsStatus = 'Failed to save auto sync settings'
563 |
564 | return saveSettingsStatus
565 |
566 |
567 | def loadServiceConfig():
568 |
569 | globalServiceConfig = settingsServiceConfigFile()
570 |
571 | # read settings file
572 | try:
573 | with open(globalServiceConfig, 'rb') as settingsFileHandle:
574 | fsSettings = pickle.load(settingsFileHandle)
575 |
576 | # service config
577 | fsconfig.radioOnPlayStop60 = fsSettings['radioOnPlayStop60']
578 | fsconfig.radioOnPlayStop50 = fsSettings['radioOnPlayStop50']
579 | fsconfig.radioNotifyOn = fsSettings['radioNotifyOn']
580 |
581 | loadSettingsStatus = 'Loaded service configuration'
582 | except Exception:
583 | loadSettingsStatus = 'Failed to load service configuration'
584 |
585 | return loadSettingsStatus
586 |
587 | def saveServiceConfig():
588 |
589 | globalServiceConfig = settingsServiceConfigFile()
590 |
591 | fsSettings = {}
592 |
593 | # service
594 | fsSettings['radioOnPlayStop60'] = fsconfig.radioOnPlayStop60
595 | fsSettings['radioOnPlayStop50'] = fsconfig.radioOnPlayStop50
596 | fsSettings['radioNotifyOn'] = fsconfig.radioNotifyOn
597 |
598 | # create or overwrite settings file
599 | try:
600 | with open(globalServiceConfig, 'wb') as settingsFileHandle:
601 | pickle.dump(fsSettings, settingsFileHandle)
602 |
603 | saveSettingsStatus = 'Service configuration saved'
604 | except Exception:
605 | saveSettingsStatus = 'Failed to save service configuration'
606 |
607 | return saveSettingsStatus
608 |
609 |
610 |
611 | def loadActiveServiceSetting():
612 |
613 | fsconfig.activeService = activeServiceFlagGet()
614 |
615 | def saveActiveServiceSetting():
616 |
617 | if fsconfig.activeService:
618 | activeServiceFlagSet()
619 | else:
620 | activeServiceFlagDel()
621 |
622 |
623 | def loadActiveInfoSetting():
624 |
625 | fsconfig.activeInfo = activeInfoFlagGet()
626 |
627 | def saveActiveInfoSetting():
628 |
629 | if fsconfig.activeInfo:
630 | activeInfoFlagSet()
631 | else:
632 | activeInfoFlagDel()
633 |
634 |
635 | def activeServiceFlagGet():
636 |
637 | # active-service flag file
638 | serviceStateFlagFolder = settingsFolder()
639 | serviceStateFlagFile = os.path.join(serviceStateFlagFolder, 'fs_service_active')
640 |
641 | # check whether flag file exists
642 | if os.path.isfile(serviceStateFlagFile):
643 | return True
644 | else:
645 | return False
646 |
647 | def activeServiceFlagSet():
648 |
649 | # active-service flag file
650 | serviceStateFlagFolder = settingsFolder()
651 | serviceStateFlagFile = os.path.join(serviceStateFlagFolder, 'fs_service_active')
652 |
653 | # check file does not already exist
654 | if not os.path.isfile(serviceStateFlagFile):
655 |
656 | # create active-service flag file
657 | open(serviceStateFlagFile, 'w').close()
658 |
659 | def activeServiceFlagDel():
660 |
661 | # active-service flag file
662 | serviceStateFlagFolder = settingsFolder()
663 | serviceStateFlagFile = os.path.join(serviceStateFlagFolder, 'fs_service_active')
664 |
665 | # check file exists
666 | if os.path.isfile(serviceStateFlagFile):
667 |
668 | # delete active-service flag file
669 | os.remove(serviceStateFlagFile)
670 |
671 |
672 | def useServiceFlagGet():
673 |
674 | # use-service flag file
675 | serviceStateFlagFolder = settingsFolder()
676 | serviceStateFlagFile = os.path.join(serviceStateFlagFolder, 'fs_use_service')
677 |
678 | # check whether flag file exists
679 | if os.path.isfile(serviceStateFlagFile):
680 | return True
681 | else:
682 | return False
683 |
684 | def useServiceFlagSet():
685 |
686 | # use-service flag file
687 | serviceStateFlagFolder = settingsFolder()
688 | serviceStateFlagFile = os.path.join(serviceStateFlagFolder, 'fs_use_service')
689 |
690 | # check file does not already exist
691 | if not os.path.isfile(serviceStateFlagFile):
692 |
693 | # create use-service flag file
694 | open(serviceStateFlagFile, 'w').close()
695 |
696 | def useServiceFlagDel():
697 |
698 | # use-service flag file
699 | serviceStateFlagFolder = settingsFolder()
700 | serviceStateFlagFile = os.path.join(serviceStateFlagFolder, 'fs_use_service')
701 |
702 | # check file exists
703 | if os.path.isfile(serviceStateFlagFile):
704 |
705 | # delete use-service flag file
706 | os.remove(serviceStateFlagFile)
707 |
708 | def activeInfoFlagFile():
709 | # active info panel flag file
710 | infoStateFlagFolder = settingsFolder()
711 | infoStateFlagFile = os.path.join(infoStateFlagFolder, 'fs_info_active')
712 | return infoStateFlagFile
713 |
714 | def activeInfoFlagIsOld():
715 |
716 | # active info panel flag file
717 | infoStateFlagFile = activeInfoFlagFile()
718 |
719 | # check whether flag file exists
720 | if os.path.isfile(infoStateFlagFile):
721 |
722 | # check age of file (modified time) - seconds since epoch
723 | infoFileTime = os.path.getmtime(infoStateFlagFile)
724 |
725 | # compare file age with current time
726 | currentTime = calendar.timegm(time.gmtime())
727 | ageInSeconds = currentTime - infoFileTime
728 |
729 | # file is older than four seconds
730 | if ageInSeconds > 4:
731 | return True
732 |
733 | # file is active - i.e. not older than four seconds
734 | else:
735 | return False
736 |
737 | # file does not exist - treat as not old
738 | else:
739 | return False
740 |
741 | def activeInfoFlagGet():
742 |
743 | # active info panel flag file
744 | infoStateFlagFile = activeInfoFlagFile()
745 |
746 | # check whether flag file exists
747 | if os.path.isfile(infoStateFlagFile):
748 | return True
749 | else:
750 | return False
751 |
752 | def activeInfoFlagSet():
753 |
754 | # active info panel flag file
755 | infoStateFlagFile = activeInfoFlagFile()
756 |
757 | # check file does not already exist - NOT NECESSARY AS NEED TO CONTINUALLY FLAG INFO PANEL AS ACTIVE WHILE RUNNING
758 | # if not os.path.isfile(infoStateFlagFile):
759 |
760 | # create active-info flag file
761 | open(infoStateFlagFile, 'w').close()
762 |
763 |
764 | def activeInfoFlagDel():
765 |
766 | # active info panel flag file
767 | infoStateFlagFile = activeInfoFlagFile()
768 |
769 | # check file exists
770 | if os.path.isfile(infoStateFlagFile):
771 |
772 | # delete active-service flag file
773 | os.remove(infoStateFlagFile)
774 |
775 |
--------------------------------------------------------------------------------
/script.video.fswitch/fswitch_keylisten.py:
--------------------------------------------------------------------------------
1 | import xbmc
2 | import xbmcaddon
3 | import xbmcgui
4 | import shutil
5 |
6 | from threading import Timer
7 |
8 | # translate object
9 | translate = xbmcaddon.Addon().getLocalizedString
10 |
11 | class KeyListener(xbmcgui.WindowXMLDialog):
12 | 'function for getting pressed key code method and associated dialog window'
13 |
14 | TIMEOUT = 8
15 |
16 | KAITOAST_HEADING = 401
17 | KAITOAST_MESSAGE = 402
18 |
19 | MSG_PRESSKEY = 30000
20 | MSG_TIMEOUT = 30001
21 |
22 | # object creation
23 | def __new__(cls):
24 | try:
25 | version = xbmc.getInfoLabel('system.buildversion')
26 | if version[0:2] >= "17":
27 | return super(KeyListener, cls).__new__(cls, "DialogNotification.xml", "")
28 | else:
29 | return super(KeyListener, cls).__new__(cls, "DialogKaiToast.xml", "")
30 | except:
31 | xbmc.log("NOTICE = KeyListener no found")
32 |
33 | # object initialization
34 | def __init__(self):
35 | self.keyPressed = None
36 |
37 | # initialization event
38 | def onInit(self):
39 | try:
40 | self.getControl(self.KAITOAST_HEADING).addLabel(translate(self.MSG_PRESSKEY))
41 | self.getControl(self.KAITOAST_MESSAGE).addLabel(translate(self.MSG_TIMEOUT) % self.TIMEOUT)
42 | except AttributeError:
43 | self.getControl(self.KAITOAST_HEADING).setLabel(translate(self.MSG_PRESSKEY))
44 | self.getControl(self.KAITOAST_MESSAGE).setLabel(translate(self.MSG_TIMEOUT) % self.TIMEOUT)
45 |
46 | # window event (key listener)
47 | def onAction(self, action):
48 |
49 | # set key pressed to none
50 | self.keyPressed = None
51 |
52 | # get key pressed button code
53 | keyCode = action.getButtonCode()
54 |
55 | # check for a valid button code (ignore mouse input etc)
56 | if keyCode != 0:
57 |
58 | # convert button code to a string
59 | self.keyPressed = str(keyCode)
60 |
61 | # close dialog window
62 | self.close()
63 |
64 | @staticmethod
65 | def getKeyPressed():
66 |
67 | # create the dialog window
68 | getkeyDialog = KeyListener()
69 |
70 | # create a timer to close dialog window
71 | getkeyTimer = Timer(KeyListener.TIMEOUT, getkeyDialog.close)
72 |
73 | # start the time
74 | getkeyTimer.start()
75 |
76 | # show the dialog window and wait for it to close
77 | getkeyDialog.doModal()
78 |
79 | # cancel the timer (if window closed before timer has ended)
80 | getkeyTimer.cancel()
81 |
82 | # get the key pressed from the dialog window
83 | keyPressed = getkeyDialog.keyPressed
84 |
85 | # destroy the dialog window object
86 | del getkeyDialog
87 |
88 | # return the key pressed
89 | return keyPressed
90 |
91 |
--------------------------------------------------------------------------------
/script.video.fswitch/fswitch_message.py:
--------------------------------------------------------------------------------
1 | import xbmcgui
2 | import fswitch_config as fsconfig
3 |
4 | def notifyInfo(title, msg):
5 |
6 | if fsconfig.radioNotifyOn:
7 | notifyDialog = xbmcgui.Dialog()
8 | notifyDialog.notification(title, msg, xbmcgui.NOTIFICATION_INFO, 2500, False)
9 |
10 | def notifyQuickInfo(title, msg):
11 |
12 | if fsconfig.radioNotifyOn:
13 | notifyDialog = xbmcgui.Dialog()
14 | notifyDialog.notification(title, msg, xbmcgui.NOTIFICATION_INFO, 400, False)
15 |
16 | def notifyWarn(title, msg):
17 |
18 | if fsconfig.radioNotifyOn:
19 | notifyDialog = xbmcgui.Dialog()
20 | notifyDialog.notification(title, msg, xbmcgui.NOTIFICATION_WARNING, 1000, False)
21 |
22 | def notifyQuickWarn(title, msg):
23 |
24 | if fsconfig.radioNotifyOn:
25 | notifyDialog = xbmcgui.Dialog()
26 | notifyDialog.notification(title, msg, xbmcgui.NOTIFICATION_WARNING, 400, False)
27 |
--------------------------------------------------------------------------------
/script.video.fswitch/fswitch_player.py:
--------------------------------------------------------------------------------
1 | import xbmc
2 | import fswitch_message as fsmsg
3 | import fswitch_util as fsutil
4 | import fswitch_config as fsconfig
5 |
6 | class fsPlayer(xbmc.Player):
7 | ' player subclass'
8 |
9 | def __init__(self):
10 | super(xbmc.Player, self).__init__()
11 |
12 | # onPlayBack action includes onResume
13 | def onPlayBackStarted(self):
14 |
15 | # only switch on video files (not audio)
16 | if not xbmc.Player().isPlayingAudio():
17 | fsconfig.lastPlayedMediaType = 'video'
18 |
19 | if fsconfig.radioOnPlayStart:
20 |
21 | # retry this up to 100 times - for slow DVD-ISO play-back (100 x 0.4s = 40 seconds max)
22 | for retryCounter in range(0, 100):
23 |
24 | # set the output mode automatically
25 | setModeStatus, statusType = fsutil.setDisplayModeAuto()
26 |
27 | # video not started - wait, then retry
28 | if (setModeStatus == 'No playing video detected.'):
29 | xbmc.sleep(400)
30 |
31 | # video started - retry if FPS not yet found in log (note: wait 0.4s already in get source FPS function)
32 | else:
33 | if (setModeStatus != 'Failed to get source framerate.'):
34 | break
35 |
36 | # display notification
37 | if statusType == 'warn':
38 | fsmsg.notifyQuickWarn('Frequency Switcher', setModeStatus)
39 | else:
40 | fsmsg.notifyInfo('Frequency Switcher', setModeStatus)
41 |
42 | else:
43 | fsconfig.lastPlayedMediaType = 'audio'
44 |
45 | def onPlayBackEnded(self):
46 | self.onPlayBackEndedOrStopped()
47 |
48 | def onPlayBackStopped(self):
49 | self.onPlayBackEndedOrStopped()
50 |
51 | def onPlayBackEndedOrStopped(self):
52 |
53 | # only switch on video files (not audio)
54 | if fsconfig.lastPlayedMediaType == 'video':
55 |
56 | if fsconfig.radioOnPlayStop60 or fsconfig.radioOnPlayStop50:
57 |
58 | # check current display mode setting
59 | currentOutputMode, currentAmlogicMode = fsutil.getDisplayMode()
60 |
61 | if currentOutputMode == 'unsupported':
62 | setModeStatus = 'Unsupported resolution: ' + currentAmlogicMode
63 | statusType = 'warn'
64 |
65 | elif currentOutputMode == 'invalid':
66 | setModeStatus = 'Error, unexpected mode: ' + currentAmlogicMode
67 | statusType = 'warn'
68 |
69 | else:
70 | # get current resolution
71 | resSplit = currentOutputMode.find('-')
72 | currentRes = currentOutputMode[0:resSplit]
73 |
74 | # set the output mode
75 | if fsconfig.radioOnPlayStop60:
76 | setModeStatus, statusType = fsutil.setDisplayMode(currentRes + '-60hz')
77 | else:
78 | setModeStatus, statusType = fsutil.setDisplayMode(currentRes + '-50hz')
79 |
80 | # display notification
81 | if statusType == 'warn':
82 | fsmsg.notifyQuickWarn('Frequency Switcher', setModeStatus)
83 | else:
84 | fsmsg.notifyInfo('Frequency Switcher', setModeStatus)
85 |
86 |
--------------------------------------------------------------------------------
/script.video.fswitch/fswitch_service.py:
--------------------------------------------------------------------------------
1 | import xbmc
2 |
3 | # delay startup to improve stability
4 | xbmc.sleep(2000)
5 |
6 | import fswitch_config as fsconfig
7 | import fswitch_configutil as fsconfigutil
8 | import fswitch_player as fsplay
9 |
10 | class ServiceMain:
11 |
12 | @staticmethod
13 | def run():
14 |
15 | # load settings
16 | loadSettingsStatus = fsconfigutil.loadSettings()
17 |
18 | # check whether service should be activated
19 | if fsconfig.radioOnPlayStart:
20 |
21 | # record service as active
22 | fsconfig.activeService = True
23 | fsconfigutil.saveActiveServiceSetting()
24 |
25 | # create Player subclass
26 | fsplayer = fsplay.fsPlayer()
27 |
28 | # check for configuration changes every four seconds
29 | monitor_abort = xbmc.Monitor() # For Kodi >= 14
30 | while not monitor_abort.abortRequested() and fsconfig.radioOnPlayStart:
31 |
32 | xbmc.sleep(4000)
33 |
34 | # reload settings - to allow service stop and configuration changes without exiting XBMC
35 | fsconfig.radioOnPlayStart = fsconfigutil.useServiceFlagGet()
36 |
37 | fsconfigutil.loadServiceConfig()
38 |
39 | # check that service flagged as 'not used' is not also flagged as 'active' (can happen when clean up not run prior to reinstall)
40 | else:
41 | fsconfigutil.loadActiveServiceSetting()
42 |
43 | # service is finished - record service as not active
44 | if fsconfig.activeService:
45 |
46 | fsconfig.activeService = False
47 | fsconfigutil.saveActiveServiceSetting()
48 |
49 | # only run main function if module is running directly (i.e. not imported)
50 | if __name__ == '__main__':
51 |
52 | ServiceMain.run()
53 |
54 |
--------------------------------------------------------------------------------
/script.video.fswitch/fswitch_util.py:
--------------------------------------------------------------------------------
1 | import os
2 | import sys
3 | import platform
4 | import time
5 | import subprocess
6 | import xbmc
7 | import xbmcaddon
8 | import fswitch_config as fsconfig
9 | import fswitch_configutil as fsconfigutil
10 |
11 | def getSourceFPS():
12 | # function for getting for source frame rate from the XBMC log file
13 |
14 | # initialize constants
15 | refVideoOpen = 'NOTICE: DVDPlayer: Opening: '
16 | refVideoFPSstart = 'NOTICE: fps: '
17 | refVideoFPSend = ', pwidth: '
18 |
19 | # initialize return values
20 | videoFileName = None
21 | videoFPSValue = None
22 |
23 | # get location of log file
24 | if fsconfig.osPlatform[0:7] == 'Windows':
25 | logFileName = xbmc.translatePath('special://home\kodi.log')
26 | else:
27 | if os.path.isfile(xbmc.translatePath('special://temp/ftmc.log')):
28 | logFileName = xbmc.translatePath('special://temp/ftmc.log')
29 | elif os.path.isfile(xbmc.translatePath('special://temp/spmc.log')):
30 | logFileName = xbmc.translatePath('special://temp/spmc.log')
31 | else:
32 | logFileName = xbmc.translatePath('special://temp/kodi.log')
33 |
34 | # wait 0.40 second for log file to update (with debug on W7: 0.35 not quite long enough for some files)
35 | xbmc.sleep(400)
36 |
37 | # check osPlatform linux2 (Krypton)
38 | osPlatform, osVariant = getPlatformType()
39 |
40 | version = xbmc.getInfoLabel('system.buildversion')
41 | if version[0:2] >= "17":
42 | videoFPSValue = xbmc.getInfoLabel('Player.Process(VideoFps)')
43 | videoFileName = xbmc.Player().getPlayingFile()
44 | else:
45 | # open log file as read only
46 | with open(logFileName, 'r') as logFile:
47 |
48 | # move pointer to the EOF
49 | logFile.seek(0, 2)
50 |
51 | # get pointer location as the file size
52 | logFileSize = logFile.tell()
53 |
54 | # move pointer to 40k characters before EOF (or to BOF)
55 | logFile.seek(max(logFileSize - 40000, 0), 0)
56 |
57 | # create list of lines from pointer to EOF
58 | logFileLines = logFile.readlines()
59 |
60 | # slice list to include just the last 1000 lines (with debug on W7: 200=10sec, 600=30sec, 800=45sec, 1000=2min40sec)
61 | logFileLines = logFileLines[-1000:]
62 |
63 | # reverse the list so most recent entry is first
64 | logFileLines.reverse()
65 |
66 | # parse the list (from most recent backwards)
67 | for logFileIndex, logFileLine in enumerate(logFileLines):
68 |
69 | # find reference to video opening
70 | if refVideoOpen in logFileLine:
71 |
72 | # find start of video file name
73 | linePointer = logFileLine.find(refVideoOpen) + len(refVideoOpen)
74 |
75 | # read video file name
76 | videoFileName = logFileLine[linePointer:].rstrip('\n')
77 |
78 | # Now find the FPS
79 |
80 | # slice new list at current index
81 | logFileLines2 = logFileLines[:logFileIndex]
82 |
83 | # reverse list2 so oldest entry is first
84 | logFileLines2.reverse()
85 |
86 | # parse list2 (from video opening reference forward)
87 | for logFileLine2 in logFileLines2:
88 |
89 | # find reference to FPS
90 | if refVideoFPSstart in logFileLine2:
91 |
92 | # find start and end of FPS value
93 | linePointerStart = logFileLine2.find(refVideoFPSstart) + len(refVideoFPSstart)
94 | linePointerEnd = logFileLine2.find(refVideoFPSend)
95 |
96 | # read FPS value
97 | videoFPSValue = logFileLine2[linePointerStart:linePointerEnd]
98 |
99 | # truncate FPS to three decimal places
100 | decSplit = videoFPSValue.find('.') + 4
101 | videoFPSValue = videoFPSValue[0:decSplit]
102 |
103 | # only save FPS if not 0.000 (seen on one dvd-iso)
104 | if videoFPSValue != '0.000':
105 |
106 | # save FPS for use in setDisplayModeAuto
107 | fsconfig.lastDetectedFps = videoFPSValue
108 | fsconfig.lastDetectedFile = videoFileName
109 | fsconfigutil.saveLastDetectedFps()
110 |
111 | # found FPS - stop parsing list2
112 | break
113 |
114 | # FPS is 0.000 - treat as not found
115 | else:
116 | videoFPSValue = None
117 |
118 | # found video open and FPS (if not 0.000) - stop parsing the list
119 | break
120 |
121 | # only save FPS if not 0.000 (seen on one dvd-iso)
122 | if videoFPSValue != '0.000':
123 | # save FPS for use in setDisplayModeAuto
124 | fsconfig.lastDetectedFps = videoFPSValue
125 | fsconfig.lastDetectedFile = videoFileName
126 | fsconfigutil.saveLastDetectedFps()
127 | else:
128 | videoFPSValue = None
129 |
130 | return videoFileName, videoFPSValue
131 |
132 | def getPlatformType():
133 | # function for getting platform type
134 |
135 | osPlatform = sys.platform
136 |
137 | if osPlatform == 'win32':
138 | osVariant = platform.system() + ' ' + platform.release()
139 |
140 | elif (osPlatform[0:5] == 'linux') and os.path.isfile("/sys/class/display/mode"):
141 | try:
142 | productBrand = subprocess.Popen(['getprop', 'ro.product.brand'], stdout=subprocess.PIPE).communicate()[0].strip()
143 | productDevice = subprocess.Popen(['getprop', 'ro.product.device'], stdout=subprocess.PIPE).communicate()[0].strip()
144 | osVariant = productBrand + ' ' + productDevice
145 | except:
146 | osVariant = platform.system() + ' ' + platform.release()
147 | else:
148 | osVariant = 'unsupported'
149 |
150 | return osPlatform, osVariant
151 |
152 | def getDisplayMode():
153 | # function to read the current output mode from display/mode
154 |
155 | modeFile = None
156 | outputMode = None
157 | amlogicMode = None
158 |
159 | modeFileAndroid = "/sys/class/display/mode"
160 | modeFileWindows = "d:\\x8mode.txt"
161 |
162 | if fsconfig.osPlatform[0:7] == 'Windows':
163 | modeFile = modeFileWindows
164 | else:
165 | modeFile = modeFileAndroid
166 |
167 | # check file exists
168 | if os.path.isfile(modeFile):
169 | # check file is writable
170 | if os.access(modeFile, os.R_OK):
171 | with open(modeFile, 'r') as modeFileHandle:
172 | amlogicMode = modeFileHandle.readline().strip()
173 |
174 | # convert AMLOGIC output mode to more descriptive mode
175 | if amlogicMode == '1080p':
176 | outputMode = '1080p-60hz'
177 | elif amlogicMode == '1080p60hz':
178 | outputMode = '1080p-60hz'
179 | elif amlogicMode == '1080p50hz':
180 | outputMode = '1080p-50hz'
181 | elif amlogicMode == '1080p30hz':
182 | outputMode = '1080p-30hz'
183 | elif amlogicMode == '1080p25hz':
184 | outputMode = '1080p-25hz'
185 | elif amlogicMode == '1080p24hz':
186 | outputMode = '1080p-24hz'
187 | elif amlogicMode == '720p':
188 | outputMode = '720p-60hz'
189 | elif amlogicMode == '720p50hz':
190 | outputMode = '720p-50hz'
191 | elif amlogicMode == '2160p60hz':
192 | outputMode = '4k2k-60hz'
193 | elif amlogicMode == '2160p50hz':
194 | outputMode = '4k2k-50hz'
195 | elif amlogicMode == '2160p30hz':
196 | outputMode = '4k2k-30hz'
197 | elif amlogicMode == '2160p25hz':
198 | outputMode = '4k2k-25hz'
199 | elif amlogicMode == '2160p24hz':
200 | outputMode = '4k2k-24hz'
201 | else:
202 | outputMode = "unsupported"
203 |
204 | if amlogicMode == '':
205 | outputMode = "invalid"
206 | amlogicMode = 'Mode file read, but is empty.'
207 | else:
208 | outputMode = "invalid"
209 | amlogicMode = 'Mode file found, but could not read.'
210 | else:
211 | outputMode = "invalid"
212 | amlogicMode = 'Mode file not found.'
213 |
214 | return outputMode, amlogicMode
215 |
216 | def getDisplayModeFileStatus():
217 | # function to check that the display/mode file exists and is writable
218 |
219 | modeFile = None
220 | fileStatus = None
221 |
222 | modeFileAndroid = "/sys/class/display/mode"
223 | modeFileWindows = "d:\\x8mode.txt"
224 |
225 | if fsconfig.osPlatform[0:7] == 'Windows':
226 | modeFile = modeFileWindows
227 | else:
228 | modeFile = modeFileAndroid
229 | try:
230 | subprocess.call(["su", "root", "chmod", "666", "/sys/class/display/mode"])
231 | subprocess.call(["su", "root", "chmod", "666", "/sys/class/amhdmitx/amhdmitx0/hdcp_mode"])
232 | except:
233 | pass
234 |
235 | # check file exists
236 | if os.path.isfile(modeFile):
237 | # check file is writable
238 | if os.access(modeFile, os.W_OK):
239 | fileStatus = 'OK: Frequency switching is supported'
240 | else:
241 | fileStatus = 'HDMI mode file is read only'
242 | else:
243 | fileStatus = 'HDMI mode file not found'
244 |
245 | return modeFile, fileStatus
246 |
247 | def setDisplayMode(newOutputMode):
248 | # function to write the current output mode from display/mode
249 |
250 | # check whether display/mode file it writable
251 | modeFile, fileStatus = getDisplayModeFileStatus()
252 |
253 | # display/mode file is not writable
254 | if fileStatus[:2] != 'OK':
255 | setModeStatus = fileStatus
256 | statusType = 'warn'
257 |
258 | # display/mode file is writable
259 | else:
260 |
261 | # convert output mode to a valid AMLOGIC mode
262 | if newOutputMode == '1080p-60hz':
263 | newAmlogicMode = '1080p60hz'
264 | elif newOutputMode == '1080p-50hz':
265 | newAmlogicMode = '1080p50hz'
266 | elif newOutputMode == '1080p-30hz':
267 | newAmlogicMode = '1080p30hz'
268 | elif newOutputMode == '1080p-25hz':
269 | newAmlogicMode = '1080p25hz'
270 | elif newOutputMode == '1080p-24hz':
271 | newAmlogicMode = '1080p24hz'
272 | elif newOutputMode == '720p-60hz':
273 | newAmlogicMode = '720p'
274 | elif newOutputMode == '720p-50hz':
275 | newAmlogicMode = '720p50hz'
276 | elif newOutputMode == '4k2k-60hz':
277 | newAmlogicMode = '2160p60hz'
278 | elif newOutputMode == '4k2k-50hz':
279 | newAmlogicMode = '2160p50hz'
280 | elif newOutputMode == '4k2k-30hz':
281 | newAmlogicMode = '2160p30hz'
282 | elif newOutputMode == '4k2k-25hz':
283 | newAmlogicMode = '2160p25hz'
284 | elif newOutputMode == '4k2k-24hz':
285 | newAmlogicMode = '2160p24hz'
286 | else:
287 | setModeStatus = 'Unsupported mode requested.'
288 | statusType = 'warn'
289 | return setModeStatus, statusType
290 |
291 | # check current display mode setting
292 | currentOutputMode, currentAmlogicMode = getDisplayMode()
293 |
294 | # get current resolution
295 | resSplit = currentOutputMode.find('-')
296 | currentRes = currentOutputMode[0:resSplit]
297 |
298 | # get new resolution
299 | resSplit = newOutputMode.find('-')
300 | newRes = newOutputMode[0:resSplit]
301 |
302 | # get new frequency
303 | freqSplit = newOutputMode.find('-') + 1
304 | newFreq = newOutputMode[freqSplit:len(newOutputMode)]
305 |
306 | # current output mode is the same as new output mode
307 | if currentOutputMode == newOutputMode:
308 | setModeStatus = 'Frequency already set to ' + newFreq
309 | statusType = 'warn'
310 |
311 | # current output mode is different to new output mode
312 | else:
313 |
314 | # new resolution is different to current resolution
315 | if newRes != currentRes:
316 | setModeStatus = 'Resolution changed, please reconfigure'
317 | statusType = 'warn'
318 |
319 | # new resolution is the same as the current resolution
320 | else:
321 | fsconfigutil.loadLastFreqChangeSetting()
322 |
323 | # check that at least 4 seconds has elapsed since the last frequency change
324 | secToNextFreqChange = 4 - (int(time.time()) - fsconfig.lastFreqChange)
325 | if secToNextFreqChange > 1:
326 | setModeStatus = 'Stand-down ' + str(secToNextFreqChange) + ' seconds'
327 | statusType = 'warn'
328 | elif secToNextFreqChange == 1:
329 | setModeStatus = 'Stand-down ' + str(secToNextFreqChange) + ' second'
330 | statusType = 'warn'
331 |
332 | # more than 4 seconds has elapsed since the last frequency change
333 | else:
334 | # set new display mode
335 | with open(modeFile, 'w') as modeFileHandle:
336 | modeFileHandle.write(newAmlogicMode)
337 |
338 | # save time display mode was changed
339 | fsconfig.lastFreqChange = int(time.time())
340 | fsconfigutil.saveLastFreqChangeSetting()
341 |
342 | setModeStatus = 'Frequency changed to ' + newFreq
343 | statusType = 'info'
344 |
345 | try:
346 | with open("/sys/class/amhdmitx/amhdmitx0/hdcp_mode", 'w') as modeFileamhdmitx:
347 | modeFileamhdmitx.write('11')
348 | except:
349 | pass
350 |
351 | return setModeStatus, statusType
352 |
353 | def getCurrentFPS():
354 |
355 | # get currently playing video
356 | videoFileNamePlay = getPlayingVideo()
357 |
358 | # playing video not detected
359 | if videoFileNamePlay is None:
360 | setModeStatus = 'No playing video detected.'
361 | statusType = 'warn'
362 |
363 | # playing video detected
364 | else:
365 |
366 | # check last detected info (before reading the log file)
367 | fsconfigutil.loadLastDetectedFps()
368 |
369 | # last detected file name matches currently playing video, so use last detected FPS
370 | if fsconfig.lastDetectedFile == videoFileNamePlay:
371 | videoFileNameLog = fsconfig.lastDetectedFile
372 | videoFPSValue = fsconfig.lastDetectedFps
373 |
374 | # FPS not stored as last detected FPS
375 | else:
376 | # read FPS from XBMC log
377 | videoFileNameLog, videoFPSValue = getSourceFPS()
378 |
379 | # FPS not detected
380 | if videoFPSValue is None:
381 | setModeStatus = 'Failed to get source framerate.'
382 | statusType = 'warn'
383 |
384 | # FPS detected
385 | else:
386 | # log file name doesn't match currently playing video
387 | if videoFileNameLog != videoFileNamePlay:
388 | setModeStatus = 'Found source framerate for wrong video file.'
389 | statusType = 'warn'
390 |
391 | # log file name matches currently playing video
392 | else:
393 | setModeStatus = videoFPSValue
394 | statusType = 'ok'
395 |
396 | return setModeStatus, statusType
397 |
398 | def setDisplayModeAuto():
399 | # function to write the current output mode based on FPS to Frequency configuration
400 |
401 | # check current display mode setting
402 | currentOutputMode, currentAmlogicMode = getDisplayMode()
403 |
404 | if currentOutputMode == 'unsupported':
405 | setModeStatus = 'Unsupported resolution: ' + currentAmlogicMode
406 | statusType = 'warn'
407 |
408 | elif currentOutputMode == 'invalid':
409 | setModeStatus = 'Error, unexpected mode: ' + currentAmlogicMode
410 | statusType = 'warn'
411 |
412 | else:
413 | # load auto sync settings
414 | fsconfigutil.loadAutoSyncSettings()
415 |
416 | # get current resolution
417 | resSplit = currentOutputMode.find('-')
418 | currentRes = currentOutputMode[0:resSplit]
419 |
420 | mode60hz = currentRes + '-60hz'
421 | mode50hz = currentRes + '-50hz'
422 | mode30hz = currentRes + '-30hz'
423 | mode25hz = currentRes + '-25hz'
424 | mode24hz = currentRes + '-24hz'
425 |
426 | autoSync = []
427 |
428 | syncConfig = []
429 | if fsconfig.radioAuto60hz:
430 | syncConfig.extend([(fsconfig.edit60hzFps1, mode60hz),
431 | (fsconfig.edit60hzFps2, mode60hz),
432 | (fsconfig.edit60hzFps3, mode60hz),
433 | (fsconfig.edit60hzFps4, mode60hz)])
434 |
435 | if fsconfig.radioAuto50hz:
436 | syncConfig.extend([(fsconfig.edit50hzFps1, mode50hz),
437 | (fsconfig.edit50hzFps2, mode50hz),
438 | (fsconfig.edit50hzFps3, mode50hz),
439 | (fsconfig.edit50hzFps4, mode50hz)])
440 |
441 | if fsconfig.radioAuto30hz:
442 | syncConfig.extend([(fsconfig.edit30hzFps1, mode30hz),
443 | (fsconfig.edit30hzFps2, mode30hz),
444 | (fsconfig.edit30hzFps3, mode30hz),
445 | (fsconfig.edit30hzFps4, mode30hz)])
446 |
447 | if fsconfig.radioAuto25hz:
448 | syncConfig.extend([(fsconfig.edit25hzFps1, mode25hz),
449 | (fsconfig.edit25hzFps2, mode25hz),
450 | (fsconfig.edit25hzFps3, mode25hz),
451 | (fsconfig.edit25hzFps4, mode25hz)])
452 |
453 | if fsconfig.radioAuto24hz:
454 | syncConfig.extend([(fsconfig.edit24hzFps1, mode24hz),
455 | (fsconfig.edit24hzFps2, mode24hz),
456 | (fsconfig.edit24hzFps3, mode24hz),
457 | (fsconfig.edit24hzFps4, mode24hz)])
458 |
459 | # build auto sync list
460 | for (syncFPS, syncMode) in syncConfig:
461 | if syncFPS != '':
462 | autoSync.insert(0, (syncFPS, syncMode))
463 |
464 | if not autoSync:
465 | setModeStatus = 'No FPS to frequency configuration defined'
466 | statusType = 'warn'
467 |
468 | else:
469 |
470 | # get FPS of currently playing video
471 | setModeStatus, statusType = getCurrentFPS()
472 |
473 | if statusType == 'ok':
474 | videoFPSValue = setModeStatus
475 |
476 | # search auto sync list for FPS
477 | fpsFoundInSyncList = False
478 | for (syncFPS, syncFreq) in autoSync:
479 | if syncFPS == videoFPSValue:
480 | fpsFoundInSyncList = True
481 | break
482 |
483 | # FPS not found configured in auto sync list
484 | if not fpsFoundInSyncList:
485 | setModeStatus = 'Source framerate not configured: ' + videoFPSValue
486 | statusType = 'warn'
487 |
488 | # FPS found in auto sync list
489 | else:
490 |
491 | # check for unsupported mode '720p-24hz'
492 | if syncFreq == '720p-24hz':
493 | setModeStatus = syncFreq + ' is not supported'
494 | statusType = 'warn'
495 |
496 | else:
497 | # set the output mode
498 | setModeStatus, statusType = setDisplayMode(syncFreq)
499 |
500 | return setModeStatus, statusType
501 |
502 | def mapKey(keyScope, keyMappings):
503 | # function for saving key mappings - rewrites entire zswitch.xml file
504 |
505 | # build key map
506 | mapStart = '<' + keyScope + '>'
507 | keyStart = 'runaddon(script.frequency.switcher,'
509 | keyEnd = ')'
510 | mapEnd = ''
511 |
512 | keyMap = mapStart
513 | for (keyCode, keyFunction) in keyMappings:
514 | keyMap = keyMap + keyStart + keyCode + keyMiddle + keyFunction + keyEnd
515 | keyMap = keyMap + mapEnd
516 |
517 | # key map file
518 | keymapFolder = xbmc.translatePath('special://userdata/keymaps')
519 | keymapFile = os.path.join(keymapFolder, 'zswitch.xml')
520 |
521 | # create keymap folder if it doesn't already exist
522 | if not os.path.exists(keymapFolder):
523 | os.makedirs(keymapFolder)
524 |
525 | # create or overwrite keymap file
526 | try:
527 | with open(keymapFile, 'w') as keymapFileHandle:
528 | keymapFileHandle.write(keyMap)
529 | mapKeyStatus = 'Keys activated'
530 | except Exception:
531 | mapKeyStatus = 'Failed to activate keys'
532 |
533 | # load updated key maps
534 | xbmc.executebuiltin('action(reloadkeymaps)')
535 |
536 | return mapKeyStatus
537 |
538 | def mapKeyReset():
539 |
540 | # key map file
541 | keymapFolder = xbmc.translatePath('special://userdata/keymaps')
542 | keymapFile = os.path.join(keymapFolder, 'zswitch.xml')
543 |
544 | # check file exists
545 | if not os.path.isfile(keymapFile):
546 | mapKeyResetStatus = 'No keys currently active'
547 | return mapKeyResetStatus
548 |
549 | # delete key map file
550 | try:
551 | os.remove(keymapFile)
552 | mapKeyResetStatus = 'Keys deactivated'
553 | except Exception:
554 | mapKeyResetStatus = 'Failed to deactivate keys'
555 |
556 | # load updated key maps
557 | xbmc.executebuiltin('action(reloadkeymaps)')
558 |
559 | return mapKeyResetStatus
560 |
561 | def mapKeyActive():
562 |
563 | # key map file
564 | keymapFolder = xbmc.translatePath('special://userdata/keymaps')
565 | keymapFile = os.path.join(keymapFolder, 'zswitch.xml')
566 |
567 | # check file exists
568 | return os.path.isfile(keymapFile)
569 |
570 | def getPlayingVideo():
571 | # function to get the file name of the currently playing video
572 |
573 | if xbmc.Player().isPlayingVideo():
574 | videoFileName = xbmc.Player().getPlayingFile()
575 | else:
576 | videoFileName = None
577 |
578 | return videoFileName
579 |
--------------------------------------------------------------------------------
/script.video.fswitch/fswitch_window.py:
--------------------------------------------------------------------------------
1 | import xbmc
2 | import xbmcgui
3 | import os
4 | import fswitch_config as fsconfig
5 | import fswitch_configutil as fsconfigutil
6 | import fswitch_util as fsutil
7 | import fswitch_keylisten as fskeylisten
8 |
9 | from pyxbmct.addonwindow import *
10 |
11 | class MapKeysWindow(AddonDialogWindow):
12 |
13 | def __init__(self, title=''):
14 | # base class constructor
15 | super(MapKeysWindow, self).__init__(title)
16 |
17 | # set window width + height, and grid rows + columns
18 | self.setGeometry(750, 650, 12, 13)
19 |
20 | # create, place, then set objects
21 | self.labelCurrentRes = Label('', alignment=ALIGN_LEFT)
22 | self.placeControl(self.labelCurrentRes, 1, 1, columnspan=10, pad_y=11)
23 |
24 | self.radio60hz = RadioButton('60 hz')
25 | self.placeControl(self.radio60hz, 2, 1, columnspan=3)
26 | self.radio60hz.setSelected(fsconfig.radio60hz)
27 |
28 | self.radio50hz = RadioButton('50 hz')
29 | self.placeControl(self.radio50hz, 3, 1, columnspan=3)
30 | self.radio50hz.setSelected(fsconfig.radio50hz)
31 |
32 | self.radio30hz = RadioButton('30 hz')
33 | self.placeControl(self.radio30hz, 4, 1, columnspan=3)
34 | self.radio30hz.setSelected(fsconfig.radio30hz)
35 |
36 | self.radio25hz = RadioButton('25 hz')
37 | self.placeControl(self.radio25hz, 5, 1, columnspan=3)
38 | self.radio25hz.setSelected(fsconfig.radio25hz)
39 |
40 | self.radio24hz = RadioButton('24 hz')
41 | self.placeControl(self.radio24hz, 6, 1, columnspan=3)
42 | self.radio24hz.setSelected(fsconfig.radio24hz)
43 |
44 | self.radioAuto = RadioButton('Automatic')
45 | self.placeControl(self.radioAuto, 7, 1, columnspan=3)
46 | self.radioAuto.setSelected(fsconfig.radioAuto)
47 |
48 | self.radioInfo = RadioButton('Info.')
49 | self.placeControl(self.radioInfo, 8, 1, columnspan=3)
50 | self.radioInfo.setSelected(fsconfig.radioInfo)
51 |
52 | self.buttonMap60hz = Button('Select Key')
53 | self.placeControl(self.buttonMap60hz, 2, 7, columnspan=3)
54 |
55 | self.buttonMap50hz = Button('Select Key')
56 | self.placeControl(self.buttonMap50hz, 3, 7, columnspan=3)
57 |
58 | self.buttonMap30hz = Button('Select Key')
59 | self.placeControl(self.buttonMap30hz, 4, 7, columnspan=3)
60 |
61 | self.buttonMap25hz = Button('Select Key')
62 | self.placeControl(self.buttonMap25hz, 5, 7, columnspan=3)
63 |
64 | self.buttonMap24hz = Button('Select Key')
65 | self.placeControl(self.buttonMap24hz, 6, 7, columnspan=3)
66 |
67 | self.buttonMapAuto = Button('Select Key')
68 | self.placeControl(self.buttonMapAuto, 7, 7, columnspan=3)
69 |
70 | self.buttonMapInfo = Button('Select Key')
71 | self.placeControl(self.buttonMapInfo, 8, 7, columnspan=3)
72 |
73 | self.labelKey60hz = Label('')
74 | self.placeControl(self.labelKey60hz, 2, 5, columnspan=2, pad_y=11)
75 | self.labelKey60hz.setLabel(fsconfig.key60hz)
76 |
77 | self.labelKey50hz = Label('')
78 | self.placeControl(self.labelKey50hz, 3, 5, columnspan=2, pad_y=11)
79 | self.labelKey50hz.setLabel(fsconfig.key50hz)
80 |
81 | self.labelKey30hz = Label('')
82 | self.placeControl(self.labelKey30hz, 4, 5, columnspan=2, pad_y=11)
83 | self.labelKey30hz.setLabel(fsconfig.key30hz)
84 |
85 | self.labelKey25hz = Label('')
86 | self.placeControl(self.labelKey25hz, 5, 5, columnspan=2, pad_y=11)
87 | self.labelKey25hz.setLabel(fsconfig.key25hz)
88 |
89 | self.labelKey24hz = Label('')
90 | self.placeControl(self.labelKey24hz, 6, 5, columnspan=2, pad_y=11)
91 | self.labelKey24hz.setLabel(fsconfig.key24hz)
92 |
93 | self.labelKeyAuto = Label('')
94 | self.placeControl(self.labelKeyAuto, 7, 5, columnspan=2, pad_y=11)
95 | self.labelKeyAuto.setLabel(fsconfig.keyAuto)
96 |
97 | self.labelKeyInfo = Label('')
98 | self.placeControl(self.labelKeyInfo, 8, 5, columnspan=2, pad_y=11)
99 | self.labelKeyInfo.setLabel(fsconfig.keyInfo)
100 |
101 | self.buttonMapKeysSave = Button('Activate Keys')
102 | self.placeControl(self.buttonMapKeysSave, 10, 1, columnspan=4)
103 |
104 | self.buttonMapKeysReset = Button('Deactivate Keys')
105 | self.placeControl(self.buttonMapKeysReset, 11, 1, columnspan=4)
106 |
107 | self.checkKeyMap()
108 |
109 | self.labelStatus60hz = Label('')
110 | self.placeControl(self.labelStatus60hz, 2, 11, columnspan=2, pad_y=11)
111 | self.labelStatus60hz.setLabel(fsconfig.status60hz)
112 |
113 | self.labelStatus50hz = Label('')
114 | self.placeControl(self.labelStatus50hz, 3, 11, columnspan=2, pad_y=11)
115 | self.labelStatus50hz.setLabel(fsconfig.status50hz)
116 |
117 | self.labelStatus30hz = Label('')
118 | self.placeControl(self.labelStatus30hz, 4, 11, columnspan=2, pad_y=11)
119 | self.labelStatus30hz.setLabel(fsconfig.status30hz)
120 |
121 | self.labelStatus25hz = Label('')
122 | self.placeControl(self.labelStatus25hz, 5, 11, columnspan=2, pad_y=11)
123 | self.labelStatus25hz.setLabel(fsconfig.status25hz)
124 |
125 | self.labelStatus24hz = Label('')
126 | self.placeControl(self.labelStatus24hz, 6, 11, columnspan=2, pad_y=11)
127 | self.labelStatus24hz.setLabel(fsconfig.status24hz)
128 |
129 | self.labelStatusAuto = Label('')
130 | self.placeControl(self.labelStatusAuto, 7, 11, columnspan=2, pad_y=11)
131 | self.labelStatusAuto.setLabel(fsconfig.statusAuto)
132 |
133 | self.labelStatusInfo = Label('')
134 | self.placeControl(self.labelStatusInfo, 8, 11, columnspan=2, pad_y=11)
135 | self.labelStatusInfo.setLabel(fsconfig.statusInfo)
136 |
137 | self.labelInfoTitle = Label('', alignment=ALIGN_LEFT)
138 | self.placeControl(self.labelInfoTitle, 10, 6, columnspan=8, pad_y=11)
139 |
140 | self.labelInfoText = Label('', alignment=ALIGN_LEFT)
141 | self.placeControl(self.labelInfoText, 11, 6, columnspan=8, pad_y=11)
142 |
143 | # connect buttons and actions to functions
144 | self.connect(self.radio60hz, self.clickRadio60hz)
145 | self.connect(self.radio50hz, self.clickRadio50hz)
146 | self.connect(self.radio30hz, self.clickRadio30hz)
147 | self.connect(self.radio25hz, self.clickRadio25hz)
148 | self.connect(self.radio24hz, self.clickRadio24hz)
149 | self.connect(self.radioAuto, self.clickRadioAuto)
150 | self.connect(self.radioInfo, self.clickRadioInfo)
151 | self.connect(self.buttonMap60hz, self.clickButtonMap60hz)
152 | self.connect(self.buttonMap50hz, self.clickButtonMap50hz)
153 | self.connect(self.buttonMap30hz, self.clickButtonMap30hz)
154 | self.connect(self.buttonMap25hz, self.clickButtonMap25hz)
155 | self.connect(self.buttonMap24hz, self.clickButtonMap24hz)
156 | self.connect(self.buttonMapAuto, self.clickButtonMapAuto)
157 | self.connect(self.buttonMapInfo, self.clickButtonMapInfo)
158 | self.connect(self.buttonMapKeysSave, self.clickMapKeysSave)
159 | self.connect(self.buttonMapKeysReset, self.clickMapKeysReset)
160 | self.connect(ACTION_NAV_BACK, self.close)
161 |
162 | # set the enabled state of objects
163 | self.atSetup = True
164 | self.clickRadio60hz()
165 | self.clickRadio50hz()
166 | self.clickRadio30hz()
167 | self.clickRadio25hz()
168 | self.clickRadio24hz()
169 | self.clickRadioAuto()
170 | self.clickRadioInfo()
171 | self.atSetup = False
172 |
173 | # check current display mode setting
174 | currentOutputMode, currentAmlogicMode = fsutil.getDisplayMode()
175 |
176 | if currentOutputMode == 'unsupported':
177 | self.labelCurrentRes.setLabel('Unsupported resolution: ' + currentAmlogicMode)
178 | self.disableAll()
179 |
180 | elif currentOutputMode == 'invalid':
181 | self.labelCurrentRes.setLabel('Error: ' + currentAmlogicMode)
182 | self.disableAll()
183 |
184 | else:
185 | # get current resolution
186 | resSplit = currentOutputMode.find('-')
187 | self.currentRes = currentOutputMode[0:resSplit]
188 | self.labelCurrentRes.setLabel('Current resolution: ' + self.currentRes)
189 |
190 | if self.currentRes == '720p':
191 | self.disable24hz()
192 |
193 | # check whether res has changed since KeyMap was last saved
194 | if (self.currentRes != fsconfig.keymapRes) and (fsconfig.keymapRes != ''):
195 | self.labelCurrentRes.setLabel('Current resolution: ' + self.currentRes + ' (active resolution was ' + fsconfig.keymapRes + ')')
196 | self.clickMapKeysReset()
197 |
198 | # define key navigation (up-down)
199 | self.radio60hz.controlDown(self.radio50hz)
200 | self.radio50hz.controlUp(self.radio60hz)
201 | self.radio50hz.controlDown(self.radio30hz)
202 | self.radio30hz.controlUp(self.radio50hz)
203 | self.radio30hz.controlDown(self.radio25hz)
204 | self.radio25hz.controlUp(self.radio30hz)
205 | self.radio25hz.controlDown(self.radio24hz)
206 | self.radio24hz.controlUp(self.radio25hz)
207 | self.radio24hz.controlDown(self.radioAuto)
208 | self.radioAuto.controlUp(self.radio24hz)
209 | self.radioAuto.controlDown(self.radioInfo)
210 | self.radioInfo.controlUp(self.radioAuto)
211 | self.radioInfo.controlDown(self.buttonMapKeysSave)
212 | self.buttonMapKeysSave.controlUp(self.radioInfo)
213 | self.buttonMapKeysSave.controlDown(self.buttonMapKeysReset)
214 | self.buttonMapKeysReset.controlUp(self.buttonMapKeysSave)
215 |
216 | self.buttonMap60hz.controlDown(self.buttonMap50hz)
217 | self.buttonMap50hz.controlUp(self.buttonMap60hz)
218 | self.buttonMap50hz.controlDown(self.buttonMap30hz)
219 | self.buttonMap30hz.controlUp(self.buttonMap50hz)
220 | self.buttonMap30hz.controlDown(self.buttonMap25hz)
221 | self.buttonMap25hz.controlUp(self.buttonMap30hz)
222 | self.buttonMap25hz.controlDown(self.buttonMap24hz)
223 | self.buttonMap24hz.controlUp(self.buttonMap50hz)
224 | self.buttonMap24hz.controlDown(self.buttonMapAuto)
225 | self.buttonMapAuto.controlUp(self.buttonMap24hz)
226 | self.buttonMapAuto.controlDown(self.buttonMapInfo)
227 | self.buttonMapInfo.controlUp(self.buttonMapAuto)
228 | self.buttonMapInfo.controlDown(self.buttonMapKeysSave)
229 |
230 | # define key navigation (left-right)
231 | self.radio60hz.controlRight(self.buttonMap60hz)
232 | self.buttonMap60hz.controlLeft(self.radio60hz)
233 | self.radio50hz.controlRight(self.buttonMap50hz)
234 | self.buttonMap50hz.controlLeft(self.radio50hz)
235 | self.radio30hz.controlRight(self.buttonMap30hz)
236 | self.buttonMap30hz.controlLeft(self.radio30hz)
237 | self.radio25hz.controlRight(self.buttonMap25hz)
238 | self.buttonMap25hz.controlLeft(self.radio25hz)
239 | self.radio24hz.controlRight(self.buttonMap24hz)
240 | self.buttonMap24hz.controlLeft(self.radio24hz)
241 | self.radioAuto.controlRight(self.buttonMapAuto)
242 | self.buttonMapAuto.controlLeft(self.radioAuto)
243 | self.radioInfo.controlRight(self.buttonMapInfo)
244 | self.buttonMapInfo.controlLeft(self.radioInfo)
245 |
246 | # set initial focus
247 | self.setFocus(self.radio60hz)
248 |
249 | def disable24hz(self):
250 |
251 | self.radio24hz.setEnabled(False)
252 | self.buttonMap24hz.setEnabled(False)
253 | self.labelKey24hz.setEnabled(False)
254 |
255 | def disableAll(self):
256 |
257 | self.radio60hz.setEnabled(False)
258 | self.buttonMap60hz.setEnabled(False)
259 | self.labelKey60hz.setEnabled(False)
260 |
261 | self.radio50hz.setEnabled(False)
262 | self.buttonMap50hz.setEnabled(False)
263 | self.labelKey50hz.setEnabled(False)
264 |
265 | self.radio30hz.setEnabled(False)
266 | self.buttonMap30hz.setEnabled(False)
267 | self.labelKey30hz.setEnabled(False)
268 |
269 | self.radio25hz.setEnabled(False)
270 | self.buttonMap25hz.setEnabled(False)
271 | self.labelKey25hz.setEnabled(False)
272 |
273 | self.radio24hz.setEnabled(False)
274 | self.buttonMap24hz.setEnabled(False)
275 | self.labelKey24hz.setEnabled(False)
276 |
277 | self.radioAuto.setEnabled(False)
278 | self.buttonMapAuto.setEnabled(False)
279 | self.labelKeyAuto.setEnabled(False)
280 |
281 | self.radioInfo.setEnabled(False)
282 | self.buttonMapInfo.setEnabled(False)
283 | self.labelKeyInfo.setEnabled(False)
284 |
285 | self.buttonMapKeysSave.setEnabled(False)
286 | self.buttonMapKeysReset.setEnabled(False)
287 |
288 | self.clickMapKeysReset()
289 |
290 | def clickRadio60hz(self):
291 |
292 | if self.radio60hz.isSelected():
293 | self.buttonMap60hz.setEnabled(True)
294 | self.labelKey60hz.setEnabled(True)
295 | else:
296 | self.buttonMap60hz.setEnabled(False)
297 | self.labelKey60hz.setEnabled(False)
298 |
299 | if not self.atSetup:
300 | self.clickMapKeysReset()
301 |
302 | def clickRadio50hz(self):
303 |
304 | if self.radio50hz.isSelected():
305 | self.buttonMap50hz.setEnabled(True)
306 | self.labelKey50hz.setEnabled(True)
307 | else:
308 | self.buttonMap50hz.setEnabled(False)
309 | self.labelKey50hz.setEnabled(False)
310 |
311 | if not self.atSetup:
312 | self.clickMapKeysReset()
313 |
314 | def clickRadio30hz(self):
315 |
316 | if self.radio30hz.isSelected():
317 | self.buttonMap30hz.setEnabled(True)
318 | self.labelKey30hz.setEnabled(True)
319 | else:
320 | self.buttonMap30hz.setEnabled(False)
321 | self.labelKey30hz.setEnabled(False)
322 |
323 | if not self.atSetup:
324 | self.clickMapKeysReset()
325 |
326 | def clickRadio25hz(self):
327 |
328 | if self.radio25hz.isSelected():
329 | self.buttonMap25hz.setEnabled(True)
330 | self.labelKey25hz.setEnabled(True)
331 | else:
332 | self.buttonMap25hz.setEnabled(False)
333 | self.labelKey25hz.setEnabled(False)
334 |
335 | if not self.atSetup:
336 | self.clickMapKeysReset()
337 |
338 | def clickRadio24hz(self):
339 |
340 | if self.radio24hz.isSelected():
341 | self.buttonMap24hz.setEnabled(True)
342 | self.labelKey24hz.setEnabled(True)
343 | else:
344 | self.buttonMap24hz.setEnabled(False)
345 | self.labelKey24hz.setEnabled(False)
346 |
347 | if not self.atSetup:
348 | self.clickMapKeysReset()
349 |
350 | def clickRadioAuto(self):
351 |
352 | if self.radioAuto.isSelected():
353 | self.buttonMapAuto.setEnabled(True)
354 | self.labelKeyAuto.setEnabled(True)
355 | else:
356 | self.buttonMapAuto.setEnabled(False)
357 | self.labelKeyAuto.setEnabled(False)
358 |
359 | if not self.atSetup:
360 | self.clickMapKeysReset()
361 |
362 | def clickRadioInfo(self):
363 |
364 | if self.radioInfo.isSelected():
365 | self.buttonMapInfo.setEnabled(True)
366 | self.labelKeyInfo.setEnabled(True)
367 | else:
368 | self.buttonMapInfo.setEnabled(False)
369 | self.labelKeyInfo.setEnabled(False)
370 |
371 | if not self.atSetup:
372 | self.clickMapKeysReset()
373 |
374 | def clickButtonMap60hz(self):
375 |
376 | self.clickMapKeysReset()
377 |
378 | keyPressed = fskeylisten.KeyListener.getKeyPressed()
379 |
380 | if keyPressed is not None:
381 | self.labelKey60hz.setLabel(str(keyPressed))
382 | self.removeDupeKey(keyPressed, '60hz')
383 |
384 | def clickButtonMap50hz(self):
385 |
386 | self.clickMapKeysReset()
387 |
388 | keyPressed = fskeylisten.KeyListener.getKeyPressed()
389 |
390 | if keyPressed is not None:
391 | self.labelKey50hz.setLabel(str(keyPressed))
392 | self.removeDupeKey(keyPressed, '50hz')
393 |
394 | def clickButtonMap30hz(self):
395 |
396 | self.clickMapKeysReset()
397 |
398 | keyPressed = fskeylisten.KeyListener.getKeyPressed()
399 |
400 | if keyPressed is not None:
401 | self.labelKey30hz.setLabel(str(keyPressed))
402 | self.removeDupeKey(keyPressed, '30hz')
403 |
404 | def clickButtonMap25hz(self):
405 |
406 | self.clickMapKeysReset()
407 |
408 | keyPressed = fskeylisten.KeyListener.getKeyPressed()
409 |
410 | if keyPressed is not None:
411 | self.labelKey25hz.setLabel(str(keyPressed))
412 | self.removeDupeKey(keyPressed, '25hz')
413 |
414 | def clickButtonMap24hz(self):
415 |
416 | self.clickMapKeysReset()
417 |
418 | keyPressed = fskeylisten.KeyListener.getKeyPressed()
419 |
420 | if keyPressed is not None:
421 | self.labelKey24hz.setLabel(str(keyPressed))
422 | self.removeDupeKey(keyPressed, '24hz')
423 |
424 | def clickButtonMapAuto(self):
425 |
426 | self.clickMapKeysReset()
427 |
428 | keyPressed = fskeylisten.KeyListener.getKeyPressed()
429 |
430 | if keyPressed is not None:
431 | self.labelKeyAuto.setLabel(str(keyPressed))
432 | self.removeDupeKey(keyPressed, 'Auto')
433 |
434 | def clickButtonMapInfo(self):
435 |
436 | self.clickMapKeysReset()
437 |
438 | keyPressed = fskeylisten.KeyListener.getKeyPressed()
439 |
440 | if keyPressed is not None:
441 | self.labelKeyInfo.setLabel(str(keyPressed))
442 | self.removeDupeKey(keyPressed, 'Info')
443 |
444 | def removeDupeKey(self, keyPressed, mappedAction):
445 |
446 | if (self.labelKey60hz.getLabel() == keyPressed) and (mappedAction != '60hz'):
447 | self.labelKey60hz.setLabel('')
448 |
449 | if (self.labelKey50hz.getLabel() == keyPressed) and (mappedAction != '50hz'):
450 | self.labelKey50hz.setLabel('')
451 |
452 | if (self.labelKey30hz.getLabel() == keyPressed) and (mappedAction != '30hz'):
453 | self.labelKey30hz.setLabel('')
454 |
455 | if (self.labelKey25hz.getLabel() == keyPressed) and (mappedAction != '25hz'):
456 | self.labelKey25hz.setLabel('')
457 |
458 | if (self.labelKey24hz.getLabel() == keyPressed) and (mappedAction != '24hz'):
459 | self.labelKey24hz.setLabel('')
460 |
461 | if (self.labelKeyAuto.getLabel() == keyPressed) and (mappedAction != 'Auto'):
462 | self.labelKeyAuto.setLabel('')
463 |
464 | if (self.labelKeyInfo.getLabel() == keyPressed) and (mappedAction != 'Info'):
465 | self.labelKeyInfo.setLabel('')
466 |
467 | def clickMapKeysSave(self):
468 |
469 | self.labelInfoTitle.setLabel('Keys activating...')
470 | self.labelInfoText.setLabel('Saving settings...')
471 | xbmc.sleep(600)
472 |
473 | actionRes = self.currentRes
474 |
475 | keyMappings = []
476 |
477 | if self.radio60hz.isSelected():
478 | if self.labelKey60hz.getLabel() != '':
479 | keyMappings.insert(0, (self.labelKey60hz.getLabel(), actionRes + '-60hz'))
480 | self.labelStatus60hz.setLabel('Active')
481 |
482 | if self.radio50hz.isSelected():
483 | if self.labelKey50hz.getLabel() != '':
484 | keyMappings.insert(0, (self.labelKey50hz.getLabel(), actionRes + '-50hz'))
485 | self.labelStatus50hz.setLabel('Active')
486 |
487 | if self.radio30hz.isSelected():
488 | if self.labelKey30hz.getLabel() != '':
489 | keyMappings.insert(0, (self.labelKey30hz.getLabel(), actionRes + '-30hz'))
490 | self.labelStatus30hz.setLabel('Active')
491 |
492 | if self.radio25hz.isSelected():
493 | if self.labelKey25hz.getLabel() != '':
494 | keyMappings.insert(0, (self.labelKey25hz.getLabel(), actionRes + '-25hz'))
495 | self.labelStatus25hz.setLabel('Active')
496 |
497 | if self.radio24hz.isSelected() and (actionRes == '1080p'):
498 | if self.labelKey24hz.getLabel() != '':
499 | keyMappings.insert(0, (self.labelKey24hz.getLabel(), actionRes + '-24hz'))
500 | self.labelStatus24hz.setLabel('Active')
501 |
502 | if self.radioAuto.isSelected():
503 | if self.labelKeyAuto.getLabel() != '':
504 | keyMappings.insert(0, (self.labelKeyAuto.getLabel(), 'auto'))
505 | self.labelStatusAuto.setLabel('Active')
506 |
507 | if self.radioInfo.isSelected():
508 | if self.labelKeyInfo.getLabel() != '':
509 | keyMappings.insert(0, (self.labelKeyInfo.getLabel(), 'info'))
510 | self.labelStatusInfo.setLabel('Active')
511 |
512 | keyScope = 'global'
513 |
514 | if not keyMappings:
515 | mapKeyStatus = "No active keys defined"
516 | else:
517 | mapKeyStatus = fsutil.mapKey(keyScope, keyMappings)
518 | self.buttonMapKeysReset.setEnabled(True)
519 |
520 | self.labelInfoTitle.setLabel(mapKeyStatus)
521 | xbmc.sleep(600)
522 |
523 | self.saveAllSettings()
524 |
525 | def clickMapKeysReset(self):
526 |
527 | if not fsutil.mapKeyActive():
528 | self.labelInfoTitle.setLabel('')
529 | self.labelInfoText.setLabel('')
530 | else:
531 | self.labelInfoTitle.setLabel('Keys deactivating...')
532 | self.labelInfoText.setLabel('')
533 | xbmc.sleep(600)
534 |
535 | self.labelStatus60hz.setLabel('')
536 | self.labelStatus50hz.setLabel('')
537 | self.labelStatus30hz.setLabel('')
538 | self.labelStatus25hz.setLabel('')
539 | self.labelStatus24hz.setLabel('')
540 | self.labelStatusAuto.setLabel('')
541 | self.labelStatusInfo.setLabel('')
542 |
543 | mapKeyResetStatus = fsutil.mapKeyReset()
544 |
545 | self.labelInfoTitle.setLabel(mapKeyResetStatus)
546 | xbmc.sleep(600)
547 |
548 | self.saveStatusSettings()
549 |
550 | self.buttonMapKeysReset.setEnabled(False)
551 |
552 | def checkKeyMap(self):
553 |
554 | # check whether keymap has been deleted or renamed by another add-on (e.g Keymap Editor)
555 | if not fsutil.mapKeyActive():
556 |
557 | # reload key maps
558 | xbmc.executebuiltin('action(reloadkeymaps)')
559 |
560 | fsconfig.status60hz = ''
561 | fsconfig.status50hz = ''
562 | fsconfig.status30hz = ''
563 | fsconfig.status25hz = ''
564 | fsconfig.status24hz = ''
565 | fsconfig.statusAuto = ''
566 | fsconfig.statusInfo = ''
567 | fsconfig.keymapRes = ''
568 |
569 | saveSettingsStatus = fsconfigutil.saveSettings()
570 |
571 | self.buttonMapKeysReset.setEnabled(False)
572 |
573 | def saveStatusSettings(self):
574 |
575 | fsconfig.status60hz = self.labelStatus60hz.getLabel()
576 | fsconfig.status50hz = self.labelStatus50hz.getLabel()
577 | fsconfig.status30hz = self.labelStatus30hz.getLabel()
578 | fsconfig.status25hz = self.labelStatus25hz.getLabel()
579 | fsconfig.status24hz = self.labelStatus24hz.getLabel()
580 | fsconfig.statusAuto = self.labelStatusAuto.getLabel()
581 | fsconfig.statusInfo = self.labelStatusInfo.getLabel()
582 | fsconfig.keymapRes = ''
583 |
584 | saveSettingsStatus = fsconfigutil.saveSettings()
585 |
586 | def saveAllSettings(self):
587 |
588 | fsconfig.radio60hz = self.radio60hz.isSelected()
589 | fsconfig.radio50hz = self.radio50hz.isSelected()
590 | fsconfig.radio30hz = self.radio30hz.isSelected()
591 | fsconfig.radio25hz = self.radio25hz.isSelected()
592 | fsconfig.radio24hz = self.radio24hz.isSelected()
593 | fsconfig.radioAuto = self.radioAuto.isSelected()
594 | fsconfig.radioInfo = self.radioInfo.isSelected()
595 | fsconfig.key60hz = self.labelKey60hz.getLabel()
596 | fsconfig.key50hz = self.labelKey50hz.getLabel()
597 | fsconfig.key30hz = self.labelKey30hz.getLabel()
598 | fsconfig.key25hz = self.labelKey25hz.getLabel()
599 | fsconfig.key24hz = self.labelKey24hz.getLabel()
600 | fsconfig.keyAuto = self.labelKeyAuto.getLabel()
601 | fsconfig.keyInfo = self.labelKeyInfo.getLabel()
602 | fsconfig.status60hz = self.labelStatus60hz.getLabel()
603 | fsconfig.status50hz = self.labelStatus50hz.getLabel()
604 | fsconfig.status30hz = self.labelStatus30hz.getLabel()
605 | fsconfig.status25hz = self.labelStatus25hz.getLabel()
606 | fsconfig.status24hz = self.labelStatus24hz.getLabel()
607 | fsconfig.statusAuto = self.labelStatusAuto.getLabel()
608 | fsconfig.statusInfo = self.labelStatusInfo.getLabel()
609 | fsconfig.keymapRes = self.currentRes
610 |
611 | saveSettingsStatus = fsconfigutil.saveSettings()
612 |
613 | self.labelInfoText.setLabel(saveSettingsStatus)
614 |
615 | class ConfigWindow(AddonDialogWindow):
616 |
617 | def __init__(self, title=''):
618 | # base class constructor
619 | super(ConfigWindow, self).__init__(title)
620 |
621 | # set window width + height, and grid rows + columns
622 | self.setGeometry(750, 650, 12, 26)
623 |
624 | # create, place, then set objects
625 | self.radio60hz = RadioButton('60 hz')
626 | self.placeControl(self.radio60hz, 1, 2, columnspan=6)
627 | self.radio60hz.setSelected(fsconfig.radioAuto60hz)
628 |
629 | self.radio50hz = RadioButton('50 hz')
630 | self.placeControl(self.radio50hz, 2, 2, columnspan=6)
631 | self.radio50hz.setSelected(fsconfig.radioAuto50hz)
632 |
633 | self.radio30hz = RadioButton('30 hz')
634 | self.placeControl(self.radio30hz, 3, 2, columnspan=6)
635 | self.radio30hz.setSelected(fsconfig.radioAuto30hz)
636 |
637 | self.radio25hz = RadioButton('25 hz')
638 | self.placeControl(self.radio25hz, 4, 2, columnspan=6)
639 | self.radio25hz.setSelected(fsconfig.radioAuto25hz)
640 |
641 | self.radio24hz = RadioButton('24 hz')
642 | self.placeControl(self.radio24hz, 5, 2, columnspan=6)
643 | self.radio24hz.setSelected(fsconfig.radioAuto24hz)
644 |
645 | self.edit60hzFps1 = Edit('')
646 | self.placeControl(self.edit60hzFps1, 1, 9, columnspan=3, pad_y=11)
647 | self.edit60hzFps1.setText(fsconfig.edit60hzFps1)
648 |
649 | self.edit60hzFps2 = Edit('')
650 | self.placeControl(self.edit60hzFps2, 1, 13, columnspan=3, pad_y=11)
651 | self.edit60hzFps2.setText(fsconfig.edit60hzFps2)
652 |
653 | self.edit60hzFps3 = Edit('')
654 | self.placeControl(self.edit60hzFps3, 1, 17, columnspan=3, pad_y=11)
655 | self.edit60hzFps3.setText(fsconfig.edit60hzFps3)
656 |
657 | self.edit60hzFps4 = Edit('')
658 | self.placeControl(self.edit60hzFps4, 1, 21, columnspan=3, pad_y=11)
659 | self.edit60hzFps4.setText(fsconfig.edit60hzFps4)
660 |
661 | self.edit50hzFps1 = Edit('')
662 | self.placeControl(self.edit50hzFps1, 2, 9, columnspan=3, pad_y=11)
663 | self.edit50hzFps1.setText(fsconfig.edit50hzFps1)
664 |
665 | self.edit50hzFps2 = Edit('')
666 | self.placeControl(self.edit50hzFps2, 2, 13, columnspan=3, pad_y=11)
667 | self.edit50hzFps2.setText(fsconfig.edit50hzFps2)
668 |
669 | self.edit50hzFps3 = Edit('')
670 | self.placeControl(self.edit50hzFps3, 2, 17, columnspan=3, pad_y=11)
671 | self.edit50hzFps3.setText(fsconfig.edit50hzFps3)
672 |
673 | self.edit50hzFps4 = Edit('')
674 | self.placeControl(self.edit50hzFps4, 2, 21, columnspan=3, pad_y=11)
675 | self.edit50hzFps4.setText(fsconfig.edit50hzFps4)
676 |
677 | self.edit30hzFps1 = Edit('')
678 | self.placeControl(self.edit30hzFps1, 3, 9, columnspan=3, pad_y=11)
679 | self.edit30hzFps1.setText(fsconfig.edit30hzFps1)
680 |
681 | self.edit30hzFps2 = Edit('')
682 | self.placeControl(self.edit30hzFps2, 3, 13, columnspan=3, pad_y=11)
683 | self.edit30hzFps2.setText(fsconfig.edit30hzFps2)
684 |
685 | self.edit30hzFps3 = Edit('')
686 | self.placeControl(self.edit30hzFps3, 3, 17, columnspan=3, pad_y=11)
687 | self.edit30hzFps3.setText(fsconfig.edit30hzFps3)
688 |
689 | self.edit30hzFps4 = Edit('')
690 | self.placeControl(self.edit30hzFps4, 3, 21, columnspan=3, pad_y=11)
691 | self.edit30hzFps4.setText(fsconfig.edit30hzFps4)
692 |
693 | self.edit25hzFps1 = Edit('')
694 | self.placeControl(self.edit25hzFps1, 4, 9, columnspan=3, pad_y=11)
695 | self.edit25hzFps1.setText(fsconfig.edit25hzFps1)
696 |
697 | self.edit25hzFps2 = Edit('')
698 | self.placeControl(self.edit25hzFps2, 4, 13, columnspan=3, pad_y=11)
699 | self.edit25hzFps2.setText(fsconfig.edit25hzFps2)
700 |
701 | self.edit25hzFps3 = Edit('')
702 | self.placeControl(self.edit25hzFps3, 4, 17, columnspan=3, pad_y=11)
703 | self.edit25hzFps3.setText(fsconfig.edit25hzFps3)
704 |
705 | self.edit25hzFps4 = Edit('')
706 | self.placeControl(self.edit25hzFps4, 4, 21, columnspan=3, pad_y=11)
707 | self.edit25hzFps4.setText(fsconfig.edit25hzFps4)
708 |
709 | self.edit24hzFps1 = Edit('')
710 | self.placeControl(self.edit24hzFps1, 5, 9, columnspan=3, pad_y=11)
711 | self.edit24hzFps1.setText(fsconfig.edit24hzFps1)
712 |
713 | self.edit24hzFps2 = Edit('')
714 | self.placeControl(self.edit24hzFps2, 5, 13, columnspan=3, pad_y=11)
715 | self.edit24hzFps2.setText(fsconfig.edit24hzFps2)
716 |
717 | self.edit24hzFps3 = Edit('')
718 | self.placeControl(self.edit24hzFps3, 5, 17, columnspan=3, pad_y=11)
719 | self.edit24hzFps3.setText(fsconfig.edit24hzFps3)
720 |
721 | self.edit24hzFps4 = Edit('')
722 | self.placeControl(self.edit24hzFps4, 5, 21, columnspan=3, pad_y=11)
723 | self.edit24hzFps4.setText(fsconfig.edit24hzFps4)
724 |
725 | self.buttonConfigSave = Button('Save Configuration')
726 | self.placeControl(self.buttonConfigSave, 9, 2, columnspan=8)
727 |
728 | self.labelInfoTitle = Label('', alignment=ALIGN_LEFT)
729 | self.placeControl(self.labelInfoTitle, 9, 12, columnspan=16, pad_y=11)
730 |
731 | self.labelInfoText = Label('', alignment=ALIGN_LEFT)
732 | self.placeControl(self.labelInfoText, 10, 12, columnspan=16, pad_y=11)
733 |
734 | # connect buttons and actions to functions
735 | self.connect(self.radio60hz, self.clickRadio60hz)
736 | self.connect(self.radio50hz, self.clickRadio50hz)
737 | self.connect(self.radio30hz, self.clickRadio30hz)
738 | self.connect(self.radio25hz, self.clickRadio25hz)
739 | self.connect(self.radio24hz, self.clickRadio24hz)
740 | self.connect(self.buttonConfigSave, self.clickConfigSave)
741 | self.connect(ACTION_NAV_BACK, self.close)
742 |
743 | # set the enabled state of objects
744 | self.clickRadio60hz()
745 | self.clickRadio50hz()
746 | self.clickRadio30hz()
747 | self.clickRadio25hz()
748 | self.clickRadio24hz()
749 |
750 | # define key navigation (up-down)
751 | self.radio60hz.controlDown(self.radio50hz)
752 | self.radio50hz.controlUp(self.radio60hz)
753 | self.radio50hz.controlDown(self.radio30hz)
754 | self.radio30hz.controlUp(self.radio50hz)
755 | self.radio30hz.controlDown(self.radio25hz)
756 | self.radio25hz.controlUp(self.radio30hz)
757 | self.radio25hz.controlDown(self.radio24hz)
758 | self.radio24hz.controlUp(self.radio25hz)
759 | self.radio24hz.controlDown(self.buttonConfigSave)
760 | self.buttonConfigSave.controlUp(self.radio24hz)
761 |
762 | self.edit60hzFps1.controlDown(self.edit50hzFps1)
763 | self.edit50hzFps1.controlUp(self.edit60hzFps1)
764 | self.edit50hzFps1.controlDown(self.edit30hzFps1)
765 | self.edit30hzFps1.controlUp(self.edit50hzFps1)
766 | self.edit30hzFps1.controlDown(self.edit25hzFps1)
767 | self.edit25hzFps1.controlUp(self.edit30hzFps1)
768 | self.edit25hzFps1.controlDown(self.edit24hzFps1)
769 | self.edit24hzFps1.controlUp(self.edit25hzFps1)
770 | self.edit24hzFps1.controlDown(self.buttonConfigSave)
771 |
772 | self.edit60hzFps2.controlDown(self.edit50hzFps2)
773 | self.edit50hzFps2.controlUp(self.edit60hzFps2)
774 | self.edit50hzFps2.controlDown(self.edit30hzFps2)
775 | self.edit30hzFps2.controlUp(self.edit50hzFps2)
776 | self.edit30hzFps2.controlDown(self.edit25hzFps2)
777 | self.edit25hzFps2.controlUp(self.edit30hzFps2)
778 | self.edit25hzFps2.controlDown(self.edit24hzFps2)
779 | self.edit24hzFps2.controlUp(self.edit25hzFps2)
780 | self.edit24hzFps2.controlDown(self.buttonConfigSave)
781 |
782 | self.edit60hzFps3.controlDown(self.edit50hzFps3)
783 | self.edit50hzFps3.controlUp(self.edit60hzFps3)
784 | self.edit50hzFps3.controlDown(self.edit30hzFps3)
785 | self.edit30hzFps3.controlUp(self.edit50hzFps3)
786 | self.edit30hzFps3.controlDown(self.edit25hzFps3)
787 | self.edit25hzFps3.controlUp(self.edit30hzFps3)
788 | self.edit25hzFps3.controlDown(self.edit24hzFps3)
789 | self.edit24hzFps3.controlUp(self.edit25hzFps3)
790 | self.edit24hzFps3.controlDown(self.buttonConfigSave)
791 |
792 | self.edit60hzFps4.controlDown(self.edit50hzFps4)
793 | self.edit50hzFps4.controlUp(self.edit60hzFps4)
794 | self.edit50hzFps4.controlDown(self.edit30hzFps4)
795 | self.edit30hzFps4.controlUp(self.edit50hzFps4)
796 | self.edit30hzFps4.controlDown(self.edit25hzFps4)
797 | self.edit25hzFps4.controlUp(self.edit30hzFps4)
798 | self.edit25hzFps4.controlDown(self.edit24hzFps4)
799 | self.edit24hzFps4.controlUp(self.edit25hzFps4)
800 | self.edit24hzFps4.controlDown(self.buttonConfigSave)
801 |
802 | # define key navigation (left-right)
803 | self.radio60hz.controlRight(self.edit60hzFps1)
804 | self.edit60hzFps1.controlLeft(self.radio60hz)
805 | self.edit60hzFps1.controlRight(self.edit60hzFps2)
806 | self.edit60hzFps2.controlLeft(self.edit60hzFps1)
807 | self.edit60hzFps2.controlRight(self.edit60hzFps3)
808 | self.edit60hzFps3.controlLeft(self.edit60hzFps2)
809 | self.edit60hzFps3.controlRight(self.edit60hzFps4)
810 | self.edit60hzFps4.controlLeft(self.edit60hzFps3)
811 |
812 | self.radio50hz.controlRight(self.edit50hzFps1)
813 | self.edit50hzFps1.controlLeft(self.radio50hz)
814 | self.edit50hzFps1.controlRight(self.edit50hzFps2)
815 | self.edit50hzFps2.controlLeft(self.edit50hzFps1)
816 | self.edit50hzFps2.controlRight(self.edit50hzFps3)
817 | self.edit50hzFps3.controlLeft(self.edit50hzFps2)
818 | self.edit50hzFps3.controlRight(self.edit50hzFps4)
819 | self.edit50hzFps4.controlLeft(self.edit50hzFps3)
820 |
821 | self.radio30hz.controlRight(self.edit30hzFps1)
822 | self.edit30hzFps1.controlLeft(self.radio30hz)
823 | self.edit30hzFps1.controlRight(self.edit30hzFps2)
824 | self.edit30hzFps2.controlLeft(self.edit30hzFps1)
825 | self.edit30hzFps2.controlRight(self.edit30hzFps3)
826 | self.edit30hzFps3.controlLeft(self.edit30hzFps2)
827 | self.edit30hzFps3.controlRight(self.edit30hzFps4)
828 | self.edit30hzFps4.controlLeft(self.edit30hzFps3)
829 |
830 | self.radio25hz.controlRight(self.edit25hzFps1)
831 | self.edit25hzFps1.controlLeft(self.radio25hz)
832 | self.edit25hzFps1.controlRight(self.edit25hzFps2)
833 | self.edit25hzFps2.controlLeft(self.edit25hzFps1)
834 | self.edit25hzFps2.controlRight(self.edit25hzFps3)
835 | self.edit25hzFps3.controlLeft(self.edit25hzFps2)
836 | self.edit25hzFps3.controlRight(self.edit25hzFps4)
837 | self.edit25hzFps4.controlLeft(self.edit25hzFps3)
838 |
839 | self.radio24hz.controlRight(self.edit24hzFps1)
840 | self.edit24hzFps1.controlLeft(self.radio24hz)
841 | self.edit24hzFps1.controlRight(self.edit24hzFps2)
842 | self.edit24hzFps2.controlLeft(self.edit24hzFps1)
843 | self.edit24hzFps2.controlRight(self.edit24hzFps3)
844 | self.edit24hzFps3.controlLeft(self.edit24hzFps2)
845 | self.edit24hzFps3.controlRight(self.edit24hzFps4)
846 | self.edit24hzFps4.controlLeft(self.edit24hzFps3)
847 |
848 | # set initial focus
849 | self.setFocus(self.radio60hz)
850 |
851 | def clickRadio60hz(self):
852 |
853 | if self.radio60hz.isSelected():
854 | self.edit60hzFps1.setEnabled(True)
855 | self.edit60hzFps2.setEnabled(True)
856 | self.edit60hzFps3.setEnabled(True)
857 | self.edit60hzFps4.setEnabled(True)
858 | else:
859 | self.edit60hzFps1.setEnabled(False)
860 | self.edit60hzFps2.setEnabled(False)
861 | self.edit60hzFps3.setEnabled(False)
862 | self.edit60hzFps4.setEnabled(False)
863 |
864 | def clickRadio50hz(self):
865 |
866 | if self.radio50hz.isSelected():
867 | self.edit50hzFps1.setEnabled(True)
868 | self.edit50hzFps2.setEnabled(True)
869 | self.edit50hzFps3.setEnabled(True)
870 | self.edit50hzFps4.setEnabled(True)
871 | else:
872 | self.edit50hzFps1.setEnabled(False)
873 | self.edit50hzFps2.setEnabled(False)
874 | self.edit50hzFps3.setEnabled(False)
875 | self.edit50hzFps4.setEnabled(False)
876 |
877 | def clickRadio30hz(self):
878 |
879 | if self.radio30hz.isSelected():
880 | self.edit30hzFps1.setEnabled(True)
881 | self.edit30hzFps2.setEnabled(True)
882 | self.edit30hzFps3.setEnabled(True)
883 | self.edit30hzFps4.setEnabled(True)
884 | else:
885 | self.edit30hzFps1.setEnabled(False)
886 | self.edit30hzFps2.setEnabled(False)
887 | self.edit30hzFps3.setEnabled(False)
888 | self.edit30hzFps4.setEnabled(False)
889 |
890 | def clickRadio25hz(self):
891 |
892 | if self.radio25hz.isSelected():
893 | self.edit25hzFps1.setEnabled(True)
894 | self.edit25hzFps2.setEnabled(True)
895 | self.edit25hzFps3.setEnabled(True)
896 | self.edit25hzFps4.setEnabled(True)
897 | else:
898 | self.edit25hzFps1.setEnabled(False)
899 | self.edit25hzFps2.setEnabled(False)
900 | self.edit25hzFps3.setEnabled(False)
901 | self.edit25hzFps4.setEnabled(False)
902 |
903 |
904 | def clickRadio24hz(self):
905 |
906 | if self.radio24hz.isSelected():
907 | self.edit24hzFps1.setEnabled(True)
908 | self.edit24hzFps2.setEnabled(True)
909 | self.edit24hzFps3.setEnabled(True)
910 | self.edit24hzFps4.setEnabled(True)
911 | else:
912 | self.edit24hzFps1.setEnabled(False)
913 | self.edit24hzFps2.setEnabled(False)
914 | self.edit24hzFps3.setEnabled(False)
915 | self.edit24hzFps4.setEnabled(False)
916 |
917 | def clickConfigSave(self):
918 |
919 | self.labelInfoTitle.setLabel('Verifying settings...')
920 | self.labelInfoText.setLabel('')
921 | xbmc.sleep(600)
922 |
923 | fpsEditList = [self.edit60hzFps1,
924 | self.edit60hzFps2,
925 | self.edit60hzFps3,
926 | self.edit60hzFps4,
927 | self.edit50hzFps1,
928 | self.edit50hzFps2,
929 | self.edit50hzFps3,
930 | self.edit50hzFps4,
931 | self.edit30hzFps1,
932 | self.edit30hzFps2,
933 | self.edit30hzFps3,
934 | self.edit30hzFps4,
935 | self.edit25hzFps1,
936 | self.edit25hzFps2,
937 | self.edit25hzFps3,
938 | self.edit25hzFps4,
939 | self.edit24hzFps1,
940 | self.edit24hzFps2,
941 | self.edit24hzFps3,
942 | self.edit24hzFps4]
943 |
944 | self.fpsList = [] # FPS list for duplicate checking
945 |
946 | fpsIsValid = True
947 | for (fpsEditItem) in fpsEditList:
948 | if fpsIsValid:
949 | fpsIsValid, fpsMsg = self.verifyFPS(fpsEditItem)
950 |
951 | if not fpsIsValid:
952 | self.labelInfoTitle.setLabel(fpsMsg)
953 | self.labelInfoText.setLabel('Settings not saved')
954 | else:
955 | self.labelInfoTitle.setLabel('Settings verified')
956 | self.labelInfoText.setLabel('Saving settings...')
957 | xbmc.sleep(600)
958 |
959 | self.saveFpsSettings()
960 |
961 | def verifyFPS(self, editFps):
962 |
963 | currentFps = editFps.getText()
964 |
965 | if currentFps == '':
966 | fpsIsValid = True
967 | fpsMsg = ''
968 |
969 | else:
970 | # check that edit field contains a number
971 | try:
972 | numCurrentFps = float(currentFps)
973 | # not a valid number - set field text to red
974 | except ValueError:
975 | fpsIsValid = False
976 | fpsMsg = 'Invalid FPS: ' + currentFps
977 |
978 | # is a valid number
979 | else:
980 |
981 | # number is outside reasonable FPS range (1-70)
982 | if (numCurrentFps < 1) or (numCurrentFps > 70):
983 | fpsIsValid = False
984 | fpsMsg = 'Invalid FPS: ' + currentFps
985 |
986 | # number is within reasonable FPS range (1-70)
987 | else:
988 |
989 | # truncate FPS to three decimal places
990 | decSplit = currentFps.find('.') + 4
991 | newFps = currentFps[0:decSplit]
992 |
993 | # check fpsList for duplicates
994 | dupeFpsFound = False
995 | for (fpsItem) in self.fpsList:
996 | if fpsItem == newFps:
997 | dupeFpsFound = True
998 | break
999 |
1000 | # duplicate FPS detected
1001 | if dupeFpsFound:
1002 | fpsIsValid = False
1003 | fpsMsg = 'Duplicate FPS: ' + currentFps
1004 |
1005 | # no duplicate FPS detected
1006 | else:
1007 | fpsIsValid = True
1008 |
1009 | if currentFps == newFps:
1010 | fpsMsg = 'OK - FPS verified.'
1011 | else:
1012 | editFps.setText(newFps)
1013 | fpsMsg = 'OK - FPS truncated: ' + currentFps
1014 |
1015 | # add FPS to list for dupe checking
1016 | self.fpsList.insert(0, currentFps)
1017 |
1018 | return fpsIsValid, fpsMsg
1019 |
1020 | def saveFpsSettings(self):
1021 |
1022 | fsconfig.edit60hzFps1 = self.edit60hzFps1.getText()
1023 | fsconfig.edit60hzFps2 = self.edit60hzFps2.getText()
1024 | fsconfig.edit60hzFps3 = self.edit60hzFps3.getText()
1025 | fsconfig.edit60hzFps4 = self.edit60hzFps4.getText()
1026 | fsconfig.edit50hzFps1 = self.edit50hzFps1.getText()
1027 | fsconfig.edit50hzFps2 = self.edit50hzFps2.getText()
1028 | fsconfig.edit50hzFps3 = self.edit50hzFps3.getText()
1029 | fsconfig.edit50hzFps4 = self.edit50hzFps4.getText()
1030 | fsconfig.edit30hzFps1 = self.edit30hzFps1.getText()
1031 | fsconfig.edit30hzFps2 = self.edit30hzFps2.getText()
1032 | fsconfig.edit30hzFps3 = self.edit30hzFps3.getText()
1033 | fsconfig.edit30hzFps4 = self.edit30hzFps4.getText()
1034 | fsconfig.edit25hzFps1 = self.edit25hzFps1.getText()
1035 | fsconfig.edit25hzFps2 = self.edit25hzFps2.getText()
1036 | fsconfig.edit25hzFps3 = self.edit25hzFps3.getText()
1037 | fsconfig.edit25hzFps4 = self.edit25hzFps4.getText()
1038 | fsconfig.edit24hzFps1 = self.edit24hzFps1.getText()
1039 | fsconfig.edit24hzFps2 = self.edit24hzFps2.getText()
1040 | fsconfig.edit24hzFps3 = self.edit24hzFps3.getText()
1041 | fsconfig.edit24hzFps4 = self.edit24hzFps4.getText()
1042 |
1043 | fsconfig.radioAuto60hz = self.radio60hz.isSelected()
1044 | fsconfig.radioAuto50hz = self.radio50hz.isSelected()
1045 | fsconfig.radioAuto30hz = self.radio30hz.isSelected()
1046 | fsconfig.radioAuto25hz = self.radio25hz.isSelected()
1047 | fsconfig.radioAuto24hz = self.radio24hz.isSelected()
1048 |
1049 | saveSettingsStatus = fsconfigutil.saveSettings()
1050 |
1051 | self.labelInfoText.setLabel(saveSettingsStatus)
1052 |
1053 | class MapEventsWindow(AddonDialogWindow):
1054 |
1055 | def __init__(self, title=''):
1056 | # base class constructor
1057 | super(MapEventsWindow, self).__init__(title)
1058 |
1059 | # set window width + height, and grid rows + columns
1060 | self.setGeometry(750, 650, 12, 26)
1061 |
1062 | # create, place, then set objects
1063 | self.labelCurrentRes = Label('', alignment=ALIGN_LEFT)
1064 | self.placeControl(self.labelCurrentRes, 1, 2, columnspan=20, pad_y=11)
1065 |
1066 | self.labelActiveService = Label('', alignment=ALIGN_LEFT)
1067 | self.placeControl(self.labelActiveService, 2, 2, columnspan=20, pad_y=11)
1068 |
1069 | self.radioOnPlayStart = RadioButton('Playback Starts')
1070 | self.placeControl(self.radioOnPlayStart, 4, 2, columnspan=8)
1071 | self.radioOnPlayStart.setSelected(fsconfig.radioOnPlayStart)
1072 |
1073 | self.labelOnPlayStart = Label('Auto-set HDMI mode on playback start', alignment=ALIGN_LEFT)
1074 | self.placeControl(self.labelOnPlayStart, 4, 11, columnspan=14, pad_y=11)
1075 |
1076 | self.radioOnPlayStop60 = RadioButton('Default 60 hz')
1077 | self.placeControl(self.radioOnPlayStop60, 5, 2, columnspan=8)
1078 | self.radioOnPlayStop60.setSelected(fsconfig.radioOnPlayStop60)
1079 |
1080 | self.labelOnPlayStop60 = Label('Set mode to 60 hz on playback stop', alignment=ALIGN_LEFT)
1081 | self.placeControl(self.labelOnPlayStop60, 5, 11, columnspan=14, pad_y=11)
1082 |
1083 | self.radioOnPlayStop50 = RadioButton('Default 50 hz')
1084 | self.placeControl(self.radioOnPlayStop50, 6, 2, columnspan=8)
1085 | self.radioOnPlayStop50.setSelected(fsconfig.radioOnPlayStop50)
1086 |
1087 | self.labelOnPlayStop50 = Label('Set mode to 50 hz on playback stop', alignment=ALIGN_LEFT)
1088 | self.placeControl(self.labelOnPlayStop50, 6, 11, columnspan=14, pad_y=11)
1089 |
1090 | self.radioNotifyOn = RadioButton('')
1091 | self.placeControl(self.radioNotifyOn, 8, 2, columnspan=8)
1092 | self.radioNotifyOn.setSelected(fsconfig.radioNotifyOn)
1093 |
1094 | self.buttonConfigSave = Button('Save Configuration')
1095 | self.placeControl(self.buttonConfigSave, 10, 2, columnspan=8)
1096 |
1097 | self.labelInfoTitle = Label('', alignment=ALIGN_LEFT)
1098 | self.placeControl(self.labelInfoTitle, 10, 12, columnspan=16, pad_y=11)
1099 |
1100 | # self.labelInfoText = Label('', alignment=ALIGN_LEFT)
1101 | # self.placeControl(self.labelInfoText, 11, 12, columnspan=16, pad_y=11)
1102 |
1103 | # check current display mode setting
1104 | currentOutputMode, currentAmlogicMode = fsutil.getDisplayMode()
1105 |
1106 | if currentOutputMode == 'unsupported':
1107 | self.labelCurrentRes.setLabel('Unsupported resolution: ' + currentAmlogicMode)
1108 | self.disableAll()
1109 |
1110 | elif currentOutputMode == 'invalid':
1111 | self.labelCurrentRes.setLabel('Error: ' + currentAmlogicMode)
1112 | self.disableAll()
1113 |
1114 | else:
1115 | # get current resolution
1116 | resSplit = currentOutputMode.find('-')
1117 | self.currentRes = currentOutputMode[0:resSplit]
1118 | self.labelCurrentRes.setLabel('Current resolution: ' + self.currentRes)
1119 |
1120 | # connect buttons and actions to functions
1121 | self.connect(self.radioOnPlayStart, self.clickRadioOnPlayStart)
1122 | self.connect(self.radioOnPlayStop60, self.clickRadioOnPlayStop60)
1123 | self.connect(self.radioOnPlayStop50, self.clickRadioOnPlayStop50)
1124 | self.connect(self.radioNotifyOn, self.clickRadioNotifyOn)
1125 | self.connect(self.buttonConfigSave, self.clickConfigSave)
1126 | self.connect(ACTION_NAV_BACK, self.close)
1127 |
1128 | # set the enabled state of objects
1129 | self.checkIfActive()
1130 | self.clickRadioOnPlayStop60()
1131 | self.clickRadioOnPlayStop50()
1132 | self.clickRadioNotifyOn()
1133 | self.clickRadioOnPlayStart()
1134 |
1135 | # define key navigation (up-down)
1136 | self.radioOnPlayStart.controlDown(self.radioOnPlayStop60)
1137 | self.radioOnPlayStop60.controlUp(self.radioOnPlayStart)
1138 |
1139 | self.radioOnPlayStop60.controlDown(self.radioOnPlayStop50)
1140 | self.radioOnPlayStop50.controlUp(self.radioOnPlayStop60)
1141 |
1142 | self.radioOnPlayStop50.controlDown(self.radioNotifyOn)
1143 | self.radioNotifyOn.controlUp(self.radioOnPlayStop50)
1144 |
1145 | self.radioNotifyOn.controlDown(self.buttonConfigSave)
1146 | self.buttonConfigSave.controlUp(self.radioNotifyOn)
1147 |
1148 | # set initial focus
1149 | self.setFocus(self.radioOnPlayStart)
1150 |
1151 | def clickRadioOnPlayStart(self):
1152 | if self.radioOnPlayStart.isSelected():
1153 | self.labelOnPlayStart.setEnabled(True)
1154 | self.radioOnPlayStop60.setEnabled(True)
1155 | self.radioOnPlayStop50.setEnabled(True)
1156 | self.clickRadioOnPlayStop60()
1157 | self.clickRadioOnPlayStop50()
1158 | self.radioNotifyOn.setEnabled(True)
1159 | else:
1160 | self.labelOnPlayStart.setEnabled(False)
1161 | self.radioOnPlayStop60.setEnabled(False)
1162 | self.radioOnPlayStop50.setEnabled(False)
1163 | self.labelOnPlayStop60.setEnabled(False)
1164 | self.labelOnPlayStop50.setEnabled(False)
1165 | self.radioNotifyOn.setEnabled(False)
1166 |
1167 | self.checkIfActive()
1168 |
1169 | def clickRadioOnPlayStop60(self):
1170 | if self.radioOnPlayStop60.isSelected():
1171 | self.labelOnPlayStop60.setEnabled(True)
1172 | self.radioOnPlayStop50.setSelected(False)
1173 | self.labelOnPlayStop50.setEnabled(False)
1174 | else:
1175 | self.labelOnPlayStop60.setEnabled(False)
1176 |
1177 | self.checkIfActive()
1178 |
1179 | def clickRadioOnPlayStop50(self):
1180 | if self.radioOnPlayStop50.isSelected():
1181 | self.labelOnPlayStop50.setEnabled(True)
1182 | self.radioOnPlayStop60.setSelected(False)
1183 | self.labelOnPlayStop60.setEnabled(False)
1184 | else:
1185 | self.labelOnPlayStop50.setEnabled(False)
1186 |
1187 | self.checkIfActive()
1188 |
1189 | def checkIfActive(self):
1190 |
1191 | fsconfigutil.loadActiveServiceSetting()
1192 |
1193 | if fsconfig.activeService:
1194 | if fsconfig.radioOnPlayStart:
1195 | self.labelActiveService.setLabel('Service running')
1196 | else:
1197 | self.labelActiveService.setLabel('Service running - restart XBMC')
1198 |
1199 | else:
1200 | if fsconfig.radioOnPlayStart:
1201 | self.labelActiveService.setLabel('Service stopped - restart XBMC')
1202 | else:
1203 | self.labelActiveService.setLabel('Service stopped')
1204 |
1205 | def clickRadioNotifyOn(self):
1206 | if self.radioNotifyOn.isSelected():
1207 | self.radioNotifyOn.setLabel('Notifications On')
1208 | else:
1209 | self.radioNotifyOn.setLabel('Notifications Off')
1210 |
1211 | self.checkIfActive()
1212 |
1213 | def clickConfigSave(self):
1214 | self.labelInfoTitle.setLabel('Saving settings...')
1215 | xbmc.sleep(600)
1216 |
1217 | fsconfig.radioOnPlayStart = self.radioOnPlayStart.isSelected()
1218 | fsconfig.radioOnPlayStop60 = self.radioOnPlayStop60.isSelected()
1219 | fsconfig.radioOnPlayStop50 = self.radioOnPlayStop50.isSelected()
1220 | fsconfig.radioNotifyOn = self.radioNotifyOn.isSelected()
1221 |
1222 | saveSettingsStatus = fsconfigutil.saveSettings()
1223 |
1224 | if not fsconfig.radioOnPlayStart:
1225 | xbmc.sleep(4500)
1226 |
1227 | self.labelInfoTitle.setLabel(saveSettingsStatus)
1228 |
1229 | self.checkIfActive()
1230 |
1231 | def disableAll(self):
1232 |
1233 | self.labelInfoTitle.setEnabled(False)
1234 | self.labelActiveService.setEnabled(False)
1235 |
1236 | self.radioOnPlayStart.setEnabled(False)
1237 | self.radioOnPlayStop60.setEnabled(False)
1238 | self.radioOnPlayStop50.setEnabled(False)
1239 | self.radioNotifyOn.setEnabled(False)
1240 | self.buttonConfigSave.setEnabled(False)
1241 |
1242 | self.disableService()
1243 |
1244 | def disableService(self):
1245 |
1246 | self.radioOnPlayStart.setSelected(False)
1247 |
1248 | self.clickRadioOnPlayStart()
1249 |
1250 | self.clickConfigSave()
1251 |
1252 | class MainWindow(AddonDialogWindow):
1253 |
1254 | def __init__(self, title=''):
1255 | # base class constructor
1256 | super(MainWindow, self).__init__(title)
1257 |
1258 | # set window width + height, and grid rows + columns
1259 | self.setGeometry(750, 650, 12, 13)
1260 |
1261 | self.labelInfoTitle = Label('', alignment=ALIGN_LEFT)
1262 | self.placeControl(self.labelInfoTitle, 1, 1, columnspan=8)
1263 |
1264 | self.labelInfoText = Label('', alignment=ALIGN_LEFT)
1265 | self.placeControl(self.labelInfoText, 2, 1, columnspan=8)
1266 |
1267 | # create and place objects
1268 | self.buttonWindowMapEvents = Button('Service')
1269 | self.placeControl(self.buttonWindowMapEvents, 4, 1, columnspan=5)
1270 |
1271 | self.buttonWindowConfig = Button('Frame Rates')
1272 | self.placeControl(self.buttonWindowConfig, 5, 1, columnspan=5)
1273 |
1274 | self.buttonWindowMapKeys = Button('Map Keys')
1275 | self.placeControl(self.buttonWindowMapKeys, 6, 1, columnspan=5)
1276 |
1277 | self.buttonCleanup = Button('Clean Up')
1278 | self.placeControl(self.buttonCleanup, 8, 1, columnspan=5)
1279 |
1280 | self.labelInfoStatus1 = Label('', alignment=ALIGN_LEFT)
1281 | self.placeControl(self.labelInfoStatus1, 4, 7, columnspan=8, pad_y=11)
1282 |
1283 | self.labelInfoStatus2 = Label('', alignment=ALIGN_LEFT)
1284 | self.placeControl(self.labelInfoStatus2, 6, 7, columnspan=8, pad_y=11)
1285 |
1286 | self.labelCleanupStatus = Label('', alignment=ALIGN_LEFT)
1287 | self.placeControl(self.labelCleanupStatus, 8, 7, columnspan=8, pad_y=11)
1288 | # check platform type
1289 | self.checkPlatformType()
1290 | self.checkDisplayModeFileStatus()
1291 | self.checkStatus()
1292 |
1293 | # connect buttons and actions to functions
1294 | self.connect(self.buttonWindowMapEvents, self.windowMapEvents)
1295 | self.connect(self.buttonWindowConfig, self.windowConfig)
1296 | self.connect(self.buttonWindowMapKeys, self.windowMapKeys)
1297 | self.connect(self.buttonCleanup, self.cleanup)
1298 | self.connect(ACTION_NAV_BACK, self.close)
1299 |
1300 | # define key navigation
1301 | self.buttonWindowMapEvents.controlDown(self.buttonWindowConfig)
1302 | self.buttonWindowConfig.controlUp(self.buttonWindowMapEvents)
1303 |
1304 | self.buttonWindowConfig.controlDown(self.buttonWindowMapKeys)
1305 | self.buttonWindowMapKeys.controlUp(self.buttonWindowConfig)
1306 |
1307 | self.buttonWindowMapKeys.controlDown(self.buttonCleanup)
1308 | self.buttonCleanup.controlUp(self.buttonWindowMapKeys)
1309 |
1310 | # set initial focus
1311 | self.setFocus(self.buttonWindowMapEvents)
1312 |
1313 | def windowConfig(self):
1314 |
1315 | # create and show the Auto Sync configuration window
1316 | fsConfigWindow = ConfigWindow('Refresh rate to frame rate synchronization')
1317 | self.close()
1318 | fsConfigWindow.doModal()
1319 | self.doModal()
1320 |
1321 | def windowMapEvents(self):
1322 |
1323 | # create and show the Map Events configuration window
1324 | fsMapEventsWindow = MapEventsWindow('Service configuration')
1325 | self.close()
1326 |
1327 | fsMapEventsWindow.doModal()
1328 |
1329 | self.checkStatus()
1330 | self.doModal()
1331 |
1332 | def windowMapKeys(self):
1333 |
1334 | # create and show the Map Keys configuration window
1335 | fsMapKeysWindow = MapKeysWindow('Map keys')
1336 | self.close()
1337 |
1338 | fsMapKeysWindow.doModal()
1339 |
1340 | self.checkStatus()
1341 | self.doModal()
1342 |
1343 | def checkPlatformType(self):
1344 |
1345 | self.labelInfoTitle.setLabel('Detecting platform...')
1346 | xbmc.sleep(200)
1347 |
1348 | osPlatform, osVariant = fsutil.getPlatformType()
1349 |
1350 | if osPlatform is None:
1351 | self.labelInfoTitle.setLabel('Failed to detect platform')
1352 | fsconfig.osPlatform = 'unknown'
1353 | self.disableAll()
1354 |
1355 | elif osVariant == 'Windows 7':
1356 | self.labelInfoTitle.setLabel(osVariant + ' (testing only)')
1357 | fsconfig.osPlatform = osVariant
1358 |
1359 | else:
1360 | self.labelInfoTitle.setLabel(osVariant)
1361 | fsconfig.osPlatform = osVariant
1362 |
1363 | fsconfigutil.saveSettings()
1364 |
1365 | def checkDisplayModeFileStatus(self):
1366 |
1367 | self.labelInfoText.setLabel('Checking display mode file...')
1368 | xbmc.sleep(200)
1369 |
1370 | modeFile, fileStatus = fsutil.getDisplayModeFileStatus()
1371 |
1372 | if fileStatus is None:
1373 | self.labelInfoText.setLabel('HDMI mode file check failed.')
1374 |
1375 | elif fileStatus[:2] == 'OK':
1376 | self.labelInfoText.setLabel(fileStatus[4:])
1377 |
1378 | else:
1379 | self.labelInfoText.setLabel(fileStatus)
1380 | self.disableAll()
1381 |
1382 | def checkStatus(self):
1383 |
1384 | self.checkIfActive()
1385 | self.checkIfKeysMapped()
1386 |
1387 | # check for settings folder
1388 | golbalSettingsFolder = fsconfigutil.settingsFolder()
1389 |
1390 | if (self.labelInfoStatus1.getLabel() != 'Service stopped') or (self.labelInfoStatus2.getLabel() == 'Keys activated') or (os.path.isdir(golbalSettingsFolder)):
1391 | self.buttonCleanup.setEnabled(True)
1392 | else:
1393 | self.buttonCleanup.setEnabled(False)
1394 | self.labelCleanupStatus.setLabel('Clean up complete')
1395 |
1396 | def checkIfActive(self):
1397 |
1398 | fsconfigutil.loadActiveServiceSetting()
1399 |
1400 | if fsconfig.activeService:
1401 | if fsconfig.radioOnPlayStart:
1402 | self.labelInfoStatus1.setLabel('Service running')
1403 | else:
1404 | self.labelInfoStatus1.setLabel('Service running - restart XBMC')
1405 |
1406 | else:
1407 | if fsconfig.radioOnPlayStart:
1408 | self.labelInfoStatus1.setLabel('Service stopped - restart XBMC')
1409 | else:
1410 | self.labelInfoStatus1.setLabel('Service stopped')
1411 |
1412 | def checkIfKeysMapped(self):
1413 |
1414 | if fsutil.mapKeyActive():
1415 | self.labelInfoStatus2.setLabel('Keys activated')
1416 |
1417 | else:
1418 | self.labelInfoStatus2.setLabel('Keys deactivated')
1419 |
1420 | def disableAll(self):
1421 |
1422 | self.buttonWindowConfig.setEnabled(False)
1423 | self.buttonWindowMapEvents.setEnabled(False)
1424 | self.buttonWindowMapKeys.setEnabled(False)
1425 |
1426 | def cleanup(self):
1427 |
1428 | self.disableAll()
1429 |
1430 | if (self.labelInfoStatus1.getLabel() != 'Service stopped'):
1431 |
1432 | self.labelInfoStatus1.setLabel('Service stopping...')
1433 |
1434 | fsconfig.radioOnPlayStart = False
1435 |
1436 | saveSettingsStatus = fsconfigutil.saveSettings()
1437 | xbmc.sleep(4500)
1438 |
1439 | self.checkIfActive()
1440 |
1441 | if (self.labelInfoStatus2.getLabel() == 'Keys activated'):
1442 |
1443 | self.labelInfoStatus2.setLabel('Keys deactivating...')
1444 | xbmc.sleep(600)
1445 |
1446 | mapKeyResetStatus = fsutil.mapKeyReset()
1447 |
1448 | self.labelInfoStatus2.setLabel(mapKeyResetStatus)
1449 | xbmc.sleep(600)
1450 |
1451 | self.checkIfKeysMapped()
1452 |
1453 | fsconfigutil.deleteAllSettingsFiles()
1454 |
1455 | self.checkStatus()
1456 |
1457 | if (self.labelCleanupStatus.getLabel() != 'Clean up complete'):
1458 | self.labelCleanupStatus.setLabel('Clean up incomplete')
1459 |
1460 | self.setFocus(self.buttonCleanup)
1461 |
1462 | class InfoPanel():
1463 |
1464 | @staticmethod
1465 | def showInfo():
1466 |
1467 | # get current window
1468 | windowID = xbmcgui.getCurrentWindowId()
1469 |
1470 | # check for a valid window (10007 = system info, 12005 = full screen video)
1471 | # if (windowID == 12005) or (windowID == 10007):
1472 | if (windowID == 12005):
1473 | currentWindow = xbmcgui.Window(windowID)
1474 |
1475 | # flag info panel as active
1476 | fsconfig.activeInfo = True
1477 | fsconfigutil.saveActiveInfoSetting()
1478 |
1479 | # create info panel objects
1480 |
1481 | # same height as codec info
1482 | # panelTop = 19
1483 | # under codec info
1484 | panelTop = 158
1485 |
1486 | panelBorder = 10
1487 | panelLineTop = panelTop + panelBorder
1488 | panelLineSpacing = 23
1489 | panelLineCount = 3
1490 |
1491 | descHdmiMode = 'Output frequency:'
1492 | descSourceFPS = 'Source framerate:'
1493 | descCurrentFPS = 'Current framerate:'
1494 |
1495 | imageInfoPanel = xbmcgui.ControlImage(-200, panelTop, 1920, (panelBorder * 2) + (panelLineSpacing * panelLineCount), 'DialogBack2.png', colorDiffuse='0xBBBBBBBB')
1496 |
1497 | # Output Frequency ------------------------------------------------------------------------------------------------------------------------------------------------------------------
1498 | labelHdmiModeTitle = xbmcgui.ControlLabel(50, panelLineTop, 150, 20, descHdmiMode, font='font12')
1499 | labelHdmiMode = xbmcgui.ControlLabel(200, panelLineTop, 100, 20, '', font='font12')
1500 |
1501 | # get current display mode setting
1502 | currentOutputMode, currentAmlogicMode = fsutil.getDisplayMode()
1503 |
1504 | # get current frequency
1505 | freqSplit = currentOutputMode.find('-') + 1
1506 | currentFreq = currentOutputMode[freqSplit:len(currentOutputMode)-2]
1507 |
1508 | labelHdmiMode.setLabel(currentFreq + ' hz')
1509 |
1510 | # Source FPS ------------------------------------------------------------------------------------------------------------------------------------------------------------------
1511 | labelSourceFpsTitle = xbmcgui.ControlLabel(50, panelLineTop + (panelLineSpacing * 1), 150, 20, descSourceFPS, font='font12')
1512 | labelSourceFps = xbmcgui.ControlLabel(200, panelLineTop + (panelLineSpacing * 1), 100, 20, '', font='font12')
1513 |
1514 | # get FPS of currently playing video
1515 | setModeStatus, statusType = fsutil.getCurrentFPS()
1516 |
1517 | if statusType == 'ok':
1518 | labelSourceFps.setLabel(setModeStatus)
1519 | else:
1520 | labelSourceFps.setLabel('')
1521 |
1522 | # Current FPS ------------------------------------------------------------------------------------------------------------------------------------------------------------------
1523 | labelCurrentFpsTitle = xbmcgui.ControlLabel(50, panelLineTop + (panelLineSpacing * 2), 150, 20, descCurrentFPS, font='font12')
1524 | labelCurrentFps = xbmcgui.ControlLabel(200, panelLineTop + (panelLineSpacing * 2), 100, 20, '', font='font12')
1525 |
1526 | # get current rendered FPS
1527 | currentFPS = xbmc.getInfoLabel('System.FPS')
1528 |
1529 | labelCurrentFps.setLabel(currentFPS)
1530 |
1531 | # ------------------------------------------------------------------------------------------------------------------------------------------------------------------
1532 |
1533 | # build list of controls
1534 | controlList = [imageInfoPanel, labelHdmiModeTitle, labelHdmiMode, labelSourceFpsTitle, labelSourceFps, labelCurrentFpsTitle, labelCurrentFps]
1535 |
1536 | # if fsconfig.radioAuto50hz:
1537 | # syncConfig.extend([(fsconfig.edit50hzFps1, mode50hz),
1538 | # (fsconfig.edit50hzFps2, mode50hz),
1539 | # (fsconfig.edit50hzFps3, mode50hz),
1540 | # (fsconfig.edit50hzFps4, mode50hz)])
1541 |
1542 | # autoSync.insert(0, (syncFPS, syncMode))
1543 |
1544 | # add info panel to window
1545 | currentWindow.addControls(controlList)
1546 |
1547 | refreshCounter = 0
1548 |
1549 | # check for configuration changes every 0.25 second
1550 | while fsconfig.activeInfo:
1551 |
1552 | xbmc.sleep(250)
1553 |
1554 | refreshCounter = refreshCounter + 1
1555 |
1556 | # Every half second (update panel)
1557 | if (refreshCounter == 2) or (refreshCounter == 4):
1558 |
1559 | # Update Current FPS ------------------------------------------------------------------------------------------------------------------------------------------------------------------
1560 | currentFPS = xbmc.getInfoLabel('System.FPS')
1561 | labelCurrentFps.setLabel(currentFPS)
1562 |
1563 | # Every second (update panel)
1564 | if refreshCounter == 4:
1565 |
1566 | # Update Source FPS ------------------------------------------------------------------------------------------------------------------------------------------------------------------
1567 | setModeStatus, statusType = fsutil.getCurrentFPS()
1568 | if statusType == 'ok':
1569 | labelSourceFps.setLabel(setModeStatus)
1570 | else:
1571 | labelSourceFps.setLabel('')
1572 |
1573 | # Update Output Frequency ------------------------------------------------------------------------------------------------------------------------------------------------------------------
1574 | currentOutputMode, currentAmlogicMode = fsutil.getDisplayMode()
1575 | freqSplit = currentOutputMode.find('-') + 1
1576 | currentFreq = currentOutputMode[freqSplit:len(currentOutputMode)-2]
1577 | labelHdmiMode.setLabel(currentFreq + ' hz')
1578 |
1579 | # ------------------------------------------------------------------------------------------------------------------------------------------------------------------
1580 |
1581 | # Every quarter second - reload settings, to allow info panel stop
1582 | fsconfigutil.loadActiveInfoSetting()
1583 |
1584 | # Every second (check and update panel status)
1585 | if refreshCounter == 4:
1586 |
1587 | # check that user has not deactivate in last 0.25 seconds
1588 | if fsconfig.activeInfo:
1589 |
1590 | # check if window is still active
1591 | windowIDcheck = xbmcgui.getCurrentWindowId()
1592 |
1593 | # if window is not activate then disable info panel
1594 | if windowID != windowIDcheck:
1595 | fsconfig.activeInfo = False
1596 |
1597 | # rewrite flag file (necessary even when active for detection of old flag file should XBMC exit unexpectedly)
1598 | fsconfigutil.saveActiveInfoSetting()
1599 |
1600 | # reset refresh counter
1601 | refreshCounter = 0
1602 |
1603 |
1604 | # remove info from window
1605 | currentWindow.removeControls(controlList)
1606 |
1607 |
--------------------------------------------------------------------------------
/script.video.fswitch/resources/language/English/strings.po:
--------------------------------------------------------------------------------
1 | msgid ""
2 | msgstr ""
3 | "Project-Id-Version: XBMC Main Translation Project (Frodo)\n"
4 | "Report-Msgid-Bugs-To: http://trac.xbmc.org/\n"
5 | "POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
6 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
7 | "Last-Translator: XBMC Translation Team\n"
8 | "Language-Team: English (http://www.transifex.com/projects/p/XBMC-Main-Frodo/language/en/)\n"
9 | "MIME-Version: 1.0\n"
10 | "Content-Type: text/plain; charset=UTF-8\n"
11 | "Content-Transfer-Encoding: 8bit\n"
12 | "Language: en\n"
13 | "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14 |
15 | #English
16 |
17 | msgctxt "#30000"
18 | msgid "Press the key you want to assign now"
19 | msgstr ""
20 |
21 | msgctxt "#30001"
22 | msgid "Timeout in %.0f seconds.."
23 | msgstr ""
--------------------------------------------------------------------------------