mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-30 21:00:39 +00:00
ANDROID: Split deprecated code in its own function
This allows to remove deprecation warning on a limited part of code
This commit is contained in:
parent
bed4b2ee0d
commit
abca8ce013
@ -343,36 +343,8 @@ public class ScummVMEventsBase implements
|
||||
}
|
||||
}
|
||||
|
||||
// The KeyEvent.ACTION_MULTIPLE constant was deprecated in API level 29 (Q).
|
||||
// No longer used by the input system.
|
||||
// getAction() value: multiple duplicate key events have occurred in a row, or a complex string is being delivered.
|
||||
// If the key code is not KEYCODE_UNKNOWN then the getRepeatCount() method returns the number of times the given key code should be executed.
|
||||
// Otherwise, if the key code is KEYCODE_UNKNOWN, then this is a sequence of characters as returned by getCharacters().
|
||||
// sequence of characters
|
||||
// getCharacters() is also deprecated in API level 29
|
||||
// For the special case of a ACTION_MULTIPLE event with key code of KEYCODE_UNKNOWN,
|
||||
// this is a raw string of characters associated with the event. In all other cases it is null.
|
||||
// TODO What is the use case for this?
|
||||
// Does it make sense to keep it with a Build.VERSION.SDK_INT < Build.VERSION_CODES.Q check?
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
if (action == KeyEvent.ACTION_MULTIPLE
|
||||
&& keyCode == KeyEvent.KEYCODE_UNKNOWN) {
|
||||
final KeyCharacterMap m = KeyCharacterMap.load(e.getDeviceId());
|
||||
final KeyEvent[] es = m.getEvents(e.getCharacters().toCharArray());
|
||||
|
||||
if (es == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (KeyEvent s : es) {
|
||||
_scummvm.pushEvent(JE_KEY,
|
||||
s.getAction(),
|
||||
s.getKeyCode(),
|
||||
eventUnicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK,
|
||||
s.getMetaState(),
|
||||
s.getRepeatCount(),
|
||||
0);
|
||||
}
|
||||
if (onKeyMultiple(action, keyCode, e)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -470,6 +442,45 @@ public class ScummVMEventsBase implements
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets called only on Android < Q
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean onKeyMultiple(int action, int keyCode, KeyEvent e) {
|
||||
// The KeyEvent.ACTION_MULTIPLE constant was deprecated in API level 29 (Q).
|
||||
// No longer used by the input system.
|
||||
// getAction() value: multiple duplicate key events have occurred in a row, or a complex string is being delivered.
|
||||
// If the key code is not KEYCODE_UNKNOWN then the getRepeatCount() method returns the number of times the given key code should be executed.
|
||||
// Otherwise, if the key code is KEYCODE_UNKNOWN, then this is a sequence of characters as returned by getCharacters().
|
||||
// sequence of characters
|
||||
// getCharacters() is also deprecated in API level 29
|
||||
// For the special case of a ACTION_MULTIPLE event with key code of KEYCODE_UNKNOWN,
|
||||
// this is a raw string of characters associated with the event. In all other cases it is null.
|
||||
// TODO What is the use case for this?
|
||||
// Does it make sense to keep it with a Build.VERSION.SDK_INT < Build.VERSION_CODES.Q check?
|
||||
if (action == KeyEvent.ACTION_MULTIPLE
|
||||
&& keyCode == KeyEvent.KEYCODE_UNKNOWN) {
|
||||
final KeyCharacterMap m = KeyCharacterMap.load(e.getDeviceId());
|
||||
final KeyEvent[] es = m.getEvents(e.getCharacters().toCharArray());
|
||||
|
||||
if (es == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (KeyEvent s : es) {
|
||||
_scummvm.pushEvent(JE_KEY,
|
||||
s.getAction(),
|
||||
s.getKeyCode(),
|
||||
s.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK,
|
||||
s.getMetaState(),
|
||||
s.getRepeatCount(),
|
||||
0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Aux method to provide a description for a MotionEvent action
|
||||
* Given an action int, returns a string description
|
||||
|
Loading…
Reference in New Issue
Block a user