|
3 | 3 | :PROPERTIES: |
4 | 4 | :EXPORT_FILE_NAME: SUMMARY.md |
5 | 5 | :END: |
6 | | - |
7 | 6 | #+BEGIN_SRC emacs-lisp :exports results :results value raw replace |
8 | 7 | (org-build-gitbook-toc) |
9 | 8 | #+END_SRC |
@@ -212,59 +211,270 @@ Buttplug helps you with whatever your wants and needs may be. |
212 | 211 | ** Wait This Doesn't Sound Technical |
213 | 212 | ** There is No Such Thing As Ethical Buttplugging Under Open Source |
214 | 213 | ** You Must Be This Tall To Code With This Library |
215 | | -* Ok So Here's How You Could Actually Use Buttplug |
216 | | -** Thermonuclear War |
217 | | -** How about a Nice Game of Chess? |
218 | | -** Thermonuclear War |
219 | | -* Architecture |
| 214 | +** Empathy for the User Having Sex With Your Software |
| 215 | +* Strategies Against Buttplug Architecture |
220 | 216 | :PROPERTIES: |
221 | 217 | :EXPORT_FILE_NAME: architecture.md |
222 | 218 | :END: |
223 | | -** Kyle Stop Trying To Be Stunt Rock And Just Write a Fucking Section Name |
224 | | -** Implementation Types |
225 | | - |
226 | | -The Buttplug Standard can be implemented in different ways. This |
227 | | -section covers the terms used throughout this document. |
228 | | - |
229 | | -** Libraries |
230 | | - |
231 | | -Implementing the standard as a library for a certain programming |
232 | | -language allows developers to either build servers on top of the |
233 | | -library in that language, or to integrate the library into their |
234 | | -applications that also use that language (or FFI/bindings to that |
235 | | -language). For instance, the C# implementation of the Buttplug |
236 | | -Standard can be used with a WebSocket implementation on top of it to |
237 | | -be a server that other applications can talk to. It could also be |
238 | | -compiled into a Unity game so that the communication exists only in |
239 | | -the executable itself. |
240 | | - |
241 | | -** Servers |
242 | | - |
243 | | -As mentioned above, servers are a thin layer on top of a library that |
244 | | -allow other applications to access hardware managed by the server. For |
245 | | -instance, a Web Application may not have the capability to talk to |
246 | | -hardware by itself, but can connect with a Buttplug Server |
247 | | -implementation via HTTP, WebSockets, or other standardized protocols. |
248 | | -Programs like Max/MSP and Pd could communicate with a Buttplug Server |
249 | | -implementation via OSC. |
250 | | - |
251 | | -** Applications (aka Clients) |
252 | | - |
253 | | -Applications, or clients, refer to programs that in some way interact |
254 | | -with a server to perform some sort of job for the user. A few ideas |
255 | | -for applications: |
256 | | - |
257 | | -- A movie player that sends synchronization commands while playing an |
258 | | - encoded video. |
259 | | -- A music player that syncs sex toys with the BPM of the current |
260 | | - track. |
261 | | -- A video game that somehow involves sex toy interaction |
262 | | - |
263 | | -All of these would need to talk to a Buttplug server to establish |
264 | | -which devices to use, then communicate with those devices. |
265 | | - |
266 | | - |
267 | | -* Usage Examples |
| 219 | +In this section, we'll cover what makes up Buttplug as an abstract |
| 220 | +architecture. Getting a hang of the definitions and contexts here is |
| 221 | +important, and will hopefully aid in understanding the amalgamation of |
| 222 | +flailing, crying, and screaming we call "project documentation". |
| 223 | + |
| 224 | +All of the concepts here are abstract. While we do have "reference |
| 225 | +implementations" that are implemented by the Buttplug Core Team, we do |
| 226 | +not require any specific programming language or serialization type |
| 227 | +for implementing the protocol or client/server architecture of |
| 228 | +Buttplug. Go wild. Surprise us. Make a Haskell version of all this |
| 229 | +that really is one big IO Monad joke. Make an INTERCAL version because |
| 230 | +there's already power play built into the language. Make a C version |
| 231 | +because... |
| 232 | + |
| 233 | +Ok you know what maybe don't make a C version. Do you really want to |
| 234 | +put C in your butt? |
| 235 | + |
| 236 | +** A Note for Grizzled Developers |
| 237 | +This section is written for those who may not be used to reading |
| 238 | +concise system architecture definitions in specifications or |
| 239 | +visualizing large systems via technical descriptions. All of the |
| 240 | +information in the Architecture portion of this document is also in |
| 241 | +the Buttplug Protocol Specification Introduction, in a more concise, |
| 242 | +somewhat less friendly form that may be more familiar. |
| 243 | + |
| 244 | +** The 3 Genders: Server, Client, Application |
| 245 | +There are 3 distinct conceptual parts to Buttplug. How all of these |
| 246 | +exist (as separate programs, all in the same program, or some other |
| 247 | +combination) are up to the needs of the developer and their specific |
| 248 | +application. However, when we talk about these parts in documentation |
| 249 | +and implementation, we keep them as separate ideas. |
| 250 | +*** Buttplug Servers |
| 251 | +A Buttplug Server is the piece that actually talks to hardware |
| 252 | +somehow. This is usually via an Operating System Specific library or |
| 253 | +API. It handles coordination of device connections/disconnections, and |
| 254 | +manages which clients can talk to hardware. A few examples of jobs the |
| 255 | +server has: |
| 256 | + |
| 257 | +- The server is in charge of finding devices connected to the |
| 258 | + computer, be they bluetooth, usb, serial, firewire, parallel, or |
| 259 | + whatever other device communication type is supported by the server |
| 260 | + implementation in question. |
| 261 | +- The server contains the knowledge of how to talk to a specific toy |
| 262 | + in the way that it understands, which we'll explain more about in |
| 263 | + "Buttplug Protocol" section. |
| 264 | +- If a client is controlling a device, then for some reason |
| 265 | + disconnects, it is the server's job to stop the device until the |
| 266 | + client has reconnected and sent new control commands. |
| 267 | + |
| 268 | +The server may be in charge of other tasks too. At a bare minimum, a |
| 269 | +server should handle all non-device messages in the Buttplug Protocol |
| 270 | +spec. |
| 271 | + |
| 272 | +*** Buttplug Clients |
| 273 | +Buttplug Clients are what developers use to talk to Buttplug Servers. |
| 274 | +Clients are responsible for messages staying synced between the |
| 275 | +developer's code and the servers. They may also expose devices and |
| 276 | +interfaces in a language specific way that the developer is used to |
| 277 | +working with. |
| 278 | +*** Applications |
| 279 | +Applications put some sort of specific UI/UX in front of a Buttplug |
| 280 | +Client. This could be: |
| 281 | + |
| 282 | +- A simple slider to control a toy from a web page |
| 283 | +- A 3D game |
| 284 | +- A word processor that makes the toy vibrate every time you hit a |
| 285 | + key. |
| 286 | + |
| 287 | +The ideas here really are endless. All of these will use a Buttplug |
| 288 | +Client to talk to a Buttplug Server. |
| 289 | +*** Configuration Examples |
| 290 | +There are multiple configurations and possibilities available, |
| 291 | +depending on the programming language, operating system, and hardware |
| 292 | +platform the developers and users choose. |
| 293 | + |
| 294 | +Once again trying to limit specifics, here's a couple of examples of |
| 295 | +how these pieces might go together: |
| 296 | + |
| 297 | +- Someone builds a movie player application that is just one |
| 298 | + executable, containing both a Buttplug Server and Client. This |
| 299 | + allows them to use the Client API, which makes accessing the server |
| 300 | + easy, while also meaning users only have one thing to install and |
| 301 | + don't have to worry about connecting to outside programs. |
| 302 | +- Someone builds a web app to control sex toys. The web browser does |
| 303 | + not support a way to access the sex toy hardware. The web app will |
| 304 | + contain a Buttplug Client that talks over the network to a native |
| 305 | + Buttplug Server, which has the ability to talk to the hardware. |
| 306 | + |
| 307 | +** Buttplug Protocol and Etiquette |
| 308 | + |
| 309 | +As a user of a Buttplug Client (which most developers using Buttplug |
| 310 | +will be), you will usually be sheltered from the sausage factory that |
| 311 | +is the Buttplug Message Protocol. If you'd like to see how the sausage |
| 312 | +is made in all of its raw glory, read on. |
| 313 | + |
| 314 | +If I may quote the author of the intro to this document |
| 315 | + |
| 316 | +#+BEGIN_QUOTE |
| 317 | +The only real function of Buttplug is make it easy for developers to |
| 318 | +get computers to talk to sex toys. |
| 319 | +#+END_QUOTE |
| 320 | + |
| 321 | +To understand how Buttplug simplifies this situation, let's take a |
| 322 | +look at how computer controlled sex toy communication normally |
| 323 | +happens. |
| 324 | + |
| 325 | +*** Computer To Toy Communication |
| 326 | + |
| 327 | +The computer needs to talk to the computer controlled sex toy, |
| 328 | +otherwise it wouldn't be computer controlled. To do this, is usually |
| 329 | +talks some sort of simple, "low-level" language that the toy |
| 330 | +manufacturer came up with. |
| 331 | + |
| 332 | +For instance, if the computer wants to talk to a vibrator (we'll call |
| 333 | +this one Sex Toy A), the manufacturer may have made it so the computer |
| 334 | +has to say something like (> denotes messages computer sends to toy, < |
| 335 | +denotes messages toy sends to computer): |
| 336 | + |
| 337 | +#+BEGIN_QUOTE |
| 338 | +> Vibrate:50; |
| 339 | +< OK; |
| 340 | +> Vibrate:10; |
| 341 | +< OK; |
| 342 | +#+END_QUOTE |
| 343 | + |
| 344 | +Which means that the vibrator should run at 50% of its top speed, then |
| 345 | +later, at 10%. On each of those commands, the toy ends back a message |
| 346 | +to say "Yes that was a correctly formatted message and I am now doing |
| 347 | +the thing you said." |
| 348 | + |
| 349 | +However, another manufacturer making another vibrator (calling this |
| 350 | +one Sex Toy B) may have commands that look like: |
| 351 | + |
| 352 | +#+BEGIN_QUOTE |
| 353 | +> 5, |
| 354 | +> 1, |
| 355 | +#+END_QUOTE |
| 356 | + |
| 357 | +These commands mean basically the same thing as what we sent to the |
| 358 | +first toy. Vibrate at 50%, vibrate at 10%. We don't get back anything |
| 359 | +from these commands, we just fire them off and hope they run. |
| 360 | + |
| 361 | +If the computer were to send the commands for Sex Toy B to the |
| 362 | +Sex Toy A, it would at get back errors saying the language was |
| 363 | +incorrect: |
| 364 | + |
| 365 | +#+BEGIN_QUOTE |
| 366 | +> Vibrate:50; |
| 367 | +< OK; |
| 368 | +> 5, |
| 369 | +< ERR; |
| 370 | +#+END_QUOTE |
| 371 | + |
| 372 | +What happens if we send Sex Toy A commands to Sex Toy B? |
| 373 | + |
| 374 | +#+BEGIN_QUOTE |
| 375 | +> 5, |
| 376 | +> Vibrate:10; |
| 377 | +#+END_QUOTE |
| 378 | + |
| 379 | +Sure, the toy doesn't vibrate, but now the computer doesn't know that. |
| 380 | +Only the user knows since they aren't getting vibrated, and they are |
| 381 | +probably very unhappy about that. |
| 382 | + |
| 383 | +This is life at the Computer-To-Toy communication level. It's not |
| 384 | +pretty, and it's not easy. |
| 385 | +*** Application to Computer Communication |
| 386 | +Moving up to the next level, there's 2 ways that Applications tell the |
| 387 | +computer to send information to hardware. |
| 388 | + |
| 389 | +- Via raw commands. This means just using the language talked about in |
| 390 | + the last section to make the computer talk to the toy. This happens |
| 391 | + a lot in applications that manufacturers make for their own |
| 392 | + hardware. |
| 393 | +- Via an API (Application Programming Interface) of some kind. These |
| 394 | + are basically "simplified languages," usually put out by a |
| 395 | + manufacturer, to make it easy for developers to control the hardware |
| 396 | + without having to know the low level language the computer uses to |
| 397 | + talk to it. These APIs will usually only work for the toys the |
| 398 | + manufacturer makes, and there may be different APIs for different |
| 399 | + toys. |
| 400 | + |
| 401 | +*** Where the Buttplug Protocol Comes into Play |
| 402 | +Consider Buttplug to be sort of a Rosetta Stone for sex toys. As |
| 403 | +mentioned in the last section, it's an API. Instead of just talking to |
| 404 | +one kind of toy, it talks to as many toys as we've figured out the low |
| 405 | +level language for. |
| 406 | + |
| 407 | +Revisiting our example above, when an application wants to talk to a |
| 408 | +sex toy using Buttplug, it will send messages similar to this (encoded |
| 409 | +here in JSON for readability, but this information can be send in |
| 410 | +other formats too): |
| 411 | + |
| 412 | +#+BEGIN_QUOTE |
| 413 | +{ |
| 414 | + "SingleMotorVibrateCmd": { |
| 415 | + "Id": 1, |
| 416 | + "DeviceIndex": 1, |
| 417 | + "Speed": 0.5, |
| 418 | + } |
| 419 | +} |
| 420 | + |
| 421 | +... |
| 422 | + |
| 423 | +{ |
| 424 | + "SingleMotorVibrateCmd": { |
| 425 | + "Id": 2, |
| 426 | + "DeviceIndex": 1, |
| 427 | + "Speed": 0.1, |
| 428 | + } |
| 429 | +} |
| 430 | +#+END_QUOTE |
| 431 | + |
| 432 | +These two messages just say "Make the device at index 1 vibrate at |
| 433 | +50%, then 10%." In the Buttplug Server code, we know what kind of toy |
| 434 | +hardware we're talking to, so we can convert it to Sex Toy A or Sex |
| 435 | +Toy B without the application developer having to know anything about |
| 436 | +how A or B actually work. Not only that, when yet another computer |
| 437 | +controlled vibrator named Sex Toy C comes out 6 months after the |
| 438 | +developer writes the code to send the message above, their code may |
| 439 | +very well "just work" with the new toy without them having to make any |
| 440 | +changes. |
| 441 | + |
| 442 | +*** What the Buttplug Protocol Looks Like |
| 443 | +The Buttplug Protocol is made up of a number of different messages |
| 444 | +that fit into a few different classes. |
| 445 | + |
| 446 | +- Messages sent between a Buttplug Client and Server to establish |
| 447 | + communication and synchronize state (what toys are available, |
| 448 | + etc...) |
| 449 | +- Messages sent by a Buttplug Client to control a specific brand/model |
| 450 | + of toy. |
| 451 | +- Messages send by a Buttplug Client to control a class of toys (all |
| 452 | + vibrating toys, all thrusting toys, etc...) |
| 453 | + |
| 454 | +Each message is strictly defined in the Buttplug Protocol |
| 455 | +Specification, and later we'll go over applications for all of them in |
| 456 | +the "Buttplug Message Guide" section of this document. For now, it's |
| 457 | +worth knowing that each message has 2 required fields: |
| 458 | + |
| 459 | +- Name, which lets the receiver know what it's supposed to do when it |
| 460 | + gets that message. |
| 461 | +- Id, which allows the sender and receiver to let each other know |
| 462 | + where in the conversation they are. If a sender sends a message with |
| 463 | + an Id of 5 and needs information back in relation to that message, |
| 464 | + it will wait for the receiver to send back a message that also has |
| 465 | + an Id of 5. |
| 466 | + |
| 467 | +All fields outside of these are specific to message and will be |
| 468 | +covered in the specification or the Message Guide. |
| 469 | + |
| 470 | + |
| 471 | +* Here's How You Could Actually Use Buttplug |
| 472 | +** Thermonuclear War |
| 473 | +** How about a Nice Game of Chess? |
| 474 | +** Thermonuclear War |
| 475 | +* Buttplug Message Guide |
| 476 | +* Old Stuff |
| 477 | +** Usage Examples |
268 | 478 | :PROPERTIES: |
269 | 479 | :EXPORT_FILE_NAME: usages.md |
270 | 480 | :END: |
@@ -377,3 +587,48 @@ application like the Buttplug Server would've required wrapping in |
377 | 587 | something like nw.js, massively inflating distributable size. |
378 | 588 | Implementing a C# version of the Buttplug Library also gives us a |
379 | 589 | platform into Unity integration. |
| 590 | +** Architecture |
| 591 | +*** Implementation Types |
| 592 | + |
| 593 | +The Buttplug Standard can be implemented in different ways. This |
| 594 | +section covers the terms used throughout this document. |
| 595 | + |
| 596 | +*** Libraries |
| 597 | + |
| 598 | +Implementing the standard as a library for a certain programming |
| 599 | +language allows developers to either build servers on top of the |
| 600 | +library in that language, or to integrate the library into their |
| 601 | +applications that also use that language (or FFI/bindings to that |
| 602 | +language). For instance, the C# implementation of the Buttplug |
| 603 | +Standard can be used with a WebSocket implementation on top of it to |
| 604 | +be a server that other applications can talk to. It could also be |
| 605 | +compiled into a Unity game so that the communication exists only in |
| 606 | +the executable itself. |
| 607 | + |
| 608 | +*** Servers |
| 609 | + |
| 610 | +As mentioned above, servers are a thin layer on top of a library that |
| 611 | +allow other applications to access hardware managed by the server. For |
| 612 | +instance, a Web Application may not have the capability to talk to |
| 613 | +hardware by itself, but can connect with a Buttplug Server |
| 614 | +implementation via HTTP, WebSockets, or other standardized protocols. |
| 615 | +Programs like Max/MSP and Pd could communicate with a Buttplug Server |
| 616 | +implementation via OSC. |
| 617 | + |
| 618 | +*** Applications (aka Clients) |
| 619 | + |
| 620 | + |
| 621 | +Applications, or clients, refer to programs that in some way interact |
| 622 | +with a server to perform some sort of job for the user. A few ideas |
| 623 | +for applications: |
| 624 | + |
| 625 | +- A movie player that sends synchronization commands while playing an |
| 626 | + encoded video. |
| 627 | +- A music player that syncs sex toys with the BPM of the current |
| 628 | + track. |
| 629 | +- A video game that somehow involves sex toy interaction |
| 630 | + |
| 631 | +All of these would need to talk to a Buttplug server to establish |
| 632 | +which devices to use, then communicate with those devices. |
| 633 | + |
| 634 | + |
0 commit comments