1 /+ 2 The MIT License (MIT) 3 4 Copyright (c) <2013> <Oleg Butko (deviator), Anton Akzhigitov (Akzwar)> 5 6 Permission is hereby granted, free of charge, to any person obtaining a copy 7 of this software and associated documentation files (the "Software"), to deal 8 in the Software without restriction, including without limitation the rights 9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 copies of the Software, and to permit persons to whom the Software is 11 furnished to do so, subject to the following conditions: 12 13 The above copyright notice and this permission notice shall be included in 14 all copies or substantial portions of the Software. 15 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 THE SOFTWARE. 23 +/ 24 25 module desgui.core.event; 26 27 public import desmath.linear.vector; 28 29 /++ 30 события клавиатуры 31 +/ 32 struct DiKeyboardEvent 33 { 34 /++ модификаторы (SHIFT, ALT etc) +/ 35 enum Mod 36 { 37 NONE = 0x0000, 38 LSHIFT = 0x0001, 39 RSHIFT = 0x0002, 40 LCTRL = 0x0040, 41 RCTRL = 0x0080, 42 LALT = 0x0100, 43 RALT = 0x0200, 44 LGUI = 0x0400, 45 RGUI = 0x0800, 46 NUM = 0x1000, 47 CAPS = 0x2000, 48 MODE = 0x4000, 49 CTRL = (LCTRL|RCTRL), 50 SHIFT = (LSHIFT|RSHIFT), 51 ALT = (LALT|RALT), 52 GUI = (LGUI|RGUI), 53 } 54 /++ нажата или отпущена клавиша +/ 55 bool pressed; 56 /++ если нажата и удерживается +/ 57 bool repeat; 58 /++ код клавиши +/ 59 uint scan; 60 uint key; 61 /++ модификатор +/ 62 uint mod; 63 } 64 65 /++ 66 событие ввода текста 67 +/ 68 struct DiTextEvent { dchar ch; } 69 70 /++ 71 событие мыши 72 +/ 73 struct DiMouseEvent 74 { 75 enum Type { PRESSED, RELEASED, MOTION, WHEEL }; 76 enum Button 77 { 78 LEFT = 1<<0, 79 MIDDLE = 1<<1, 80 RIGHT = 1<<2, 81 X1 = 1<<3, 82 X2 = 1<<4, 83 } 84 /++ тип события +/ 85 Type type; 86 87 /++ mask for motion, button for pressed/released, 0 for wheel+/ 88 uint btn; 89 90 ivec2 data; 91 } 92 93 /++ 94 событие джостика 95 +/ 96 struct DiJoyEvent 97 { 98 /++ номер джостика +/ 99 uint joy; 100 101 /++ тип события +/ 102 enum Type { AXIS, BUTTON, BALL, HAT }; 103 Type type; 104 105 /++ номер изменившегося элемента +/ 106 size_t no; 107 108 /++ состояние всех осей +/ 109 float[] axis; 110 /++ состояние всех кнопок ( true - нажата, false - нет ) +/ 111 bool[] buttons; 112 /++ состояние всех трэкболов +/ 113 ivec2[] balls; 114 /++ состояние всех шляпок +/ 115 byte[] hats; 116 }