├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── build.bat
└── src
├── Run Debug Mode.bat
├── Thumbparams_Configurator
├── Thumbparams_Configurator.sln
└── Thumbparams_Configurator
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── AssemblyInfo.cs
│ ├── Config.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── Thumbparams_Configurator.csproj
│ ├── Thumbparams_Configurator.csproj.user
│ └── icon.ico
├── VERSION
├── app.vrmanifest
├── bindings
├── chest_thumbparams_bindings.json
├── first_launch
├── knuckles_thumbparams_bindings.json
├── left_elbow_thumbparams_bindings.json
├── left_foot_thumbparams_bindings.json
├── left_knee_thumbparams_bindings.json
├── right_elbow_thumbparams_bindings.json
├── right_foot_thumbparams_bindings.json
├── right_knee_thumbparams_bindings.json
├── touch_thumbparams_bindings.json
└── waist_thumbparams_bindings.json
├── config.json
├── icon.ico
├── main.py
├── osc.py
├── ovr.py
├── print_parameters_markdown.py
├── requirements.txt
├── setup.py
├── tinyoscquery
├── query.py
├── queryservice.py
├── shared
│ ├── __init__.py
│ └── node.py
└── utility.py
├── tray_icon.py
├── xbox_controller.py
└── xinput_joystick.py
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: i5ucc
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13 | custom:
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | output/
2 | build/
3 | dist/
4 | src/output/
5 | src/build/
6 | src/dist/
7 | .vscode/
8 | venv/
9 | obj/
10 | bin/
11 | .vs/
12 | __pycache__/
13 | *.log
14 | .venv/
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ThumbParamsOSC
2 | [](https://github.com/I5UCC/VRCThumbParamsOSC/releases/latest)
3 | [](https://github.com/I5UCC/VRCThumbParamsOSC/releases/latest)
4 |
5 |
6 | OSC program that makes SteamVR controller actions, Tracker button actions and XInput actions accessible as Avatar Parameters.
7 |
8 | Currently supports ***Valve-Index***, ***Oculus(Meta)-Touch***, SteamVR Trackers and XInput Controllers.
9 |
10 | ### [ Discord Support Server](https://discord.gg/rqcWHje3hn)
11 |
12 | ### [🢃 Download Latest release](https://github.com/I5UCC/VRCThumbParamsOSC/releases/latest)
13 |
14 | # Available Parameters
15 |
16 | Following sections go over all available parameters.
17 | All parameters are **case-sensitive**.
18 |
19 | ## SteamVR Controller Parameters
20 |
21 | | Parameter | Type |
22 | |-----------|------|
23 | | ControllerType | int |
24 | | RightThumb | int |
25 | | LeftThumb | int |
26 | | LeftAButton | bool |
27 | | LeftBButton | bool |
28 | | LeftABButtons | bool |
29 | | LeftTrackPad | bool |
30 | | LeftThumbStick | bool |
31 | | RightAButton | bool |
32 | | RightBButton | bool |
33 | | RightABButtons | bool |
34 | | RightTrackPad | bool |
35 | | RightThumbStick | bool |
36 | | LeftAButtonClick | bool |
37 | | LeftBButtonClick | bool |
38 | | LeftTrackPadClick | bool |
39 | | LeftThumbStickClick | bool |
40 | | RightAButtonClick | bool |
41 | | RightBButtonClick | bool |
42 | | RightTrackPadClick | bool |
43 | | RightThumbStickClick | bool |
44 | | LeftGrab | bool |
45 | | RightGrab | bool |
46 | | LeftTrigger | float |
47 | | RightTrigger | float |
48 | | LeftGrabForce | float |
49 | | RightGrabForce | float |
50 | | RightTrackpadForce | float |
51 | | LeftTrackpadForce | float |
52 | | LeftStickMoved | bool |
53 | | RightStickMoved | bool |
54 | | LeftTrackPadY | float |
55 | | RightTrackPadY | float |
56 |
57 | ## Tracker Parameters
58 |
59 | | Parameter | Type |
60 | |-----------|------|
61 | | LeftFootTracker | bool |
62 | | RightFootTracker | bool |
63 | | WaistTracker | bool |
64 | | ChestTracker | bool |
65 | | LeftElbowTracker | bool |
66 | | RightElbowTracker | bool |
67 | | LeftKneeTracker | bool |
68 | | RightKneeTracker | bool |
69 |
70 | ## XInput Parameters
71 |
72 | | Parameter | Type |
73 | |-----------|------|
74 | | XInputAButton | bool |
75 | | XInputBButton | bool |
76 | | XInputXButton | bool |
77 | | XInputYButton | bool |
78 | | XInputLeftThumbstick | bool |
79 | | XInputRightThumbstick | bool |
80 | | XInputLeftBumper | bool |
81 | | XInputRightBumper | bool |
82 | | XInputBackButton | bool |
83 | | XInputStartButton | bool |
84 | | XInputLeftDPad | bool |
85 | | XInputRightDPad | bool |
86 | | XInputUpDPad | bool |
87 | | XInputDownDPad | bool |
88 | | XInputLeftTrigger | float |
89 | | XInputRightTrigger | float |
90 | | XInputLeftStickMoved | bool |
91 | | XInputRightStickMoved | bool |
92 | | XInputDPadMoved | bool |
93 |
94 | ## Special Parameters
95 |
96 | The two int parameters ***RightThumb*** and ***LeftThumb*** represent the position of each thumb with the numbers from 0 to 4:
97 |
98 | | Value | Real Position |
99 | | ----- | ------------- |
100 | | 0 | Not Touching |
101 | | 1 | A/X Button |
102 | | 2 | B/Y Button |
103 | | 3 | Trackpad |
104 | | 4 | Thumbstick |
105 |
106 | The int ***ControllerType*** gives what controller is currently being used:
107 |
108 | | Controller | Value |
109 | | ----- | ------------- |
110 | | Meta/Oculus Touch | 2 |
111 | | Index | 1 |
112 | | XInput Controller | 10 |
113 | | XInput+Meta | 12 |
114 | | XInput+Index | 11 |
115 | | Any other controller/No Controller | 0 |
116 |
117 | ***\[Left/Right]ABButtons*** detects if the thumb is on *either* the A or B buttons, or Touching both *at the same time*.
118 |
119 | Tracker Power button parameters require Tracker roles to be set up in SteamVR:
120 | Go to `SteamVR-Settings > Manage Trackers` and set up tracking roles for each tracker respectively:
121 | 
122 |
123 | # How to use
124 |
125 | Activate OSC in VRChat:
126 | 
127 |
128 | In Action menu, got to Options>OSC>Enable
129 |
130 | Run `Configurator.exe` to configure the program.
131 |
132 | Then just run the `ThumbParamsOSC.exe` and you are all set!
133 |
134 | # OSC Troubleshoot
135 |
136 | If you have problems with this program, try this to fix it:
137 | - Automatic way:
138 | - Close VRChat.
139 | - Run `Configurator.exe` and click on the Button "Reset OSC Config"
140 | - Startup VRChat again and it should work.
141 | - Manual way:
142 | - Close VRChat.
143 | - Open 'Run' in Windows (Windows Key + R)
144 | - Type in `%APPDATA%\..\LocalLow\VRChat\VRChat\OSC`
145 | - Delete the folders that start with 'usr_*'.
146 | - Startup VRChat again and it should work.
147 |
148 | # Decreasing OSC Traffic
149 | ThumbparamsOSC consistently sends the current state of each parameter, with a lot of parameters the OSC traffic can increase significantly.
150 | To mitigate this there are a three things you can do:
151 | - Disable all parameters that you do not need.
152 | - Switch to a different mode then "Always Send"
153 | - Lower the Polling Rate
154 | You can read on how to do that in [#Configuration](https://github.com/I5UCC/VRCThumbParamsOSC?tab=readme-ov-file#configuration)
155 |
156 | # Configuration
157 |
158 | Running `Configurator.exe` lets you customize the Parameters that you want to have sent to VRChat, and some more things:
159 |
160 | 
161 |
162 | Unchecking or checking any of the parameters and the hitting `save` will save the current settings.
163 | You can use the buttons below to do quick unticking or ticking of groups of parameters
164 | - `Floating Time` allows values "float" on the last value registered, it is measured in seconds.
165 | - If `Floating Time` is set to -1 for boolean values, they will act like a toggle instead of always updating to the current state.
166 | - Tick the `Unsigned` Box for any supported parameter to map the float value to [0, 1] instead of [-1, 1]
167 | - `Mode` has 3 different values:
168 | - "Send On Change" (Default) As the name might suggest, it sends a parameter only when it has changed from its previous value.
169 | - "Send On Positive" It sends a Parameter when it changes, but also continuosly sends Positive values every Poll.
170 | - "Always Send" This is like the old behaviour, just sends the parameters current state every Poll.
171 | - You can use the three buttons below to quickly switch between modes for every parameter
172 |
173 | # Automatic launch with SteamVR
174 | On first launch of the program, it registers as an Overlay app on SteamVR just like other well known programs like XSOverlay or OVRAdvancedSettings and can be launched on startup:
175 | 
176 | 
177 |
178 | After setting the option to ON it will launch the program ***without the console*** on SteamVR startup.
179 |
180 | # Command line Arguments
181 | You can run this by using ```ThumbParamsOSC.exe {Arguments}``` in command line.
182 |
183 | | Option | Value |
184 | | ----- | ------------- |
185 | | -d, --debug | prints values for debugging |
186 | | -i IP, --ip IP | set OSC IP. Default=127.0.0.1 |
187 | | -p PORT, --port PORT | set OSC port. Default=9000 |
188 |
189 | # Credit
190 | - [pyopenvr](https://github.com/cmbruns/pyopenvr) thank you.
191 | - [benaclejames](https://github.com/benaclejames) and [Greendayle](https://github.com/Greendayle) for the inspiration!
192 |
193 | # Great Projects making use of ThumbparamsOSC:
194 | - [VRC-ASL_Gestures](https://github.com/I5UCC/VRC-ASL_Gestures) by me :)
195 | - [VRCImmersiveImmobilize](https://github.com/I5UCC/VRCImmersiveImmobilize) by me :)
196 | - [AutoImmobilizeOSC](https://github.com/SouljaVR/AutoImmobilizeOSC) by [SouljaVR](https://github.com/SouljaVR)
197 | - [Drone-OSC-Controller](https://github.com/qbitzvr/Drone-OSC-Controller) by [Qbitz](https://github.com/qbitzvr)
198 |
--------------------------------------------------------------------------------
/build.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | cd %~dp0
4 | rmdir /S /Q src/build
5 | rmdir /S /Q build
6 | rmdir /S /Q src\Thumbparams_Configurator\Thumbparams_Configurator\bin
7 |
8 | cd src/Thumbparams_Configurator
9 | dotnet publish -r win-x64
10 | cd ..
11 | "../.venv/Scripts/python.exe" setup.py build
12 | cd build
13 | robocopy exe.win-amd64-3.11 ThumbparamsOSC /MOVE /E /NFL /NDL /NJH /NJS /nc /ns /np
14 | cd ..
15 | powershell -c "copy Thumbparams_Configurator\Thumbparams_Configurator\bin\Debug\net4.8.1-windows\win-x64\publish\Thumbparams_Configurator.exe build/ThumbparamsOSC/Configurator.exe"
16 | powershell -c "copy Thumbparams_Configurator\Thumbparams_Configurator\bin\Debug\net4.8.1-windows\win-x64\publish\Newtonsoft.Json.dll build/ThumbparamsOSC/Newtonsoft.Json.dll"
17 | cd %~dp0
18 | robocopy src/build build /MOVE /E /NFL /NDL /NJH /NJS /nc /ns /np
19 | cd build
20 | 7z a ThumbparamsOSC.zip ThumbparamsOSC
--------------------------------------------------------------------------------
/src/Run Debug Mode.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | start ThumbParamsOSC.exe --debug
--------------------------------------------------------------------------------
/src/Thumbparams_Configurator/Thumbparams_Configurator.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.3.32804.467
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thumbparams_Configurator", "Thumbparams_Configurator\Thumbparams_Configurator.csproj", "{C6082960-8B8D-4531-8628-702C4EC3F844}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {C6082960-8B8D-4531-8628-702C4EC3F844}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {C6082960-8B8D-4531-8628-702C4EC3F844}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {C6082960-8B8D-4531-8628-702C4EC3F844}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {C6082960-8B8D-4531-8628-702C4EC3F844}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {0810E561-83D9-4326-82E5-1A0CA43E8B68}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/src/Thumbparams_Configurator/Thumbparams_Configurator/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/Thumbparams_Configurator/Thumbparams_Configurator/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace Configurator
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Thumbparams_Configurator/Thumbparams_Configurator/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Thumbparams_Configurator/Thumbparams_Configurator/Config.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace Configurator
5 | {
6 | public class Action
7 | {
8 | public string name { get; set; }
9 | public string type { get; set; }
10 | public string skeleton { get; set; }
11 | public object osc_parameter { get; set; }
12 | public object enabled { get; set; }
13 | public object always { get; set; }
14 | public object floating { get; set; }
15 | public object timestamp { get; set; }
16 | public object last_value { get; set; }
17 | public object unsigned { get; set; }
18 | public object binary { get; set; }
19 | }
20 |
21 | public class ControllerType
22 | {
23 | public bool enabled { get; set; }
24 | public int always { get; set; }
25 | public int last_value { get; set; }
26 | public int timestamp { get; set; }
27 | }
28 |
29 | public class SpecialParameter
30 | {
31 | public bool enabled { get; set; }
32 | public int always { get; set; }
33 | public int last_value { get; set; }
34 | }
35 |
36 | public class DefaultBinding
37 | {
38 | public string controller_type { get; set; }
39 | public string binding_url { get; set; }
40 | }
41 |
42 | public class Config
43 | {
44 | public string IP { get; set; }
45 | public int Port { get; set; }
46 | public int Server_Port { get; set; }
47 | public int HTTP_Port { get; set; }
48 | public int PollingRate { get; set; }
49 | public int StickMoveTolerance { get; set; }
50 | public int Binary_bits { get; set; }
51 | public ControllerType ControllerType { get; set; }
52 | public SpecialParameter LeftThumb { get; set; }
53 | public SpecialParameter RightThumb { get; set; }
54 | public SpecialParameter LeftABButtons { get; set; }
55 | public SpecialParameter RightABButtons { get; set; }
56 | public List default_bindings { get; set; }
57 | public List actions { get; set; }
58 | public List xinput_actions { get; set; }
59 | public List ConcatenateActions()
60 | {
61 | return actions.Concat(xinput_actions).ToList();
62 | }
63 | }
64 |
65 | }
--------------------------------------------------------------------------------
/src/Thumbparams_Configurator/Thumbparams_Configurator/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | Send On Change
34 | Send On Positive
35 | Always Send
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/src/Thumbparams_Configurator/Thumbparams_Configurator/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.IO;
4 | using System.Collections.ObjectModel;
5 | using Newtonsoft.Json;
6 | using Newtonsoft.Json.Linq;
7 | using System.Windows.Controls;
8 | using System.Text.RegularExpressions;
9 | using System.Security.RightsManagement;
10 |
11 | namespace Configurator
12 | {
13 | public partial class MainWindow : Window
14 | {
15 | public ObservableCollection ParameterList { get; set; }
16 | private Config config;
17 | private string ConfigPath;
18 | private bool Startup;
19 |
20 | public MainWindow()
21 | {
22 | Startup = true;
23 | InitializeComponent();
24 | ParameterList = new ObservableCollection();
25 |
26 | ConfigPath = AppDomain.CurrentDomain.BaseDirectory + "config.json";
27 | config = JsonConvert.DeserializeObject(File.ReadAllText(ConfigPath));
28 |
29 | Tbx_IP.Text = config.IP;
30 | Tbx_Port.Text = config.Port.ToString();
31 | Tbx_Server_Port.Text = config.Server_Port.ToString();
32 | Tbx_http_port.Text = config.HTTP_Port.ToString();
33 | Tbx_PollingRate.Text = config.PollingRate.ToString();
34 | Tbx_StickMoveTolerance.Text = config.StickMoveTolerance.ToString();
35 | Tbx_Binary.Text = config.Binary_bits.ToString();
36 |
37 | ParameterList.Add(new BoolStringClass("ControllerType", config.ControllerType.enabled, config.ControllerType.always, "Integer", "Unavailable", false, false, false, "Hidden"));
38 | ParameterList.Add(new BoolStringClass("LeftThumb", config.LeftThumb.enabled, config.LeftThumb.always, "Integer", "Infl. by bools", false, false, false, "Hidden"));
39 | ParameterList.Add(new BoolStringClass("RightThumb", config.RightThumb.enabled, config.RightThumb.always, "Integer", "Infl. by bools", false, false, false, "Hidden"));
40 |
41 | ParameterList.Add(new BoolStringClass("LeftABButtons", config.LeftABButtons.enabled, config.LeftABButtons.always, "Boolean", "Infl. by A,B", false, false, false, "Hidden"));
42 | ParameterList.Add(new BoolStringClass("RightABButtons", config.RightABButtons.enabled, config.RightABButtons.always, "Boolean", "Infl. by A,B", false, false, false, "Hidden"));
43 |
44 | foreach (Action a in config.ConcatenateActions()) {
45 | if (a.type != "vector2")
46 | {
47 | ParameterList.Add(new BoolStringClass((string)a.osc_parameter, (bool)a.enabled, int.Parse(a.always.ToString()), a.type == "boolean" ? "Boolean" : a.type == "skeleton" ? "Skeleton" : "Float", a.floating.ToString(), true, false, (bool)a.binary, "Hidden"));
48 | }
49 | else {
50 | String[] tmp = ((JArray)a.osc_parameter).ToObject();
51 | bool[] tmp2 = ((JArray)a.enabled).ToObject();
52 | float[] tmp3 = ((JArray)a.floating).ToObject();
53 | int[] tmp4 = ((JArray)a.always).ToObject();
54 | bool[] tmp5 = ((JArray)a.unsigned).ToObject();
55 | bool[] tmp6 = ((JArray)a.binary).ToObject();
56 | for (int i = 0; i < tmp.Length; i++)
57 | {
58 | ParameterList.Add(new BoolStringClass(tmp[i], tmp2[i], tmp4[i], i > 1 ? "Boolean" : "Float", tmp3[i] == -100 ? "Infl. by X,Y" : tmp3[i].ToString(), tmp3[i] != -100, i < 2 ? tmp5[i] : true, i < 2 ? tmp6[i] : true, i >= 2 ? "Hidden" : "Visible"));
59 | }
60 | }
61 | }
62 |
63 | this.DataContext = this;
64 | Startup = false;
65 | }
66 |
67 | public class BoolStringClass
68 | {
69 | public BoolStringClass(string Text, bool IsSelected, int AlwaysSend, string Type, string Floating = "0.0", bool isEnabled = true, bool Unsigned = true, bool Binary = true, string Unsigned_Visibility = "Visible")
70 | {
71 | this.Text = Text;
72 | this.IsSelected = IsSelected;
73 | this.AlwaysSend = AlwaysSend;
74 | this.Type = Type;
75 | this.Floating = this.Type == "Skeleton" ? "Unavailable" : Floating;
76 | this.isEnabled = this.Type == "Skeleton" ? false : isEnabled;
77 | this.Unsigned = Unsigned;
78 | this.Binary = Binary;
79 | this.Unsigned_Visibility = Unsigned_Visibility;
80 | this.Binary_Visibility = this.Type == "Float" ? "Visible" : "Hidden";
81 | this.isModesEnabled = this.Type == "Skeleton" ? false : true;
82 | }
83 |
84 | public string Text { get; set; }
85 |
86 | public bool IsSelected { get; set; }
87 |
88 | public int AlwaysSend { get; set; }
89 |
90 | public string Type { get; set; }
91 |
92 | public string Floating { get; set; }
93 |
94 | public bool isEnabled { get; set; }
95 |
96 | public bool Unsigned { get; set; }
97 |
98 | public bool Binary { get; set; }
99 |
100 | public string Unsigned_Visibility { get; set; }
101 |
102 | public string Binary_Visibility { get; set; }
103 |
104 | public bool isModesEnabled { get; set; }
105 |
106 | public string DisplayString
107 | {
108 | get { return String.Format("{0,-25}\t{1}\t", Text, Type); }
109 | }
110 |
111 | }
112 |
113 | private void Save_Clicked(object sender, RoutedEventArgs e)
114 | {
115 | File.WriteAllText(ConfigPath, JsonConvert.SerializeObject(config, Formatting.Indented));
116 | Close();
117 | }
118 |
119 |
120 | private void CheckBox_Checked_Unsigned(object sender, RoutedEventArgs e)
121 | {
122 | if (Startup)
123 | return;
124 |
125 | CheckBox checkBox = sender as CheckBox;
126 |
127 | bool check = (bool)checkBox.IsChecked;
128 | string name = checkBox.ToolTip.ToString();
129 |
130 | foreach (Action a in config.actions)
131 | {
132 | if (a.type == "vector2")
133 | {
134 | JArray tmp = ((JArray)a.osc_parameter);
135 | JArray tmp2 = ((JArray)a.unsigned);
136 |
137 | for (int i = 0; i < tmp.Count; i++)
138 | {
139 | if (tmp[i].ToString() == name)
140 | {
141 | tmp2[i] = check;
142 | a.unsigned = tmp2;
143 | return;
144 | }
145 | }
146 | }
147 | }
148 | foreach (Action a in config.xinput_actions)
149 | {
150 | if (a.type == "vector2")
151 | {
152 | JArray tmp = ((JArray)a.osc_parameter);
153 | JArray tmp2 = ((JArray)a.unsigned);
154 |
155 | for (int i = 0; i < tmp.Count; i++)
156 | {
157 | if (tmp[i].ToString() == name)
158 | {
159 | tmp2[i] = check;
160 | a.unsigned = tmp2;
161 | return;
162 | }
163 | }
164 | }
165 | }
166 |
167 | }
168 |
169 | private void CheckBox_Checked_Binary(object sender, RoutedEventArgs e)
170 | {
171 | if (Startup)
172 | return;
173 |
174 | CheckBox checkBox = sender as CheckBox;
175 |
176 | bool check = (bool)checkBox.IsChecked;
177 | string name = checkBox.ToolTip.ToString();
178 |
179 | foreach (Action a in config.actions)
180 | {
181 | if (a.type == "vector2")
182 | {
183 | JArray tmp = ((JArray)a.osc_parameter);
184 | JArray tmp2 = ((JArray)a.binary);
185 |
186 | for (int i = 0; i < tmp.Count; i++)
187 | {
188 | if (tmp[i].ToString() == name)
189 | {
190 | tmp2[i] = check;
191 | a.binary = tmp2;
192 | return;
193 | }
194 | }
195 | }
196 | else
197 | {
198 | if (a.osc_parameter.ToString() == name)
199 | a.binary = check;
200 | }
201 | }
202 | foreach (Action a in config.xinput_actions)
203 | {
204 | if (a.type == "vector2")
205 | {
206 | JArray tmp = ((JArray)a.osc_parameter);
207 | JArray tmp2 = ((JArray)a.binary);
208 |
209 | for (int i = 0; i < tmp.Count; i++)
210 | {
211 | if (tmp[i].ToString() == name)
212 | {
213 | tmp2[i] = check;
214 | a.binary = tmp2;
215 | return;
216 | }
217 | }
218 | }
219 | else
220 | {
221 | if (a.osc_parameter.ToString() == name)
222 | a.binary = check;
223 | }
224 | }
225 |
226 | }
227 |
228 |
229 | private void CheckBox_Checked(object sender, RoutedEventArgs e)
230 | {
231 | if (Startup)
232 | return;
233 |
234 | CheckBox checkBox = sender as CheckBox;
235 |
236 | bool check = (bool)checkBox.IsChecked;
237 | string content = checkBox.Content.ToString();
238 | string name = content.Substring(0, content.IndexOf(" "));
239 |
240 | switch (name)
241 | {
242 | case "ControllerType":
243 | config.ControllerType.enabled = check;
244 | return;
245 | case "LeftThumb":
246 | config.LeftThumb.enabled = check;
247 | return;
248 | case "RightThumb":
249 | config.RightThumb.enabled = check;
250 | return;
251 | case "LeftABButtons":
252 | config.LeftABButtons.enabled = check;
253 | return;
254 | case "RightABButtons":
255 | config.RightABButtons.enabled = check;
256 | return;
257 | }
258 |
259 | foreach (Action a in config.actions)
260 | {
261 | if (a.type != "vector2")
262 | {
263 | if (a.osc_parameter.ToString() == name)
264 | {
265 | a.enabled = check;
266 | return;
267 | }
268 | }
269 | else
270 | {
271 | JArray tmp = ((JArray)a.osc_parameter);
272 | JArray tmp2 = ((JArray)a.enabled);
273 |
274 | for (int i = 0; i < tmp.Count; i++)
275 | {
276 | if (tmp[i].ToString() == name)
277 | {
278 | tmp2[i] = check;
279 | a.enabled = tmp2;
280 | return;
281 | }
282 | }
283 | }
284 | }
285 | foreach (Action a in config.xinput_actions)
286 | {
287 | if (a.type != "vector2")
288 | {
289 | if (a.osc_parameter.ToString() == name)
290 | {
291 | a.enabled = check;
292 | return;
293 | }
294 | }
295 | else
296 | {
297 | JArray tmp = ((JArray)a.osc_parameter);
298 | JArray tmp2 = ((JArray)a.enabled);
299 |
300 | for (int i = 0; i < tmp.Count; i++)
301 | {
302 | if (tmp[i].ToString() == name)
303 | {
304 | tmp2[i] = check;
305 | a.enabled = tmp2;
306 | return;
307 | }
308 | }
309 | }
310 | }
311 |
312 | }
313 |
314 | private void TextChanged(object sender, TextChangedEventArgs e)
315 | {
316 | if (Startup)
317 | return;
318 |
319 | Tbx_Port.Text = Regex.Replace(Tbx_Port.Text, "[^0-9]", "");
320 | Tbx_Port.SelectionStart = Tbx_Port.Text.Length;
321 | Tbx_Server_Port.Text = Regex.Replace(Tbx_Server_Port.Text, "[^0-9]", "");
322 | Tbx_Server_Port.SelectionStart = Tbx_Server_Port.Text.Length;
323 | Tbx_http_port.Text = Regex.Replace(Tbx_http_port.Text, "[^0-9]", "");
324 | Tbx_http_port.SelectionStart = Tbx_http_port.Text.Length;
325 | Tbx_PollingRate.Text = Regex.Replace(Tbx_PollingRate.Text, "[^0-9]", "");
326 | Tbx_PollingRate.SelectionStart = Tbx_PollingRate.Text.Length;
327 | Tbx_StickMoveTolerance.Text = Regex.Replace(Tbx_StickMoveTolerance.Text, "[^0-9]", "");
328 | Tbx_StickMoveTolerance.SelectionStart = Tbx_StickMoveTolerance.Text.Length;
329 | Tbx_Binary.Text = Regex.Replace(Tbx_Binary.Text, "[^0-9]", "");
330 | Tbx_Binary.SelectionStart = Tbx_Binary.Text.Length;
331 |
332 | config.IP = Tbx_IP.Text;
333 | config.Port = Tbx_Port.Text != "" ? int.Parse(Tbx_Port.Text) : 0;
334 | config.Server_Port = Tbx_Server_Port.Text != "" ? int.Parse(Tbx_Server_Port.Text) : 0;
335 | config.HTTP_Port = Tbx_http_port.Text != "" ? int.Parse(Tbx_http_port.Text) : 0;
336 | config.PollingRate = Tbx_PollingRate.Text != "" ? int.Parse(Tbx_PollingRate.Text) : 0;
337 | config.StickMoveTolerance = Tbx_StickMoveTolerance.Text != "" ? int.Parse(Tbx_StickMoveTolerance.Text) : 0;
338 | config.Binary_bits = Tbx_Binary.Text != "" ? int.Parse(Tbx_Binary.Text) : 0;
339 | }
340 |
341 | private void Button_Param_Click(object sender, RoutedEventArgs e)
342 | {
343 | if (Startup)
344 | return;
345 | Startup = true;
346 | bool value = ((Button)sender).Name == "TAP";
347 | foreach (BoolStringClass item in Lbx_Params.Items)
348 | {
349 | item.IsSelected = value;
350 | }
351 |
352 | config.ControllerType.enabled = value;
353 | config.LeftThumb.enabled = value;
354 | config.RightThumb.enabled = value;
355 | config.LeftABButtons.enabled = value;
356 | config.RightABButtons.enabled = value;
357 |
358 | foreach (Action a in config.actions)
359 | {
360 | if (a.type == "vector2")
361 | {
362 | if (((JArray)a.enabled).Count > 2)
363 | a.enabled = new JArray(new bool[3] { value, value, value });
364 | else
365 | a.enabled = new JArray(new bool[2] { value, value });
366 | }
367 | else
368 | {
369 | a.enabled = value;
370 | }
371 | }
372 | foreach (Action a in config.xinput_actions)
373 | {
374 | if (a.type == "vector2")
375 | {
376 | if (((JArray)a.enabled).Count > 2)
377 | a.enabled = new JArray(new bool[3] { value, value, value });
378 | else
379 | a.enabled = new JArray(new bool[2] { value, value });
380 | }
381 | else
382 | {
383 | a.enabled = value;
384 | }
385 | }
386 |
387 | Lbx_Params.Items.Refresh();
388 | Startup = false;
389 | }
390 |
391 | private void Tick_all_Click(object sender, RoutedEventArgs e)
392 | {
393 | if (Startup)
394 | return;
395 | Startup = true;
396 | foreach (BoolStringClass item in Lbx_Params.Items)
397 | {
398 | item.IsSelected = true;
399 | }
400 |
401 | config.ControllerType.enabled = true;
402 | config.LeftThumb.enabled = true;
403 | config.RightThumb.enabled = true;
404 | config.LeftABButtons.enabled = true;
405 | config.RightABButtons.enabled = true;
406 |
407 | foreach (Action a in config.actions)
408 | {
409 | if (a.type == "vector2")
410 | {
411 | if (((JArray)a.enabled).Count > 2)
412 | a.enabled = new JArray(new bool[3] { true, true, true });
413 | else
414 | a.enabled = new JArray(new bool[2] { true, true });
415 | }
416 | else
417 | {
418 | a.enabled = true;
419 | }
420 | }
421 | foreach (Action a in config.xinput_actions)
422 | {
423 | if (a.type == "vector2")
424 | {
425 | if (((JArray)a.enabled).Count > 2)
426 | a.enabled = new JArray(new bool[3] { true, true, true });
427 | else
428 | a.enabled = new JArray(new bool[2] { true, true });
429 | }
430 | else
431 | {
432 | a.enabled = true;
433 | }
434 | }
435 | Startup = false;
436 | Lbx_Params.Items.Refresh();
437 | }
438 |
439 | private void Reset_OSC_Clicked(object sender, RoutedEventArgs e)
440 | {
441 | if (Startup)
442 | return;
443 | string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
444 | string[] folders = Directory.GetDirectories(appdata + "\\..\\LocalLow\\VRChat\\VRChat\\OSC");
445 | foreach (string folder in folders)
446 | {
447 | string foldername = folder.Substring(folder.LastIndexOf("\\") + 1);
448 | if (foldername.Contains("usr_"))
449 | {
450 | DirectoryInfo dir = new DirectoryInfo(folder);
451 | dir.Delete(true);
452 | }
453 | }
454 | MessageBox.Show("OSC cache cleared!", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
455 | }
456 |
457 | private void Mode_Click(object sender, RoutedEventArgs e)
458 | {
459 | if (Startup)
460 | return;
461 | Startup = true;
462 | Button button = sender as Button;
463 | int value = button.Name == "ASP" ? 1 : button.Name == "AS" ? 2 : 0;
464 |
465 | foreach (BoolStringClass item in Lbx_Params.Items)
466 | {
467 | item.AlwaysSend = value;
468 | }
469 |
470 | config.ControllerType.always = value;
471 | config.LeftThumb.always = value;
472 | config.RightThumb.always = value;
473 | config.LeftABButtons.always = value;
474 | config.RightABButtons.always = value;
475 |
476 | foreach (Action a in config.actions)
477 | {
478 | if (a.type == "vector2")
479 | {
480 | if (((JArray)a.enabled).Count > 2)
481 | a.always = new JArray(new int[3] { value, value, value });
482 | else
483 | a.always = new JArray(new int[2] { value, value });
484 | }
485 | else
486 | {
487 | a.always = value;
488 | }
489 | }
490 | foreach (Action a in config.xinput_actions)
491 | {
492 | if (a.type == "vector2")
493 | {
494 | if (((JArray)a.enabled).Count > 2)
495 | a.always = new JArray(new int[3] { value, value, value });
496 | else
497 | a.always = new JArray(new int[2] { value, value });
498 | }
499 | else
500 | {
501 | a.always = value;
502 | }
503 | }
504 | Startup = false;
505 | Lbx_Params.Items.Refresh();
506 | }
507 |
508 | private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
509 | {
510 | if (Startup)
511 | return;
512 | string text = ((TextBox)sender).Text;
513 | if (text == string.Empty || text == "-")
514 | text = "0";
515 |
516 | for (int i = 0; i < config.actions.Count; i++)
517 | {
518 | Action a = config.actions[i];
519 | if (a.osc_parameter is string)
520 | {
521 | if (a.osc_parameter.ToString() == ((TextBox)sender).ToolTip.ToString())
522 | {
523 | a.floating = float.Parse(text.Replace(".", ","));
524 | return;
525 | }
526 | }
527 | else
528 | {
529 | string[] temp = ((JArray)a.osc_parameter).ToObject();
530 | float[] floats = null;
531 |
532 | if (a.floating is Single[])
533 | floats = (Single[])a.floating;
534 | else
535 | floats = ((JArray)a.floating).ToObject();
536 |
537 | for (int j = 0; j < temp.Length; j++)
538 | {
539 | if (temp[j].ToString() == ((TextBox)sender).ToolTip.ToString())
540 | {
541 | floats[j] = float.Parse(text.Replace(".", ","));
542 | config.actions[i].floating = floats;
543 | }
544 | }
545 | }
546 |
547 | }
548 | for (int i = 0; i < config.xinput_actions.Count; i++)
549 | {
550 | Action a = config.xinput_actions[i];
551 | if (a.osc_parameter is string)
552 | {
553 | if (a.osc_parameter.ToString() == ((TextBox)sender).ToolTip.ToString())
554 | {
555 | a.floating = float.Parse(text.Replace(".", ","));
556 | return;
557 | }
558 | }
559 | else
560 | {
561 | string[] temp = ((JArray)a.osc_parameter).ToObject();
562 | float[] floats = null;
563 |
564 | if (a.floating is Single[])
565 | floats = (Single[])a.floating;
566 | else
567 | floats = ((JArray)a.floating).ToObject();
568 |
569 | for (int j = 0; j < temp.Length; j++)
570 | {
571 | if (temp[j].ToString() == ((TextBox)sender).ToolTip.ToString())
572 | {
573 | floats[j] = float.Parse(text.Replace(".", ","));
574 | config.xinput_actions[i].floating = floats;
575 | }
576 | }
577 | }
578 |
579 | }
580 | }
581 |
582 | private void TextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
583 | {
584 | if (Startup)
585 | return;
586 | Regex regex = new Regex("[0-9,\\.-]+");
587 | e.Handled = !regex.IsMatch(e.Text);
588 | }
589 |
590 | private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
591 | {
592 | if (Startup)
593 | return;
594 | ComboBox box = sender as ComboBox;
595 | string name = box.ToolTip.ToString();
596 | int value = box.SelectedIndex;
597 |
598 | switch (name)
599 | {
600 | case "ControllerType":
601 | config.ControllerType.always = value;
602 | return;
603 | case "LeftThumb":
604 | config.LeftThumb.always = value;
605 | return;
606 | case "RightThumb":
607 | config.RightThumb.always = value;
608 | return;
609 | case "LeftABButtons":
610 | config.LeftABButtons.always = value;
611 | return;
612 | case "RightABButtons":
613 | config.RightABButtons.always = value;
614 | return;
615 | }
616 |
617 | foreach (Action a in config.actions)
618 | {
619 | if (a.type != "vector2")
620 | {
621 | if (a.osc_parameter.ToString() == name)
622 | {
623 | a.always = value;
624 | return;
625 | }
626 | }
627 | else
628 | {
629 | JArray tmp = ((JArray)a.osc_parameter);
630 | JArray tmp2 = ((JArray)a.always);
631 |
632 | for (int i = 0; i < tmp.Count; i++)
633 | {
634 | if (tmp[i].ToString() == name)
635 | {
636 | tmp2[i] = value;
637 | a.always = tmp2;
638 | return;
639 | }
640 | }
641 | }
642 | }
643 |
644 | foreach (Action a in config.xinput_actions)
645 | {
646 | if (a.type != "vector2")
647 | {
648 | if (a.osc_parameter.ToString() == name)
649 | {
650 | a.always = value;
651 | return;
652 | }
653 | }
654 | else
655 | {
656 | JArray tmp = ((JArray)a.osc_parameter);
657 | JArray tmp2 = ((JArray)a.always);
658 |
659 | for (int i = 0; i < tmp.Count; i++)
660 | {
661 | if (tmp[i].ToString() == name)
662 | {
663 | tmp2[i] = value;
664 | a.always = tmp2;
665 | return;
666 | }
667 | }
668 | }
669 | }
670 | }
671 |
672 | private void Untick_SteamVR_Parameters(object sender, RoutedEventArgs e)
673 | {
674 | if (Startup)
675 | return;
676 | Startup = true;
677 | foreach (BoolStringClass item in Lbx_Params.Items)
678 | {
679 | if (!item.Text.Contains("XInput") && item.Text != "ControllerType")
680 | {
681 | item.IsSelected = false;
682 | }
683 | }
684 |
685 | config.LeftThumb.enabled = false;
686 | config.RightThumb.enabled = false;
687 | config.LeftABButtons.enabled = false;
688 | config.RightABButtons.enabled = false;
689 |
690 | foreach (Action a in config.actions)
691 | {
692 | if (a.type == "vector2")
693 | {
694 | if (((JArray)a.enabled).Count > 2)
695 | a.enabled = new JArray(new bool[3] { false, false, false });
696 | else
697 | a.enabled = new JArray(new bool[2] { false, false });
698 | }
699 | else
700 | {
701 | a.enabled = false;
702 | }
703 | }
704 |
705 | Lbx_Params.Items.Refresh();
706 | Startup = false;
707 | }
708 |
709 | private void Untick_XInput_Parameters(object sender, RoutedEventArgs e)
710 | {
711 | if (Startup)
712 | return;
713 | Startup = true;
714 | foreach (BoolStringClass item in Lbx_Params.Items)
715 | {
716 | if (item.Text.Contains("XInput"))
717 | {
718 | item.IsSelected = false;
719 | }
720 | }
721 |
722 | foreach (Action a in config.xinput_actions)
723 | {
724 | if (a.type == "vector2")
725 | {
726 | if (((JArray)a.enabled).Count > 2)
727 | a.enabled = new JArray(new bool[3] { false, false, false });
728 | else
729 | a.enabled = new JArray(new bool[2] { false, false });
730 | }
731 | else
732 | {
733 | a.enabled = false;
734 | }
735 | }
736 |
737 | Lbx_Params.Items.Refresh();
738 | Startup = false;
739 | }
740 | }
741 | }
742 |
--------------------------------------------------------------------------------
/src/Thumbparams_Configurator/Thumbparams_Configurator/Thumbparams_Configurator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net4.8.1-windows
6 | true
7 | icon.ico
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Thumbparams_Configurator/Thumbparams_Configurator/Thumbparams_Configurator.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Designer
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Thumbparams_Configurator/Thumbparams_Configurator/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/I5UCC/VRCThumbParamsOSC/dbc3b1e6b5ef3f3b820a1cf812d9a6ca3e3b6f3d/src/Thumbparams_Configurator/Thumbparams_Configurator/icon.ico
--------------------------------------------------------------------------------
/src/VERSION:
--------------------------------------------------------------------------------
1 | v2.3.2
--------------------------------------------------------------------------------
/src/app.vrmanifest:
--------------------------------------------------------------------------------
1 | {
2 | "source": "builtin",
3 | "applications": [
4 | {
5 | "app_key": "i5ucc.thumbparamsosc",
6 | "launch_type": "binary",
7 | "binary_path_windows": "./ThumbParamsOSC_NoConsole.exe",
8 | "is_dashboard_overlay": true,
9 | "action_manifest_path": "./config.json",
10 |
11 | "strings": {
12 | "en_us": {
13 | "name": "ThumbParamsOSC",
14 | "description": "ThumbParams implementation to send touched face buttons over OSC"
15 | }
16 | }
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/src/bindings/chest_thumbparams_bindings.json:
--------------------------------------------------------------------------------
1 | {
2 | "action_manifest_version" : 0,
3 | "alias_info" : {},
4 | "app_key" : "i5ucc.thumbparamsosc",
5 | "bindings" : {
6 | "/actions/thumbparams" : {
7 | "sources" : [
8 | {
9 | "inputs" : {
10 | "click" : {
11 | "output" : "/actions/thumbparams/in/chesttracker"
12 | }
13 | },
14 | "mode" : "button",
15 | "path" : "/user/chest/input/power"
16 | }
17 | ]
18 | }
19 | },
20 | "category" : "steamvr_input",
21 | "controller_type" : "vive_tracker_chest",
22 | "description" : "",
23 | "interaction_profile" : "",
24 | "name" : "Default configuration for ThumbParamsOSC Vive Tracker on Chest",
25 | "options" : {},
26 | "simulated_actions" : []
27 | }
28 |
--------------------------------------------------------------------------------
/src/bindings/first_launch:
--------------------------------------------------------------------------------
1 | This file gets deleted after first launch :)
--------------------------------------------------------------------------------
/src/bindings/knuckles_thumbparams_bindings.json:
--------------------------------------------------------------------------------
1 | {
2 | "action_manifest_version" : 0,
3 | "alias_info" : {},
4 | "app_key" : "i5ucc.thumbparamsosc",
5 | "bindings" : {
6 | "/actions/thumbparams" : {
7 | "skeleton": [
8 | {
9 | "output": "/actions/thumbparams/in/LeftHandSkeleton",
10 | "path": "/user/hand/left/input/skeleton/left"
11 | },
12 | {
13 | "output": "/actions/thumbparams/in/RightHandSkeleton",
14 | "path": "/user/hand/right/input/skeleton/right"
15 | }
16 | ],
17 | "sources" : [
18 | {
19 | "inputs" : {
20 | "position" : {
21 | "output" : "/actions/thumbparams/in/lefttrackpadxy"
22 | },
23 | "touch" : {
24 | "output" : "/actions/thumbparams/in/lefttrackpad"
25 | }
26 | },
27 | "mode" : "trackpad",
28 | "path" : "/user/hand/left/input/trackpad"
29 | },
30 | {
31 | "inputs" : {
32 | "position" : {
33 | "output" : "/actions/thumbparams/in/righttrackpadxy"
34 | },
35 | "touch" : {
36 | "output" : "/actions/thumbparams/in/righttrackpad"
37 | }
38 | },
39 | "mode" : "trackpad",
40 | "path" : "/user/hand/right/input/trackpad"
41 | },
42 | {
43 | "inputs" : {
44 | "click" : {
45 | "output" : "/actions/thumbparams/in/leftstickclick"
46 | },
47 | "touch" : {
48 | "output" : "/actions/thumbparams/in/leftstick"
49 | }
50 | },
51 | "mode" : "button",
52 | "path" : "/user/hand/left/input/thumbstick"
53 | },
54 | {
55 | "inputs" : {
56 | "click" : {
57 | "output" : "/actions/thumbparams/in/leftbbuttonclick"
58 | },
59 | "touch" : {
60 | "output" : "/actions/thumbparams/in/leftbbutton"
61 | }
62 | },
63 | "mode" : "button",
64 | "path" : "/user/hand/left/input/b"
65 | },
66 | {
67 | "inputs" : {
68 | "click" : {
69 | "output" : "/actions/thumbparams/in/leftabuttonclick"
70 | },
71 | "touch" : {
72 | "output" : "/actions/thumbparams/in/leftabutton"
73 | }
74 | },
75 | "mode" : "button",
76 | "path" : "/user/hand/left/input/a"
77 | },
78 | {
79 | "inputs" : {
80 | "click" : {
81 | "output" : "/actions/thumbparams/in/rightstickclick"
82 | },
83 | "touch" : {
84 | "output" : "/actions/thumbparams/in/rightstick"
85 | }
86 | },
87 | "mode" : "button",
88 | "path" : "/user/hand/right/input/thumbstick"
89 | },
90 | {
91 | "inputs" : {
92 | "click" : {
93 | "output" : "/actions/thumbparams/in/rightbbuttonclick"
94 | },
95 | "touch" : {
96 | "output" : "/actions/thumbparams/in/rightbbutton"
97 | }
98 | },
99 | "mode" : "button",
100 | "path" : "/user/hand/right/input/b"
101 | },
102 | {
103 | "inputs" : {
104 | "click" : {
105 | "output" : "/actions/thumbparams/in/rightabuttonclick"
106 | },
107 | "touch" : {
108 | "output" : "/actions/thumbparams/in/rightabutton"
109 | }
110 | },
111 | "mode" : "button",
112 | "path" : "/user/hand/right/input/a"
113 | },
114 | {
115 | "inputs" : {
116 | "pull" : {
117 | "output" : "/actions/thumbparams/in/lefttrigger"
118 | }
119 | },
120 | "mode" : "trigger",
121 | "path" : "/user/hand/left/input/trigger"
122 | },
123 | {
124 | "inputs" : {
125 | "pull" : {
126 | "output" : "/actions/thumbparams/in/righttrigger"
127 | }
128 | },
129 | "mode" : "trigger",
130 | "path" : "/user/hand/right/input/trigger"
131 | },
132 | {
133 | "inputs" : {
134 | "position" : {
135 | "output" : "/actions/thumbparams/in/leftstickxy"
136 | }
137 | },
138 | "mode" : "joystick",
139 | "path" : "/user/hand/left/input/thumbstick"
140 | },
141 | {
142 | "inputs" : {
143 | "position" : {
144 | "output" : "/actions/thumbparams/in/rightstickxy"
145 | }
146 | },
147 | "mode" : "joystick",
148 | "path" : "/user/hand/right/input/thumbstick"
149 | },
150 | {
151 | "inputs" : {
152 | "click" : {
153 | "output" : "/actions/thumbparams/in/lefttrackpadclick"
154 | }
155 | },
156 | "mode" : "button",
157 | "path" : "/user/hand/left/input/trackpad"
158 | },
159 | {
160 | "inputs" : {
161 | "click" : {
162 | "output" : "/actions/thumbparams/in/righttrackpadclick"
163 | }
164 | },
165 | "mode" : "button",
166 | "path" : "/user/hand/right/input/trackpad"
167 | },
168 | {
169 | "inputs" : {
170 | "force" : {
171 | "output" : "/actions/thumbparams/in/leftgrabforce"
172 | }
173 | },
174 | "mode" : "force_sensor",
175 | "path" : "/user/hand/left/input/grip"
176 | },
177 | {
178 | "inputs" : {
179 | "force" : {
180 | "output" : "/actions/thumbparams/in/rightgrabforce"
181 | }
182 | },
183 | "mode" : "force_sensor",
184 | "path" : "/user/hand/right/input/grip"
185 | },
186 | {
187 | "inputs" : {
188 | "grab" : {
189 | "output" : "/actions/thumbparams/in/leftgrab"
190 | }
191 | },
192 | "mode" : "grab",
193 | "parameters" : {
194 | "value_hold_threshold" : "1.35"
195 | },
196 | "path" : "/user/hand/left/input/grip"
197 | },
198 | {
199 | "inputs" : {
200 | "grab" : {
201 | "output" : "/actions/thumbparams/in/rightgrab"
202 | }
203 | },
204 | "mode" : "grab",
205 | "parameters" : {
206 | "value_hold_threshold" : "1.35"
207 | },
208 | "path" : "/user/hand/right/input/grip"
209 | },
210 | {
211 | "inputs" : {
212 | "force" : {
213 | "output" : "/actions/thumbparams/in/lefttrackpadforce"
214 | }
215 | },
216 | "mode" : "force_sensor",
217 | "path" : "/user/hand/left/input/trackpad"
218 | },
219 | {
220 | "inputs" : {
221 | "force" : {
222 | "output" : "/actions/thumbparams/in/righttrackpadforce"
223 | }
224 | },
225 | "mode" : "force_sensor",
226 | "path" : "/user/hand/right/input/trackpad"
227 | }
228 | ]
229 | }
230 | },
231 | "category" : "steamvr_input",
232 | "controller_type" : "knuckles",
233 | "description" : "",
234 | "interaction_profile" : "",
235 | "name" : "Default configuration for ThumbParamsOSC Index Knuckles Controller.",
236 | "options" : {},
237 | "simulated_actions" : []
238 | }
239 |
--------------------------------------------------------------------------------
/src/bindings/left_elbow_thumbparams_bindings.json:
--------------------------------------------------------------------------------
1 | {
2 | "action_manifest_version" : 0,
3 | "alias_info" : {},
4 | "app_key" : "i5ucc.thumbparamsosc",
5 | "bindings" : {
6 | "/actions/thumbparams" : {
7 | "sources" : [
8 | {
9 | "inputs" : {
10 | "click" : {
11 | "output" : "/actions/thumbparams/in/leftelbowtracker"
12 | }
13 | },
14 | "mode" : "button",
15 | "path" : "/user/elbow/left/input/power"
16 | }
17 | ]
18 | }
19 | },
20 | "category" : "steamvr_input",
21 | "controller_type" : "vive_tracker_left_elbow",
22 | "description" : "",
23 | "interaction_profile" : "",
24 | "name" : "Default configuration for ThumbParamsOSC Vive Tracker on Left Elbow.",
25 | "options" : {},
26 | "simulated_actions" : []
27 | }
28 |
--------------------------------------------------------------------------------
/src/bindings/left_foot_thumbparams_bindings.json:
--------------------------------------------------------------------------------
1 | {
2 | "action_manifest_version" : 0,
3 | "alias_info" : {},
4 | "app_key" : "i5ucc.thumbparamsosc",
5 | "bindings" : {
6 | "/actions/thumbparams" : {
7 | "sources" : [
8 | {
9 | "inputs" : {
10 | "click" : {
11 | "output" : "/actions/thumbparams/in/leftfoottracker"
12 | }
13 | },
14 | "mode" : "button",
15 | "path" : "/user/foot/left/input/power"
16 | }
17 | ]
18 | }
19 | },
20 | "category" : "steamvr_input",
21 | "controller_type" : "vive_tracker_left_foot",
22 | "description" : "",
23 | "interaction_profile" : "",
24 | "name" : "Default configuration for ThumbParamsOSC Vive Tracker on Left Foot",
25 | "options" : {},
26 | "simulated_actions" : []
27 | }
28 |
--------------------------------------------------------------------------------
/src/bindings/left_knee_thumbparams_bindings.json:
--------------------------------------------------------------------------------
1 | {
2 | "action_manifest_version" : 0,
3 | "alias_info" : {},
4 | "app_key" : "i5ucc.thumbparamsosc",
5 | "bindings" : {
6 | "/actions/thumbparams" : {
7 | "sources" : [
8 | {
9 | "inputs" : {
10 | "click" : {
11 | "output" : "/actions/thumbparams/in/leftkneetracker"
12 | }
13 | },
14 | "mode" : "button",
15 | "path" : "/user/knee/left/input/power"
16 | }
17 | ]
18 | }
19 | },
20 | "category" : "steamvr_input",
21 | "controller_type" : "vive_tracker_left_knee",
22 | "description" : "",
23 | "interaction_profile" : "",
24 | "name" : "Default configuration for ThumbParamsOSC Vive Tracker on Left Elbow.",
25 | "options" : {},
26 | "simulated_actions" : []
27 | }
28 |
--------------------------------------------------------------------------------
/src/bindings/right_elbow_thumbparams_bindings.json:
--------------------------------------------------------------------------------
1 | {
2 | "action_manifest_version" : 0,
3 | "alias_info" : {},
4 | "app_key" : "i5ucc.thumbparamsosc",
5 | "bindings" : {
6 | "/actions/thumbparams" : {
7 | "sources" : [
8 | {
9 | "inputs" : {
10 | "click" : {
11 | "output" : "/actions/thumbparams/in/rightelbowtracker"
12 | }
13 | },
14 | "mode" : "button",
15 | "path" : "/user/elbow/right/input/power"
16 | }
17 | ]
18 | }
19 | },
20 | "category" : "steamvr_input",
21 | "controller_type" : "vive_tracker_right_elbow",
22 | "description" : "",
23 | "interaction_profile" : "",
24 | "name" : "Default configuration for ThumbParamsOSC Vive Tracker on Left Elbow.",
25 | "options" : {},
26 | "simulated_actions" : []
27 | }
28 |
--------------------------------------------------------------------------------
/src/bindings/right_foot_thumbparams_bindings.json:
--------------------------------------------------------------------------------
1 | {
2 | "action_manifest_version" : 0,
3 | "alias_info" : {},
4 | "app_key" : "i5ucc.thumbparamsosc",
5 | "bindings" : {
6 | "/actions/thumbparams" : {
7 | "sources" : [
8 | {
9 | "inputs" : {
10 | "click" : {
11 | "output" : "/actions/thumbparams/in/rightfoottracker"
12 | }
13 | },
14 | "mode" : "button",
15 | "path" : "/user/foot/right/input/power"
16 | }
17 | ]
18 | }
19 | },
20 | "category" : "steamvr_input",
21 | "controller_type" : "vive_tracker_right_foot",
22 | "description" : "",
23 | "interaction_profile" : "",
24 | "name" : "Default configuration for ThumbParamsOSC Vive Tracker on Right Foot",
25 | "options" : {},
26 | "simulated_actions" : []
27 | }
28 |
--------------------------------------------------------------------------------
/src/bindings/right_knee_thumbparams_bindings.json:
--------------------------------------------------------------------------------
1 | {
2 | "action_manifest_version" : 0,
3 | "alias_info" : {},
4 | "app_key" : "i5ucc.thumbparamsosc",
5 | "bindings" : {
6 | "/actions/thumbparams" : {
7 | "sources" : [
8 | {
9 | "inputs" : {
10 | "click" : {
11 | "output" : "/actions/thumbparams/in/rightkneetracker"
12 | }
13 | },
14 | "mode" : "button",
15 | "path" : "/user/knee/right/input/power"
16 | }
17 | ]
18 | }
19 | },
20 | "category" : "steamvr_input",
21 | "controller_type" : "vive_tracker_right_knee",
22 | "description" : "",
23 | "interaction_profile" : "",
24 | "name" : "Default configuration for ThumbParamsOSC Vive Tracker on Left Elbow.",
25 | "options" : {},
26 | "simulated_actions" : []
27 | }
28 |
--------------------------------------------------------------------------------
/src/bindings/touch_thumbparams_bindings.json:
--------------------------------------------------------------------------------
1 | {
2 | "action_manifest_version" : 0,
3 | "alias_info" : {},
4 | "app_key" : "i5ucc.thumbparamsosc",
5 | "bindings" : {
6 | "/actions/thumbparams" : {
7 | "sources" : [
8 | {
9 | "inputs" : {
10 | "touch" : {
11 | "output" : "/actions/thumbparams/in/lefttrackpad"
12 | }
13 | },
14 | "mode" : "trackpad",
15 | "path" : "/user/hand/left/input/trackpad"
16 | },
17 | {
18 | "inputs" : {
19 | "touch" : {
20 | "output" : "/actions/thumbparams/in/righttrackpad"
21 | }
22 | },
23 | "mode" : "trackpad",
24 | "path" : "/user/hand/right/input/trackpad"
25 | },
26 | {
27 | "inputs" : {
28 | "touch" : {
29 | "output" : "/actions/thumbparams/in/leftstick"
30 | }
31 | },
32 | "mode" : "button",
33 | "path" : "/user/hand/left/input/thumbstick"
34 | },
35 | {
36 | "inputs" : {
37 | "touch" : {
38 | "output" : "/actions/thumbparams/in/leftbbutton"
39 | }
40 | },
41 | "mode" : "button",
42 | "path" : "/user/hand/left/input/b"
43 | },
44 | {
45 | "inputs" : {
46 | "touch" : {
47 | "output" : "/actions/thumbparams/in/leftabutton"
48 | }
49 | },
50 | "mode" : "button",
51 | "path" : "/user/hand/left/input/a"
52 | },
53 | {
54 | "inputs" : {
55 | "touch" : {
56 | "output" : "/actions/thumbparams/in/rightstick"
57 | }
58 | },
59 | "mode" : "button",
60 | "path" : "/user/hand/right/input/thumbstick"
61 | },
62 | {
63 | "inputs" : {
64 | "click" : {
65 | "output" : "/actions/thumbparams/in/rightbbuttonclick"
66 | },
67 | "touch" : {
68 | "output" : "/actions/thumbparams/in/rightbbutton"
69 | }
70 | },
71 | "mode" : "button",
72 | "path" : "/user/hand/right/input/b"
73 | },
74 | {
75 | "inputs" : {
76 | "click" : {
77 | "output" : "/actions/thumbparams/in/rightabuttonclick"
78 | },
79 | "touch" : {
80 | "output" : "/actions/thumbparams/in/rightabutton"
81 | }
82 | },
83 | "mode" : "button",
84 | "path" : "/user/hand/right/input/a"
85 | },
86 | {
87 | "inputs" : {
88 | "click" : {
89 | "output" : "/actions/thumbparams/in/rightstickclick"
90 | },
91 | "touch" : {
92 | "output" : "/actions/thumbparams/in/rightstick"
93 | }
94 | },
95 | "mode" : "button",
96 | "path" : "/user/hand/right/input/joystick"
97 | },
98 | {
99 | "inputs" : {
100 | "click" : {
101 | "output" : "/actions/thumbparams/in/leftstickclick"
102 | },
103 | "touch" : {
104 | "output" : "/actions/thumbparams/in/leftstick"
105 | }
106 | },
107 | "mode" : "button",
108 | "path" : "/user/hand/left/input/joystick"
109 | },
110 | {
111 | "inputs" : {
112 | "click" : {
113 | "output" : "/actions/thumbparams/in/leftabuttonclick"
114 | },
115 | "touch" : {
116 | "output" : "/actions/thumbparams/in/leftabutton"
117 | }
118 | },
119 | "mode" : "button",
120 | "path" : "/user/hand/left/input/x"
121 | },
122 | {
123 | "inputs" : {
124 | "click" : {
125 | "output" : "/actions/thumbparams/in/leftbbuttonclick"
126 | },
127 | "touch" : {
128 | "output" : "/actions/thumbparams/in/leftbbutton"
129 | }
130 | },
131 | "mode" : "button",
132 | "path" : "/user/hand/left/input/y"
133 | },
134 | {
135 | "inputs" : {
136 | "pull" : {
137 | "output" : "/actions/thumbparams/in/lefttrigger"
138 | }
139 | },
140 | "mode" : "trigger",
141 | "path" : "/user/hand/left/input/trigger"
142 | },
143 | {
144 | "inputs" : {
145 | "pull" : {
146 | "output" : "/actions/thumbparams/in/righttrigger"
147 | }
148 | },
149 | "mode" : "trigger",
150 | "path" : "/user/hand/right/input/trigger"
151 | },
152 | {
153 | "inputs" : {
154 | "position" : {
155 | "output" : "/actions/thumbparams/in/leftstickxy"
156 | }
157 | },
158 | "mode" : "joystick",
159 | "path" : "/user/hand/left/input/joystick"
160 | },
161 | {
162 | "inputs" : {
163 | "position" : {
164 | "output" : "/actions/thumbparams/in/rightstickxy"
165 | }
166 | },
167 | "mode" : "joystick",
168 | "path" : "/user/hand/right/input/joystick"
169 | },
170 | {
171 | "inputs" : {
172 | "pull" : {
173 | "output" : "/actions/thumbparams/in/leftgrabforce"
174 | }
175 | },
176 | "mode" : "trigger",
177 | "path" : "/user/hand/left/input/grip"
178 | },
179 | {
180 | "inputs" : {
181 | "click" : {
182 | "output" : "/actions/thumbparams/in/leftgrab"
183 | }
184 | },
185 | "mode" : "button",
186 | "path" : "/user/hand/left/input/grip"
187 | },
188 | {
189 | "inputs" : {
190 | "pull" : {
191 | "output" : "/actions/thumbparams/in/rightgrabforce"
192 | }
193 | },
194 | "mode" : "trigger",
195 | "path" : "/user/hand/right/input/grip"
196 | },
197 | {
198 | "inputs" : {
199 | "click" : {
200 | "output" : "/actions/thumbparams/in/rightgrab"
201 | }
202 | },
203 | "mode" : "button",
204 | "path" : "/user/hand/right/input/grip"
205 | },
206 | {
207 | "inputs" : {
208 | "click" : {
209 | "output" : "/actions/thumbparams/in/lefttrackpadclick"
210 | },
211 | "touch" : {
212 | "output" : "/actions/thumbparams/in/lefttrackpad"
213 | }
214 | },
215 | "mode" : "button",
216 | "path" : "/user/hand/left/input/thumbrest"
217 | },
218 | {
219 | "inputs" : {
220 | "click" : {
221 | "output" : "/actions/thumbparams/in/righttrackpadclick"
222 | },
223 | "touch" : {
224 | "output" : "/actions/thumbparams/in/righttrackpad"
225 | }
226 | },
227 | "mode" : "button",
228 | "path" : "/user/hand/right/input/thumbrest"
229 | }
230 | ]
231 | }
232 | },
233 | "category" : "steamvr_input",
234 | "controller_type" : "oculus_touch",
235 | "description" : "",
236 | "interaction_profile" : "",
237 | "name" : "Default configuration for ThumbParamsOSC Oculus Touch Controller.",
238 | "options" : {},
239 | "simulated_actions" : []
240 | }
241 |
--------------------------------------------------------------------------------
/src/bindings/waist_thumbparams_bindings.json:
--------------------------------------------------------------------------------
1 | {
2 | "action_manifest_version" : 0,
3 | "alias_info" : {},
4 | "app_key" : "i5ucc.thumbparamsosc",
5 | "bindings" : {
6 | "/actions/thumbparams" : {
7 | "sources" : [
8 | {
9 | "inputs" : {
10 | "click" : {
11 | "output" : "/actions/thumbparams/in/waisttracker"
12 | }
13 | },
14 | "mode" : "button",
15 | "path" : "/user/waist/input/power"
16 | }
17 | ]
18 | }
19 | },
20 | "category" : "steamvr_input",
21 | "controller_type" : "vive_tracker_waist",
22 | "description" : "",
23 | "interaction_profile" : "",
24 | "name" : "Default configuration for ThumbParamsOSC Vive Tracker on Waist",
25 | "options" : {},
26 | "simulated_actions" : []
27 | }
28 |
--------------------------------------------------------------------------------
/src/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "IP": "127.0.0.1",
3 | "Port": 9000,
4 | "Server_Port": 0,
5 | "HTTP_Port": 0,
6 | "PollingRate": 25,
7 | "StickMoveTolerance": 5,
8 | "Binary_bits": 4,
9 | "ControllerType": {
10 | "enabled": true,
11 | "always": 2,
12 | "last_value": 0,
13 | "timestamp": 0
14 | },
15 | "LeftThumb": {
16 | "enabled": true,
17 | "always": 2,
18 | "last_value": 0
19 | },
20 | "RightThumb": {
21 | "enabled": true,
22 | "always": 2,
23 | "last_value": 0
24 | },
25 | "LeftABButtons": {
26 | "enabled": true,
27 | "always": 2,
28 | "last_value": 0
29 | },
30 | "RightABButtons": {
31 | "enabled": true,
32 | "always": 2,
33 | "last_value": 0
34 | },
35 | "default_bindings": [
36 | {
37 | "controller_type": "knuckles",
38 | "binding_url": "bindings/knuckles_thumbparams_bindings.json"
39 | },
40 | {
41 | "controller_type": "oculus_touch",
42 | "binding_url": "bindings/touch_thumbparams_bindings.json"
43 | },
44 | {
45 | "controller_type": "vive_tracker_left_foot",
46 | "binding_url": "bindings/left_foot_thumbparams_bindings.json"
47 | },
48 | {
49 | "controller_type": "vive_tracker_right_foot",
50 | "binding_url": "bindings/right_foot_thumbparams_bindings.json"
51 | },
52 | {
53 | "controller_type": "vive_tracker_waist",
54 | "binding_url": "bindings/waist_thumbparams_bindings.json"
55 | },
56 | {
57 | "controller_type": "vive_tracker_chest",
58 | "binding_url": "bindings/chest_thumbparams_bindings.json"
59 | },
60 | {
61 | "controller_type": "vive_tracker_left_elbow",
62 | "binding_url": "bindings/left_elbow_thumbparams_bindings.json"
63 | },
64 | {
65 | "controller_type": "vive_tracker_left_knee",
66 | "binding_url": "bindings/left_knee_thumbparams_bindings.json"
67 | },
68 | {
69 | "controller_type": "vive_tracker_right_elbow",
70 | "binding_url": "bindings/right_elbow_thumbparams_bindings.json"
71 | },
72 | {
73 | "controller_type": "vive_tracker_right_knee",
74 | "binding_url": "bindings/right_knee_thumbparams_bindings.json"
75 | }
76 | ],
77 | "actions": [
78 | {
79 | "name": "/actions/thumbparams/in/RightHandSkeleton",
80 | "type": "skeleton",
81 | "skeleton": "/skeleton/hand/right",
82 | "osc_parameter": "RightHandSkeleton",
83 | "enabled": true,
84 | "always": 2,
85 | "floating": 0.0,
86 | "timestamp": 0,
87 | "last_value": false,
88 | "unsigned": null,
89 | "binary": false
90 | },
91 | {
92 | "name": "/actions/thumbparams/in/LeftHandSkeleton",
93 | "type": "skeleton",
94 | "skeleton": "/skeleton/hand/left",
95 | "osc_parameter": "LeftHandSkeleton",
96 | "enabled": true,
97 | "always": 2,
98 | "floating": 0.0,
99 | "timestamp": 0,
100 | "last_value": false,
101 | "unsigned": null,
102 | "binary": false
103 | },
104 | {
105 | "name": "/actions/thumbparams/in/leftabutton",
106 | "type": "boolean",
107 | "osc_parameter": "LeftAButton",
108 | "enabled": true,
109 | "always": 2,
110 | "floating": 0.0,
111 | "timestamp": 0,
112 | "last_value": false,
113 | "unsigned": null,
114 | "binary": false
115 | },
116 | {
117 | "name": "/actions/thumbparams/in/leftbbutton",
118 | "type": "boolean",
119 | "osc_parameter": "LeftBButton",
120 | "enabled": true,
121 | "always": 2,
122 | "floating": 0.0,
123 | "timestamp": 0,
124 | "last_value": false,
125 | "unsigned": null,
126 | "binary": false
127 | },
128 | {
129 | "name": "/actions/thumbparams/in/lefttrackpad",
130 | "type": "boolean",
131 | "osc_parameter": "LeftTrackPad",
132 | "enabled": true,
133 | "always": 2,
134 | "floating": 0.0,
135 | "timestamp": 0,
136 | "last_value": false,
137 | "unsigned": null,
138 | "binary": false
139 | },
140 | {
141 | "name": "/actions/thumbparams/in/leftstick",
142 | "type": "boolean",
143 | "osc_parameter": "LeftThumbStick",
144 | "enabled": true,
145 | "always": 2,
146 | "floating": 0.0,
147 | "timestamp": 0,
148 | "last_value": false,
149 | "unsigned": null,
150 | "binary": false
151 | },
152 | {
153 | "name": "/actions/thumbparams/in/rightabutton",
154 | "type": "boolean",
155 | "osc_parameter": "RightAButton",
156 | "enabled": true,
157 | "always": 2,
158 | "floating": 0.0,
159 | "timestamp": 0,
160 | "last_value": false,
161 | "unsigned": null,
162 | "binary": false
163 | },
164 | {
165 | "name": "/actions/thumbparams/in/rightbbutton",
166 | "type": "boolean",
167 | "osc_parameter": "RightBButton",
168 | "enabled": true,
169 | "always": 2,
170 | "floating": 0.0,
171 | "timestamp": 0,
172 | "last_value": false,
173 | "unsigned": null,
174 | "binary": false
175 | },
176 | {
177 | "name": "/actions/thumbparams/in/righttrackpad",
178 | "type": "boolean",
179 | "osc_parameter": "RightTrackPad",
180 | "enabled": true,
181 | "always": 2,
182 | "floating": 0.0,
183 | "timestamp": 0,
184 | "last_value": false,
185 | "unsigned": null,
186 | "binary": false
187 | },
188 | {
189 | "name": "/actions/thumbparams/in/rightstick",
190 | "type": "boolean",
191 | "osc_parameter": "RightThumbStick",
192 | "enabled": true,
193 | "always": 2,
194 | "floating": 0.0,
195 | "timestamp": 0,
196 | "last_value": false,
197 | "unsigned": null,
198 | "binary": false
199 | },
200 | {
201 | "name": "/actions/thumbparams/in/leftabuttonclick",
202 | "type": "boolean",
203 | "osc_parameter": "LeftAButtonClick",
204 | "enabled": true,
205 | "always": 2,
206 | "floating": 0.0,
207 | "timestamp": 0,
208 | "last_value": false,
209 | "unsigned": null,
210 | "binary": false
211 | },
212 | {
213 | "name": "/actions/thumbparams/in/leftbbuttonclick",
214 | "type": "boolean",
215 | "osc_parameter": "LeftBButtonClick",
216 | "enabled": true,
217 | "always": 2,
218 | "floating": 0.0,
219 | "timestamp": 0,
220 | "last_value": false,
221 | "unsigned": null,
222 | "binary": false
223 | },
224 | {
225 | "name": "/actions/thumbparams/in/lefttrackpadclick",
226 | "type": "boolean",
227 | "osc_parameter": "LeftTrackPadClick",
228 | "enabled": true,
229 | "always": 2,
230 | "floating": 0.0,
231 | "timestamp": 0,
232 | "last_value": false,
233 | "unsigned": null,
234 | "binary": false
235 | },
236 | {
237 | "name": "/actions/thumbparams/in/leftstickclick",
238 | "type": "boolean",
239 | "osc_parameter": "LeftThumbStickClick",
240 | "enabled": true,
241 | "always": 2,
242 | "floating": 0.0,
243 | "timestamp": 0,
244 | "last_value": false,
245 | "unsigned": null,
246 | "binary": false
247 | },
248 | {
249 | "name": "/actions/thumbparams/in/rightabuttonclick",
250 | "type": "boolean",
251 | "osc_parameter": "RightAButtonClick",
252 | "enabled": true,
253 | "always": 2,
254 | "floating": 0.0,
255 | "timestamp": 0,
256 | "last_value": false,
257 | "unsigned": null,
258 | "binary": false
259 | },
260 | {
261 | "name": "/actions/thumbparams/in/rightbbuttonclick",
262 | "type": "boolean",
263 | "osc_parameter": "RightBButtonClick",
264 | "enabled": true,
265 | "always": 2,
266 | "floating": 0.0,
267 | "timestamp": 0,
268 | "last_value": false,
269 | "unsigned": null,
270 | "binary": false
271 | },
272 | {
273 | "name": "/actions/thumbparams/in/righttrackpadclick",
274 | "type": "boolean",
275 | "osc_parameter": "RightTrackPadClick",
276 | "enabled": true,
277 | "always": 2,
278 | "floating": 0.0,
279 | "timestamp": 0,
280 | "last_value": false,
281 | "unsigned": null,
282 | "binary": false
283 | },
284 | {
285 | "name": "/actions/thumbparams/in/rightstickclick",
286 | "type": "boolean",
287 | "osc_parameter": "RightThumbStickClick",
288 | "enabled": true,
289 | "always": 2,
290 | "floating": 0.0,
291 | "timestamp": 0,
292 | "last_value": false,
293 | "unsigned": null,
294 | "binary": false
295 | },
296 | {
297 | "name": "/actions/thumbparams/in/leftgrab",
298 | "type": "boolean",
299 | "osc_parameter": "LeftGrab",
300 | "enabled": true,
301 | "always": 2,
302 | "floating": 0.0,
303 | "timestamp": 0,
304 | "last_value": false,
305 | "unsigned": null,
306 | "binary": false
307 | },
308 | {
309 | "name": "/actions/thumbparams/in/rightgrab",
310 | "type": "boolean",
311 | "osc_parameter": "RightGrab",
312 | "enabled": true,
313 | "always": 2,
314 | "floating": 0.0,
315 | "timestamp": 0,
316 | "last_value": false,
317 | "unsigned": null,
318 | "binary": false
319 | },
320 | {
321 | "name": "/actions/thumbparams/in/leftfoottracker",
322 | "type": "boolean",
323 | "osc_parameter": "LeftFootTracker",
324 | "enabled": true,
325 | "always": 2,
326 | "floating": 0.0,
327 | "timestamp": 0,
328 | "last_value": false,
329 | "unsigned": null,
330 | "binary": false
331 | },
332 | {
333 | "name": "/actions/thumbparams/in/rightfoottracker",
334 | "type": "boolean",
335 | "osc_parameter": "RightFootTracker",
336 | "enabled": true,
337 | "always": 2,
338 | "floating": 0.0,
339 | "timestamp": 0,
340 | "last_value": false,
341 | "unsigned": null,
342 | "binary": false
343 | },
344 | {
345 | "name": "/actions/thumbparams/in/waisttracker",
346 | "type": "boolean",
347 | "osc_parameter": "WaistTracker",
348 | "enabled": true,
349 | "always": 2,
350 | "floating": 0.0,
351 | "timestamp": 0,
352 | "last_value": false,
353 | "unsigned": null,
354 | "binary": false
355 | },
356 | {
357 | "name": "/actions/thumbparams/in/chesttracker",
358 | "type": "boolean",
359 | "osc_parameter": "ChestTracker",
360 | "enabled": true,
361 | "always": 2,
362 | "floating": 0.0,
363 | "timestamp": 0,
364 | "last_value": false,
365 | "unsigned": null,
366 | "binary": false
367 | },
368 | {
369 | "name": "/actions/thumbparams/in/leftelbowtracker",
370 | "type": "boolean",
371 | "osc_parameter": "LeftElbowTracker",
372 | "enabled": true,
373 | "always": 2,
374 | "floating": 0.0,
375 | "timestamp": 0,
376 | "last_value": false,
377 | "unsigned": null,
378 | "binary": false
379 | },
380 | {
381 | "name": "/actions/thumbparams/in/rightelbowtracker",
382 | "type": "boolean",
383 | "osc_parameter": "RightElbowTracker",
384 | "enabled": true,
385 | "always": 2,
386 | "floating": 0.0,
387 | "timestamp": 0,
388 | "last_value": false,
389 | "unsigned": null,
390 | "binary": false
391 | },
392 | {
393 | "name": "/actions/thumbparams/in/leftkneetracker",
394 | "type": "boolean",
395 | "osc_parameter": "LeftKneeTracker",
396 | "enabled": true,
397 | "always": 2,
398 | "floating": 0.0,
399 | "timestamp": 0,
400 | "last_value": false,
401 | "unsigned": null,
402 | "binary": false
403 | },
404 | {
405 | "name": "/actions/thumbparams/in/rightkneetracker",
406 | "type": "boolean",
407 | "osc_parameter": "RightKneeTracker",
408 | "enabled": true,
409 | "always": 2,
410 | "floating": 0.0,
411 | "timestamp": 0,
412 | "last_value": false,
413 | "unsigned": null,
414 | "binary": false
415 | },
416 | {
417 | "name": "/actions/thumbparams/in/lefttrigger",
418 | "type": "vector1",
419 | "osc_parameter": "LeftTrigger",
420 | "enabled": true,
421 | "always": 2,
422 | "floating": 0.0,
423 | "timestamp": 0,
424 | "last_value": 0.0,
425 | "unsigned": null,
426 | "binary": false
427 | },
428 | {
429 | "name": "/actions/thumbparams/in/righttrigger",
430 | "type": "vector1",
431 | "osc_parameter": "RightTrigger",
432 | "enabled": true,
433 | "always": 2,
434 | "floating": 0.0,
435 | "timestamp": 0,
436 | "last_value": 0.0,
437 | "unsigned": null,
438 | "binary": false
439 | },
440 | {
441 | "name": "/actions/thumbparams/in/leftgrabforce",
442 | "type": "vector1",
443 | "osc_parameter": "LeftGrabForce",
444 | "enabled": true,
445 | "always": 2,
446 | "floating": 0.0,
447 | "timestamp": 0,
448 | "last_value": 0.0,
449 | "unsigned": null,
450 | "binary": false
451 | },
452 | {
453 | "name": "/actions/thumbparams/in/rightgrabforce",
454 | "type": "vector1",
455 | "osc_parameter": "RightGrabForce",
456 | "enabled": true,
457 | "always": 2,
458 | "floating": 0.0,
459 | "timestamp": 0,
460 | "last_value": 0.0,
461 | "unsigned": null,
462 | "binary": false
463 | },
464 | {
465 | "name": "/actions/thumbparams/in/righttrackpadforce",
466 | "type": "vector1",
467 | "osc_parameter": "RightTrackpadForce",
468 | "enabled": true,
469 | "always": 2,
470 | "floating": 0.0,
471 | "timestamp": 0,
472 | "last_value": 0.0,
473 | "unsigned": null,
474 | "binary": false
475 | },
476 | {
477 | "name": "/actions/thumbparams/in/lefttrackpadforce",
478 | "type": "vector1",
479 | "osc_parameter": "LeftTrackpadForce",
480 | "enabled": true,
481 | "always": 2,
482 | "floating": 0.0,
483 | "timestamp": 0,
484 | "last_value": 0.0,
485 | "unsigned": null,
486 | "binary": false
487 | },
488 | {
489 | "name": "/actions/thumbparams/in/leftstickxy",
490 | "type": "vector2",
491 | "osc_parameter": [
492 | "LeftThumbStickX",
493 | "LeftThumbStickY",
494 | "LeftStickMoved"
495 | ],
496 | "enabled": [
497 | true,
498 | true,
499 | true
500 | ],
501 | "always": [
502 | 2,
503 | 2,
504 | 2
505 | ],
506 | "floating": [
507 | 0.0,
508 | 0.0,
509 | -100
510 | ],
511 | "timestamp": [
512 | 0.0,
513 | 0.0,
514 | 0.0
515 | ],
516 | "last_value": [
517 | 0.0,
518 | 0.0,
519 | 0.0
520 | ],
521 | "unsigned": [
522 | false,
523 | false,
524 | false
525 | ],
526 | "binary": [
527 | false,
528 | false,
529 | false
530 | ]
531 | },
532 | {
533 | "name": "/actions/thumbparams/in/rightstickxy",
534 | "type": "vector2",
535 | "osc_parameter": [
536 | "RightThumbStickX",
537 | "RightThumbStickY",
538 | "RightStickMoved"
539 | ],
540 | "enabled": [
541 | true,
542 | true,
543 | true
544 | ],
545 | "always": [
546 | 2,
547 | 2,
548 | 2
549 | ],
550 | "floating": [
551 | 0.0,
552 | 0.0,
553 | -100
554 | ],
555 | "timestamp": [
556 | 0.0,
557 | 0.0,
558 | 0.0
559 | ],
560 | "last_value": [
561 | 0.0,
562 | 0.0,
563 | 0.0
564 | ],
565 | "unsigned": [
566 | false,
567 | false,
568 | false
569 | ],
570 | "binary": [
571 | false,
572 | false,
573 | false
574 | ]
575 | },
576 | {
577 | "name": "/actions/thumbparams/in/lefttrackpadxy",
578 | "type": "vector2",
579 | "osc_parameter": [
580 | "LeftTrackPadX",
581 | "LeftTrackPadY"
582 | ],
583 | "enabled": [
584 | true,
585 | true
586 | ],
587 | "always": [
588 | 2,
589 | 2
590 | ],
591 | "floating": [
592 | 0.0,
593 | 0.0
594 | ],
595 | "timestamp": [
596 | 0.0,
597 | 0.0
598 | ],
599 | "last_value": [
600 | 0.0,
601 | 0.0
602 | ],
603 | "unsigned": [
604 | false,
605 | false
606 | ],
607 | "binary": [
608 | false,
609 | false
610 | ]
611 | },
612 | {
613 | "name": "/actions/thumbparams/in/righttrackpadxy",
614 | "type": "vector2",
615 | "osc_parameter": [
616 | "RightTrackPadX",
617 | "RightTrackPadY"
618 | ],
619 | "enabled": [
620 | true,
621 | true
622 | ],
623 | "always": [
624 | 2,
625 | 2
626 | ],
627 | "floating": [
628 | 0.0,
629 | 0.0
630 | ],
631 | "timestamp": [
632 | 0.0,
633 | 0.0
634 | ],
635 | "last_value": [
636 | 0.0,
637 | 0.0
638 | ],
639 | "unsigned": [
640 | false,
641 | false
642 | ],
643 | "binary": [
644 | false,
645 | false
646 | ]
647 | }
648 | ],
649 | "xinput_actions": [
650 | {
651 | "name": "A",
652 | "type": "boolean",
653 | "osc_parameter": "XInputAButton",
654 | "enabled": true,
655 | "always": 2,
656 | "floating": 0.0,
657 | "timestamp": 0,
658 | "last_value": false,
659 | "unsigned": null,
660 | "binary": false
661 | },
662 | {
663 | "name": "B",
664 | "type": "boolean",
665 | "osc_parameter": "XInputBButton",
666 | "enabled": true,
667 | "always": 2,
668 | "floating": 0.0,
669 | "timestamp": 0,
670 | "last_value": false,
671 | "unsigned": null,
672 | "binary": false
673 | },
674 | {
675 | "name": "X",
676 | "type": "boolean",
677 | "osc_parameter": "XInputXButton",
678 | "enabled": true,
679 | "always": 2,
680 | "floating": 0.0,
681 | "timestamp": 0,
682 | "last_value": false,
683 | "unsigned": null,
684 | "binary": false
685 | },
686 | {
687 | "name": "Y",
688 | "type": "boolean",
689 | "osc_parameter": "XInputYButton",
690 | "enabled": true,
691 | "always": 2,
692 | "floating": 0.0,
693 | "timestamp": 0,
694 | "last_value": false,
695 | "unsigned": null,
696 | "binary": false
697 | },
698 | {
699 | "name": "LeftThumb",
700 | "type": "boolean",
701 | "osc_parameter": "XInputLeftThumbstick",
702 | "enabled": true,
703 | "always": 2,
704 | "floating": 0.0,
705 | "timestamp": 0,
706 | "last_value": false,
707 | "unsigned": null,
708 | "binary": false
709 | },
710 | {
711 | "name": "RightThumb",
712 | "type": "boolean",
713 | "osc_parameter": "XInputRightThumbstick",
714 | "enabled": true,
715 | "always": 2,
716 | "floating": 0.0,
717 | "timestamp": 0,
718 | "last_value": false,
719 | "unsigned": null,
720 | "binary": false
721 | },
722 | {
723 | "name": "LeftBumper",
724 | "type": "boolean",
725 | "osc_parameter": "XInputLeftBumper",
726 | "enabled": true,
727 | "always": 2,
728 | "floating": 0.0,
729 | "timestamp": 0,
730 | "last_value": false,
731 | "unsigned": null,
732 | "binary": false
733 | },
734 | {
735 | "name": "RightBumper",
736 | "type": "boolean",
737 | "osc_parameter": "XInputRightBumper",
738 | "enabled": true,
739 | "always": 2,
740 | "floating": 0.0,
741 | "timestamp": 0,
742 | "last_value": false,
743 | "unsigned": null,
744 | "binary": false
745 | },
746 | {
747 | "name": "Back",
748 | "type": "boolean",
749 | "osc_parameter": "XInputBackButton",
750 | "enabled": true,
751 | "always": 2,
752 | "floating": 0.0,
753 | "timestamp": 0,
754 | "last_value": false,
755 | "unsigned": null,
756 | "binary": false
757 | },
758 | {
759 | "name": "Start",
760 | "type": "boolean",
761 | "osc_parameter": "XInputStartButton",
762 | "enabled": true,
763 | "always": 2,
764 | "floating": 0.0,
765 | "timestamp": 0,
766 | "last_value": false,
767 | "unsigned": null,
768 | "binary": false
769 | },
770 | {
771 | "name": "LeftDPad",
772 | "type": "boolean",
773 | "osc_parameter": "XInputLeftDPad",
774 | "enabled": true,
775 | "always": 2,
776 | "floating": 0.0,
777 | "timestamp": 0,
778 | "last_value": false,
779 | "unsigned": null,
780 | "binary": false
781 | },
782 | {
783 | "name": "RightDPad",
784 | "type": "boolean",
785 | "osc_parameter": "XInputRightDPad",
786 | "enabled": true,
787 | "always": 2,
788 | "floating": 0.0,
789 | "timestamp": 0,
790 | "last_value": false,
791 | "unsigned": null,
792 | "binary": false
793 | },
794 | {
795 | "name": "UpDPad",
796 | "type": "boolean",
797 | "osc_parameter": "XInputUpDPad",
798 | "enabled": true,
799 | "always": 2,
800 | "floating": 0.0,
801 | "timestamp": 0,
802 | "last_value": false,
803 | "unsigned": null,
804 | "binary": false
805 | },
806 | {
807 | "name": "DownDPad",
808 | "type": "boolean",
809 | "osc_parameter": "XInputDownDPad",
810 | "enabled": true,
811 | "always": 2,
812 | "floating": 0.0,
813 | "timestamp": 0,
814 | "last_value": false,
815 | "unsigned": null,
816 | "binary": false
817 | },
818 | {
819 | "name": "LeftTrigger",
820 | "type": "vector1",
821 | "osc_parameter": "XInputLeftTrigger",
822 | "enabled": true,
823 | "always": 2,
824 | "floating": 0.0,
825 | "timestamp": 0,
826 | "last_value": 0.0,
827 | "unsigned": null,
828 | "binary": false
829 | },
830 | {
831 | "name": "RightTrigger",
832 | "type": "vector1",
833 | "osc_parameter": "XInputRightTrigger",
834 | "enabled": true,
835 | "always": 2,
836 | "floating": 0.0,
837 | "timestamp": 0,
838 | "last_value": 0.0,
839 | "unsigned": null,
840 | "binary": false
841 | },
842 | {
843 | "name": "LeftJoystickXY",
844 | "type": "vector2",
845 | "osc_parameter": [
846 | "XInputLeftThumbStickX",
847 | "XInputLeftThumbStickY",
848 | "XInputLeftStickMoved"
849 | ],
850 | "enabled": [
851 | true,
852 | true,
853 | true
854 | ],
855 | "always": [
856 | 2,
857 | 2,
858 | 2
859 | ],
860 | "floating": [
861 | 0.0,
862 | 0.0,
863 | -100
864 | ],
865 | "timestamp": [
866 | 0.0,
867 | 0.0,
868 | 0.0
869 | ],
870 | "last_value": [
871 | 0.0,
872 | 0.0,
873 | 0.0
874 | ],
875 | "unsigned": [
876 | false,
877 | false,
878 | false
879 | ],
880 | "binary": [
881 | false,
882 | false,
883 | false
884 | ]
885 | },
886 | {
887 | "name": "RightJoystickXY",
888 | "type": "vector2",
889 | "osc_parameter": [
890 | "XInputRightThumbStickX",
891 | "XInputRightThumbStickY",
892 | "XInputRightStickMoved"
893 | ],
894 | "enabled": [
895 | true,
896 | true,
897 | true
898 | ],
899 | "always": [
900 | 2,
901 | 2,
902 | 2
903 | ],
904 | "floating": [
905 | 0.0,
906 | 0.0,
907 | -100
908 | ],
909 | "timestamp": [
910 | 0.0,
911 | 0.0,
912 | 0.0
913 | ],
914 | "last_value": [
915 | 0.0,
916 | 0.0,
917 | 0.0
918 | ],
919 | "unsigned": [
920 | false,
921 | false,
922 | false
923 | ],
924 | "binary": [
925 | false,
926 | false,
927 | false
928 | ]
929 | },
930 | {
931 | "name": "DPadXY",
932 | "type": "vector2",
933 | "osc_parameter": [
934 | "XInputDPadX",
935 | "XInputDPadY",
936 | "XInputDPadMoved"
937 | ],
938 | "enabled": [
939 | true,
940 | true,
941 | true
942 | ],
943 | "always": [
944 | 2,
945 | 2,
946 | 2
947 | ],
948 | "floating": [
949 | 0.0,
950 | 0.0,
951 | -100
952 | ],
953 | "timestamp": [
954 | 0.0,
955 | 0.0,
956 | 0.0
957 | ],
958 | "last_value": [
959 | 0.0,
960 | 0.0,
961 | 0.0
962 | ],
963 | "unsigned": [
964 | false,
965 | false,
966 | false
967 | ],
968 | "binary": [
969 | false,
970 | false,
971 | false
972 | ]
973 | }
974 | ]
975 | }
--------------------------------------------------------------------------------
/src/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/I5UCC/VRCThumbParamsOSC/dbc3b1e6b5ef3f3b820a1cf812d9a6ca3e3b6f3d/src/icon.ico
--------------------------------------------------------------------------------
/src/main.py:
--------------------------------------------------------------------------------
1 | import argparse
2 | import ctypes
3 | import json
4 | import logging
5 | import os
6 | import sys
7 | import time
8 | import traceback
9 | import glob
10 | import shutil
11 | from tray_icon import TrayIcon
12 | from threading import Thread
13 |
14 | from zeroconf._exceptions import NonUniqueNameException
15 |
16 | from osc import OSC
17 | from ovr import OVR
18 | from xbox_controller import XboxController
19 |
20 |
21 | def get_absolute_path(relative_path) -> str:
22 | """
23 | Gets absolute path relative to the executable.
24 | Parameters:
25 | relative_path (str): Relative path
26 | Returns:
27 | str: Absolute path
28 | """
29 | base_path = os.path.dirname(sys.executable if getattr(sys, 'frozen', False)
30 | else os.path.abspath(__file__))
31 | return os.path.join(base_path, relative_path)
32 |
33 |
34 | def print_debugoutput() -> None:
35 | """
36 | Prints the debugoutput string.
37 | Returns:
38 | None
39 | """
40 | index = 0
41 | _debugoutput = ""
42 | os.system('cls' if os.name == 'nt' else 'clear')
43 |
44 | def get_debug_string(parameter, value, floating="", always = 0) -> str:
45 | nonlocal index
46 | if isinstance(value, float):
47 | value = f"{value:.4f}"
48 |
49 | if floating != "" and float(floating) > 0:
50 | floating = f"Floating: {floating}s"
51 | else:
52 | floating = ""
53 | match always:
54 | case 0:
55 | always = "SOC"
56 | case 1:
57 | always = "SOP"
58 | case _:
59 | always = ""
60 |
61 | res = f"{parameter.ljust(23, ' ')}\t{str(value).ljust(6, ' ')}\t{floating.ljust(10, ' ')}\t{always}\t" + ("\n" if index % 2 == 0 else "")
62 | index += 1
63 | return res
64 |
65 | if config["ControllerType"]["enabled"]:
66 | _debugoutput += get_debug_string("ControllerType", config["ControllerType"]["last_value"], "", config["ControllerType"]["always"])
67 | if config["LeftThumb"]["enabled"]:
68 | _debugoutput += get_debug_string("LeftThumb", config["LeftThumb"]["last_value"], "", config["LeftThumb"]["always"])
69 | if config["RightThumb"]["enabled"]:
70 | _debugoutput += get_debug_string("RightThumb", config["RightThumb"]["last_value"], "", config["RightThumb"]["always"])
71 | if config["LeftABButtons"]["enabled"]:
72 | _debugoutput += get_debug_string("LeftABButtons", config["LeftABButtons"]["last_value"], "", config["LeftABButtons"]["always"])
73 | if config["RightABButtons"]["enabled"]:
74 | _debugoutput += get_debug_string("RightABButtons", config["RightABButtons"]["last_value"], "", config["RightABButtons"]["always"])
75 |
76 | for action in config["actions"]:
77 | if action["enabled"]:
78 | if action["type"] == "vector2":
79 | _debugoutput += get_debug_string(action["osc_parameter"][0], action["last_value"][0], action["floating"][0], action["always"][0])
80 | _debugoutput += get_debug_string(action["osc_parameter"][1], action["last_value"][1], action["floating"][1], action["always"][1])
81 | if len(action["osc_parameter"]) > 2:
82 | _debugoutput += get_debug_string(action["osc_parameter"][2], action["last_value"][2], action["floating"][2], action["always"][2])
83 | else:
84 | _debugoutput += get_debug_string(action["osc_parameter"], action["last_value"], action["floating"], action["always"])
85 |
86 | for action in config["xinput_actions"]:
87 | if action["enabled"]:
88 | if action["type"] == "vector2":
89 | _debugoutput += get_debug_string(action["osc_parameter"][0], action["last_value"][0], action["floating"][0], action["always"][0])
90 | _debugoutput += get_debug_string(action["osc_parameter"][1], action["last_value"][1], action["floating"][1], action["always"][1])
91 | if len(action["osc_parameter"]) > 2:
92 | _debugoutput += get_debug_string(action["osc_parameter"][2], action["last_value"][2], action["floating"][2], action["always"][2])
93 | else:
94 | _debugoutput += get_debug_string(action["osc_parameter"], action["last_value"], action["floating"], action["always"])
95 |
96 | print(_debugoutput)
97 |
98 |
99 | def resend_parameters(avatar_id) -> None:
100 | """
101 | Resends all parameters to the new avatar.
102 | Parameters:
103 | avatar_id (str): Avatar ID
104 | Returns:
105 | None
106 | """
107 | global osc
108 |
109 | if osc.curr_avatar == avatar_id:
110 | return
111 |
112 | logging.info(f"Resending parameters to {avatar_id}")
113 | osc.curr_avatar = avatar_id
114 |
115 | if config["ControllerType"]["enabled"]:
116 | osc.send_parameter("ControllerType", config["ControllerType"]["last_value"])
117 | if config["LeftThumb"]["enabled"]:
118 | osc.send_parameter("LeftThumb", config["LeftThumb"]["last_value"])
119 | if config["RightThumb"]["enabled"]:
120 | osc.send_parameter("RightThumb", config["RightThumb"]["last_value"])
121 | if config["LeftABButtons"]["enabled"]:
122 | osc.send_parameter("LeftABButtons", config["LeftABButtons"]["last_value"])
123 | if config["RightABButtons"]["enabled"]:
124 | osc.send_parameter("RightABButtons", config["RightABButtons"]["last_value"])
125 |
126 | for action in config["actions"]:
127 | if action["type"] == "vector2":
128 | osc.send_parameter(action["osc_parameter"][0], action["last_value"][0])
129 | osc.send_parameter(action["osc_parameter"][1], action["last_value"][1])
130 | if len(action["osc_parameter"]) > 2:
131 | osc.send_parameter(action["osc_parameter"][2], action["last_value"][2])
132 | continue
133 | osc.send_parameter(action["osc_parameter"], action["last_value"])
134 |
135 |
136 | def handle_input() -> None:
137 | """
138 | Handles SteamVR input and sends it to VRChat.
139 | Returns:
140 | None
141 | """
142 | ovr.poll_next_events()
143 | osc.refresh_time()
144 |
145 | if config["ControllerType"]["enabled"] and (osc.curr_time - config["ControllerType"]["timestamp"] > 10.0 or config["ControllerType"]["always"]):
146 | _controller_type = ovr.get_controllertype()
147 | if _controller_type == 0 and xinput.is_plugged:
148 | _controller_type = 10
149 | elif _controller_type != 0 and xinput.is_plugged:
150 | _controller_type += 10
151 | osc.send("ControllerType", _controller_type)
152 |
153 | lefthandskeleton = ovr.get_value(config["actions"][0])
154 | osc.send(config["actions"][0], lefthandskeleton)
155 |
156 | righthandskeleton = ovr.get_value(config["actions"][1])
157 | osc.send(config["actions"][1], righthandskeleton)
158 |
159 | _strinputs = ""
160 | for action in config["actions"][2:10]: # Touch Actions
161 | val = ovr.get_value(action)
162 | _strinputs += "1" if val else "0"
163 | osc.send(action, val)
164 | osc.send("LeftThumb", _strinputs[:4].rfind("1") + 1)
165 | osc.send("RightThumb", _strinputs[4:].rfind("1") + 1)
166 | osc.send("LeftABButtons", _strinputs[0] == "1" and _strinputs[1] == "1")
167 | osc.send("RightABButtons", _strinputs[4] == "1" and _strinputs[5] == "1")
168 |
169 | for action in config["actions"][10:]:
170 | val = ovr.get_value(action)
171 | osc.send(action, val)
172 |
173 | # xinput buttons
174 | for action in config["xinput_actions"]:
175 | val = xinput.get_value(action)
176 | osc.send(action, val)
177 |
178 | if debug:
179 | print_debugoutput()
180 |
181 |
182 | def get_server_needed() -> bool:
183 | """
184 | Checks if the OSC server is needed.
185 | """
186 | if config["ControllerType"]["enabled"] and not config["ControllerType"]["always"]:
187 | return True
188 | if config["LeftThumb"]["enabled"] and not config["LeftThumb"]["always"]:
189 | return True
190 | if config["RightThumb"]["enabled"] and not config["RightThumb"]["always"]:
191 | return True
192 | if config["LeftABButtons"]["enabled"] and not config["LeftABButtons"]["always"]:
193 | return True
194 | if config["RightABButtons"]["enabled"] and not config["RightABButtons"]["always"]:
195 | return True
196 | for action in config["actions"]:
197 | if action["type"] != "vector2":
198 | if not action["always"] and action["enabled"]:
199 | return True
200 | continue
201 | if not action["always"][0] and action["enabled"][0] or not action["always"][1] and action["enabled"][1]:
202 | return True
203 | if len(action["always"]) > 2 and not action["always"][2] and action["enabled"][2]:
204 | return True
205 | return False
206 |
207 |
208 | def stop() -> None:
209 | """
210 | Stops the program.
211 | Returns:
212 | None
213 | """
214 | xinput.running = False
215 | tray.stop()
216 | ovr.shutdown()
217 | osc.shutdown()
218 |
219 | logging.basicConfig(level=logging.DEBUG if len(sys.argv) > 1 else logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S', handlers=[logging.StreamHandler(), logging.FileHandler(get_absolute_path("log.log"))])
220 |
221 | VERSION = open(get_absolute_path("VERSION")).read().strip()
222 |
223 | tray = TrayIcon(stop, get_absolute_path("icon.ico"))
224 | tray.run()
225 |
226 | # Argument Parser
227 | parser = argparse.ArgumentParser(description='ThumbParamsOSC: Takes button data from SteamVR and sends it to an OSC-Client')
228 | parser.add_argument('-d', '--debug', required=False, action='store_true', help='prints values for debugging')
229 | parser.add_argument('-i', '--ip', required=False, type=str, help="set OSC ip. Default=127.0.0.1")
230 | parser.add_argument('-p', '--port', required=False, type=str, help="set OSC port. Default=9000")
231 | ip = None
232 | port = None
233 | debug = False
234 | try:
235 | args = parser.parse_args()
236 | ip = args.ip
237 | port = args.port
238 | debug = args.debug
239 | except Exception as e:
240 | logging.error("Argument Error, continuing without arguments")
241 | ip = None
242 | port = None
243 | debug = False
244 |
245 | if os.name == 'nt':
246 | try:
247 | ctypes.windll.kernel32.SetConsoleTitleW(f"ThumbParamsOSC {VERSION}" + (" (Debug)" if debug else ""))
248 | except Exception:
249 | pass
250 |
251 | CONFIG_PATH = get_absolute_path('config.json')
252 | MANIFEST_PATH = get_absolute_path("app.vrmanifest")
253 | FIRST_LAUNCH_FILE = get_absolute_path("bindings/first_launch")
254 | config: dict = json.load(open(CONFIG_PATH))
255 | config["IP"] = ip if ip else config["IP"]
256 | config["Port"] = port if port else config["Port"]
257 | POLLINGRATE = 1 / float(config['PollingRate'])
258 |
259 | try:
260 | if os.path.isfile(FIRST_LAUNCH_FILE):
261 | if os.name == "nt":
262 | ctypes.windll.user32.MessageBoxW(0, "ThumbParamsOSC is now running and has registered as an Overlay on Steam.\nIt will now open automatically with SteamVR\nOpen Configurator.exe to change sent Parameters and other Settings if you havent yet.\n.This is only shown once.", "ThumbparamsOSC", 0)
263 | logging.info("First Launch, deleting OSC cache. Registering app to run on SteamVR start...")
264 | cache_path = os.getenv('APPDATA') + '\\..\\LocalLow\\VRChat\\VRChat\\OSC\\usr_*'
265 | user_folders = glob.glob(cache_path)
266 | for folder in user_folders:
267 | shutil.rmtree(folder)
268 | except Exception as e:
269 | logging.error("Error while deleting OSC cache.")
270 | logging.error(traceback.format_exc())
271 |
272 | try:
273 | ovr: OVR = OVR(config, CONFIG_PATH, MANIFEST_PATH, FIRST_LAUNCH_FILE)
274 | osc: OSC = OSC(config, lambda addr, value: resend_parameters(value), get_server_needed())
275 | xinput = XboxController(polling_rate=config.get("XInputPollingRate", 1000))
276 | except OSError as e:
277 | logging.error("You can only bind to the port 9001 once.")
278 | logging.error(traceback.format_exc())
279 | if os.name == "nt":
280 | ctypes.windll.user32.MessageBoxW(0, "You can only bind to the port 9001 once.", "AvatarParameterSync - Error", 0)
281 | stop()
282 | except NonUniqueNameException as e:
283 | logging.error("NonUniqueNameException, trying again...")
284 | os.execv(sys.executable, ['python'] + sys.argv)
285 | except Exception as e:
286 | logging.error("UNEXPECTED ERROR\n")
287 | logging.error("Please Create an Issue on GitHub with the following information:\n")
288 | logging.error(traceback.format_exc())
289 | input("\nPress ENTER to exit")
290 | stop()
291 |
292 | logging.info(f"ThumbParamsOSC {VERSION} running...")
293 | logging.info(f"IP: {osc.ip}")
294 | logging.info(f"Port: {osc.port}")
295 | logging.info(f"Server Port: {osc.server_port}")
296 | logging.info(f"HTTP Port: {osc.http_port}")
297 | logging.info(f"PollingRate: {POLLINGRATE}s ({config['PollingRate']} Hz)")
298 | logging.info(f"StickMoveTolerance: {osc.stick_tolerance} ({config['StickMoveTolerance']}%)")
299 | logging.info("Open Configurator.exe to change sent Parameters and other Settings.")
300 |
301 |
302 | def main_loop():
303 | # Main Loop
304 | while True:
305 | handle_input()
306 | time.sleep(POLLINGRATE)
307 |
308 |
309 | try:
310 | thread = Thread(target=xinput.polling_loop, daemon=True)
311 | thread.start()
312 | main_loop()
313 | except KeyboardInterrupt:
314 | pass
315 | except Exception:
316 | logging.error("UNEXPECTED ERROR\n")
317 | logging.error("Please Create an Issue on GitHub with the following information:\n")
318 | logging.error(traceback.format_exc())
319 | input("\nPress ENTER to exit")
320 | stop()
321 |
--------------------------------------------------------------------------------
/src/osc.py:
--------------------------------------------------------------------------------
1 | from pythonosc import udp_client, dispatcher, osc_server
2 | from tinyoscquery.queryservice import OSCQueryService
3 | from tinyoscquery.utility import get_open_tcp_port, get_open_udp_port, check_if_tcp_port_open, check_if_udp_port_open
4 | from tinyoscquery.query import OSCQueryBrowser, OSCQueryClient
5 | import time
6 | import os
7 | from threading import Thread
8 | from psutil import process_iter
9 | import logging
10 | from ovr import FINGERS, SPLAYFINGERS
11 | import copy
12 |
13 | AVATAR_PARAMETERS_PREFIX = "/avatar/parameters/"
14 | AVATAR_CHANGE_PARAMETER = "/avatar/change"
15 |
16 | class OSC:
17 | def __init__(self, conf: dict, avatar_change_function, run_server = True) -> None:
18 | self.config = conf
19 | self.ip = conf["IP"]
20 | self.port = conf["Port"]
21 | self.server_port = conf["Server_Port"]
22 | self.http_port = conf["HTTP_Port"]
23 | self.stick_tolerance = int(conf['StickMoveTolerance']) / 100
24 | self.curr_avatar = ""
25 | self.curr_time = 0
26 | self.binary_num_bits = int(conf["Binary_bits"])
27 | self.binary_potencies = [2**i for i in range(self.binary_num_bits)]
28 | self.binary_potency = (2**self.binary_num_bits) - 1
29 | self.server = None
30 | self.oscqs = None
31 | self.osc_client = udp_client.SimpleUDPClient(self.ip, self.port)
32 | if run_server:
33 | self.start_server(avatar_change_function)
34 |
35 | def start_server(self, avatar_change_function) -> None:
36 | """
37 | Starts the OSC server and OSCQuery endpoints and advertises them.
38 | Parameters:
39 | avatar_change_function (function): Function to be called when the avatar changes
40 | Returns:
41 | None
42 | """
43 | self.disp = dispatcher.Dispatcher()
44 | self.disp.map(AVATAR_CHANGE_PARAMETER, avatar_change_function)
45 | if self.server_port != 9001:
46 | logging.info("OSC Server port is not default, testing port availability and advertising OSCQuery endpoints")
47 | if self.server_port <= 0 or not check_if_udp_port_open(self.server_port):
48 | self.server_port = get_open_udp_port()
49 | if self.http_port <= 0 or not check_if_tcp_port_open(self.http_port):
50 | self.http_port = self.server_port if check_if_tcp_port_open(self.server_port) else get_open_tcp_port()
51 | else:
52 | logging.info("OSC Server port is default.")
53 |
54 | logging.info("Waiting for VRChat to start.")
55 | while not self.is_running():
56 | time.sleep(3)
57 | logging.info("VRChat started!")
58 | self.qclient = self._wait_get_oscquery_client()
59 | self.curr_avatar = self.qclient.query_node(AVATAR_CHANGE_PARAMETER).value[0]
60 | self.server = osc_server.ThreadingOSCUDPServer((self.ip, self.server_port), self.disp)
61 | server_thread = Thread(target=self._osc_server_serve, daemon=True)
62 | server_thread.start()
63 | self.oscqs = OSCQueryService("ThumbParamsOSC", self.http_port, self.server_port)
64 | self.oscqs.advertise_endpoint(AVATAR_CHANGE_PARAMETER, access="readwrite")
65 |
66 |
67 | def is_running(self) -> bool:
68 | """
69 | Checks if VRChat is running.
70 | Returns:
71 | bool: True if VRChat is running, False if not
72 | """
73 | _proc_name = "VRChat.exe" if os.name == 'nt' else "VRChat"
74 | return _proc_name in (p.name() for p in process_iter())
75 |
76 |
77 | def _wait_get_oscquery_client(self) -> OSCQueryClient:
78 | """
79 | Waits for VRChat to be discovered and ready and returns the OSCQueryClient.
80 | Returns:
81 | OSCQueryClient: OSCQueryClient for VRChat
82 | """
83 | service_info = None
84 | logging.info("Waiting for VRChat to be discovered.")
85 | while service_info is None:
86 | browser = OSCQueryBrowser()
87 | time.sleep(2) # Wait for discovery
88 | service_info = browser.find_service_by_name("VRChat")
89 | logging.info("VRChat discovered!")
90 | client = OSCQueryClient(service_info)
91 | logging.info("Waiting for VRChat to be ready.")
92 | while client.query_node(AVATAR_CHANGE_PARAMETER) is None:
93 | time.sleep(2)
94 | logging.info("VRChat ready!")
95 | return client
96 |
97 |
98 | def _osc_server_serve(self) -> None:
99 | """
100 | Starts the OSC server.
101 | Returns:
102 | None
103 | """
104 | logging.info(f"Starting OSC client on {self.ip}:{self.server_port}:{self.http_port}")
105 | self.server.serve_forever(2)
106 |
107 |
108 | def _float_to_binary(self, float_value):
109 | """
110 | Converts a float value to binary parameters.
111 | Parameters:
112 | float_value (float): Float value to convert
113 | num_bits (int): Number of bits to use
114 | Returns:
115 | list: Binary parameters + negative flag
116 | """
117 | negative = float_value < 0
118 | float_value = abs(float_value)
119 |
120 | # Calculate the total base-10 value based on the float value and number of bits
121 | total_base_10 = int(float_value * self.binary_potency)
122 |
123 | # Convert the total base-10 value to binary parameters
124 | binary_params = [int(bit) for bit in format(total_base_10, f'0{self.binary_num_bits}b')]
125 |
126 | # Add the negative flag to the end of the binary parameters and return
127 | return binary_params + [negative]
128 |
129 |
130 | def _binary_to_float(self, binary_params: list):
131 | """
132 | Reconstructs binary parameters back to a float value.
133 | Parameters:
134 | binary_params (list): Binary parameters + negative flag
135 | Returns:
136 | float: Float value
137 | """
138 | negative = binary_params.pop()
139 | # Calculate the total base-10 value from the binary parameters
140 | total_base_10 = int(''.join(map(str, binary_params)), 2)
141 |
142 | # Map the total base-10 value to a float in the range [0.0, 1.0]
143 | float_value = total_base_10 / self.binary_potency
144 |
145 | return -float_value if negative else float_value
146 |
147 |
148 | def _send_boolean_toggle(self, action: dict, value: bool) -> None:
149 | """
150 | Sends a boolean action as a toggle to VRChat via OSC.
151 | Parameters:
152 | action (dict): Action
153 | value (bool): Value of the parameter
154 | Returns:
155 | None
156 | """
157 | if not action["enabled"]:
158 | return
159 |
160 | if value:
161 | action["last_value"] = not action["last_value"]
162 | time.sleep(0.1)
163 | self.send_parameter(action["osc_parameter"], action["last_value"])
164 | return
165 |
166 | if action["always"]:
167 | self.send_parameter(action["osc_parameter"], action["last_value"])
168 |
169 |
170 | def _send_boolean(self, action: dict, value: bool) -> None:
171 | """
172 | Sends a boolean action to VRChat via OSC.
173 | Parameters:
174 | action (dict): Action
175 | value (bool): Value of the parameter
176 | Returns:
177 | None
178 | """
179 | _do_send = action["always"] == 2 or (action["always"] == 0 and action["last_value"] != value) or (action["always"] == 1 and value)
180 |
181 | if not action["enabled"] or not _do_send:
182 | return
183 |
184 | if action["floating"]:
185 | if value:
186 | action["timestamp"] = self.curr_time
187 | elif not value and self.curr_time - action["timestamp"] <= action["floating"]:
188 | value = action["last_value"]
189 |
190 | if _do_send:
191 | self.send_parameter(action["osc_parameter"], value)
192 | action["last_value"] = value
193 |
194 |
195 | def _send_vector1(self, action: dict, value: float) -> None:
196 | """
197 | Sends a vector1 action to VRChat via OSC.
198 | Parameters:
199 | action (dict): Action
200 | value (float): Value of the parameter
201 | Returns:
202 | None
203 | """
204 | _do_send = action["always"] == 2 or (action["always"] == 0 and action["last_value"] != value) or (action["always"] == 1 and value)
205 |
206 | if not action["enabled"] or not _do_send:
207 | return
208 |
209 | if action["floating"]:
210 | if value > action["last_value"]:
211 | action["timestamp"] = self.curr_time
212 | elif value < action["last_value"] and self.curr_time - action["timestamp"] <= action["floating"]:
213 | value = action["last_value"]
214 |
215 | if _do_send:
216 | if action["binary"]:
217 | tmp = self._float_to_binary(value)
218 | self.send_parameter(action["osc_parameter"] + "_Negative", tmp[-1])
219 | tmp = tmp[:-1]
220 | tmp.reverse()
221 | for i in range(len(tmp)):
222 | self.send_parameter(action["osc_parameter"] + str(self.binary_potencies), tmp[i])
223 | else:
224 | self.send_parameter(action["osc_parameter"], value)
225 | action["last_value"] = value
226 |
227 |
228 | def _send_vector2(self, action: dict, value: tuple) -> None:
229 | """
230 | Sends a vector2 action to VRChat via OSC.
231 | Parameters:
232 | action (dict): Action
233 | value (tuple): X and Y value of the parameter in a tuple
234 | Returns:
235 | None
236 | """
237 | val_x, val_y = value[0], value[1]
238 | if action["unsigned"][0]:
239 | val_x = (val_x + 1) / 2
240 | if action["unsigned"][1]:
241 | val_y = (val_y + 1) / 2
242 |
243 | if action["floating"]:
244 | if val_x:
245 | action["timestamp"][0] = self.curr_time
246 | elif not val_x and self.curr_time - action["timestamp"][0] <= action["floating"][0]:
247 | val_x = action["last_value"][0]
248 | if val_y:
249 | action["timestamp"][1] = self.curr_time
250 | elif not val_y and self.curr_time - action["timestamp"][1] <= action["floating"][1]:
251 | val_y = action["last_value"][1]
252 |
253 | val_bool = (val_x > self.stick_tolerance or val_y > self.stick_tolerance) or (val_x < -self.stick_tolerance or val_y < -self.stick_tolerance)
254 | value = [val_x, val_y, val_bool]
255 |
256 | for i in range(len(action["osc_parameter"])):
257 | if not action["enabled"][i]:
258 | continue
259 | if action["always"][i] == 2 or (action["always"][i] == 0 and action["last_value"][i] != value[i]) or (action["always"][i] == 1 and value[i]):
260 | if action["binary"][i]:
261 | value[i] = self._float_to_binary(value[i])
262 | tmp = value[i]
263 | self.send_parameter(action["osc_parameter"][i] + "_Negative", tmp[-1])
264 | tmp = tmp[:-1]
265 | tmp.reverse()
266 | for j in range(len(tmp)):
267 | self.send_parameter(action["osc_parameter"][i] + str(self.binary_potencies), tmp[j])
268 | else:
269 | self.send_parameter(action["osc_parameter"][i], value[i])
270 | action["last_value"][i] = value[i]
271 |
272 |
273 | def _send_skeleton(self, action: dict, skeleton) -> None:
274 | if skeleton is None or not action["enabled"]:
275 | return
276 |
277 | base_osc_parameter = action['osc_parameter']
278 | parameters = [(FINGERS, "Curl", skeleton.flFingerCurl), (SPLAYFINGERS, "Splay", skeleton.flFingerSplay)]
279 |
280 | for param_group, param_type, finger_data in parameters:
281 | for fname, fidx in param_group.items():
282 | osc_parameter = f"{base_osc_parameter}/{param_type}/{fname}"
283 | self._send_vector1({**action, "osc_parameter": osc_parameter}, finger_data[fidx])
284 |
285 |
286 | def refresh_time(self) -> None:
287 | """
288 | Refreshes the current time.
289 | Returns:
290 | None
291 | """
292 | self.curr_time = time.time()
293 |
294 |
295 | def send_parameter(self, parameter: str, value) -> None:
296 | """
297 | Sends a parameter to VRChat via OSC.
298 | Parameters:
299 | parameter (str): Name of the parameter
300 | value (any): Value of the parameter
301 | floating (str): Floating value of the parameter, just for for debug output
302 | Returns:
303 | None
304 | """
305 | self.osc_client.send_message(AVATAR_PARAMETERS_PREFIX + parameter, value)
306 |
307 |
308 | def send(self, action: dict | str, value: bool | float | tuple) -> None:
309 | """
310 | Sends an OSC message to VRChat.
311 | Parameters:
312 | action (dict | str): Action or OSC address
313 | value (bool | float | tuple): Value of the parameter
314 | Returns:
315 | None
316 | """
317 | if isinstance(action, str):
318 | self.config[action]["osc_parameter"] = action
319 | self.config[action]["floating"] = 0.0
320 | self._send_boolean(self.config[action], value)
321 | return
322 |
323 | match action['type']:
324 | case "boolean":
325 | if action["floating"] == -1:
326 | self._send_boolean_toggle(action, value)
327 | else:
328 | self._send_boolean(action, value)
329 | case "vector1":
330 | self._send_vector1(action, value)
331 | case "vector2":
332 | self._send_vector2(action, value)
333 | case "skeleton":
334 | self._send_skeleton(action, value)
335 | case _:
336 | raise TypeError("Unknown action type: " + action['type'])
337 |
338 | def shutdown(self) -> None:
339 | """
340 | Stops the OSC server.
341 | Returns:
342 | None
343 | """
344 | if self.server:
345 | self.server.shutdown()
346 | if self.oscqs:
347 | self.oscqs.stop()
348 |
--------------------------------------------------------------------------------
/src/ovr.py:
--------------------------------------------------------------------------------
1 | import openvr
2 | import openvr.error_code
3 | import os
4 | import logging
5 |
6 | FINGERS = {
7 | "Thumb": openvr.VRFinger_Thumb,
8 | "Index": openvr.VRFinger_Index,
9 | "Middle": openvr.VRFinger_Middle,
10 | "Ring": openvr.VRFinger_Ring,
11 | "Pinky": openvr.VRFinger_Pinky
12 | }
13 |
14 | SPLAYFINGERS = {
15 | "Index": openvr.VRFingerSplay_Thumb_Index,
16 | "Middle": openvr.VRFingerSplay_Index_Middle,
17 | "Ring": openvr.VRFingerSplay_Middle_Ring,
18 | "Pinky": openvr.VRFingerSplay_Ring_Pinky
19 | }
20 |
21 | class OVR:
22 | def __init__(self, config:dict, config_path: str, manifest_path: str, first_launch_file: str):
23 | self.application = openvr.init(openvr.VRApplication_Utility)
24 | logging.info("OpenVR Initialized.")
25 | openvr.VRInput().setActionManifestPath(config_path)
26 | openvr.VRApplications().addApplicationManifest(manifest_path)
27 | logging.info("Application Manifest Added.")
28 | if os.path.isfile(first_launch_file):
29 | openvr.VRApplications().setApplicationAutoLaunch("i5ucc.thumbparamsosc", True)
30 | logging.info("Application set to auto launch.")
31 | os.remove(first_launch_file)
32 | self.action_set_handle = openvr.VRInput().getActionSetHandle("/actions/thumbparams")
33 | self.actionsets = (openvr.VRActiveActionSet_t * 1)()
34 | self.actionset = self.actionsets[0]
35 | self.actionset.ulActionSet = self.action_set_handle
36 | for action in config["actions"]:
37 | action["handle"] = openvr.VRInput().getActionHandle(action['name'])
38 |
39 |
40 | def get_controllertype(self) -> int:
41 | """
42 | Gets the type of controller from SteamVR.
43 | Returns:
44 | int: Type of controller (0 = Unknown, 1 = Knuckles, 2 = Oculus/Meta Touch)
45 | """
46 | for i in range(1, openvr.k_unMaxTrackedDeviceCount):
47 | device_class = openvr.VRSystem().getTrackedDeviceClass(i)
48 | if device_class == 2:
49 | match openvr.VRSystem().getStringTrackedDeviceProperty(i, openvr.Prop_ControllerType_String):
50 | case 'knuckles':
51 | return 1
52 | case 'oculus_touch':
53 | return 2
54 | case _:
55 | return 0
56 | return 0
57 |
58 |
59 | def get_value(self, action: dict) -> bool | float | tuple | openvr.VRSkeletalSummaryData_t | None:
60 | """
61 | Gets the value of an action by querying SteamVR.
62 | Parameters:
63 | action (dict): Action
64 | Returns:
65 | any: Value of the action
66 | """
67 | match action['type']:
68 | case "boolean":
69 | return bool(openvr.VRInput().getDigitalActionData(action['handle'], openvr.k_ulInvalidInputValueHandle).bState)
70 | case "vector1":
71 | return float(openvr.VRInput().getAnalogActionData(action['handle'], openvr.k_ulInvalidInputValueHandle).x)
72 | case "vector2":
73 | tmp = openvr.VRInput().getAnalogActionData(action['handle'], openvr.k_ulInvalidInputValueHandle)
74 | return tmp.x, tmp.y
75 | case "skeleton":
76 | try:
77 | tmp = openvr.VRInput().getSkeletalSummaryData(action['handle'], openvr.VRSummaryType_FromDevice)
78 | return tmp
79 | except openvr.error_code.InputError_NoData:
80 | return None
81 | case _:
82 | raise TypeError("Unknown action type: " + action['type'])
83 |
84 |
85 | def poll_next_events(self):
86 | _event = openvr.VREvent_t()
87 | _has_events = True
88 | while _has_events:
89 | _has_events = self.application.pollNextEvent(_event)
90 | try:
91 | openvr.VRInput().updateActionState(self.actionsets)
92 | except openvr.error_code.InputError_NoData:
93 | logging.error("No data available for action state update.")
94 |
95 |
96 | def shutdown(self) -> bool:
97 | """Shuts down the OVR handler."""
98 |
99 | try:
100 | openvr.shutdown()
101 | return True
102 | except Exception as e:
103 | print("Error shutting down OVR: " + str(e))
104 | return False
105 |
--------------------------------------------------------------------------------
/src/print_parameters_markdown.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | with open('config.json') as file:
4 | data = json.load(file)
5 |
6 | controller_params = list()
7 | xinput_params = list()
8 | tracker_params = list()
9 |
10 | for action in data["actions"]:
11 | param = action["osc_parameter"]
12 | t = action["type"]
13 | value = None
14 | if t == "vector2":
15 | for i in range(len(param)):
16 | if i == 2:
17 | value = (param[i], "bool")
18 | else:
19 | value = (param[i], "float")
20 | elif t == "vector1":
21 | value = (param, "float")
22 | else:
23 | value = (param, "bool")
24 |
25 | if "Tracker" in param:
26 | tracker_params.append(value)
27 | else:
28 | controller_params.append(value)
29 |
30 |
31 | for action in data["xinput_actions"]:
32 | param = action["osc_parameter"]
33 | t = action["type"]
34 | value = None
35 | if t == "vector2":
36 | for i in range(len(param)):
37 | if i == 2:
38 | value = (param[i], "bool")
39 | else:
40 | value = (param[i], "float")
41 | elif t == "vector1":
42 | value = (param, "float")
43 | else:
44 | value = (param, "bool")
45 |
46 | xinput_params.append(value)
47 |
48 |
49 | print("##SteamVR Controller Parameters")
50 | print("| Parameter | Type |")
51 | print("|-----------|------|")
52 | for param, t in controller_params:
53 | print(f"| {param} | {t} |")
54 |
55 | print("\n## Tracker Parameters")
56 | print("| Parameter | Type |")
57 | print("|-----------|------|")
58 | for param, t in tracker_params:
59 | print(f"| {param} | {t} |")
60 |
61 | print("\n## XInput Parameters")
62 | print("| Parameter | Type |")
63 | print("|-----------|------|")
64 | for param, t in xinput_params:
65 | print(f"| {param} | {t} |")
--------------------------------------------------------------------------------
/src/requirements.txt:
--------------------------------------------------------------------------------
1 | zeroconf==0.119.0
2 | python-osc
3 | openvr
4 | argparse
5 | requests
6 | psutil
7 | pyglet
8 | pillow
9 | pystray
10 | ifaddr
--------------------------------------------------------------------------------
/src/setup.py:
--------------------------------------------------------------------------------
1 | from cx_Freeze import setup, Executable
2 |
3 | VERSION = open("VERSION").read().strip()
4 |
5 | packages = ["argparse", "certifi", "charset_normalizer", "idna", "ifaddr", "lief", "openvr", "psutil", "pyglet", "pythonosc", "requests", "urllib3", "zeroconf", "ctypes", "pystray", "PIL"]
6 | exclude = ["tkinter", "lib2to3", "test", "unittest", "xmlrpc"]
7 | file_include = ["config.json", "Run Debug Mode.bat", "bindings/", "app.vrmanifest", "VERSION", "icon.ico"]
8 | bin_excludes = ["_bz2.pyd", "_decimal.pyd", "_hashlib.pyd", "_lzma.pyd", "_queue.pyd", "_ssl.pyd", "libcrypto-1_1.dll", "libssl-1_1.dll", "ucrtbase.dll", "VCRUNTIME140.dll"]
9 |
10 | build_exe_options = {"packages": packages, "excludes": exclude, "include_files": file_include, "bin_excludes": bin_excludes}
11 |
12 | setup(
13 | name="ThumbParamsOSC",
14 | version=VERSION,
15 | description="ThumbParamsOSC",
16 | options={"build_exe": build_exe_options},
17 | executables=[Executable("main.py", target_name="ThumbParamsOSC.exe", base=False, icon="icon.ico"), Executable("main.py", target_name="ThumbParamsOSC_NoConsole.exe", base="Win32GUI", icon="icon.ico")],
18 | )
19 |
--------------------------------------------------------------------------------
/src/tinyoscquery/query.py:
--------------------------------------------------------------------------------
1 | import time
2 | from zeroconf import ServiceBrowser, ServiceInfo, ServiceListener, Zeroconf
3 | import requests
4 |
5 | from .shared.node import OSCQueryNode, OSC_Type_String_to_Python_Type, OSCAccess, OSCHostInfo
6 |
7 | class OSCQueryListener(ServiceListener):
8 |
9 | def __init__(self) -> None:
10 | self.osc_services = {}
11 | self.oscjson_services = {}
12 |
13 | super().__init__()
14 |
15 | def remove_service(self, zc: 'Zeroconf', type_: str, name: str) -> None:
16 | if name in self.osc_services:
17 | del self.osc_services[name]
18 |
19 | if name in self.oscjson_services:
20 | del self.oscjson_services[name]
21 |
22 | def add_service(self, zc: 'Zeroconf', type_: str, name: str) -> None:
23 | if type_ == '_osc._udp.local.':
24 | self.osc_services[name] = zc.get_service_info(type_, name)
25 | elif type_ == '_oscjson._tcp.local.':
26 | self.oscjson_services[name] = zc.get_service_info(type_, name)
27 |
28 | def update_service(self, zc: 'Zeroconf', type_: str, name: str) -> None:
29 | if type_ == '_osc._udp.local.':
30 | self.osc_services[name] = zc.get_service_info(type_, name)
31 | elif type_ == '_oscjson._tcp.local.':
32 | self.oscjson_services[name] = zc.get_service_info(type_, name)
33 |
34 |
35 | class OSCQueryBrowser(object):
36 | def __init__(self) -> None:
37 | self.listener = OSCQueryListener()
38 | self.zc = Zeroconf()
39 | self.browser = ServiceBrowser(self.zc, ["_oscjson._tcp.local.", "_osc._udp.local."], self.listener)
40 |
41 | def get_discovered_osc(self):
42 | return [oscsvc[1] for oscsvc in self.listener.osc_services.items()]
43 |
44 | def get_discovered_oscquery(self):
45 | return [oscjssvc[1] for oscjssvc in self.listener.oscjson_services.items()]
46 |
47 | def find_service_by_name(self, name):
48 | for svc in self.get_discovered_oscquery():
49 | client = OSCQueryClient(svc)
50 | if name in client.get_host_info().name:
51 | return svc
52 |
53 | return None
54 |
55 | def find_nodes_by_endpoint_address(self, address) -> list[tuple[ServiceInfo, OSCHostInfo, OSCQueryNode]]:
56 | svcs = []
57 | for svc in self.get_discovered_oscquery():
58 | client = OSCQueryClient(svc)
59 | hi = client.get_host_info()
60 | if hi is None:
61 | continue
62 | node = client.query_node(address)
63 | if node is not None:
64 | svcs.append((svc, hi, node))
65 |
66 | return svcs
67 |
68 |
69 | class OSCQueryClient(object):
70 | def __init__(self, service_info) -> None:
71 | if not isinstance(service_info, ServiceInfo):
72 | raise Exception("service_info isn't a ServiceInfo class!")
73 |
74 | if service_info.type != "_oscjson._tcp.local.":
75 | raise Exception("service_info does not represent an OSCQuery service!")
76 |
77 | self.service_info = service_info
78 | self.last_json = None
79 |
80 | def _get_query_root(self):
81 | return f"http://{self._get_ip_str()}:{self.service_info.port}"
82 |
83 | def _get_ip_str(self):
84 | ip_str = '.'.join([str(int(num)) for num in self.service_info.addresses[0]])
85 | return ip_str
86 |
87 | def query_node(self, node="/"):
88 | url = self._get_query_root() + node
89 | r = None
90 | try:
91 | r = requests.get(url)
92 | except Exception as ex:
93 | print("Error querying node...", ex)
94 | if r is None:
95 | return None
96 |
97 | if r.status_code == 404:
98 | return None
99 |
100 | if r.status_code != 200:
101 | raise Exception("Node query error: (HTTP", r.status_code, ") ", r.content)
102 |
103 | self.last_json = r.json()
104 |
105 | return self._make_node_from_json(self.last_json)
106 |
107 |
108 | def get_host_info(self):
109 | url = self._get_query_root() + "/HOST_INFO"
110 | r = None
111 | try:
112 | r = requests.get(url)
113 | except Exception as ex:
114 | #print("Error querying HOST_INFO...", ex)
115 | pass
116 | if r is None:
117 | return None
118 |
119 | if r.status_code != 200:
120 | raise Exception("Node query error: (HTTP", r.status_code, ") ", r.content)
121 |
122 | json = r.json()
123 | hi = OSCHostInfo(json["NAME"], json['EXTENSIONS'])
124 | if 'OSC_IP' in json:
125 | hi.osc_ip = json["OSC_IP"]
126 | else:
127 | hi.osc_ip = self._get_ip_str()
128 |
129 | if 'OSC_PORT' in json:
130 | hi.osc_port = json['OSC_PORT']
131 | else:
132 | hi.osc_port = self.service_info.port
133 |
134 | if 'OSC_TRANSPORT' in json:
135 | hi.osc_transport = json['OSC_TRANSPORT']
136 | else:
137 | hi.osc_transport = "UDP"
138 |
139 | return hi
140 |
141 | def _make_node_from_json(self, json):
142 | newNode = OSCQueryNode()
143 |
144 | if "CONTENTS" in json:
145 | subNodes = []
146 | for subNode in json["CONTENTS"]:
147 | subNodes.append(self._make_node_from_json(json["CONTENTS"][subNode]))
148 | newNode.contents = subNodes
149 |
150 | # This *should* be required but some implementations don't have it...
151 | if "FULL_PATH" in json:
152 | newNode.full_path = json["FULL_PATH"]
153 |
154 | if "TYPE" in json:
155 | newNode.type_ = OSC_Type_String_to_Python_Type(json["TYPE"])
156 |
157 | if "DESCRIPTION" in json:
158 | newNode.description = json["DESCRIPTION"]
159 |
160 | if "ACCESS" in json:
161 | newNode.access = OSCAccess(json["ACCESS"])
162 |
163 | if "VALUE" in json:
164 | newNode.value = []
165 | # This should always be an array... throw an exception here?
166 | if not isinstance(json['VALUE'], list):
167 | raise Exception("OSCQuery JSON Value is not List / Array? Out-of-spec?")
168 |
169 | for idx, v in enumerate(json["VALUE"]):
170 | # According to the spec, if there is not yet a value, the return will be an empty JSON object
171 | if isinstance(v, dict) and not v:
172 | # FIXME does this apply to all values in the value array always...? I assume it does here
173 | newNode.value = []
174 | break
175 | else:
176 | newNode.value.append(newNode.type_[idx](v))
177 |
178 |
179 | return newNode
180 |
181 |
182 |
183 |
184 | if __name__ == "__main__":
185 | browser = OSCQueryBrowser()
186 | time.sleep(2) # Wait for discovery
187 |
188 | for service_info in browser.get_discovered_oscquery():
189 | client = OSCQueryClient(service_info)
190 |
191 | # Find host info
192 | host_info = client.get_host_info()
193 | print(f"Found OSC Host: {host_info.name} with ip {host_info.osc_ip}:{host_info.osc_port}")
194 |
195 | # Query a node and print its value
196 | node = client.query_node("/test/node")
197 | print(f"Node is a {node.type_} with value {node.value}")
198 |
199 |
200 |
--------------------------------------------------------------------------------
/src/tinyoscquery/queryservice.py:
--------------------------------------------------------------------------------
1 | from zeroconf import ServiceInfo, Zeroconf
2 | from http.server import SimpleHTTPRequestHandler, HTTPServer
3 | from .shared.node import OSCQueryNode, OSCHostInfo, OSCAccess
4 | import json, threading
5 |
6 |
7 | class OSCQueryService(object):
8 | """
9 | A class providing an OSCQuery service. Automatically sets up a oscjson http server and advertises the oscjson server and osc server on zeroconf.
10 |
11 | Attributes
12 | ----------
13 | serverName : str
14 | Name of your OSC Service
15 | httpPort : int
16 | Desired TCP port number for the oscjson HTTP server
17 | oscPort : int
18 | Desired UDP port number for the osc server
19 | """
20 |
21 | def __init__(self, serverName, httpPort, oscPort, oscIp="127.0.0.1") -> None:
22 | self.serverName = serverName
23 | self.httpPort = httpPort
24 | self.oscPort = oscPort
25 | self.oscIp = oscIp
26 |
27 | self.root_node = OSCQueryNode("/", description="root node")
28 | self.host_info = OSCHostInfo(serverName, {"ACCESS":True,"CLIPMODE":False,"RANGE":True,"TYPE":True,"VALUE":True},
29 | self.oscIp, self.oscPort, "UDP")
30 |
31 | self._zeroconf = Zeroconf()
32 | self._startOSCQueryService()
33 | self._advertiseOSCService()
34 | self.http_server = OSCQueryHTTPServer(self.root_node, self.host_info, ('', self.httpPort), OSCQueryHTTPHandler)
35 | self.http_thread = threading.Thread(target=self._startHTTPServer)
36 | self.http_thread.start()
37 |
38 | def stop(self):
39 | self.http_server.shutdown()
40 |
41 | def add_node(self, node):
42 | self.root_node.add_child_node(node)
43 |
44 | def advertise_endpoint(self, address, value=None, access=OSCAccess.READWRITE_VALUE):
45 | new_node = OSCQueryNode(full_path=address, access=access)
46 | if value is not None:
47 | if not isinstance(value, list):
48 | new_node.value = [value]
49 | new_node.type_ = [type(value)]
50 | else:
51 | new_node.value = value
52 | new_node.type_ = [type(v) for v in value]
53 | self.add_node(new_node)
54 |
55 | def _startOSCQueryService(self):
56 | oscqsDesc = {'txtvers': 1}
57 | oscqsInfo = ServiceInfo("_oscjson._tcp.local.", "%s._oscjson._tcp.local." % self.serverName, self.httpPort,
58 | 0, 0, oscqsDesc, "%s.oscjson.local." % self.serverName, addresses=["127.0.0.1"])
59 | self._zeroconf.register_service(oscqsInfo)
60 |
61 |
62 | def _startHTTPServer(self):
63 | self.http_server.serve_forever()
64 |
65 | def _advertiseOSCService(self):
66 | oscDesc = {'txtvers': 1}
67 | oscInfo = ServiceInfo("_osc._udp.local.", "%s._osc._udp.local." % self.serverName, self.oscPort,
68 | 0, 0, oscDesc, "%s.osc.local." % self.serverName, addresses=["127.0.0.1"])
69 |
70 | self._zeroconf.register_service(oscInfo)
71 |
72 |
73 | class OSCQueryHTTPServer(HTTPServer):
74 | def __init__(self, root_node, host_info, server_address: tuple[str, int], RequestHandlerClass, bind_and_activate: bool = ...) -> None:
75 | super().__init__(server_address, RequestHandlerClass, bind_and_activate)
76 | self.root_node = root_node
77 | self.host_info = host_info
78 |
79 |
80 | class OSCQueryHTTPHandler(SimpleHTTPRequestHandler):
81 | def do_GET(self) -> None:
82 | if 'HOST_INFO' in self.path:
83 | self.send_response(200)
84 | self.send_header("Content-type", "text/json")
85 | self.end_headers()
86 | self.wfile.write(bytes(str(self.server.host_info.to_json()), 'utf-8'))
87 | return
88 | node = self.server.root_node.find_subnode(self.path)
89 | if node is None:
90 | self.send_response(404)
91 | self.send_header("Content-type", "text/json")
92 | self.end_headers()
93 | self.wfile.write(bytes("OSC Path not found", 'utf-8'))
94 | else:
95 | self.send_response(200)
96 | self.send_header("Content-type", "text/json")
97 | self.end_headers()
98 | self.wfile.write(bytes(str(node.to_json()), 'utf-8'))
99 |
100 | def log_message(self, format, *args):
101 | pass
102 |
103 |
--------------------------------------------------------------------------------
/src/tinyoscquery/shared/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/I5UCC/VRCThumbParamsOSC/dbc3b1e6b5ef3f3b820a1cf812d9a6ca3e3b6f3d/src/tinyoscquery/shared/__init__.py
--------------------------------------------------------------------------------
/src/tinyoscquery/shared/node.py:
--------------------------------------------------------------------------------
1 | from enum import IntEnum
2 | import json
3 | from json import JSONEncoder
4 |
5 | class OSCNodeEncoder(JSONEncoder):
6 | def default(self, o):
7 | if isinstance(o, OSCQueryNode):
8 | obj_dict = {}
9 | for k, v in vars(o).items():
10 | if v is None:
11 | continue
12 | if k.lower() == "type_":
13 | obj_dict["TYPE"] = Python_Type_List_to_OSC_Type(v)
14 | if k == "contents":
15 | obj_dict["CONTENTS"] = {}
16 | for subNode in v:
17 | if subNode.full_path is not None:
18 | obj_dict["CONTENTS"][subNode.full_path.split("/")[-1]] = subNode
19 | else:
20 | continue
21 | else:
22 | obj_dict[k.upper()] = v
23 |
24 | # FIXME: I missed something, so here's a hack!
25 |
26 | if "TYPE_" in obj_dict:
27 | del obj_dict["TYPE_"]
28 | return obj_dict
29 |
30 | if isinstance(o, type):
31 | return Python_Type_List_to_OSC_Type([o])
32 |
33 | if isinstance(o, OSCHostInfo):
34 | obj_dict = {}
35 | for k, v in vars(o).items():
36 | if v is None:
37 | continue
38 | obj_dict[k.upper()] = v
39 | return obj_dict
40 |
41 | return json.JSONEncoder.default(self, o)
42 |
43 | class OSCAccess(IntEnum):
44 | NO_VALUE = 0
45 | READONLY_VALUE = 1
46 | WRITEONLY_VALUE = 2
47 | READWRITE_VALUE = 3
48 |
49 | class OSCQueryNode():
50 | def __init__(self, full_path=None, contents=None, type_=None, access=None, description=None, value=None, host_info=None):
51 | self.contents = contents
52 | self.full_path = full_path
53 | self.access = access
54 | self.type_ = type_
55 | # Value is always an array!
56 | self.value = value
57 | self.description = description
58 | self.host_info = host_info
59 |
60 |
61 | def find_subnode(self, full_path):
62 | if self.full_path == full_path:
63 | return self
64 |
65 | foundNode = None
66 | if self.contents is None:
67 | return None
68 |
69 | for subNode in self.contents:
70 | foundNode = subNode.find_subnode(full_path)
71 | if foundNode is not None:
72 | break
73 |
74 | return foundNode
75 |
76 | def add_child_node(self, child):
77 | if child == self:
78 | return
79 |
80 | path_split = child.full_path.rsplit("/",1)
81 | if len(path_split) < 2:
82 | raise Exception("Tried to add child node with invalid full path!")
83 |
84 | parent_path = path_split[0]
85 |
86 | if parent_path == '':
87 | parent_path = "/"
88 |
89 | parent = self.find_subnode(parent_path)
90 |
91 | if parent is None:
92 | parent = OSCQueryNode(parent_path)
93 | self.add_child_node(parent)
94 |
95 |
96 | if parent.contents is None:
97 | parent.contents = []
98 | parent.contents.append(child)
99 |
100 |
101 | def to_json(self):
102 | return json.dumps(self, cls=OSCNodeEncoder)
103 |
104 |
105 | def __iter__(self):
106 | yield self
107 | if self.contents is not None:
108 | for subNode in self.contents:
109 | yield from subNode
110 |
111 | def __str__(self) -> str:
112 | return f''
113 |
114 | class OSCHostInfo():
115 | def __init__(self, name, extensions, osc_ip=None, osc_port=None, osc_transport=None, ws_ip=None, ws_port=None) -> None:
116 | self.name = name
117 | self.osc_ip = osc_ip
118 | self.osc_port = osc_port
119 | self.osc_transport = osc_transport
120 | self.ws_ip = ws_ip
121 | self.ws_port = ws_port
122 | self.extensions = extensions
123 |
124 | def to_json(self) -> str:
125 | return json.dumps(self, cls=OSCNodeEncoder)
126 |
127 | def __str__(self) -> str:
128 | return json.dumps(self, cls=OSCNodeEncoder)
129 |
130 | def OSC_Type_String_to_Python_Type(typestr):
131 | types = []
132 | for typevalue in typestr:
133 | if typevalue == '':
134 | continue
135 |
136 | if typevalue == "i":
137 | types.append(int)
138 | elif typevalue == "f" or typevalue == "h" or typevalue == "d" or typevalue == "t":
139 | types.append(float)
140 | elif typevalue == "T" or typevalue == "F":
141 | types.append(bool)
142 | elif typevalue == "s":
143 | types.append(str)
144 | else:
145 | raise Exception(f"Unknown OSC type when converting! {typevalue} -> ???")
146 |
147 |
148 | return types
149 |
150 |
151 | def Python_Type_List_to_OSC_Type(types_):
152 | output = []
153 | for type_ in types_:
154 | if type_ == int:
155 | output.append("i")
156 | elif type_ == float:
157 | output.append("f")
158 | elif type_ == bool:
159 | output.append("T")
160 | elif type_ == str:
161 | output.append("s")
162 | else:
163 | raise Exception(f"Cannot convert {type_} to OSC type!")
164 |
165 | return " ".join(output)
166 |
167 |
168 | if __name__ == "__main__":
169 | root = OSCQueryNode("/", description="root node")
170 | root.add_child_node(OSCQueryNode("/test/node/one"))
171 | root.add_child_node(OSCQueryNode("/test/node/two"))
172 | root.add_child_node(OSCQueryNode("/test/othernode/one"))
173 | root.add_child_node(OSCQueryNode("/test/othernode/three"))
174 |
175 | #print(root)
176 |
177 | for child in root:
178 | print(child)
--------------------------------------------------------------------------------
/src/tinyoscquery/utility.py:
--------------------------------------------------------------------------------
1 | import socket
2 |
3 | def get_open_tcp_port():
4 | '''
5 | Returns a valid, open, TCP port.
6 |
7 | Returns:
8 | port (int): A TCP port that is able to be bound to
9 | '''
10 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
11 | s.bind(("", 0))
12 | port = s.getsockname()[1]
13 | s.close()
14 | return port
15 |
16 | def get_open_udp_port():
17 | '''
18 | Returns a valid, open, UDP port.
19 |
20 | Returns:
21 | port (int): A UDP port that is able to be bound to
22 | '''
23 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
24 | s.bind(("", 0))
25 | port = s.getsockname()[1]
26 | s.close()
27 | return port
28 |
29 | def check_if_tcp_port_open(port: int):
30 | '''
31 | Checks if a TCP port is open.
32 |
33 | Args:
34 | port (int): The port to check
35 |
36 | Returns:
37 | open (bool): True if the port is open, False if it is not
38 | '''
39 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
40 | try:
41 | s.bind(("", port))
42 | s.close()
43 | return True
44 | except OSError:
45 | return False
46 |
47 | def check_if_udp_port_open(port: int):
48 | '''
49 | Checks if a UDP port is open.
50 |
51 | Args:
52 | port (int): The port to check
53 |
54 | Returns:
55 | open (bool): True if the port is open, False if it is not
56 | '''
57 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
58 | try:
59 | s.bind(("", port))
60 | s.close()
61 | return True
62 | except OSError:
63 | return False
--------------------------------------------------------------------------------
/src/tray_icon.py:
--------------------------------------------------------------------------------
1 | import pystray
2 | import sys
3 |
4 | from PIL import Image, ImageDraw
5 |
6 | class TrayIcon:
7 | def __init__(self, stop_func, icon_path):
8 | self.icon = Image.open(icon_path)
9 | self.menu = pystray.Menu(
10 | pystray.MenuItem("Exit", stop_func)
11 | )
12 | self.tray_icon = pystray.Icon("tray_icon", self.icon, "ThumbparamsOSC", self.menu)
13 |
14 | def run(self):
15 | self.tray_icon.run_detached()
16 |
17 | def stop(self):
18 | self.tray_icon.stop()
19 |
20 | if __name__ == "__main__":
21 | tray_icon = TrayIcon()
22 | tray_icon.run()
--------------------------------------------------------------------------------
/src/xbox_controller.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | import logging
3 | import math
4 | import time
5 |
6 | from xinput_joystick import XInputJoystick
7 |
8 | DEFAULT_ACTIONS = {
9 | "LeftJoystickY": 0.0,
10 | "LeftJoystickX": 0.0,
11 | "RightJoystickY": 0.0,
12 | "RightJoystickX": 0.0,
13 | "LeftTrigger": 0.0,
14 | "RightTrigger": 0.0,
15 | "LeftBumper": False,
16 | "RightBumper": False,
17 | "A": False,
18 | "X": False,
19 | "Y": False,
20 | "B": False,
21 | "LeftThumb": False,
22 | "RightThumb": False,
23 | "Back": False,
24 | "Start": False,
25 | "LeftDPad": False,
26 | "RightDPad": False,
27 | "UpDPad": False,
28 | "DownDPad": False,
29 | }
30 |
31 |
32 | def normalize_joy(v) -> float:
33 | """
34 | Normalizes the joystick value between -1 and 1.
35 |
36 | Parameters:
37 | ----------
38 | v : float
39 | The joystick value.
40 |
41 | Returns:
42 | -------
43 | float
44 | The normalized joystick value.
45 | """
46 | return v / XboxController.MAX_JOY_VAL
47 |
48 |
49 | def normalize_trigger(v) -> float:
50 | """
51 | Normalizes the trigger value between 0 and 1.
52 |
53 | Parameters:
54 | ----------
55 | v : float
56 | The trigger value.
57 |
58 | Returns:
59 | -------
60 | float
61 | The normalized trigger value.
62 | """
63 | return v / XboxController.MAX_TRIG_VAL
64 |
65 |
66 | axis_mapping = {
67 | "l_thumb_x": ("LeftJoystickX", normalize_joy),
68 | "l_thumb_y": ("LeftJoystickY", normalize_joy),
69 | "r_thumb_x": ("RightJoystickX", normalize_joy),
70 | "r_thumb_y": ("RightJoystickY", normalize_joy),
71 | "left_trigger": ("LeftTrigger", normalize_trigger),
72 | "right_trigger": ("RightTrigger", normalize_trigger),
73 | }
74 |
75 | button_mapping = {
76 | 1: "UpDPad",
77 | 2: "DownDPad",
78 | 3: "LeftDPad",
79 | 4: "RightDPad",
80 | 5: "Start",
81 | 6: "Back",
82 | 7: "LeftThumb",
83 | 8: "RightThumb",
84 | 9: "LeftBumper",
85 | 10: "RightBumper",
86 | 13: "A",
87 | 14: "B",
88 | 15: "X",
89 | 16: "Y",
90 | }
91 |
92 |
93 | class XboxController:
94 | MAX_TRIG_VAL = math.pow(2, 8)
95 | MAX_JOY_VAL = math.pow(2, 15)
96 |
97 | def __init__(
98 | self,
99 | polling_rate=1000,
100 | deadzone=0.2,
101 | tune_sleep_time=True,
102 | tune_polling_rate=False,
103 | target_reliability=0.99,
104 | ):
105 | self.polling_rate = polling_rate
106 | self.deadzone = deadzone
107 | self.tune_sleep_time = tune_sleep_time
108 | self.tune_polling_rate = tune_polling_rate
109 | self.target_reliability = target_reliability
110 |
111 | self.sleep_time = 1 / self.polling_rate
112 | self.actions = DEFAULT_ACTIONS
113 | self.running = True
114 |
115 | self.last_check = 0
116 | self.joystick = None
117 | self._init_joystick()
118 |
119 | # use this to measure actual polling rate
120 | self.num_polls = 0
121 | self.start_polling_time = 0
122 |
123 | @property
124 | def is_plugged(self):
125 | return (
126 | isinstance(self.joystick, XInputJoystick) and self.joystick.is_connected()
127 | )
128 |
129 | def _init_joystick(self):
130 | joysticks = XInputJoystick.enumerate_devices()
131 | if len(joysticks) > 0:
132 | self.joystick = joysticks[0]
133 | else:
134 | self.joystick = None
135 | return
136 |
137 | j = self.joystick
138 |
139 | @j.event
140 | def on_axis(axis, value):
141 | if axis in axis_mapping:
142 | mapping, func = axis_mapping[axis]
143 | self.actions[mapping] = func(value)
144 | else:
145 | logging.warning(f"Axis not found: {axis} = {value}")
146 |
147 | @j.event
148 | def on_button(button, pressed):
149 | if button in button_mapping:
150 | self.actions[button_mapping[button]] = bool(pressed)
151 | else:
152 | logging.warning(f"Button not found: {button} = {pressed}")
153 |
154 | if self.tune_polling_rate:
155 |
156 | @j.event
157 | def on_missed_packet(number):
158 | total = j.received_packets + j.missed_packets
159 | reliability = j.received_packets / float(total)
160 | if reliability < self.target_reliability:
161 | j.missed_packets = j.received_packets = 0
162 | self.polling_rate *= 1.2
163 | self.sleep_time /= 1.2
164 |
165 | def poll(self):
166 | try:
167 | if not self.is_plugged:
168 | if time.time() - self.last_check > 1:
169 | self._init_joystick()
170 | self.last_check = time.time()
171 | if self.is_plugged:
172 | self.joystick.dispatch_events()
173 | except RuntimeError:
174 | self.joystick = None
175 |
176 | def polling_loop(self):
177 | while self.running:
178 | self.poll()
179 | self.measure_effective_polling_rate()
180 | time.sleep(self.sleep_time)
181 |
182 | def measure_effective_polling_rate(self):
183 | self.num_polls += 1
184 | current_time = time.time()
185 | # measure effective polling rate every 10 seconds
186 | target_start_time = current_time - 2
187 | if self.start_polling_time < target_start_time:
188 | # Don't measure over a too long of a period
189 | delta_time = 0.1
190 | if target_start_time - delta_time < self.start_polling_time:
191 | period_time = current_time - self.start_polling_time
192 | rate = self.num_polls / period_time
193 | if self.tune_sleep_time:
194 | self.sleep_time *= 1 - (
195 | (self.polling_rate - rate) / self.polling_rate
196 | )
197 |
198 | self.start_polling_time = current_time
199 | self.num_polls = 0
200 |
201 | def get_value(self, action: dict) -> bool | tuple[float, float]:
202 | """
203 | Retrieves the value of a specified action.
204 |
205 | Parameters:
206 | ----------
207 | action : dict
208 | The action to retrieve the value for.
209 |
210 | Returns:
211 | -------
212 | The value of the action. If the action is a joystick or DPad action, it returns a tuple of two floats.
213 | If the action is not found, it raises a ValueError.
214 | """
215 | name = action["name"]
216 | if name in self.actions:
217 | return self.actions[name]
218 | elif name == "LeftJoystickXY":
219 | return dz_scaled_radial(
220 | self.actions["LeftJoystickX"],
221 | self.actions["LeftJoystickY"],
222 | self.deadzone,
223 | )
224 | elif name == "RightJoystickXY":
225 | return dz_scaled_radial(
226 | self.actions["RightJoystickX"],
227 | self.actions["RightJoystickY"],
228 | self.deadzone,
229 | )
230 | elif name == "DPadXY":
231 | x = -float(self.actions["LeftDPad"]) + float(self.actions["RightDPad"])
232 | y = -float(self.actions["DownDPad"]) + float(self.actions["UpDPad"])
233 | return x, y
234 | else:
235 | raise ValueError(f"Value for {name} not found.")
236 |
237 |
238 | def map_range(v, old_min, old_max, new_min, new_max) -> float:
239 | """
240 | Maps a value from one range to another.
241 |
242 | Parameters:
243 | ----------
244 | v : float
245 | The value to map.
246 | old_min : float
247 | The minimum value of the old range.
248 | old_max : float
249 | The maximum value of the old range.
250 | new_min : float
251 | The minimum value of the new range.
252 | new_max : float
253 | The maximum value of the new range.
254 |
255 | Returns:
256 | -------
257 | float
258 | The value mapped to the new range.
259 | """
260 | return new_min + (new_max - new_min) * (v - old_min) / (old_max - old_min)
261 |
262 |
263 | def dz_scaled_radial(x: float, y: float, deadzone: float) -> tuple[float, float]:
264 | """
265 | Scales the input values radially based on a deadzone.
266 |
267 | Parameters:
268 | ----------
269 | x : float
270 | The X value of the input.
271 | y : float
272 | The Y value of the input.
273 | deadzone : float
274 | The deadzone.
275 |
276 | Returns:
277 | -------
278 | tuple[float, float]
279 | The scaled X and Y values.
280 | """
281 | input_magnitude = math.sqrt(x**2 + y**2)
282 | if input_magnitude < deadzone:
283 | return 0.0, 0.0
284 | else:
285 | x_normalized = x / input_magnitude
286 | y_normalized = y / input_magnitude
287 | # Formula:
288 | # max_value = 1
289 | # min_value = 0
290 | # retval = input_normalized * (min_value + (max_value - min_value) * ((input_magnitude - deadzone) / (max_value - deadzone)))
291 | mapped_magnitude = map_range(input_magnitude, deadzone, 1, 0, 1)
292 | new_x = x_normalized * mapped_magnitude
293 | new_y = y_normalized * mapped_magnitude
294 | return new_x, new_y
295 |
--------------------------------------------------------------------------------
/src/xinput_joystick.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | """
4 | A module for getting input from Microsoft XBox 360 controllers via the XInput library on Windows.
5 |
6 | Adapted from Jason R. Coombs' code here:
7 | http://pydoc.net/Python/jaraco.input/1.0.1/jaraco.input.win32.xinput/
8 | under the MIT licence terms
9 |
10 | Upgraded to Python 3
11 | Modified to add deadzones, reduce noise, and support vibration
12 | Only req is Pyglet 1.2alpha1 or higher:
13 | pip install --upgrade http://pyglet.googlecode.com/archive/tip.zip
14 | """
15 |
16 | import ctypes
17 | import sys
18 | import time
19 | from itertools import count, starmap
20 | from operator import itemgetter, attrgetter
21 |
22 | from pyglet import event
23 |
24 |
25 | # structs according to
26 | # http://msdn.microsoft.com/en-gb/library/windows/desktop/ee417001%28v=vs.85%29.aspx
27 |
28 |
29 | class XINPUT_GAMEPAD(ctypes.Structure):
30 | _fields_ = [
31 | ("buttons", ctypes.c_ushort), # wButtons
32 | ("left_trigger", ctypes.c_ubyte), # bLeftTrigger
33 | ("right_trigger", ctypes.c_ubyte), # bLeftTrigger
34 | ("l_thumb_x", ctypes.c_short), # sThumbLX
35 | ("l_thumb_y", ctypes.c_short), # sThumbLY
36 | ("r_thumb_x", ctypes.c_short), # sThumbRx
37 | ("r_thumb_y", ctypes.c_short), # sThumbRy
38 | ]
39 |
40 |
41 | class XINPUT_STATE(ctypes.Structure):
42 | _fields_ = [
43 | ("packet_number", ctypes.c_ulong), # dwPacketNumber
44 | ("gamepad", XINPUT_GAMEPAD), # Gamepad
45 | ]
46 |
47 |
48 | class XINPUT_VIBRATION(ctypes.Structure):
49 | _fields_ = [
50 | ("wLeftMotorSpeed", ctypes.c_ushort),
51 | ("wRightMotorSpeed", ctypes.c_ushort),
52 | ]
53 |
54 |
55 | class XINPUT_BATTERY_INFORMATION(ctypes.Structure):
56 | _fields_ = [("BatteryType", ctypes.c_ubyte), ("BatteryLevel", ctypes.c_ubyte)]
57 |
58 |
59 | xinput = ctypes.windll.xinput1_4
60 | # xinput = ctypes.windll.xinput9_1_0 # this is the Win 8 version ?
61 | # xinput1_2, xinput1_1 (32-bit Vista SP1)
62 | # xinput1_3 (64-bit Vista SP1)
63 |
64 |
65 | def struct_dict(struct):
66 | """
67 | take a ctypes.Structure and return its field/value pairs
68 | as a dict.
69 |
70 | >>> 'buttons' in struct_dict(XINPUT_GAMEPAD)
71 | True
72 | >>> struct_dict(XINPUT_GAMEPAD)['buttons'].__class__.__name__
73 | 'CField'
74 | """
75 | get_pair = lambda field_type: (field_type[0], getattr(struct, field_type[0]))
76 | return dict(list(map(get_pair, struct._fields_)))
77 |
78 |
79 | def get_bit_values(number, size=32):
80 | """
81 | Get bit values as a list for a given number
82 |
83 | >>> get_bit_values(1) == [0]*31 + [1]
84 | True
85 |
86 | >>> get_bit_values(0xDEADBEEF)
87 | [1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L]
88 |
89 | You may override the default word size of 32-bits to match your actual
90 | application.
91 | >>> get_bit_values(0x3, 2)
92 | [1L, 1L]
93 |
94 | >>> get_bit_values(0x3, 4)
95 | [0L, 0L, 1L, 1L]
96 | """
97 | res = list(gen_bit_values(number))
98 | res.reverse()
99 | # 0-pad the most significant bit
100 | res = [0] * (size - len(res)) + res
101 | return res
102 |
103 |
104 | def gen_bit_values(number):
105 | """
106 | Return a zero or one for each bit of a numeric value up to the most
107 | significant 1 bit, beginning with the least significant bit.
108 | """
109 | number = int(number)
110 | while number:
111 | yield number & 0x1
112 | number >>= 1
113 |
114 |
115 | ERROR_DEVICE_NOT_CONNECTED = 1167
116 | ERROR_SUCCESS = 0
117 |
118 |
119 | class XInputJoystick(event.EventDispatcher):
120 | """
121 | XInputJoystick
122 |
123 | A stateful wrapper, using pyglet event model, that binds to one
124 | XInput device and dispatches events when states change.
125 |
126 | Example:
127 | controller_one = XInputJoystick(0)
128 | """
129 |
130 | max_devices = 4
131 |
132 | def __init__(self, device_number, normalize_axes=True):
133 | values = vars()
134 | del values["self"]
135 | self.__dict__.update(values)
136 |
137 | super(XInputJoystick, self).__init__()
138 |
139 | self._last_state = self.get_state()
140 | self.received_packets = 0
141 | self.missed_packets = 0
142 |
143 | # Set the method that will be called to normalize
144 | # the values for analog axis.
145 | choices = [self.translate_identity, self.translate_using_data_size]
146 | self.translate = choices[normalize_axes]
147 |
148 | def translate_using_data_size(self, value, data_size):
149 | # normalizes analog data to [0,1] for unsigned data
150 | # and [-0.5,0.5] for signed data
151 | data_bits = 8 * data_size
152 | return float(value) / (2**data_bits - 1)
153 |
154 | def translate_identity(self, value, data_size=None):
155 | return value
156 |
157 | def get_state(self):
158 | """Get the state of the controller represented by this object"""
159 | state = XINPUT_STATE()
160 | res = xinput.XInputGetState(self.device_number, ctypes.byref(state))
161 | if res == ERROR_SUCCESS:
162 | return state
163 | if res != ERROR_DEVICE_NOT_CONNECTED:
164 | raise RuntimeError(
165 | "Unknown error %d attempting to get state of device %d"
166 | % (res, self.device_number)
167 | )
168 | # else return None (device is not connected)
169 |
170 | def is_connected(self):
171 | return self._last_state is not None
172 |
173 | @staticmethod
174 | def enumerate_devices():
175 | """Returns the devices that are connected"""
176 | devices = list(map(XInputJoystick, list(range(XInputJoystick.max_devices))))
177 | return [d for d in devices if d.is_connected()]
178 |
179 | def set_vibration(self, left_motor, right_motor):
180 | """Control the speed of both motors seperately"""
181 | # Set up function argument types and return type
182 | XInputSetState = xinput.XInputSetState
183 | XInputSetState.argtypes = [ctypes.c_uint, ctypes.POINTER(XINPUT_VIBRATION)]
184 | XInputSetState.restype = ctypes.c_uint
185 |
186 | vibration = XINPUT_VIBRATION(int(left_motor * 65535), int(right_motor * 65535))
187 | XInputSetState(self.device_number, ctypes.byref(vibration))
188 |
189 | def get_battery_information(self):
190 | """Get battery type & charge level"""
191 | BATTERY_DEVTYPE_GAMEPAD = 0x00
192 | BATTERY_DEVTYPE_HEADSET = 0x01
193 | # Set up function argument types and return type
194 | XInputGetBatteryInformation = xinput.XInputGetBatteryInformation
195 | XInputGetBatteryInformation.argtypes = [
196 | ctypes.c_uint,
197 | ctypes.c_ubyte,
198 | ctypes.POINTER(XINPUT_BATTERY_INFORMATION),
199 | ]
200 | XInputGetBatteryInformation.restype = ctypes.c_uint
201 |
202 | battery = XINPUT_BATTERY_INFORMATION(0, 0)
203 | XInputGetBatteryInformation(
204 | self.device_number, BATTERY_DEVTYPE_GAMEPAD, ctypes.byref(battery)
205 | )
206 |
207 | # define BATTERY_TYPE_DISCONNECTED 0x00
208 | # define BATTERY_TYPE_WIRED 0x01
209 | # define BATTERY_TYPE_ALKALINE 0x02
210 | # define BATTERY_TYPE_NIMH 0x03
211 | # define BATTERY_TYPE_UNKNOWN 0xFF
212 | # define BATTERY_LEVEL_EMPTY 0x00
213 | # define BATTERY_LEVEL_LOW 0x01
214 | # define BATTERY_LEVEL_MEDIUM 0x02
215 | # define BATTERY_LEVEL_FULL 0x03
216 | batt_type = (
217 | "Unknown"
218 | if battery.BatteryType == 0xFF
219 | else ["Disconnected", "Wired", "Alkaline", "Nimh"][battery.BatteryType]
220 | )
221 | level = ["Empty", "Low", "Medium", "Full"][battery.BatteryLevel]
222 | return batt_type, level
223 |
224 | def dispatch_events(self):
225 | """The main event loop for a joystick"""
226 | state = self.get_state()
227 | if not state:
228 | raise RuntimeError("Joystick %d is not connected" % self.device_number)
229 | if state.packet_number != self._last_state.packet_number:
230 | # state has changed, handle the change
231 | self.update_packet_count(state)
232 | self.handle_changed_state(state)
233 | self._last_state = state
234 |
235 | def update_packet_count(self, state):
236 | """Keep track of received and missed packets for performance tuning"""
237 | self.received_packets += 1
238 | missed_packets = state.packet_number - self._last_state.packet_number - 1
239 | if missed_packets:
240 | self.dispatch_event("on_missed_packet", missed_packets)
241 | self.missed_packets += missed_packets
242 |
243 | def handle_changed_state(self, state):
244 | """Dispatch various events as a result of the state changing"""
245 | self.dispatch_event("on_state_changed", state)
246 | self.dispatch_axis_events(state)
247 | self.dispatch_button_events(state)
248 |
249 | def dispatch_axis_events(self, state):
250 | # axis fields are everything but the buttons
251 | axis_fields = dict(XINPUT_GAMEPAD._fields_)
252 | axis_fields.pop("buttons")
253 | for axis, type in list(axis_fields.items()):
254 | new_val = getattr(state.gamepad, axis)
255 | self.dispatch_event("on_axis", axis, new_val)
256 |
257 | def dispatch_button_events(self, state):
258 | changed = state.gamepad.buttons ^ self._last_state.gamepad.buttons
259 | changed = get_bit_values(changed, 16)
260 | buttons_state = get_bit_values(state.gamepad.buttons, 16)
261 | changed.reverse()
262 | buttons_state.reverse()
263 | button_numbers = count(1)
264 | changed_buttons = list(
265 | filter(itemgetter(0), list(zip(changed, button_numbers, buttons_state)))
266 | )
267 | tuple(starmap(self.dispatch_button_event, changed_buttons))
268 |
269 | def dispatch_button_event(self, changed, number, pressed):
270 | self.dispatch_event("on_button", number, pressed)
271 |
272 | # stub methods for event handlers
273 | def on_state_changed(self, state):
274 | pass
275 |
276 | def on_axis(self, axis, value):
277 | pass
278 |
279 | def on_button(self, button, pressed):
280 | pass
281 |
282 | def on_missed_packet(self, number):
283 | pass
284 |
285 |
286 | list(
287 | map(
288 | XInputJoystick.register_event_type,
289 | [
290 | "on_state_changed",
291 | "on_axis",
292 | "on_button",
293 | "on_missed_packet",
294 | ],
295 | )
296 | )
297 |
298 |
299 | def determine_optimal_sample_rate(joystick=None):
300 | """
301 | Poll the joystick slowly (beginning at 1 sample per second)
302 | and monitor the packet stream for missed packets, indicating
303 | that the sample rate is too slow to avoid missing packets.
304 | Missed packets will translate to a lost information about the
305 | joystick state.
306 | As missed packets are registered, increase the sample rate until
307 | the target reliability is reached.
308 | """
309 | # in my experience, you want to probe at 200-2000Hz for optimal
310 | # performance
311 | if joystick is None:
312 | joystick = XInputJoystick.enumerate_devices()[0]
313 |
314 | j = joystick
315 |
316 | print("Move the joystick or generate button events characteristic of your app")
317 | print("Hit Ctrl-C or press button 6 (<, Back) to quit.")
318 |
319 | # here I use the joystick object to store some state data that
320 | # would otherwise not be in scope in the event handlers
321 |
322 | # begin at 1Hz and work up until missed messages are eliminated
323 | j.probe_frequency = 1 # Hz
324 | j.quit = False
325 | j.target_reliability = 0.99 # okay to lose 1 in 100 messages
326 |
327 | @j.event
328 | def on_button(button, pressed):
329 | # flag the process to quit if the < button ('back') is pressed.
330 | j.quit = button == 6 and pressed
331 |
332 | @j.event
333 | def on_missed_packet(number):
334 | print("missed %(number)d packets" % vars())
335 | total = j.received_packets + j.missed_packets
336 | reliability = j.received_packets / float(total)
337 | if reliability < j.target_reliability:
338 | j.missed_packets = j.received_packets = 0
339 | j.probe_frequency *= 1.5
340 |
341 | while not j.quit:
342 | j.dispatch_events()
343 | time.sleep(1.0 / j.probe_frequency)
344 | print("final probe frequency was %s Hz" % j.probe_frequency)
345 |
346 |
347 | def sample_first_joystick():
348 | """
349 | Grab 1st available gamepad, logging changes to the screen.
350 | L & R analogue triggers set the vibration motor speed.
351 | """
352 | joysticks = XInputJoystick.enumerate_devices()
353 | device_numbers = list(map(attrgetter("device_number"), joysticks))
354 |
355 | print("found %d devices: %s" % (len(joysticks), device_numbers))
356 |
357 | if not joysticks:
358 | sys.exit(0)
359 |
360 | j = joysticks[0]
361 | print("using %d" % j.device_number)
362 |
363 | battery = j.get_battery_information()
364 | print(battery)
365 |
366 | @j.event
367 | def on_button(button, pressed):
368 | print("button", button, pressed)
369 |
370 | left_speed = 0
371 | right_speed = 0
372 |
373 | @j.event
374 | def on_axis(axis, value):
375 | left_speed = 0
376 | right_speed = 0
377 |
378 | print("axis", axis, value)
379 | if axis == "left_trigger":
380 | left_speed = value
381 | elif axis == "right_trigger":
382 | right_speed = value
383 | j.set_vibration(left_speed, right_speed)
384 |
385 | while True:
386 | j.dispatch_events()
387 | time.sleep(0.01)
388 |
389 |
390 | if __name__ == "__main__":
391 | # sample_first_joystick()
392 | determine_optimal_sample_rate()
393 |
--------------------------------------------------------------------------------