Skip to content

Commit

Permalink
Update app
Browse files Browse the repository at this point in the history
  • Loading branch information
brunodev85 committed Jan 24, 2024
1 parent 4409561 commit e6dd7a5
Show file tree
Hide file tree
Showing 45 changed files with 1,160 additions and 407 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId 'com.winlator'
minSdkVersion 26
targetSdkVersion 28
versionCode 9
versionName "3.2"
versionCode 10
versionName "4.0"
}

buildTypes {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

<activity android:name="com.winlator.ExternalControllerBindingsActivity"
android:theme="@style/AppTheme"
android:exported="false" />
android:exported="false"
android:screenOrientation="sensor" />
</application>
</manifest>
1 change: 1 addition & 0 deletions app/src/main/assets/box64_env_vars.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
{"name" : "BOX64_DYNAREC", "values" : ["0", "1"], "toggleSwitch" : true, "defaultValue" : "1"},
{"name" : "BOX64_DYNAREC_SAFEFLAGS", "values" : ["0", "1", "2"], "defaultValue" : "2"},
{"name" : "BOX64_DYNAREC_FASTNAN", "values" : ["0", "1"], "toggleSwitch" : true, "defaultValue" : "1"},
{"name" : "BOX64_DYNAREC_FASTROUND", "values" : ["0", "1"], "toggleSwitch" : true, "defaultValue" : "1"},
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions app/src/main/assets/box86_env_vars.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
{"name" : "BOX86_DYNAREC", "values" : ["0", "1"], "toggleSwitch" : true, "defaultValue" : "1"},
{"name" : "BOX86_DYNAREC_SAFEFLAGS", "values" : ["0", "1", "2"], "defaultValue" : "2"},
{"name" : "BOX86_DYNAREC_FASTNAN", "values" : ["0", "1"], "toggleSwitch" : true, "defaultValue" : "1"},
{"name" : "BOX86_DYNAREC_FASTROUND", "values" : ["0", "1"], "toggleSwitch" : true, "defaultValue" : "1"},
Expand Down
1 change: 1 addition & 0 deletions app/src/main/assets/inputcontrols/profiles/controls-3.icp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":3,"name":"Virtual Gamepad","cursorSpeed":1,"elements":[{"type":"D_PAD","shape":"CIRCLE","bindings":["GAMEPAD_DPAD_UP","GAMEPAD_DPAD_RIGHT","GAMEPAD_DPAD_DOWN","GAMEPAD_DPAD_LEFT"],"scale":0.85,"x":0.21568627655506134,"y":0.35555556416511536,"toggleSwitch":false,"text":"","iconId":0},{"type":"BUTTON","shape":"CIRCLE","bindings":["GAMEPAD_BUTTON_X","NONE","NONE","NONE"],"scale":1,"x":0.8133170008659363,"y":0.7333333492279053,"toggleSwitch":false,"text":"","iconId":0},{"type":"BUTTON","shape":"CIRCLE","bindings":["GAMEPAD_BUTTON_Y","NONE","NONE","NONE"],"scale":1,"x":0.8721405267715454,"y":0.6000000238418579,"toggleSwitch":false,"text":"","iconId":0},{"type":"BUTTON","shape":"CIRCLE","bindings":["GAMEPAD_BUTTON_A","NONE","NONE","NONE"],"scale":1,"x":0.8721405267715454,"y":0.8666666746139526,"toggleSwitch":false,"text":"","iconId":0},{"type":"BUTTON","shape":"CIRCLE","bindings":["GAMEPAD_BUTTON_B","NONE","NONE","NONE"],"scale":1,"x":0.9309640526771545,"y":0.7333333492279053,"toggleSwitch":false,"text":"","iconId":0},{"type":"BUTTON","shape":"RECT","bindings":["GAMEPAD_BUTTON_R2","NONE","NONE","NONE"],"scale":1,"x":0.9215686321258545,"y":0.2888889014720917,"toggleSwitch":false,"text":"","iconId":0},{"type":"BUTTON","shape":"RECT","bindings":["GAMEPAD_BUTTON_R1","NONE","NONE","NONE"],"scale":1,"x":0.9215686321258545,"y":0.42222222685813904,"toggleSwitch":false,"text":"","iconId":0},{"type":"BUTTON","shape":"RECT","bindings":["GAMEPAD_BUTTON_L1","NONE","NONE","NONE"],"scale":1,"x":0.0784313753247261,"y":0.42222222685813904,"toggleSwitch":false,"text":"","iconId":0},{"type":"BUTTON","shape":"RECT","bindings":["GAMEPAD_BUTTON_L2","NONE","NONE","NONE"],"scale":1,"x":0.0784313753247261,"y":0.2888889014720917,"toggleSwitch":false,"text":"","iconId":0},{"type":"BUTTON","shape":"ROUND_RECT","bindings":["GAMEPAD_BUTTON_START","NONE","NONE","NONE"],"scale":0.85,"x":0.538807213306427,"y":0.9111111164093018,"toggleSwitch":false,"text":"","iconId":0},{"type":"BUTTON","shape":"ROUND_RECT","bindings":["GAMEPAD_BUTTON_SELECT","NONE","NONE","NONE"],"scale":0.85,"x":0.46078431606292725,"y":0.9111111164093018,"toggleSwitch":false,"text":"","iconId":0},{"type":"STICK","shape":"CIRCLE","bindings":["GAMEPAD_LEFT_THUMB_UP","GAMEPAD_LEFT_THUMB_RIGHT","GAMEPAD_LEFT_THUMB_DOWN","GAMEPAD_LEFT_THUMB_LEFT"],"scale":1,"x":0.10784313827753067,"y":0.7333333492279053,"toggleSwitch":false,"text":"","iconId":0},{"type":"STICK","shape":"CIRCLE","bindings":["GAMEPAD_RIGHT_THUMB_UP","GAMEPAD_RIGHT_THUMB_RIGHT","GAMEPAD_RIGHT_THUMB_DOWN","GAMEPAD_RIGHT_THUMB_LEFT"],"scale":1,"x":0.7843137383460999,"y":0.35555556416511536,"toggleSwitch":false,"text":"","iconId":0},{"type":"BUTTON","shape":"CIRCLE","bindings":["GAMEPAD_BUTTON_L3","NONE","NONE","NONE"],"scale":0.85,"x":0.21568627655506134,"y":0.9111111164093018,"toggleSwitch":false,"text":"","iconId":0},{"type":"BUTTON","shape":"CIRCLE","bindings":["GAMEPAD_BUTTON_R3","NONE","NONE","NONE"],"scale":0.85,"x":0.7843137383460999,"y":0.9111111164093018,"toggleSwitch":false,"text":"","iconId":0}]}
Binary file modified app/src/main/assets/patches.tzst
Binary file not shown.
4 changes: 0 additions & 4 deletions app/src/main/java/com/winlator/ContainerDetailFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class ContainerDetailFragment extends Fragment {
private PreloaderDialog preloaderDialog;
private JSONArray gpuNames;
private Callback<String> openDirectoryCallback;
private final String[] defaultDLLOverrides = {"d3d8", "d3d9", "d3d10", "d3d10_1", "d3d10core", "d3d11", "d3d12", "d3d12core", "ddraw", "dxgi", "wined3d"};

public ContainerDetailFragment() {
this(0);
Expand Down Expand Up @@ -276,9 +275,6 @@ private void saveWineRegistryKeys(View view) {

registryEditor.setStringValue("Software\\Wine\\Direct3D", "shader_backend", "glsl");
registryEditor.setStringValue("Software\\Wine\\Direct3D", "UseGLSL", "enabled");

final String dllOverridesKey = "Software\\Wine\\DllOverrides";
for (String name : defaultDLLOverrides) registryEditor.setStringValue(dllOverridesKey, name, "native,builtin");
}
}

Expand Down
50 changes: 46 additions & 4 deletions app/src/main/java/com/winlator/ControlsEditorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.winlator.core.FileUtils;
import com.winlator.core.UnitUtils;
import com.winlator.widget.InputControlsView;
import com.winlator.widget.NumberPicker;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -117,6 +118,14 @@ else if (type == ControlElement.Type.RANGE_BUTTON) {
inputControlsView.invalidate();
});

NumberPicker npColumns = view.findViewById(R.id.NPColumns);
npColumns.setValue(element.getBindingCount());
npColumns.setOnValueChangeListener((numberPicker, value) -> {
element.setBindingCount(value);
profile.save();
inputControlsView.invalidate();
});

final TextView tvScale = view.findViewById(R.id.TVScale);
SeekBar sbScale = view.findViewById(R.id.SBScale);
sbScale.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
Expand Down Expand Up @@ -229,7 +238,19 @@ private void loadBindingSpinner(final ControlElement element, LinearLayout conta
final Spinner sBinding = view.findViewById(R.id.SBinding);

Runnable update = () -> {
String[] bindingEntries = sBindingType.getSelectedItemPosition() == 0 ? Binding.keyboardBindingLabels() : Binding.mouseBindingLabels();
String[] bindingEntries = null;
switch (sBindingType.getSelectedItemPosition()) {
case 0:
bindingEntries = Binding.keyboardBindingLabels();
break;
case 1:
bindingEntries = Binding.mouseBindingLabels();
break;
case 2:
bindingEntries = Binding.gamepadBindingLabels();
break;
}

sBinding.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, bindingEntries));
AppUtils.setSpinnerSelectionFromValue(sBinding, element.getBindingAt(index).toString());
};
Expand All @@ -243,13 +264,34 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
@Override
public void onNothingSelected(AdapterView<?> parent) {}
});
sBindingType.setSelection(element.getBindingAt(index).isKeyboard() ? 0 : 1, false);

Binding selectedBinding = element.getBindingAt(index);
if (selectedBinding.isKeyboard()) {
sBindingType.setSelection(0, false);
}
else if (selectedBinding.isMouse()) {
sBindingType.setSelection(1, false);
}
else if (selectedBinding.isGamepad()) {
sBindingType.setSelection(2, false);
}

sBinding.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
boolean isKeyboard = sBindingType.getSelectedItemPosition() == 0;
Binding binding = isKeyboard ? Binding.keyboardBindingValues()[position] : Binding.mouseBindingValues()[position];
Binding binding = Binding.NONE;
switch (sBindingType.getSelectedItemPosition()) {
case 0:
binding = Binding.keyboardBindingValues()[position];
break;
case 1:
binding = Binding.mouseBindingValues()[position];
break;
case 2:
binding = Binding.gamepadBindingValues()[position];
break;
}

if (binding != element.getBindingAt(index)) {
element.setBindingAt(index, binding);
profile.save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
Expand Down Expand Up @@ -76,6 +75,7 @@ protected void onCreate(Bundle savedInstanceState) {

private void updateControllerBinding(int keyCode, Binding binding) {
if (keyCode == KeyEvent.KEYCODE_UNKNOWN) return;

ExternalControllerBinding controllerBinding = controller.getControllerBinding(keyCode);
int position;
if (controllerBinding == null) {
Expand All @@ -93,70 +93,54 @@ private void updateControllerBinding(int keyCode, Binding binding) {
recyclerView.scrollToPosition(position);
}

private void processJoystickInput(MotionEvent event, int historyPos) {
private void processJoystickInput() {
int keyCode = KeyEvent.KEYCODE_UNKNOWN;
byte sign;
Binding binding = Binding.NONE;

final int[] axes = {MotionEvent.AXIS_X, MotionEvent.AXIS_Y, MotionEvent.AXIS_Z, MotionEvent.AXIS_RZ, MotionEvent.AXIS_HAT_X, MotionEvent.AXIS_HAT_Y};
for (int axis : axes) {
if ((sign = Mathf.sign(ExternalController.getCenteredAxis(event, axis, historyPos))) != 0) {
if (axis == MotionEvent.AXIS_X || axis == MotionEvent.AXIS_Z) {
final float[] values = {controller.state.thumbLX, controller.state.thumbLY, controller.state.thumbRX, controller.state.thumbRY, controller.state.getDPadX(), controller.state.getDPadY()};

byte sign;
for (int i = 0; i < axes.length; i++) {
if ((sign = Mathf.sign(values[i])) != 0) {
if (axes[i] == MotionEvent.AXIS_X || axes[i] == MotionEvent.AXIS_Z) {
binding = sign > 0 ? Binding.MOUSE_MOVE_RIGHT : Binding.MOUSE_MOVE_LEFT;
}
else if (axis == MotionEvent.AXIS_Y || axis == MotionEvent.AXIS_RZ) {
else if (axes[i] == MotionEvent.AXIS_Y || axes[i] == MotionEvent.AXIS_RZ) {
binding = sign > 0 ? Binding.MOUSE_MOVE_DOWN : Binding.MOUSE_MOVE_UP;
}
else if (axis == MotionEvent.AXIS_HAT_X) {
else if (axes[i] == MotionEvent.AXIS_HAT_X) {
binding = sign > 0 ? Binding.KEY_D : Binding.KEY_A;
}
else if (axis == MotionEvent.AXIS_HAT_Y) {
else if (axes[i] == MotionEvent.AXIS_HAT_Y) {
binding = sign > 0 ? Binding.KEY_S : Binding.KEY_W;
}

keyCode = ExternalControllerBinding.getKeyCodeForAxis(axis, sign);
keyCode = ExternalControllerBinding.getKeyCodeForAxis(axes[i], sign);
break;
}
}

updateControllerBinding(keyCode, binding);
}

private void processTriggerButton(MotionEvent event) {
if (event.getAxisValue(MotionEvent.AXIS_LTRIGGER) == 1 || event.getAxisValue(MotionEvent.AXIS_BRAKE) == 1) {
updateControllerBinding(ExternalControllerBinding.AXIS_LTRIGGER, Binding.NONE);
}
if (event.getAxisValue(MotionEvent.AXIS_RTRIGGER) == 1 || event.getAxisValue(MotionEvent.AXIS_GAS) == 1) {
updateControllerBinding(ExternalControllerBinding.AXIS_RTRIGGER, Binding.NONE);
}
}

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
if (event.getDeviceId() == controller.getDeviceId()) {
if (ExternalController.isDPadDevice(event)) {
processTriggerButton(event);
processJoystickInput(event, -1);
return true;
}
else if (ExternalController.isJoystickDevice(event)) {
int historySize = event.getHistorySize();
for (int i = 0; i < historySize; i++) processJoystickInput(event, i);
processJoystickInput(event, -1);
return true;
}
public boolean dispatchGenericMotionEvent(MotionEvent event) {
if (event.getDeviceId() == controller.getDeviceId() && controller.updateStateFromMotionEvent(event)) {
if (controller.state.isPressed(ExternalController.IDX_BUTTON_L2)) updateControllerBinding(KeyEvent.KEYCODE_BUTTON_L2, Binding.NONE);
if (controller.state.isPressed(ExternalController.IDX_BUTTON_R2)) updateControllerBinding(KeyEvent.KEYCODE_BUTTON_R2, Binding.NONE);
processJoystickInput();
return true;
}
return super.onGenericMotionEvent(event);
return super.dispatchGenericMotionEvent(event);
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((event.getSource() & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD &&
event.getDeviceId() == controller.getDeviceId() && event.getRepeatCount() == 0) {
updateControllerBinding(keyCode, Binding.NONE);
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getDeviceId() == controller.getDeviceId() && event.getRepeatCount() == 0) {
if (event.getAction() == KeyEvent.ACTION_DOWN) updateControllerBinding(event.getKeyCode(), Binding.NONE);
return true;
}
else return super.onKeyDown(keyCode, event);
else return super.dispatchKeyEvent(event);
}

@Override
Expand Down Expand Up @@ -208,7 +192,19 @@ private void loadBindingSpinner(ViewHolder holder, final ExternalControllerBindi
final Context $this = ExternalControllerBindingsActivity.this;

Runnable update = () -> {
String[] bindingEntries = holder.bindingType.getSelectedItemPosition() == 0 ? Binding.keyboardBindingLabels() : Binding.mouseBindingLabels();
String[] bindingEntries = null;
switch (holder.bindingType.getSelectedItemPosition()) {
case 0:
bindingEntries = Binding.keyboardBindingLabels();
break;
case 1:
bindingEntries = Binding.mouseBindingLabels();
break;
case 2:
bindingEntries = Binding.gamepadBindingLabels();
break;
}

holder.binding.setAdapter(new ArrayAdapter<>($this, android.R.layout.simple_spinner_dropdown_item, bindingEntries));
AppUtils.setSpinnerSelectionFromValue(holder.binding, item.getBinding().toString());
};
Expand All @@ -227,8 +223,19 @@ public void onNothingSelected(AdapterView<?> parent) {}
holder.binding.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
boolean isKeyboard = holder.bindingType.getSelectedItemPosition() == 0;
Binding binding = isKeyboard ? Binding.keyboardBindingValues()[position] : Binding.mouseBindingValues()[position];
Binding binding = Binding.NONE;
switch (holder.bindingType.getSelectedItemPosition()) {
case 0:
binding = Binding.keyboardBindingValues()[position];
break;
case 1:
binding = Binding.mouseBindingValues()[position];
break;
case 2:
binding = Binding.gamepadBindingValues()[position];
break;
}

if (binding != item.getBinding()) {
item.setBinding(binding);
profile.save();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/winlator/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import androidx.fragment.app.FragmentManager;

import com.google.android.material.navigation.NavigationView;
import com.winlator.contentdialog.ContentDialog;
import com.winlator.core.Callback;
import com.winlator.core.OBBImageInstaller;
import com.winlator.core.PreloaderDialog;
import com.winlator.contentdialog.ContentDialog;
import com.winlator.xenvironment.ImageFs;

import java.util.List;
Expand Down
Loading

0 comments on commit e6dd7a5

Please sign in to comment.