sa2: make the keyboard "work" (no CTRL-ASCII codes for the time being).
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
1400828452
commit
bc029dee97
2 changed files with 70 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "linux/data.h"
|
#include "linux/data.h"
|
||||||
#include "linux/paddle.h"
|
#include "linux/paddle.h"
|
||||||
|
#include "linux/keyboard.h"
|
||||||
|
|
||||||
#include "StdAfx.h"
|
#include "StdAfx.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
@ -94,6 +95,51 @@ namespace
|
||||||
return current.refresh_rate;
|
return current.refresh_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void processAppleKey(const SDL_KeyboardEvent & key)
|
||||||
|
{
|
||||||
|
// using keycode (or scan code) one takes a physical view of the keyboard
|
||||||
|
// ignoring non US layouts
|
||||||
|
// SHIFT-3 on a A2 keyboard in # while on my UK keyboard is £?
|
||||||
|
// so for now all ASCII keys are handled as text below
|
||||||
|
// but this makes it impossible to detect CTRL-ASCII... more to follow
|
||||||
|
BYTE ch = 0;
|
||||||
|
|
||||||
|
switch (key.keysym.sym)
|
||||||
|
{
|
||||||
|
case SDLK_RETURN:
|
||||||
|
ch = 0x0d;
|
||||||
|
break;
|
||||||
|
case SDLK_BACKSPACE: // same as AppleWin
|
||||||
|
case SDLK_LEFT:
|
||||||
|
ch = 0x08;
|
||||||
|
break;
|
||||||
|
case SDLK_RIGHT:
|
||||||
|
ch = 0x15;
|
||||||
|
break;
|
||||||
|
case SDLK_UP:
|
||||||
|
ch = 0x0b;
|
||||||
|
break;
|
||||||
|
case SDLK_DOWN:
|
||||||
|
ch = 0x0a;
|
||||||
|
break;
|
||||||
|
case SDLK_DELETE:
|
||||||
|
ch = 0x7f;
|
||||||
|
break;
|
||||||
|
case SDLK_ESCAPE:
|
||||||
|
ch = 0x1b;
|
||||||
|
break;
|
||||||
|
case SDLK_TAB:
|
||||||
|
ch = 0x09;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch)
|
||||||
|
{
|
||||||
|
addKeyToBuffer(ch);
|
||||||
|
std::cerr << "Apple Key Down: " << std::hex << (int)ch << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,6 +196,11 @@ void Emulator::processEvents(bool & quit)
|
||||||
processKeyUp(e.key);
|
processKeyUp(e.key);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SDL_TEXTINPUT:
|
||||||
|
{
|
||||||
|
processText(e.text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,6 +266,8 @@ void Emulator::processKeyDown(const SDL_KeyboardEvent & key, bool & quit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processAppleKey(key);
|
||||||
|
|
||||||
std::cerr << "KEY DOWN: " << key.keysym.scancode << "," << key.keysym.sym << "," << key.keysym.mod << "," << bool(key.repeat) << std::endl;
|
std::cerr << "KEY DOWN: " << key.keysym.scancode << "," << key.keysym.sym << "," << key.keysym.mod << "," << bool(key.repeat) << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -236,3 +289,17 @@ void Emulator::processKeyUp(const SDL_KeyboardEvent & key)
|
||||||
}
|
}
|
||||||
std::cerr << "KEY UP: " << key.keysym.scancode << "," << key.keysym.sym << "," << key.keysym.mod << "," << bool(key.repeat) << std::endl;
|
std::cerr << "KEY UP: " << key.keysym.scancode << "," << key.keysym.sym << "," << key.keysym.mod << "," << bool(key.repeat) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Emulator::processText(const SDL_TextInputEvent & text)
|
||||||
|
{
|
||||||
|
if (strlen(text.text) == 1)
|
||||||
|
{
|
||||||
|
const char key = text.text[0];
|
||||||
|
if (key >= 0x20 && key <= 0x7e)
|
||||||
|
{
|
||||||
|
// this is very simple, but one cannot handle CRTL-key combination.
|
||||||
|
addKeyToBuffer(key);
|
||||||
|
std::cerr << "Apple Text: " << std::hex << (int)key << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -16,8 +16,9 @@ public:
|
||||||
void processEvents(bool & quit);
|
void processEvents(bool & quit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void processKeyDown(const SDL_KeyboardEvent & e, bool & quit);
|
void processKeyDown(const SDL_KeyboardEvent & key, bool & quit);
|
||||||
void processKeyUp(const SDL_KeyboardEvent & e);
|
void processKeyUp(const SDL_KeyboardEvent & key);
|
||||||
|
void processText(const SDL_TextInputEvent & text);
|
||||||
|
|
||||||
const std::shared_ptr<SDL_Window> myWindow;
|
const std::shared_ptr<SDL_Window> myWindow;
|
||||||
const std::shared_ptr<SDL_Renderer> myRenderer;
|
const std::shared_ptr<SDL_Renderer> myRenderer;
|
||||||
|
|
Loading…
Add table
Reference in a new issue