mirror of
https://github.com/brunodev85/winlator.git
synced 2024-11-23 05:09:38 +00:00
Merge pull request #71 from longjunyu2/fix-screen-dimming-when-using-gamepad
Fix screen dimming when using game controller
This commit is contained in:
commit
8e2058e30a
@ -1,6 +1,9 @@
|
||||
package com.winlator.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.view.InputDevice;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@ -40,8 +43,9 @@ public class TouchpadView extends View {
|
||||
super(context);
|
||||
this.xServer = xServer;
|
||||
setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
setBackground(createTransparentBg());
|
||||
setClickable(true);
|
||||
setFocusable(false);
|
||||
setFocusable(true);
|
||||
setFocusableInTouchMode(false);
|
||||
updateXform(AppUtils.getScreenWidth(), AppUtils.getScreenHeight(), xServer.screenInfo.width, xServer.screenInfo.height);
|
||||
}
|
||||
@ -353,4 +357,16 @@ public class TouchpadView extends View {
|
||||
result[1] = y - lastY;
|
||||
return result;
|
||||
}
|
||||
|
||||
private StateListDrawable createTransparentBg() {
|
||||
StateListDrawable stateListDrawable = new StateListDrawable();
|
||||
|
||||
ColorDrawable focusedDrawable = new ColorDrawable(Color.TRANSPARENT);
|
||||
ColorDrawable defaultDrawable = new ColorDrawable(Color.TRANSPARENT);
|
||||
|
||||
stateListDrawable.addState(new int[]{android.R.attr.state_focused}, focusedDrawable);
|
||||
stateListDrawable.addState(new int[]{}, defaultDrawable);
|
||||
|
||||
return stateListDrawable;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user