1 /* 2 DSDL 3 Copyright (C) 2025 Inochi2D Project <luna@foxgirls.gay> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20 21 ========================================================================== 22 23 Simple DirectMedia Layer 24 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> 25 26 This software is provided 'as-is', without any express or implied 27 warranty. In no event will the authors be held liable for any damages 28 arising from the use of this software. 29 30 Permission is granted to anyone to use this software for any purpose, 31 including commercial applications, and to alter it and redistribute it 32 freely, subject to the following restrictions: 33 34 1. The origin of this software must not be misrepresented; you must not 35 claim that you wrote the original software. If you use this software 36 in a product, an acknowledgment in the product documentation would be 37 appreciated but is not required. 38 2. Altered source versions must be plainly marked as such, and must not be 39 misrepresented as being the original software. 40 3. This notice may not be removed or altered from any source distribution. 41 */ 42 43 /** 44 SDL Pen Handling 45 46 See_Also: 47 $(LINK2 https://wiki.libsdl.org/SDL3/CategoryPen, SDL3 Mouse Documentation) 48 49 Copyright: © 2025 Inochi2D Project, © 1997-2025 Sam Lantinga 50 License: Subject to the terms of the Zlib License, as written in the LICENSE file. 51 Authors: 52 Luna Nielsen 53 */ 54 module sdl.pen; 55 import sdl.stdc; 56 57 extern(C) nothrow @nogc: 58 59 /** 60 SDL pen instance IDs. 61 62 Zero is used to signify an invalid/null device. 63 64 These show up in pen events when SDL sees input from them. They remain 65 consistent as long as SDL can recognize a tool to be the same pen; but if a 66 pen physically leaves the area and returns, it might get a new ID. 67 */ 68 alias SDL_PenID = Uint32; 69 70 /** 71 Pen input flags, as reported by various pen events' `pen_state` field. 72 */ 73 enum SDL_PenInputFlags : Uint32 { 74 75 /** 76 Pen is pressed down 77 */ 78 SDL_PEN_INPUT_DOWN = (1u << 0), 79 80 /** 81 Button 1 is pressed 82 */ 83 SDL_PEN_INPUT_BUTTON_1 = (1u << 1), 84 85 /** 86 Button 2 is pressed 87 */ 88 SDL_PEN_INPUT_BUTTON_2 = (1u << 2), 89 90 /** 91 Button 3 is pressed 92 */ 93 SDL_PEN_INPUT_BUTTON_3 = (1u << 3), 94 95 /** 96 Button 4 is pressed 97 */ 98 SDL_PEN_INPUT_BUTTON_4 = (1u << 4), 99 100 /** 101 Button 5 is pressed 102 */ 103 SDL_PEN_INPUT_BUTTON_5 = (1u << 5), 104 105 /** 106 Eraser tip is used 107 */ 108 SDL_PEN_INPUT_ERASER_TIP = (1u << 30), 109 } 110 111 /** 112 Pen axis indices. 113 114 These are the valid values for the `axis` field in SDL_PenAxisEvent. All 115 axes are either normalised to 0..1 or report a (positive or negative) angle 116 in degrees, with 0.0 representing the centre. Not all pens/backends support 117 all axes: unsupported axes are always zero. 118 119 To convert angles for tilt and rotation into vector representation, use 120 SDL_sinf on the XTILT, YTILT, or ROTATION component. 121 122 Example: 123 --- 124 sinf(xtilt * PI / 180.0); 125 ---- 126 */ 127 enum SDL_PenAxis { 128 129 /** 130 Pen pressure. Unidirectional: 0 to 1.0 131 */ 132 SDL_PEN_AXIS_PRESSURE, 133 134 /** 135 Pen horizontal tilt angle. Bidirectional: -90.0 to 90.0 (left-to-right). 136 */ 137 SDL_PEN_AXIS_XTILT, 138 139 /** 140 Pen vertical tilt angle. Bidirectional: -90.0 to 90.0 (top-to-down). 141 */ 142 SDL_PEN_AXIS_YTILT, 143 144 /** 145 Pen distance to drawing surface. Unidirectional: 0.0 to 1.0 146 */ 147 SDL_PEN_AXIS_DISTANCE, 148 149 /** 150 Pen barrel rotation. Bidirectional: -180 to 179.9 (clockwise, 0 is facing up, -180.0 is facing down). 151 */ 152 SDL_PEN_AXIS_ROTATION, 153 154 /** 155 Pen finger wheel or slider (e.g., Airbrush Pen). Unidirectional: 0 to 1.0 156 */ 157 SDL_PEN_AXIS_SLIDER, 158 159 /** 160 Pressure from squeezing the pen ("barrel pressure"). 161 */ 162 SDL_PEN_AXIS_TANGENTIAL_PRESSURE, 163 164 /** 165 Total known pen axis types in this version of SDL. This number may grow in future releases! 166 */ 167 SDL_PEN_AXIS_COUNT, 168 }