fna-workbench

fna-workbench Commit Details


Date:2016-01-26 15:33:39 (9 years 7 months ago)
Author:Ethan Lee
Branch:master
Commit:6f66a333fc8220d857f97960820bbb5d1a95b9ba
Parents: 034b6f5d5f4d054ca208dab2057f6ad51e200c7b
Message:Support for more text input control characters

Changes:

File differences

src/SDL2/SDL2_FNAPlatform.cs
158158
159159
160160
161
161
162162
163
164
165
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
166186
167187
168188
......
177197
178198
179199
180
200
181201
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
202
203
204
205
197206
198207
199208
200
201
202
203
209
210
211
212
204213
205214
206215
......
209218
210219
211220
212
213
214
215
216
217
218
219
220
221
221222
222
223
223224
224
225
225226
226
227
227
228
228229
229230
230231
......
353354
354355
355356
356
357
357358
358359
359360
......
384385
385386
386387
387
388
389
390
391
392
393
394
395
388
396389
397
398
399
400
401
390
391
392
393
402394
403395
404396
List<Keys> keys = new List<Keys>();
/* Setup Text Input Control Character Arrays
* (Only 4 control keys supported at this time)
* (Only 7 control keys supported at this time)
*/
bool[] INTERNAL_TextInputControlDown = new bool[4];
int[] INTERNAL_TextInputControlRepeat = new int[4];
bool INTERNAL_TextInputSuppress = false;
char[] textInputCharacters = new char[]
{
(char) 2,// Home
(char) 3,// End
(char) 8,// Backspace
(char) 9,// Tab
(char) 13,// Enter
(char) 127,// Delete
(char) 22// Ctrl+V (Paste)
};
Dictionary<Keys, int> textInputBindings = new Dictionary<Keys, int>()
{
{ Keys.Home,0 },
{ Keys.End,1 },
{ Keys.Back,2 },
{ Keys.Tab,3 },
{ Keys.Enter,4 },
{ Keys.Delete,5 }
// Ctrl+V is special!
};
bool[] textInputControlDown = new bool[textInputCharacters.Length];
int[] textInputControlRepeat = new int[textInputCharacters.Length];
bool textInputSuppress = false;
SDL.SDL_Event evt;
if (!keys.Contains(key))
{
keys.Add(key);
if (key == Keys.Back)
if (textInputBindings.ContainsKey(key))
{
INTERNAL_TextInputControlDown[0] = true;
INTERNAL_TextInputControlRepeat[0] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 8); // Backspace
}
else if (key == Keys.Tab)
{
INTERNAL_TextInputControlDown[1] = true;
INTERNAL_TextInputControlRepeat[1] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 9); // Tab
}
else if (key == Keys.Enter)
{
INTERNAL_TextInputControlDown[2] = true;
INTERNAL_TextInputControlRepeat[2] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 13); // Enter
int textIndex = textInputBindings[key];
textInputControlDown[textIndex] = true;
textInputControlRepeat[textIndex] = Environment.TickCount + 400;
TextInputEXT.OnTextInput(textInputCharacters[textIndex]);
}
else if (keys.Contains(Keys.LeftControl) && key == Keys.V)
{
INTERNAL_TextInputControlDown[3] = true;
INTERNAL_TextInputControlRepeat[3] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 22); // Control-V (Paste)
INTERNAL_TextInputSuppress = true;
textInputControlDown[6] = true;
textInputControlRepeat[6] = Environment.TickCount + 400;
TextInputEXT.OnTextInput(textInputCharacters[6]);
textInputSuppress = true;
}
}
}
Keys key = SDL2_KeyboardUtil.ToXNA(ref evt.key.keysym);
if (keys.Remove(key))
{
if (key == Keys.Back)
{
INTERNAL_TextInputControlDown[0] = false;
}
else if (key == Keys.Tab)
{
INTERNAL_TextInputControlDown[1] = false;
}
else if (key == Keys.Enter)
if (textInputBindings.ContainsKey(key))
{
INTERNAL_TextInputControlDown[2] = false;
textInputControlDown[textInputBindings[key]] = false;
}
else if ((!keys.Contains(Keys.LeftControl) && INTERNAL_TextInputControlDown[3]) || key == Keys.V)
else if ((!keys.Contains(Keys.LeftControl) && textInputControlDown[3]) || key == Keys.V)
{
INTERNAL_TextInputControlDown[3] = false;
INTERNAL_TextInputSuppress = false;
textInputControlDown[6] = false;
textInputSuppress = false;
}
}
}
}
// Text Input
else if (evt.type == SDL.SDL_EventType.SDL_TEXTINPUT && !INTERNAL_TextInputSuppress)
else if (evt.type == SDL.SDL_EventType.SDL_TEXTINPUT && !textInputSuppress)
{
string text;
}
}
// Text Input Controls Key Handling
if (INTERNAL_TextInputControlDown[0] && INTERNAL_TextInputControlRepeat[0] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 8);
}
if (INTERNAL_TextInputControlDown[1] && INTERNAL_TextInputControlRepeat[1] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 9);
}
if (INTERNAL_TextInputControlDown[2] && INTERNAL_TextInputControlRepeat[2] <= Environment.TickCount)
for (int i = 0; i < textInputCharacters.Length; i += 1)
{
TextInputEXT.OnTextInput((char) 13);
}
if (INTERNAL_TextInputControlDown[3] && INTERNAL_TextInputControlRepeat[3] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 22);
if (textInputControlDown[i] && textInputControlRepeat[i] <= Environment.TickCount)
{
TextInputEXT.OnTextInput(textInputCharacters[i]);
}
}
Keyboard.SetKeys(keys);

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.12127s using 13 queries.