Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect autoenabled virtual mouse #16

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ protected void onCreate(Bundle savedInstanceState) {
ViewGroup.LayoutParams params = mMousePointerImageView.getLayoutParams();
params.width = (int) (36 / 100f * LauncherPreferences.PREF_MOUSESCALE);
params.height = (int) (54 / 100f * LauncherPreferences.PREF_MOUSESCALE);
if(LauncherPreferences.PREF_VIRTUAL_MOUSE_START)
toggleVirtualMouse();
});

mTouchPad.setOnTouchListener(new View.OnTouchListener() {
Expand Down Expand Up @@ -120,8 +122,8 @@ public boolean onTouch(View v, MotionEvent event) {
}
} else {
if (action == MotionEvent.ACTION_MOVE) { // 2
mouseX = Math.max(0, Math.min(currentDisplayMetrics.widthPixels, mouseX + (x - prevX) * LauncherPreferences.PREF_MOUSESPEED));
mouseY = Math.max(0, Math.min(currentDisplayMetrics.heightPixels, mouseY + (y - prevY) * LauncherPreferences.PREF_MOUSESPEED));
mouseX = Math.max(0, Math.min(currentDisplayMetrics.widthPixels, mouseX + (x - prevX) * mouseSpeed));
mouseY = Math.max(0, Math.min(currentDisplayMetrics.heightPixels, mouseY + (y - prevY) * mouseSpeed));
placeMouseAt(mouseX, mouseY);
sendScaledMousePosition(mouseX, mouseY);
}
Expand All @@ -130,8 +132,6 @@ public boolean onTouch(View v, MotionEvent event) {
if (event.getPointerCount() == 2) {
// Right-click event when a second finger touches the screen
// Simulating right-click by sending GLFW_MOUSE_BUTTON_RIGHT event
Log.i("downthecrop","Hi from a rightclick event!");
//activateRC();
AWTInputBridge.sendKey((char)AWTInputEvent.VK_F11,AWTInputEvent.VK_F11);
AWTInputBridge.sendMousePress(AWTInputEvent.BUTTON1_DOWN_MASK);
}
Expand Down Expand Up @@ -203,14 +203,6 @@ public boolean onTouch(View v, MotionEvent event) {
} catch (Throwable th) {
Tools.showError(this, th, true);
}


getOnBackPressedDispatcher().addCallback(new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
MainActivity.dialogForceClose(JavaGUILauncherActivity.this);
}
});
}

@Override
Expand Down Expand Up @@ -261,7 +253,6 @@ public boolean onTouch(View v, MotionEvent e) { // these AWTInputEvent doesn't w
break;
case R.id.camera:
if (!cameraMode) { // Camera Mode On
Log.i("downthecrop", "Hello from the camrea Button");
AWTInputBridge.sendKey((char) AWTInputEvent.VK_F9, AWTInputEvent.VK_F9); // Send F9
cameraMode = true;
findViewById(R.id.camera).setBackground(getResources().getDrawable( R.drawable.control_button_pressed ));
Expand All @@ -272,7 +263,7 @@ public boolean onTouch(View v, MotionEvent e) { // these AWTInputEvent doesn't w
}
break;
case R.id.mouseMode:
toggleVirtualMouse(this.getCurrentFocus());
toggleVirtualMouse();
}
lastPress = time;
}
Expand Down Expand Up @@ -320,7 +311,7 @@ public void openLogOutput(View v) {
mLoggerView.setVisibility(View.VISIBLE);
}

public void toggleVirtualMouse(View v) {
public void toggleVirtualMouse() {
mIsVirtualMouseEnabled = !mIsVirtualMouseEnabled;
ImageView view = findViewById(R.id.mouseModeIco);
if(!mIsVirtualMouseEnabled){
Expand Down
Loading