mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-06 23:15:42 +02:00
Remove haptics code
It never worked anyway, as far as anyone knew, and is probably not a feature anyone particularly needs.
This commit is contained in:
parent
cd2c375e2d
commit
d565650975
6 changed files with 4 additions and 97 deletions
|
@ -217,21 +217,6 @@ RB_METHOD(inputJoystickInfo) {
|
||||||
#undef POWERCASE
|
#undef POWERCASE
|
||||||
#undef M_SYMBOL
|
#undef M_SYMBOL
|
||||||
|
|
||||||
RB_METHOD(inputRumble) {
|
|
||||||
RB_UNUSED_PARAM;
|
|
||||||
VALUE duration, strength, attack, fade;
|
|
||||||
rb_scan_args(argc, argv, "13", &duration, &strength, &attack, &fade);
|
|
||||||
|
|
||||||
int dur = NUM2INT(duration);
|
|
||||||
int str = (NIL_P(strength)) ? 1 : NUM2INT(strength);
|
|
||||||
int att = (NIL_P(attack)) ? 0 : NUM2INT(attack);
|
|
||||||
int fad = (NIL_P(fade)) ? 0 : NUM2INT(fade);
|
|
||||||
|
|
||||||
shState->input().rumble(dur, str, att, fad);
|
|
||||||
|
|
||||||
return Qnil;
|
|
||||||
}
|
|
||||||
|
|
||||||
RB_METHOD(inputGetMode) {
|
RB_METHOD(inputGetMode) {
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
|
@ -332,7 +317,6 @@ void inputBindingInit() {
|
||||||
_rb_define_module_function(module, "mouse_y", inputMouseY);
|
_rb_define_module_function(module, "mouse_y", inputMouseY);
|
||||||
|
|
||||||
_rb_define_module_function(module, "joystick", inputJoystickInfo);
|
_rb_define_module_function(module, "joystick", inputJoystickInfo);
|
||||||
_rb_define_module_function(module, "rumble", inputRumble);
|
|
||||||
|
|
||||||
_rb_define_module_function(module, "text_input", inputGetMode);
|
_rb_define_module_function(module, "text_input", inputGetMode);
|
||||||
_rb_define_module_function(module, "text_input=", inputSetMode);
|
_rb_define_module_function(module, "text_input=", inputSetMode);
|
||||||
|
|
|
@ -92,8 +92,6 @@ enum
|
||||||
|
|
||||||
REQUEST_SETTINGS,
|
REQUEST_SETTINGS,
|
||||||
|
|
||||||
REQUEST_RUMBLE,
|
|
||||||
|
|
||||||
UPDATE_FPS,
|
UPDATE_FPS,
|
||||||
UPDATE_SCREEN_RECT,
|
UPDATE_SCREEN_RECT,
|
||||||
|
|
||||||
|
@ -114,11 +112,9 @@ bool EventThread::allocUserEvents()
|
||||||
|
|
||||||
EventThread::EventThread()
|
EventThread::EventThread()
|
||||||
: js(0),
|
: js(0),
|
||||||
hapt(0),
|
|
||||||
fullscreen(false),
|
fullscreen(false),
|
||||||
showCursor(true),
|
showCursor(true),
|
||||||
joystickConnected(false),
|
joystickConnected(false)
|
||||||
hapticEffectId(0)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void EventThread::process(RGSSThreadData &rtData)
|
void EventThread::process(RGSSThreadData &rtData)
|
||||||
|
@ -173,8 +169,6 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
|
|
||||||
SDL_GetWindowSize(win, &winW, &winH);
|
SDL_GetWindowSize(win, &winW, &winH);
|
||||||
|
|
||||||
SDL_Haptic *hap;
|
|
||||||
memset(&hapticEffect, 0, sizeof(SDL_HapticEffect));
|
|
||||||
textInputBuffer.clear();
|
textInputBuffer.clear();
|
||||||
|
|
||||||
SettingsMenu *sMenu = 0;
|
SettingsMenu *sMenu = 0;
|
||||||
|
@ -388,24 +382,11 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
js = SDL_JoystickOpen(0);
|
js = SDL_JoystickOpen(0);
|
||||||
joystickConnected = true;
|
joystickConnected = true;
|
||||||
|
|
||||||
hap = SDL_HapticOpenFromJoystick(js);
|
|
||||||
Debug() << (hap ? "true" : "false");
|
|
||||||
if (hap && (SDL_HapticQuery(hap) & SDL_HAPTIC_SINE))
|
|
||||||
{
|
|
||||||
hapt = hap;
|
|
||||||
Debug() << "Haptic device initialized";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug() << "No haptic support found";
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_JOYDEVICEREMOVED :
|
case SDL_JOYDEVICEREMOVED :
|
||||||
resetInputStates();
|
resetInputStates();
|
||||||
joystickConnected = false;
|
joystickConnected = false;
|
||||||
hapt = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEBUTTONDOWN :
|
case SDL_MOUSEBUTTONDOWN :
|
||||||
|
@ -500,25 +481,6 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
}
|
}
|
||||||
|
|
||||||
sMenu->raise();
|
sMenu->raise();
|
||||||
break;
|
|
||||||
|
|
||||||
case REQUEST_RUMBLE :
|
|
||||||
if (!hapt) break;
|
|
||||||
if (!hapticEffect.type)
|
|
||||||
{
|
|
||||||
hapticEffect.type = SDL_HAPTIC_SINE;
|
|
||||||
hapticEffect.constant.attack_level = 0;
|
|
||||||
hapticEffect.constant.fade_level = 0;
|
|
||||||
hapticEffectId = SDL_HapticNewEffect(hapt, &hapticEffect);
|
|
||||||
}
|
|
||||||
if (hapticEffect.constant.length == 0 && SDL_HapticGetEffectStatus(hapt, hapticEffectId) > 0)
|
|
||||||
{
|
|
||||||
SDL_HapticStopEffect(hapt, hapticEffectId);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SDL_HapticUpdateEffect(hapt, hapticEffectId, &hapticEffect);
|
|
||||||
|
|
||||||
SDL_HapticRunEffect(hapt, hapticEffectId, 1);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UPDATE_FPS :
|
case UPDATE_FPS :
|
||||||
|
@ -732,19 +694,6 @@ void EventThread::requestSettingsMenu()
|
||||||
SDL_PushEvent(&event);
|
SDL_PushEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventThread::requestRumble(int duration, short strength, int attack, int fade)
|
|
||||||
{
|
|
||||||
SDL_Event event;
|
|
||||||
event.type = usrIdStart + REQUEST_RUMBLE;
|
|
||||||
|
|
||||||
hapticEffect.constant.length = duration;
|
|
||||||
hapticEffect.constant.level = strength;
|
|
||||||
hapticEffect.constant.attack_length = attack;
|
|
||||||
hapticEffect.constant.fade_length = fade;
|
|
||||||
|
|
||||||
SDL_PushEvent(&event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventThread::showMessageBox(const char *body, int flags)
|
void EventThread::showMessageBox(const char *body, int flags)
|
||||||
{
|
{
|
||||||
msgBoxDone.clear();
|
msgBoxDone.clear();
|
||||||
|
@ -781,11 +730,6 @@ SDL_Joystick *EventThread::joystick() const
|
||||||
return (joystickConnected) ? js : 0;
|
return (joystickConnected) ? js : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Haptic *EventThread::haptic() const
|
|
||||||
{
|
|
||||||
return hapt;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventThread::notifyFrame()
|
void EventThread::notifyFrame()
|
||||||
{
|
{
|
||||||
if (!fps.sendUpdates)
|
if (!fps.sendUpdates)
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
#include <SDL_scancode.h>
|
#include <SDL_scancode.h>
|
||||||
#include <SDL_joystick.h>
|
#include <SDL_joystick.h>
|
||||||
#include <SDL_haptic.h>
|
|
||||||
#include <SDL_mouse.h>
|
#include <SDL_mouse.h>
|
||||||
#include <SDL_mutex.h>
|
#include <SDL_mutex.h>
|
||||||
|
|
||||||
|
@ -98,8 +97,6 @@ public:
|
||||||
|
|
||||||
void requestSettingsMenu();
|
void requestSettingsMenu();
|
||||||
|
|
||||||
void requestRumble(int duration, short strength, int attack, int fade);
|
|
||||||
|
|
||||||
void requestTerminate();
|
void requestTerminate();
|
||||||
|
|
||||||
bool getFullscreen() const;
|
bool getFullscreen() const;
|
||||||
|
@ -107,7 +104,6 @@ public:
|
||||||
bool getJoystickConnected() const;
|
bool getJoystickConnected() const;
|
||||||
|
|
||||||
SDL_Joystick *joystick() const;
|
SDL_Joystick *joystick() const;
|
||||||
SDL_Haptic *haptic() const;
|
|
||||||
|
|
||||||
void showMessageBox(const char *body, int flags = 0);
|
void showMessageBox(const char *body, int flags = 0);
|
||||||
|
|
||||||
|
@ -130,9 +126,6 @@ private:
|
||||||
bool showCursor;
|
bool showCursor;
|
||||||
|
|
||||||
SDL_Joystick *js;
|
SDL_Joystick *js;
|
||||||
SDL_Haptic *hapt;
|
|
||||||
SDL_HapticEffect hapticEffect;
|
|
||||||
int hapticEffectId;
|
|
||||||
|
|
||||||
AtomicFlag msgBoxDone;
|
AtomicFlag msgBoxDone;
|
||||||
|
|
||||||
|
|
|
@ -1198,18 +1198,6 @@ int Input::getJoystickPowerLevel()
|
||||||
SDL_JOYSTICK_POWER_UNKNOWN;
|
SDL_JOYSTICK_POWER_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::rumble(int duration, int strength, int attack, int fade)
|
|
||||||
{
|
|
||||||
duration = clamp(duration, 0, 10000);
|
|
||||||
strength = clamp(strength, 1, 100);
|
|
||||||
attack = clamp(attack, 0, 10000);
|
|
||||||
fade = clamp(fade, 0, 10000);
|
|
||||||
shState->eThread().requestRumble(duration,
|
|
||||||
(short)((double)strength / 100 * 32767),
|
|
||||||
attack,
|
|
||||||
fade);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Input::getTextInputMode()
|
bool Input::getTextInputMode()
|
||||||
{
|
{
|
||||||
return (SDL_IsTextInputActive() == SDL_TRUE);
|
return (SDL_IsTextInputActive() == SDL_TRUE);
|
||||||
|
|
|
@ -72,8 +72,6 @@ public:
|
||||||
const char *getJoystickName();
|
const char *getJoystickName();
|
||||||
int getJoystickPowerLevel();
|
int getJoystickPowerLevel();
|
||||||
|
|
||||||
void rumble(int duration, int strength, int attack, int fade);
|
|
||||||
|
|
||||||
bool getTextInputMode();
|
bool getTextInputMode();
|
||||||
void setTextInputMode(bool mode);
|
void setTextInputMode(bool mode);
|
||||||
const char *getText();
|
const char *getText();
|
||||||
|
|
|
@ -171,7 +171,7 @@ int main(int argc, char *argv[]) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* initialize SDL first */
|
/* initialize SDL first */
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
|
||||||
showInitError(std::string("Error initializing SDL: ") + SDL_GetError());
|
showInitError(std::string("Error initializing SDL: ") + SDL_GetError());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue