mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
Converted BASS to use Common::KeyState
svn-id: r27635
This commit is contained in:
parent
c690cad67f
commit
05ca0d86ba
@ -497,7 +497,7 @@ void Control::doControlPanel(void) {
|
||||
_system->updateScreen();
|
||||
_mouseClicked = false;
|
||||
delay(50);
|
||||
if (_keyPressed == 27) { // escape pressed
|
||||
if (_keyPressed.keycode == Common::KEYCODE_ESCAPE) { // escape pressed
|
||||
_mouseClicked = false;
|
||||
quitPanel = true;
|
||||
}
|
||||
@ -841,7 +841,7 @@ bool Control::autoSaveExists(void) {
|
||||
|
||||
uint16 Control::saveRestorePanel(bool allowSave) {
|
||||
|
||||
_keyPressed = 0;
|
||||
_keyPressed.reset();
|
||||
_mouseWheel = 0;
|
||||
buttonControl(NULL);
|
||||
_text->drawToScreen(WITH_MASK); // flush text restore buffer
|
||||
@ -898,21 +898,21 @@ uint16 Control::saveRestorePanel(bool allowSave) {
|
||||
_system->updateScreen();
|
||||
_mouseClicked = false;
|
||||
delay(50);
|
||||
if (_keyPressed == 27) { // escape pressed
|
||||
if (_keyPressed.keycode == Common::KEYCODE_ESCAPE) { // escape pressed
|
||||
_mouseClicked = false;
|
||||
clickRes = CANCEL_PRESSED;
|
||||
quitPanel = true;
|
||||
} else if ((_keyPressed == 13) || (_keyPressed == 15)) {
|
||||
} else if ((_keyPressed.keycode == Common::KEYCODE_RETURN) || (_keyPressed.keycode == Common::KEYCODE_KP_ENTER)) {
|
||||
clickRes = handleClick(lookList[0]);
|
||||
if (clickRes == GAME_SAVED)
|
||||
saveDescriptions(saveGameTexts);
|
||||
quitPanel = true;
|
||||
_mouseClicked = false;
|
||||
_keyPressed = 0;
|
||||
} if (allowSave && _keyPressed) {
|
||||
_keyPressed.reset();
|
||||
} if (allowSave && _keyPressed.keycode) {
|
||||
handleKeyPress(_keyPressed, _selectedGame * MAX_TEXT_LEN + saveGameTexts);
|
||||
refreshNames = true;
|
||||
_keyPressed = 0;
|
||||
_keyPressed.reset();
|
||||
}
|
||||
|
||||
if (_mouseWheel) {
|
||||
@ -991,9 +991,9 @@ bool Control::checkKeyList(uint8 key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Control::handleKeyPress(uint8 key, uint8 *textBuf) {
|
||||
void Control::handleKeyPress(Common::KeyState kbd, uint8 *textBuf) {
|
||||
|
||||
if (key == 8) { // backspace
|
||||
if (kbd.keycode == Common::KEYCODE_BACKSPACE) { // backspace
|
||||
for (uint8 cnt = 0; cnt < 6; cnt++)
|
||||
if (!textBuf[cnt])
|
||||
return;
|
||||
@ -1004,15 +1004,15 @@ void Control::handleKeyPress(uint8 key, uint8 *textBuf) {
|
||||
} else {
|
||||
if (_enteredTextWidth >= PAN_LINE_WIDTH - 10)
|
||||
return;
|
||||
if (((key >= 'A') && (key <= 'Z')) || ((key >= 'a') && (key <= 'z')) ||
|
||||
((key >= '0') && (key <= '9')) || checkKeyList(key)) {
|
||||
if (((kbd.ascii >= 'A') && (kbd.ascii <= 'Z')) || ((kbd.ascii >= 'a') && (kbd.ascii <= 'z')) ||
|
||||
((kbd.ascii >= '0') && (kbd.ascii <= '9')) || checkKeyList(kbd.ascii)) {
|
||||
uint8 strLen = 0;
|
||||
while (textBuf[0]) {
|
||||
textBuf++;
|
||||
strLen++;
|
||||
}
|
||||
if (strLen < MAX_TEXT_LEN) {
|
||||
textBuf[0] = key;
|
||||
textBuf[0] = kbd.ascii;
|
||||
textBuf[1] = 0;
|
||||
}
|
||||
}
|
||||
@ -1556,18 +1556,14 @@ void Control::delay(unsigned int amount) {
|
||||
|
||||
uint32 start = _system->getMillis();
|
||||
uint32 cur = start;
|
||||
_keyPressed = 0; //reset
|
||||
_keyPressed.reset();
|
||||
|
||||
do {
|
||||
Common::EventManager *eventMan = _system->getEventManager();
|
||||
while (eventMan->pollEvent(event)) {
|
||||
switch (event.type) {
|
||||
case Common::EVENT_KEYDOWN:
|
||||
// Make sure backspace works right (this fixes a small issue on OS X)
|
||||
if (event.kbd.keycode == 8)
|
||||
_keyPressed = 8;
|
||||
else
|
||||
_keyPressed = (byte)event.kbd.ascii;
|
||||
_keyPressed = event.kbd;
|
||||
break;
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
if (!(SkyEngine::_systemVars.systemFlags & SF_MOUSE_LOCKED))
|
||||
|
@ -27,6 +27,7 @@
|
||||
#define SKY_CONTROL_H
|
||||
|
||||
#include "common/stdafx.h"
|
||||
#include "common/events.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
class OSystem;
|
||||
@ -220,7 +221,7 @@ private:
|
||||
void setUpGameSprites(uint8 *nameBuf, dataFileHeader **nameSprites, uint16 firstNum, uint16 selectedGame);
|
||||
void showSprites(dataFileHeader **nameSprites, bool allowSave);
|
||||
bool checkKeyList(uint8 key);
|
||||
void handleKeyPress(uint8 key, uint8 *textBuf);
|
||||
void handleKeyPress(Common::KeyState kbd, uint8 *textBuf);
|
||||
|
||||
uint16 _selectedGame;
|
||||
uint16 saveGameToFile(void);
|
||||
@ -243,7 +244,7 @@ private:
|
||||
Sound *_skySound;
|
||||
OSystem *_system;
|
||||
bool _mouseClicked;
|
||||
byte _keyPressed;
|
||||
Common::KeyState _keyPressed;
|
||||
int _mouseWheel;
|
||||
|
||||
struct {
|
||||
|
@ -917,7 +917,7 @@ bool Intro::escDelay(uint32 msecs) {
|
||||
do {
|
||||
while (eventMan->pollEvent(event)) {
|
||||
if (event.type == Common::EVENT_KEYDOWN) {
|
||||
if (event.kbd.keycode == 27)
|
||||
if (event.kbd.keycode == Common::KEYCODE_ESCAPE)
|
||||
return false;
|
||||
} else if (event.type == Common::EVENT_QUIT) {
|
||||
_quitProg = true;
|
||||
|
@ -191,7 +191,7 @@ void Mouse::waitMouseNotPressed(int minDelay) {
|
||||
while (eventMan->pollEvent(event)) {
|
||||
switch (event.type) {
|
||||
case Common::EVENT_KEYDOWN:
|
||||
if (event.kbd.ascii == 27) {
|
||||
if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
|
||||
minDelay = 0;
|
||||
mousePressed = false;
|
||||
}
|
||||
|
@ -217,33 +217,29 @@ void SkyEngine::initVirgin() {
|
||||
|
||||
void SkyEngine::handleKey(void) {
|
||||
|
||||
if (_keyPressed && _systemVars.paused) {
|
||||
if (_keyPressed.keycode && _systemVars.paused) {
|
||||
_skySound->fnUnPauseFx();
|
||||
_systemVars.paused = false;
|
||||
_skyScreen->setPaletteEndian((uint8 *)_skyCompact->fetchCpt(SkyEngine::_systemVars.currentPalette));
|
||||
_keyFlags = _keyPressed = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_keyFlags == Common::KBD_CTRL) {
|
||||
if (_keyPressed == 'f')
|
||||
} else if (_keyPressed.flags == Common::KBD_CTRL) {
|
||||
if (_keyPressed.keycode == 'f')
|
||||
_fastMode ^= 1;
|
||||
else if (_keyPressed == 'g')
|
||||
else if (_keyPressed.keycode == 'g')
|
||||
_fastMode ^= 2;
|
||||
else if (_keyPressed == 'd')
|
||||
else if (_keyPressed.keycode == 'd')
|
||||
_debugger->attach();
|
||||
} else {
|
||||
switch (_keyPressed) {
|
||||
switch (_keyPressed.ascii) {
|
||||
case '`':
|
||||
case '~':
|
||||
case '#':
|
||||
_debugger->attach();
|
||||
break;
|
||||
case 63:
|
||||
case Common::ASCII_F5:
|
||||
_skyControl->doControlPanel();
|
||||
break;
|
||||
|
||||
case 27:
|
||||
case Common::ASCII_ESCAPE:
|
||||
if (!_systemVars.pastIntro)
|
||||
_skyControl->restartGame();
|
||||
break;
|
||||
@ -260,14 +256,14 @@ void SkyEngine::handleKey(void) {
|
||||
|
||||
}
|
||||
}
|
||||
_keyFlags = _keyPressed = 0;
|
||||
_keyPressed.reset();
|
||||
}
|
||||
|
||||
int SkyEngine::go() {
|
||||
|
||||
_systemVars.quitGame = false;
|
||||
|
||||
_keyFlags = _keyPressed = 0;
|
||||
_keyPressed.reset();
|
||||
|
||||
uint16 result = 0;
|
||||
if (ConfMan.hasKey("save_slot") && ConfMan.getInt("save_slot") >= 0)
|
||||
@ -517,7 +513,7 @@ void SkyEngine::delay(int32 amount) {
|
||||
Common::Event event;
|
||||
|
||||
uint32 start = _system->getMillis();
|
||||
_keyFlags = _keyPressed = 0; //reset
|
||||
_keyPressed.reset();
|
||||
|
||||
if (amount < 0)
|
||||
amount = 0;
|
||||
@ -526,11 +522,7 @@ void SkyEngine::delay(int32 amount) {
|
||||
while (_eventMan->pollEvent(event)) {
|
||||
switch (event.type) {
|
||||
case Common::EVENT_KEYDOWN:
|
||||
_keyFlags = event.kbd.flags;
|
||||
if (_keyFlags == Common::KBD_CTRL)
|
||||
_keyPressed = event.kbd.keycode;
|
||||
else
|
||||
_keyPressed = (byte)event.kbd.ascii;
|
||||
_keyPressed = event.kbd;
|
||||
break;
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
if (!(_systemVars.systemFlags & SF_MOUSE_LOCKED))
|
||||
|
@ -27,6 +27,7 @@
|
||||
#define SKY_H
|
||||
|
||||
#include "common/stdafx.h"
|
||||
#include "common/events.h"
|
||||
#include "engines/engine.h"
|
||||
|
||||
namespace Sky {
|
||||
@ -60,7 +61,7 @@ class SkyCompact;
|
||||
class SkyEngine : public Engine {
|
||||
GUI::Debugger *getDebugger();
|
||||
protected:
|
||||
byte _keyPressed, _keyFlags;
|
||||
Common::KeyState _keyPressed;
|
||||
bool _floppyIntro;
|
||||
|
||||
Sound *_skySound;
|
||||
|
Loading…
Reference in New Issue
Block a user