|
2 | 2 |
|
3 | 3 | import android.content.Context; |
4 | 4 | import android.os.Build; |
| 5 | +import android.view.InputDevice; |
5 | 6 | import android.view.KeyEvent; |
6 | 7 | import android.view.LayoutInflater; |
7 | 8 | import android.view.Menu; |
8 | 9 | import android.view.MenuItem; |
| 10 | +import android.view.MotionEvent; |
9 | 11 | import android.view.View; |
10 | 12 | import android.view.ViewGroup; |
11 | 13 | import android.view.WindowManager; |
@@ -96,6 +98,20 @@ private void init() { |
96 | 98 | binding.switchProfile.setOnKeyListener(SettingsOverlay::onKey); |
97 | 99 | binding.mouseAimKey.setOnKeyListener(SettingsOverlay::onKey); |
98 | 100 |
|
| 101 | + binding.mouseAimKey.setOnGenericMotionListener((v, event) -> { |
| 102 | + // Handle middle mouse button |
| 103 | + if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { |
| 104 | + if (event.getAction() == MotionEvent.ACTION_BUTTON_PRESS) { |
| 105 | + if (event.getActionButton() == MotionEvent.BUTTON_TERTIARY) { |
| 106 | + // Middle mouse button was pressed |
| 107 | + ((EditText) v).setText("MMB"); |
| 108 | + return true; |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | + return false; // Event not handled |
| 113 | + }); |
| 114 | + |
99 | 115 |
|
100 | 116 | mouseAimActions(); |
101 | 117 | loadTouchpadInputSettings(); |
@@ -299,6 +315,7 @@ public void onRegisterKeyEventListener() { |
299 | 315 | } |
300 | 316 |
|
301 | 317 | public void onUnRegisterKeyEventListener() { |
| 318 | + // Accept key events from View |
302 | 319 | binding.launchEditor.setOnKeyListener(SettingsOverlay::onKey); |
303 | 320 | binding.pauseResume.setOnKeyListener(SettingsOverlay::onKey); |
304 | 321 | binding.switchProfile.setOnKeyListener(SettingsOverlay::onKey); |
|
0 commit comments