mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-21 09:01:56 -07:00
Mouse pointer positioning for inse canvas
This commit is contained in:
parent
99d619705c
commit
2962c55adf
4 changed files with 10 additions and 17 deletions
|
|
@ -1 +1 @@
|
|||
1696645137999
|
||||
1697525451441
|
||||
|
|
@ -276,12 +276,8 @@ public class GLFWGLSurface extends View implements GrabListener {
|
|||
//Getting scaled position from the event
|
||||
/* Tells if a double tap happened [MOUSE GRAB ONLY]. Doesn't tell where though. */
|
||||
if(!CallbackBridge.isGrabbing()) {
|
||||
float scaledInsetX = PREF_INSET_X * mScaleFactor;
|
||||
float scaledInsetY = PREF_INSET_X * mScaleFactor; // Assuming you have a Y inset as well
|
||||
|
||||
CallbackBridge.mouseX = (e.getX() * mScaleFactor) - scaledInsetX;
|
||||
CallbackBridge.mouseY = (e.getY() * mScaleFactor) - scaledInsetY;
|
||||
|
||||
CallbackBridge.mouseX = (e.getX() * mScaleFactor);
|
||||
CallbackBridge.mouseY = (e.getY() * mScaleFactor);
|
||||
//One android click = one MC click
|
||||
if(mSingleTapDetector.onTouchEvent(e)){ //
|
||||
//longPressDetector.onTouchEvent(e);// Touch Mode
|
||||
|
|
@ -486,7 +482,6 @@ public class GLFWGLSurface extends View implements GrabListener {
|
|||
|
||||
// Make sure we grabbed the mouse if necessary
|
||||
updateGrabState(CallbackBridge.isGrabbing());
|
||||
|
||||
switch(event.getActionMasked()) {
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
CallbackBridge.mouseX = (event.getX(mouseCursorIndex) * mScaleFactor);
|
||||
|
|
@ -510,11 +505,8 @@ public class GLFWGLSurface extends View implements GrabListener {
|
|||
@RequiresApi(26)
|
||||
@Override
|
||||
public boolean dispatchCapturedPointerEvent(MotionEvent e) {
|
||||
float scaledInsetX = PREF_INSET_X * mScaleFactor;
|
||||
float scaledInsetY = PREF_INSET_X * mScaleFactor; // Assuming you have a Y inset as well
|
||||
|
||||
CallbackBridge.mouseX = (e.getX() * mScaleFactor) - scaledInsetX;
|
||||
CallbackBridge.mouseY = (e.getY() * mScaleFactor) - scaledInsetY;
|
||||
CallbackBridge.mouseX = (e.getX() * mScaleFactor);
|
||||
CallbackBridge.mouseY = (e.getY() * mScaleFactor);
|
||||
|
||||
switch (e.getActionMasked()) {
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
|
|
@ -653,8 +645,8 @@ public class GLFWGLSurface extends View implements GrabListener {
|
|||
|
||||
/** Called when the size need to be set at any point during the surface lifecycle **/
|
||||
public void refreshSize(){
|
||||
windowWidth = Tools.getDisplayFriendlyRes(Tools.currentDisplayMetrics.widthPixels, mScaleFactor);
|
||||
windowHeight = Tools.getDisplayFriendlyRes(Tools.currentDisplayMetrics.heightPixels, mScaleFactor);
|
||||
windowWidth = Tools.getDisplayFriendlyRes((int) (Tools.currentDisplayMetrics.widthPixels - (PREF_INSET_X*2)), mScaleFactor);
|
||||
windowHeight = Tools.getDisplayFriendlyRes((int) (Tools.currentDisplayMetrics.heightPixels - (PREF_INSET_X*2)), mScaleFactor);
|
||||
if(mSurface == null){
|
||||
Log.w("MGLSurface", "Attempt to refresh size on null surface");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -209,7 +209,8 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
|
|||
touchCharInput = findViewById(R.id.mainTouchCharInput);
|
||||
mDrawerPullButton = findViewById(R.id.drawer_button);
|
||||
contentFrame = findViewById(R.id.content_frame);
|
||||
int inset = (int) PREF_INSET_X*2;
|
||||
int inset = (int) PREF_INSET_X;
|
||||
//touchpad.setPadding(inset,inset,inset,inset);
|
||||
contentFrame.setPadding(inset,inset,inset,inset);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class LauncherPreferences {
|
|||
PREF_BUTTONSIZE = DEFAULT_PREF.getInt("buttonscale", 100);
|
||||
PREF_MOUSESCALE = DEFAULT_PREF.getInt("mousescale", 100);
|
||||
PREF_MOUSESPEED = ((float)DEFAULT_PREF.getInt("mousespeed",100))/100f;
|
||||
PREF_INSET_X = DEFAULT_PREF.getInt("xinset", 0);
|
||||
PREF_INSET_X = DEFAULT_PREF.getInt("xinset", 0)*2;
|
||||
PREF_HIDE_SIDEBAR = DEFAULT_PREF.getBoolean("hideSidebar", false);
|
||||
PREF_IGNORE_NOTCH = DEFAULT_PREF.getBoolean("ignoreNotch", false);
|
||||
PREF_VERTYPE_RELEASE = DEFAULT_PREF.getBoolean("vertype_release", true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue