mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-07-01 23:35:59 +00:00
parent
95dcbf6024
commit
514e415956
@ -16,6 +16,7 @@ struct KeyEvent {
|
||||
u_char modifier;
|
||||
};
|
||||
|
||||
+ (BOOL)sendKeyEventForPress:(UIPress*)press down:(BOOL)down API_AVAILABLE(ios(13.4));
|
||||
+ (BOOL)sendKeyEvent:(UIKey*)key down:(BOOL)down API_AVAILABLE(ios(13.4));
|
||||
+ (struct KeyEvent) translateKeyEvent:(unichar) inputChar withModifierFlags:(UIKeyModifierFlags)modifierFlags;
|
||||
|
||||
|
@ -11,7 +11,40 @@
|
||||
|
||||
@implementation KeyboardSupport
|
||||
|
||||
+ (BOOL)sendKeyEvent:(UIKey*)key down:(BOOL)down API_AVAILABLE(ios(13.4)){
|
||||
+ (BOOL)sendKeyEventForPress:(UIPress*)press down:(BOOL)down API_AVAILABLE(ios(13.4)) {
|
||||
if (press.key != nil) {
|
||||
return [KeyboardSupport sendKeyEvent:press.key down:down];
|
||||
}
|
||||
else {
|
||||
short keyCode;
|
||||
|
||||
switch (press.type) {
|
||||
case UIPressTypeUpArrow:
|
||||
keyCode = 0x26;
|
||||
break;
|
||||
case UIPressTypeDownArrow:
|
||||
keyCode = 0x28;
|
||||
break;
|
||||
case UIPressTypeLeftArrow:
|
||||
keyCode = 0x25;
|
||||
break;
|
||||
case UIPressTypeRightArrow:
|
||||
keyCode = 0x27;
|
||||
break;
|
||||
default:
|
||||
// Unhandled press type
|
||||
return NO;
|
||||
}
|
||||
|
||||
LiSendKeyboardEvent(0x8000 | keyCode,
|
||||
down ? KEY_ACTION_DOWN : KEY_ACTION_UP,
|
||||
0);
|
||||
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)sendKeyEvent:(UIKey*)key down:(BOOL)down API_AVAILABLE(ios(13.4)) {
|
||||
char modifierFlags = 0;
|
||||
short keyCode = 0;
|
||||
|
||||
|
@ -470,7 +470,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
for (UIPress* press in presses) {
|
||||
// For now, we'll treated it as handled if we handle at least one of the
|
||||
// UIPress events inside the set.
|
||||
if (press.key != nil && [KeyboardSupport sendKeyEvent:press.key down:YES]) {
|
||||
if ([KeyboardSupport sendKeyEventForPress:press down:YES]) {
|
||||
// This will prevent the legacy UITextField from receiving the event
|
||||
handled = YES;
|
||||
}
|
||||
@ -489,7 +489,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
for (UIPress* press in presses) {
|
||||
// For now, we'll treated it as handled if we handle at least one of the
|
||||
// UIPress events inside the set.
|
||||
if (press.key != nil && [KeyboardSupport sendKeyEvent:press.key down:NO]) {
|
||||
if ([KeyboardSupport sendKeyEventForPress:press down:NO]) {
|
||||
// This will prevent the legacy UITextField from receiving the event
|
||||
handled = YES;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user