Implement function key
This commit is contained in:
@@ -2889,6 +2889,20 @@ class BuiltinFunction
|
|||||||
array.doubleArray.array[offset..offset + len] = value.castDouble;
|
array.doubleArray.array[offset..offset + len] = value.castDouble;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static void KEY(PetitComputer p, int index, wstring key)
|
||||||
|
{
|
||||||
|
index--;
|
||||||
|
if (index < 0 || index >= p.functionKey.length)
|
||||||
|
throw new OutOfRange("KEY", 1);
|
||||||
|
p.functionKey[index] = key.dup;
|
||||||
|
}
|
||||||
|
static void KEY(PetitComputer p, int index, out Array!wchar key)
|
||||||
|
{
|
||||||
|
index--;
|
||||||
|
if (index < 0 || index >= p.functionKey.length)
|
||||||
|
throw new OutOfRange("KEY", 1);
|
||||||
|
key = new Array!wchar(cast(wchar[])p.functionKey[index]);
|
||||||
|
}
|
||||||
//alias void function(PetitComputer, Value[], Value[]) BuiltinFunc;
|
//alias void function(PetitComputer, Value[], Value[]) BuiltinFunc;
|
||||||
static BuiltinFunctions[wstring] builtinFunctions;
|
static BuiltinFunctions[wstring] builtinFunctions;
|
||||||
static wstring getBasicName(BFD)(const wstring def)
|
static wstring getBasicName(BFD)(const wstring def)
|
||||||
|
|||||||
@@ -328,6 +328,7 @@ class PetitComputer
|
|||||||
{
|
{
|
||||||
console.loadFontTable();
|
console.loadFontTable();
|
||||||
}
|
}
|
||||||
|
functionKey = ["FILES", "LOAD\"", "SAVE\"", "LIST ERR", "RUN\n"];
|
||||||
writeln("OK");
|
writeln("OK");
|
||||||
}
|
}
|
||||||
int currentScreenWidth;
|
int currentScreenWidth;
|
||||||
@@ -395,6 +396,9 @@ class PetitComputer
|
|||||||
}
|
}
|
||||||
void sendKey(Key key)
|
void sendKey(Key key)
|
||||||
{
|
{
|
||||||
|
keybuffermutex.lock();
|
||||||
|
scope (exit)
|
||||||
|
keybuffermutex.unlock();
|
||||||
keybuffer[keybufferpos] = key;
|
keybuffer[keybufferpos] = key;
|
||||||
keybufferlen++;
|
keybufferlen++;
|
||||||
if(keybufferlen > keybuffer.length)
|
if(keybufferlen > keybuffer.length)
|
||||||
@@ -893,28 +897,29 @@ class PetitComputer
|
|||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
if (event.key.keysym.scancode <= SDL_SCANCODE_F5 && event.key.keysym.scancode >= SDL_SCANCODE_F1)
|
||||||
|
{
|
||||||
|
foreach(wchar k; functionKey[event.key.keysym.scancode - SDL_SCANCODE_F1])
|
||||||
|
{
|
||||||
|
sendKey(k);
|
||||||
|
}
|
||||||
|
}
|
||||||
if(key == SDLK_BACKSPACE)
|
if(key == SDLK_BACKSPACE)
|
||||||
{
|
{
|
||||||
keybuffermutex.lock();
|
|
||||||
sendKey('\u0008');
|
sendKey('\u0008');
|
||||||
keybuffermutex.unlock();
|
|
||||||
}
|
}
|
||||||
if(key == SDLK_RETURN)
|
if(key == SDLK_RETURN)
|
||||||
{
|
{
|
||||||
keybuffermutex.lock();
|
|
||||||
sendKey('\u000D');
|
sendKey('\u000D');
|
||||||
keybuffermutex.unlock();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
auto text = event.text.text[0..event.text.text.indexOf('\0')].to!wstring;
|
auto text = event.text.text[0..event.text.text.indexOf('\0')].to!wstring;
|
||||||
keybuffermutex.lock();
|
|
||||||
foreach(wchar key; text)
|
foreach(wchar key; text)
|
||||||
{
|
{
|
||||||
sendKey(key);
|
sendKey(key);
|
||||||
}
|
}
|
||||||
keybuffermutex.unlock();
|
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEWHEEL:
|
case SDL_MOUSEWHEEL:
|
||||||
synchronized (renderSync)
|
synchronized (renderSync)
|
||||||
@@ -1579,6 +1584,7 @@ class PetitComputer
|
|||||||
Hardware hardware = Hardware.wiiU;
|
Hardware hardware = Hardware.wiiU;
|
||||||
wstring versionString = "3.5.0";
|
wstring versionString = "3.5.0";
|
||||||
int version_ = 0x3050000;
|
int version_ = 0x3050000;
|
||||||
|
wstring[5] functionKey;
|
||||||
//プチコン内部表現はRGB5_A1
|
//プチコン内部表現はRGB5_A1
|
||||||
static uint toGLColor(GLenum format, ubyte r, ubyte g, ubyte b, ubyte a)
|
static uint toGLColor(GLenum format, ubyte r, ubyte g, ubyte b, ubyte a)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user