Shipwright/libultraship/libultraship/KeyboardController.cpp
Sirius902 eea5135d62
Rumble cvar and fixes (#184)
* Rumble indefinitely until turned off

* Add rumble cvar

* Register CVar

* Check if controller can rumble to insert rumble pak

* Reduce verbosity of checks

* Remove extraneous const_cast

* Once again remove extraneous const_cast

* Add per-controller settings

* Add nice spacing

* Only display controller entry if pad connected

* Const some stuff
2022-04-26 19:50:24 -04:00

57 lines
1.3 KiB
C++

#include "KeyboardController.h"
#include "GlobalCtx2.h"
namespace Ship {
KeyboardController::KeyboardController(int32_t dwControllerNumber) : Controller(dwControllerNumber) {
LoadBinding();
}
KeyboardController::~KeyboardController() {
}
bool KeyboardController::PressButton(int32_t dwScancode) {
if (ButtonMapping.contains(dwScancode)) {
dwPressedButtons |= ButtonMapping[dwScancode];
return true;
}
return false;
}
bool KeyboardController::ReleaseButton(int32_t dwScancode) {
if (ButtonMapping.contains(dwScancode)) {
dwPressedButtons &= ~ButtonMapping[dwScancode];
return true;
}
return false;
}
void KeyboardController::ReleaseAllButtons() {
dwPressedButtons = 0;
}
void KeyboardController::ReadFromSource() {
wStickX = 0;
wStickY = 0;
}
void KeyboardController::WriteToSource(ControllerCallback* controller)
{
}
std::string KeyboardController::GetControllerType() {
return "KEYBOARD";
}
std::string KeyboardController::GetConfSection() {
return GetControllerType() + " CONTROLLER " + std::to_string(GetControllerNumber() + 1);
}
std::string KeyboardController::GetBindingConfSection() {
return GetControllerType() + " CONTROLLER BINDING " + std::to_string(GetControllerNumber() + 1);
}
}