mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-10 08:55: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
File diff suppressed because it is too large
Load diff
|
@ -125,6 +125,19 @@ RB_METHOD(inputRelease) {
|
|||
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_UNUSED_PARAM;
|
||||
|
||||
|
@ -181,6 +194,20 @@ RB_METHOD(inputReleaseEx) {
|
|||
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_UNUSED_PARAM;
|
||||
|
||||
|
@ -350,10 +377,12 @@ void inputBindingInit() {
|
|||
_rb_define_module_function(module, "trigger?", inputTrigger);
|
||||
_rb_define_module_function(module, "repeat?", inputRepeat);
|
||||
_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, "triggerex?", inputTriggerEx);
|
||||
_rb_define_module_function(module, "repeatex?", inputRepeatEx);
|
||||
_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, "dir8", inputDir8);
|
||||
|
||||
|
|
|
@ -1180,6 +1180,13 @@ bool Input::isReleased(int button) {
|
|||
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)
|
||||
{
|
||||
return p->getStateRaw(code, isVKey).pressed;
|
||||
|
@ -1200,6 +1207,22 @@ bool Input::isReleasedEx(int code, bool isVKey)
|
|||
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()
|
||||
{
|
||||
return p->dir4Data.active;
|
||||
|
|
|
@ -61,10 +61,12 @@ public:
|
|||
bool isTriggered(int button);
|
||||
bool isRepeated(int button);
|
||||
bool isReleased(int button);
|
||||
unsigned int count(int button);
|
||||
bool isPressedEx(int code, bool isVKey);
|
||||
bool isTriggeredEx(int code, bool isVKey);
|
||||
bool isRepeatedEx(int code, bool isVKey);
|
||||
bool isReleasedEx(int code, bool isVKey);
|
||||
unsigned int repeatcount(int code, bool isVKey);
|
||||
|
||||
int dir4Value();
|
||||
int dir8Value();
|
||||
|
|
Loading…
Add table
Reference in a new issue