mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-13 10:25:33 +02:00
Input.count, Input.repeatcount, System.user_name
This commit is contained in:
parent
51c6f627bc
commit
79dbb9856d
4 changed files with 667 additions and 605 deletions
|
@ -122,6 +122,7 @@ RB_METHOD(mkxpRawKeyStates);
|
||||||
RB_METHOD(mkxpMouseInWindow);
|
RB_METHOD(mkxpMouseInWindow);
|
||||||
RB_METHOD(mkxpPlatform);
|
RB_METHOD(mkxpPlatform);
|
||||||
RB_METHOD(mkxpUserLanguage);
|
RB_METHOD(mkxpUserLanguage);
|
||||||
|
RB_METHOD(mkxpUserName);
|
||||||
RB_METHOD(mkxpGameTitle);
|
RB_METHOD(mkxpGameTitle);
|
||||||
RB_METHOD(mkxpPowerState);
|
RB_METHOD(mkxpPowerState);
|
||||||
RB_METHOD(mkxpSettingsMenu);
|
RB_METHOD(mkxpSettingsMenu);
|
||||||
|
@ -204,6 +205,7 @@ static void mriBindingInit() {
|
||||||
_rb_define_module_function(mod, "mouse_in_window", mkxpMouseInWindow);
|
_rb_define_module_function(mod, "mouse_in_window", mkxpMouseInWindow);
|
||||||
_rb_define_module_function(mod, "platform", mkxpPlatform);
|
_rb_define_module_function(mod, "platform", mkxpPlatform);
|
||||||
_rb_define_module_function(mod, "user_language", mkxpUserLanguage);
|
_rb_define_module_function(mod, "user_language", mkxpUserLanguage);
|
||||||
|
_rb_define_module_function(mod, "user_name", mkxpUserName);
|
||||||
_rb_define_module_function(mod, "game_title", mkxpGameTitle);
|
_rb_define_module_function(mod, "game_title", mkxpGameTitle);
|
||||||
_rb_define_module_function(mod, "power_state", mkxpPowerState);
|
_rb_define_module_function(mod, "power_state", mkxpPowerState);
|
||||||
_rb_define_module_function(mod, "nproc", mkxpCpuCount);
|
_rb_define_module_function(mod, "nproc", mkxpCpuCount);
|
||||||
|
@ -339,6 +341,12 @@ RB_METHOD(mkxpUserLanguage) {
|
||||||
return rb_str_new_cstr(mkxp_sys::getSystemLanguage().c_str());
|
return rb_str_new_cstr(mkxp_sys::getSystemLanguage().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RB_METHOD(mkxpUserName) {
|
||||||
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
|
return rb_str_new_cstr(mkxp_sys::getUserName().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
RB_METHOD(mkxpGameTitle) {
|
RB_METHOD(mkxpGameTitle) {
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,19 @@ RB_METHOD(inputRelease) {
|
||||||
return rb_bool_new(shState->input().isReleased(num));
|
return rb_bool_new(shState->input().isReleased(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RB_METHOD(inputCount) {
|
||||||
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
|
rb_check_argc(argc, 1);
|
||||||
|
|
||||||
|
VALUE button;
|
||||||
|
rb_scan_args(argc, argv, "1", &button);
|
||||||
|
|
||||||
|
int num = getButtonArg(&button);
|
||||||
|
|
||||||
|
return UINT2NUM(shState->input().count(num));
|
||||||
|
}
|
||||||
|
|
||||||
RB_METHOD(inputPressEx) {
|
RB_METHOD(inputPressEx) {
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
|
@ -181,6 +194,20 @@ RB_METHOD(inputReleaseEx) {
|
||||||
return rb_bool_new(shState->input().isReleasedEx(NUM2INT(button), 1));
|
return rb_bool_new(shState->input().isReleasedEx(NUM2INT(button), 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RB_METHOD(inputCountEx) {
|
||||||
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
|
VALUE button;
|
||||||
|
rb_scan_args(argc, argv, "1", &button);
|
||||||
|
|
||||||
|
if (SYMBOL_P(button)) {
|
||||||
|
int num = getScancodeArg(&button);
|
||||||
|
return UINT2NUM(shState->input().repeatcount(num, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return UINT2NUM(shState->input().repeatcount(NUM2INT(button), 1));
|
||||||
|
}
|
||||||
|
|
||||||
RB_METHOD(inputDir4) {
|
RB_METHOD(inputDir4) {
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
|
@ -350,10 +377,12 @@ void inputBindingInit() {
|
||||||
_rb_define_module_function(module, "trigger?", inputTrigger);
|
_rb_define_module_function(module, "trigger?", inputTrigger);
|
||||||
_rb_define_module_function(module, "repeat?", inputRepeat);
|
_rb_define_module_function(module, "repeat?", inputRepeat);
|
||||||
_rb_define_module_function(module, "release?", inputRelease);
|
_rb_define_module_function(module, "release?", inputRelease);
|
||||||
|
_rb_define_module_function(module, "count", inputCount);
|
||||||
_rb_define_module_function(module, "pressex?", inputPressEx);
|
_rb_define_module_function(module, "pressex?", inputPressEx);
|
||||||
_rb_define_module_function(module, "triggerex?", inputTriggerEx);
|
_rb_define_module_function(module, "triggerex?", inputTriggerEx);
|
||||||
_rb_define_module_function(module, "repeatex?", inputRepeatEx);
|
_rb_define_module_function(module, "repeatex?", inputRepeatEx);
|
||||||
_rb_define_module_function(module, "releaseex?", inputReleaseEx);
|
_rb_define_module_function(module, "releaseex?", inputReleaseEx);
|
||||||
|
_rb_define_module_function(module, "repeatcount", inputCountEx);
|
||||||
_rb_define_module_function(module, "dir4", inputDir4);
|
_rb_define_module_function(module, "dir4", inputDir4);
|
||||||
_rb_define_module_function(module, "dir8", inputDir8);
|
_rb_define_module_function(module, "dir8", inputDir8);
|
||||||
|
|
||||||
|
|
|
@ -1180,6 +1180,13 @@ bool Input::isReleased(int button) {
|
||||||
return p->getStateCheck(button).released;
|
return p->getStateCheck(button).released;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int Input::count(int button) {
|
||||||
|
if (button != p->repeating)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return p->repeatCount;
|
||||||
|
}
|
||||||
|
|
||||||
bool Input::isPressedEx(int code, bool isVKey)
|
bool Input::isPressedEx(int code, bool isVKey)
|
||||||
{
|
{
|
||||||
return p->getStateRaw(code, isVKey).pressed;
|
return p->getStateRaw(code, isVKey).pressed;
|
||||||
|
@ -1200,6 +1207,22 @@ bool Input::isReleasedEx(int code, bool isVKey)
|
||||||
return p->getStateRaw(code, isVKey).released;
|
return p->getStateRaw(code, isVKey).released;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int Input::repeatcount(int code, bool isVKey) {
|
||||||
|
unsigned int c = code;
|
||||||
|
if (isVKey) {
|
||||||
|
try {
|
||||||
|
c = vKeyToScancode[code];
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (c != p->rawRepeating)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return p->rawRepeatCount;
|
||||||
|
}
|
||||||
|
|
||||||
int Input::dir4Value()
|
int Input::dir4Value()
|
||||||
{
|
{
|
||||||
return p->dir4Data.active;
|
return p->dir4Data.active;
|
||||||
|
|
|
@ -61,10 +61,12 @@ public:
|
||||||
bool isTriggered(int button);
|
bool isTriggered(int button);
|
||||||
bool isRepeated(int button);
|
bool isRepeated(int button);
|
||||||
bool isReleased(int button);
|
bool isReleased(int button);
|
||||||
|
unsigned int count(int button);
|
||||||
bool isPressedEx(int code, bool isVKey);
|
bool isPressedEx(int code, bool isVKey);
|
||||||
bool isTriggeredEx(int code, bool isVKey);
|
bool isTriggeredEx(int code, bool isVKey);
|
||||||
bool isRepeatedEx(int code, bool isVKey);
|
bool isRepeatedEx(int code, bool isVKey);
|
||||||
bool isReleasedEx(int code, bool isVKey);
|
bool isReleasedEx(int code, bool isVKey);
|
||||||
|
unsigned int repeatcount(int code, bool isVKey);
|
||||||
|
|
||||||
int dir4Value();
|
int dir4Value();
|
||||||
int dir8Value();
|
int dir8Value();
|
||||||
|
|
Loading…
Add table
Reference in a new issue