mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-23 11:04:44 +00:00
AGS: Add ags_controller_arcnor plugin (used in Perfect Tides)
+ minor rework standard AGSController plugin
This commit is contained in:
parent
4ba746f6a0
commit
cb2cb19256
@ -324,6 +324,7 @@ MODULE_OBJS = \
|
||||
plugins/ags_collision_detector/ags_collision_detector.o \
|
||||
plugins/ags_consoles/ags_consoles.o \
|
||||
plugins/ags_controller/ags_controller.o \
|
||||
plugins/ags_controller/ags_controller_arcnor.o \
|
||||
plugins/ags_creditz/ags_creditz.o \
|
||||
plugins/ags_creditz/ags_creditz1.o \
|
||||
plugins/ags_creditz/ags_creditz2.o \
|
||||
|
@ -28,6 +28,25 @@ namespace AGS3 {
|
||||
namespace Plugins {
|
||||
namespace AGSController {
|
||||
|
||||
struct Controller : public IAGSScriptManagedObject {
|
||||
public:
|
||||
|
||||
int Dispose(const char *address, bool force) override {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *GetType() override {
|
||||
return "Controller";
|
||||
};
|
||||
|
||||
int Serialize(const char *address, char *buffer, int bufsize) override {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
Controller ctrlInterface;
|
||||
ConReader ctrlReader;
|
||||
|
||||
const char *AGSController::AGS_GetPluginName() {
|
||||
return "AGSController";
|
||||
}
|
||||
@ -50,6 +69,7 @@ void AGSController::AGS_EngineStartup(IAGSEngine *engine) {
|
||||
SCRIPT_METHOD(ClickMouse, AGSController::ClickMouse);
|
||||
|
||||
_engine->RequestEventHook(AGSE_PREGUIDRAW);
|
||||
_engine->AddManagedObjectReader("Controller", &ctrlReader);
|
||||
}
|
||||
|
||||
int64 AGSController::AGS_EngineOnEvent(int event, NumberPtr data) {
|
||||
@ -61,7 +81,11 @@ int64 AGSController::AGS_EngineOnEvent(int event, NumberPtr data) {
|
||||
}
|
||||
|
||||
void AGSController::Controller_Update() {
|
||||
// ::AGS::g_events->pollEvents();
|
||||
// ::AGS::g_events->pollEvents();
|
||||
}
|
||||
|
||||
void ConReader::Unserialize(int key, const char *serializedData, int dataSize) {
|
||||
// no implementation
|
||||
}
|
||||
|
||||
void AGSController::ControllerCount(ScriptMethodParams ¶ms) {
|
||||
@ -79,11 +103,13 @@ void AGSController::ControllerCount(ScriptMethodParams ¶ms) {
|
||||
}
|
||||
|
||||
void AGSController::Controller_Open(ScriptMethodParams ¶ms) {
|
||||
// No implemented needed
|
||||
Controller *newCtrl = new Controller();
|
||||
_engine->RegisterManagedObject(newCtrl, &ctrlInterface);
|
||||
params._result = newCtrl;
|
||||
}
|
||||
|
||||
void AGSController::Controller_Close(ScriptMethodParams ¶ms) {
|
||||
// No implemented needed
|
||||
// No implementation needed
|
||||
}
|
||||
|
||||
void AGSController::Controller_Plugged(ScriptMethodParams ¶ms) {
|
||||
@ -93,31 +119,43 @@ void AGSController::Controller_Plugged(ScriptMethodParams ¶ms) {
|
||||
|
||||
void AGSController::Controller_GetAxis(ScriptMethodParams ¶ms) {
|
||||
PARAMS1(int, axis);
|
||||
params._result = ::AGS::g_events->getJoystickAxis(axis);
|
||||
if (axis < 0 || axis > 31)
|
||||
params._result = false;
|
||||
else
|
||||
params._result = ::AGS::g_events->getJoystickAxis(axis);
|
||||
}
|
||||
|
||||
void AGSController::Controller_GetPOV(ScriptMethodParams ¶ms) {
|
||||
// Not supported
|
||||
debug(0, "AGSController: POV is not implemented");
|
||||
params._result = 0;
|
||||
}
|
||||
|
||||
void AGSController::Controller_IsButtonDown(ScriptMethodParams ¶ms) {
|
||||
PARAMS1(int, button);
|
||||
params._result = ::AGS::g_events->getJoystickButton(button);
|
||||
if (button < 0 || button > 31)
|
||||
params._result = false;
|
||||
else
|
||||
params._result = ::AGS::g_events->getJoystickButton(button);
|
||||
}
|
||||
|
||||
void AGSController::Controller_GetName(ScriptMethodParams ¶ms) {
|
||||
int joystickNum = ConfMan.getInt("joystick_num");
|
||||
params._result = (joystickNum != -1) ? "Joystick" : "";
|
||||
params._result = (joystickNum != -1) ? _engine->CreateScriptString("Joystick")
|
||||
: _engine->CreateScriptString("");
|
||||
}
|
||||
|
||||
void AGSController::Controller_Rumble(ScriptMethodParams ¶ms) {
|
||||
// Not supported
|
||||
debug(0, "AGSController: Rumble is not supported");
|
||||
}
|
||||
|
||||
void AGSController::Controller_IsButtonDownOnce(ScriptMethodParams ¶ms) {
|
||||
PARAMS1(int, button);
|
||||
params._result = ::AGS::g_events->getJoystickButtonOnce(button);
|
||||
if (button < 0 || button > 31)
|
||||
params._result = false;
|
||||
else
|
||||
params._result = ::AGS::g_events->getJoystickButtonOnce(button);
|
||||
}
|
||||
|
||||
void AGSController::Controller_PressAnyKey(ScriptMethodParams ¶ms) {
|
||||
@ -133,6 +171,7 @@ void AGSController::Controller_PressAnyKey(ScriptMethodParams ¶ms) {
|
||||
|
||||
void AGSController::Controller_BatteryStatus(ScriptMethodParams ¶ms) {
|
||||
// Not supported, so return -1 for "UNKNOWN"
|
||||
debug(0, "AGSController: Battery status is not supported");
|
||||
params._result = -1;
|
||||
}
|
||||
|
||||
|
@ -28,9 +28,14 @@ namespace AGS3 {
|
||||
namespace Plugins {
|
||||
namespace AGSController {
|
||||
|
||||
class ConReader : public IAGSManagedObjectReader {
|
||||
public:
|
||||
virtual void Unserialize(int key, const char *serializedData, int dataSize);
|
||||
};
|
||||
|
||||
class AGSController : public PluginBase {
|
||||
SCRIPT_HASH(AGSController)
|
||||
private:
|
||||
protected:
|
||||
void Controller_Update();
|
||||
|
||||
void ControllerCount(ScriptMethodParams ¶ms);
|
||||
|
75
engines/ags/plugins/ags_controller/ags_controller_arcnor.cpp
Normal file
75
engines/ags/plugins/ags_controller/ags_controller_arcnor.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* of the License, or(at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ags/plugins/ags_controller/ags_controller.h"
|
||||
#include "ags/plugins/ags_controller/ags_controller_arcnor.h"
|
||||
|
||||
#include "ags/events.h"
|
||||
|
||||
namespace AGS3 {
|
||||
namespace Plugins {
|
||||
namespace AGSController {
|
||||
|
||||
|
||||
void AGSControllerArcnor::AGS_EngineStartup(IAGSEngine *engine) {
|
||||
AGSController::AGS_EngineStartup(engine);
|
||||
|
||||
SCRIPT_METHOD(AGSControllerArcnor::Controller_Open^1, AGSControllerArcnor::Controller_Open);
|
||||
SCRIPT_METHOD(AGSControllerArcnor::Controller_GetAxis^1, AGSControllerArcnor::Controller_GetAxis);
|
||||
SCRIPT_METHOD(AGSControllerArcnor::Controller_IsButtonDown^1, AGSControllerArcnor::Controller_IsButtonDown);
|
||||
SCRIPT_METHOD(AGSControllerArcnor::Controller_Rumble^3, AGSControllerArcnor::Controller_Rumble);
|
||||
SCRIPT_METHOD(AGSControllerArcnor::Controller_IsButtonDownOnce^1, AGSControllerArcnor::Controller_IsButtonDownOnce);
|
||||
SCRIPT_METHOD(AGSControllerArcnor::Controller_IsButtonUpOnce^1, AGSControllerArcnor::Controller_IsButtonUpOnce);
|
||||
SCRIPT_METHOD(AGSControllerArcnor::Controller_PressAnyButton, AGSControllerArcnor::Controller_PressAnyKey);
|
||||
SCRIPT_METHOD(AGSControllerArcnor::Controller_GetPlayerIndex^0, AGSControllerArcnor::Controller_GetPlayerIndex);
|
||||
SCRIPT_METHOD(AGSControllerArcnor::Controller_SetPlayerIndex^1, AGSControllerArcnor::Controller_SetPlayerIndex);
|
||||
SCRIPT_METHOD(RunVirtualKeyboard, AGSControllerArcnor::RunVirtualKeyboard);
|
||||
}
|
||||
|
||||
void AGSControllerArcnor::Controller_IsButtonUpOnce(ScriptMethodParams ¶ms) {
|
||||
PARAMS1(int, button);
|
||||
if (button < 0 || button > 31)
|
||||
params._result = false;
|
||||
else
|
||||
params._result = !(::AGS::g_events->getJoystickButtonOnce(button));
|
||||
}
|
||||
|
||||
void AGSControllerArcnor::Controller_GetPlayerIndex(ScriptMethodParams ¶ms) {
|
||||
// return -1 as "not available"
|
||||
debug(0, "AGSController: GetPlayerIndex not implemented");
|
||||
params._result = -1;
|
||||
}
|
||||
|
||||
void AGSControllerArcnor::Controller_SetPlayerIndex(ScriptMethodParams ¶ms) {
|
||||
// PARAMS1(int, id);
|
||||
// not implemented
|
||||
debug(0, "AGSController: SetPlayerIndex not implemented");
|
||||
}
|
||||
|
||||
void AGSControllerArcnor::RunVirtualKeyboard(ScriptMethodParams ¶ms) {
|
||||
// PARAMS6(int, keyboard_mode, const char *, initialtext, const char *, headertext, const char *, guidetext, const char *, oktext, int, maxchars);
|
||||
debug(0, "AGSController: Virtual Keyboard not implemented");
|
||||
params._result = _engine->CreateScriptString("");
|
||||
}
|
||||
|
||||
} // namespace AGSController
|
||||
} // namespace Plugins
|
||||
} // namespace AGS3
|
51
engines/ags/plugins/ags_controller/ags_controller_arcnor.h
Normal file
51
engines/ags/plugins/ags_controller/ags_controller_arcnor.h
Normal file
@ -0,0 +1,51 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* of the License, or(at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AGS_PLUGINS_AGSCONTROLLER_AGSCONTROLLER_ARCNOR_H
|
||||
#define AGS_PLUGINS_AGSCONTROLLER_AGSCONTROLLER_ARCNOR_H
|
||||
|
||||
#include "ags/plugins/ags_controller/ags_controller.h"
|
||||
|
||||
namespace AGS3 {
|
||||
namespace Plugins {
|
||||
namespace AGSController {
|
||||
|
||||
class AGSControllerArcnor : public AGSController {
|
||||
SCRIPT_HASH_SUB(AGSControllerArcnor, AGSController)
|
||||
private:
|
||||
void Controller_IsButtonUpOnce(ScriptMethodParams ¶ms);
|
||||
void Controller_PressAnyButton(ScriptMethodParams ¶ms);
|
||||
void Controller_GetPlayerIndex(ScriptMethodParams ¶ms);
|
||||
void Controller_SetPlayerIndex(ScriptMethodParams ¶ms);
|
||||
void RunVirtualKeyboard(ScriptMethodParams ¶ms);
|
||||
|
||||
public:
|
||||
AGSControllerArcnor() : AGSController() {}
|
||||
virtual ~AGSControllerArcnor() {}
|
||||
|
||||
void AGS_EngineStartup(IAGSEngine *engine) override;
|
||||
};
|
||||
|
||||
} // namespace AGSController
|
||||
} // namespace Plugins
|
||||
} // namespace AGS3
|
||||
|
||||
#endif
|
@ -28,6 +28,7 @@
|
||||
#include "ags/plugins/ags_collision_detector/ags_collision_detector.h"
|
||||
#include "ags/plugins/ags_consoles/ags_consoles.h"
|
||||
#include "ags/plugins/ags_controller/ags_controller.h"
|
||||
#include "ags/plugins/ags_controller/ags_controller_arcnor.h"
|
||||
#include "ags/plugins/ags_creditz/ags_creditz1.h"
|
||||
#include "ags/plugins/ags_creditz/ags_creditz2.h"
|
||||
#include "ags/plugins/ags_fire/ags_fire.h"
|
||||
@ -90,6 +91,9 @@ Plugins::PluginBase *pluginOpen(const char *filename) {
|
||||
if (fname.equalsIgnoreCase("AGSController"))
|
||||
return new AGSController::AGSController();
|
||||
|
||||
if (fname.equalsIgnoreCase("agscontrollerplugin"))
|
||||
return new AGSController::AGSControllerArcnor();
|
||||
|
||||
if (fname.equalsIgnoreCase("AGS_Collision_Detector"))
|
||||
return new AGSCollisionDetector::AGSCollisionDetector();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user