Android: Clean up naming in Java_GCAdapter and Java_WiimoteAdapter

This isn't how we name things in Java/Kotlin.
This commit is contained in:
JosJuice 2025-01-02 15:39:41 +01:00
parent c528a70e64
commit e1ebbd0819
5 changed files with 69 additions and 69 deletions

View File

@ -8,8 +8,8 @@ import android.hardware.usb.UsbManager;
import org.dolphinemu.dolphinemu.utils.ActivityTracker;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.utils.Java_GCAdapter;
import org.dolphinemu.dolphinemu.utils.Java_WiimoteAdapter;
import org.dolphinemu.dolphinemu.utils.GCAdapter;
import org.dolphinemu.dolphinemu.utils.WiimoteAdapter;
import org.dolphinemu.dolphinemu.utils.VolleyUtil;
public class DolphinApplication extends Application
@ -25,8 +25,8 @@ public class DolphinApplication extends Application
VolleyUtil.init(getApplicationContext());
System.loadLibrary("main");
Java_GCAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
Java_WiimoteAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
GCAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
WiimoteAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
if (DirectoryInitialization.shouldStart(getApplicationContext()))
DirectoryInitialization.start(getApplicationContext());

View File

@ -24,19 +24,19 @@ import org.dolphinemu.dolphinemu.services.USBPermService;
import java.util.HashMap;
import java.util.Map;
public class Java_GCAdapter
public class GCAdapter
{
public static UsbManager manager;
@Keep
static byte[] controller_payload = new byte[37];
static byte[] controllerPayload = new byte[37];
static UsbDeviceConnection usb_con;
static UsbInterface usb_intf;
static UsbEndpoint usb_in;
static UsbEndpoint usb_out;
static UsbDeviceConnection usbConnection;
static UsbInterface usbInterface;
static UsbEndpoint usbIn;
static UsbEndpoint usbOut;
private static void RequestPermission()
private static void requestPermission()
{
HashMap<String, UsbDevice> devices = manager.getDeviceList();
for (Map.Entry<String, UsbDevice> pair : devices.entrySet())
@ -59,19 +59,19 @@ public class Java_GCAdapter
}
}
public static void Shutdown()
public static void shutdown()
{
usb_con.close();
usbConnection.close();
}
@Keep
public static int GetFD()
public static int getFd()
{
return usb_con.getFileDescriptor();
return usbConnection.getFileDescriptor();
}
@Keep
public static boolean QueryAdapter()
public static boolean queryAdapter()
{
HashMap<String, UsbDevice> devices = manager.getDeviceList();
for (Map.Entry<String, UsbDevice> pair : devices.entrySet())
@ -82,32 +82,32 @@ public class Java_GCAdapter
if (manager.hasPermission(dev))
return true;
else
RequestPermission();
requestPermission();
}
}
return false;
}
public static void InitAdapter()
public static void initAdapter()
{
byte[] init = {0x13};
usb_con.bulkTransfer(usb_out, init, init.length, 0);
usbConnection.bulkTransfer(usbOut, init, init.length, 0);
}
@Keep
public static int Input()
public static int input()
{
return usb_con.bulkTransfer(usb_in, controller_payload, controller_payload.length, 16);
return usbConnection.bulkTransfer(usbIn, controllerPayload, controllerPayload.length, 16);
}
@Keep
public static int Output(byte[] rumble)
public static int output(byte[] rumble)
{
return usb_con.bulkTransfer(usb_out, rumble, 5, 16);
return usbConnection.bulkTransfer(usbOut, rumble, 5, 16);
}
@Keep
public static boolean OpenAdapter()
public static boolean openAdapter()
{
HashMap<String, UsbDevice> devices = manager.getDeviceList();
for (Map.Entry<String, UsbDevice> pair : devices.entrySet())
@ -117,7 +117,7 @@ public class Java_GCAdapter
{
if (manager.hasPermission(dev))
{
usb_con = manager.openDevice(dev);
usbConnection = manager.openDevice(dev);
Log.info("GCAdapter: Number of configurations: " + dev.getConfigurationCount());
Log.info("GCAdapter: Number of interfaces: " + dev.getInterfaceCount());
@ -125,31 +125,31 @@ public class Java_GCAdapter
if (dev.getConfigurationCount() > 0 && dev.getInterfaceCount() > 0)
{
UsbConfiguration conf = dev.getConfiguration(0);
usb_intf = conf.getInterface(0);
usb_con.claimInterface(usb_intf, true);
usbInterface = conf.getInterface(0);
usbConnection.claimInterface(usbInterface, true);
Log.info("GCAdapter: Number of endpoints: " + usb_intf.getEndpointCount());
Log.info("GCAdapter: Number of endpoints: " + usbInterface.getEndpointCount());
if (usb_intf.getEndpointCount() == 2)
if (usbInterface.getEndpointCount() == 2)
{
for (int i = 0; i < usb_intf.getEndpointCount(); ++i)
if (usb_intf.getEndpoint(i).getDirection() == UsbConstants.USB_DIR_IN)
usb_in = usb_intf.getEndpoint(i);
for (int i = 0; i < usbInterface.getEndpointCount(); ++i)
if (usbInterface.getEndpoint(i).getDirection() == UsbConstants.USB_DIR_IN)
usbIn = usbInterface.getEndpoint(i);
else
usb_out = usb_intf.getEndpoint(i);
usbOut = usbInterface.getEndpoint(i);
InitAdapter();
initAdapter();
return true;
}
else
{
usb_con.releaseInterface(usb_intf);
usbConnection.releaseInterface(usbInterface);
}
}
Toast.makeText(DolphinApplication.getAppContext(), R.string.replug_gc_adapter,
Toast.LENGTH_LONG).show();
usb_con.close();
usbConnection.close();
}
}
}

View File

@ -22,7 +22,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class Java_WiimoteAdapter
public class WiimoteAdapter
{
final static int MAX_PAYLOAD = 23;
final static int MAX_WIIMOTES = 4;
@ -31,14 +31,14 @@ public class Java_WiimoteAdapter
final static short NINTENDO_WIIMOTE_PRODUCT_ID = 0x0306;
public static UsbManager manager;
static UsbDeviceConnection usb_con;
static UsbInterface[] usb_intf = new UsbInterface[MAX_WIIMOTES];
static UsbEndpoint[] usb_in = new UsbEndpoint[MAX_WIIMOTES];
static UsbDeviceConnection usbConnection;
static UsbInterface[] usbInterface = new UsbInterface[MAX_WIIMOTES];
static UsbEndpoint[] usbIn = new UsbEndpoint[MAX_WIIMOTES];
@Keep
public static byte[][] wiimote_payload = new byte[MAX_WIIMOTES][MAX_PAYLOAD];
public static byte[][] wiimotePayload = new byte[MAX_WIIMOTES][MAX_PAYLOAD];
private static void RequestPermission()
private static void requestPermission()
{
HashMap<String, UsbDevice> devices = manager.getDeviceList();
for (Map.Entry<String, UsbDevice> pair : devices.entrySet())
@ -65,7 +65,7 @@ public class Java_WiimoteAdapter
}
@Keep
public static boolean QueryAdapter()
public static boolean queryAdapter()
{
HashMap<String, UsbDevice> devices = manager.getDeviceList();
for (Map.Entry<String, UsbDevice> pair : devices.entrySet())
@ -77,20 +77,20 @@ public class Java_WiimoteAdapter
if (manager.hasPermission(dev))
return true;
else
RequestPermission();
requestPermission();
}
}
return false;
}
@Keep
public static int Input(int index)
public static int input(int index)
{
return usb_con.bulkTransfer(usb_in[index], wiimote_payload[index], MAX_PAYLOAD, TIMEOUT);
return usbConnection.bulkTransfer(usbIn[index], wiimotePayload[index], MAX_PAYLOAD, TIMEOUT);
}
@Keep
public static int Output(int index, byte[] buf, int size)
public static int output(int index, byte[] buf, int size)
{
byte report_number = buf[0];
@ -105,7 +105,7 @@ public class Java_WiimoteAdapter
final int HID_SET_REPORT = 0x9;
final int HID_OUTPUT = (2 << 8);
int write = usb_con.controlTransfer(
int write = usbConnection.controlTransfer(
LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE | LIBUSB_ENDPOINT_OUT,
HID_SET_REPORT,
HID_OUTPUT | report_number,
@ -120,10 +120,10 @@ public class Java_WiimoteAdapter
}
@Keep
public static boolean OpenAdapter()
public static boolean openAdapter()
{
// If the adapter is already open. Don't attempt to do it again
if (usb_con != null && usb_con.getFileDescriptor() != -1)
if (usbConnection != null && usbConnection.getFileDescriptor() != -1)
return true;
HashMap<String, UsbDevice> devices = manager.getDeviceList();
@ -135,7 +135,7 @@ public class Java_WiimoteAdapter
{
if (manager.hasPermission(dev))
{
usb_con = manager.openDevice(dev);
usbConnection = manager.openDevice(dev);
UsbConfiguration conf = dev.getConfiguration(0);
Log.info("Number of configurations: " + dev.getConfigurationCount());
@ -149,20 +149,20 @@ public class Java_WiimoteAdapter
for (int i = 0; i < MAX_WIIMOTES; ++i)
{
// One interface per Wii Remote
usb_intf[i] = dev.getInterface(i);
usb_con.claimInterface(usb_intf[i], true);
usbInterface[i] = dev.getInterface(i);
usbConnection.claimInterface(usbInterface[i], true);
// One endpoint per Wii Remote. Input only
// Output reports go through the control channel.
usb_in[i] = usb_intf[i].getEndpoint(0);
Log.info("Interface " + i + " endpoint count:" + usb_intf[i].getEndpointCount());
usbIn[i] = usbInterface[i].getEndpoint(0);
Log.info("Interface " + i + " endpoint count:" + usbInterface[i].getEndpointCount());
}
return true;
}
else
{
// XXX: Message that the device was found, but it needs to be unplugged and plugged back in?
usb_con.close();
usbConnection.close();
}
}
}

View File

@ -30,8 +30,8 @@ void WiimoteScannerAndroid::FindWiimotes(std::vector<Wiimote*>& found_wiimotes,
JNIEnv* env = IDCache::GetEnvForThread();
jmethodID openadapter_func = env->GetStaticMethodID(s_adapter_class, "OpenAdapter", "()Z");
jmethodID queryadapter_func = env->GetStaticMethodID(s_adapter_class, "QueryAdapter", "()Z");
jmethodID openadapter_func = env->GetStaticMethodID(s_adapter_class, "openAdapter", "()Z");
jmethodID queryadapter_func = env->GetStaticMethodID(s_adapter_class, "queryAdapter", "()Z");
if (env->CallStaticBooleanMethod(s_adapter_class, queryadapter_func) &&
env->CallStaticBooleanMethod(s_adapter_class, openadapter_func))
@ -55,15 +55,15 @@ bool WiimoteAndroid::ConnectInternal()
{
m_env = IDCache::GetEnvForThread();
jfieldID payload_field = m_env->GetStaticFieldID(s_adapter_class, "wiimote_payload", "[[B");
jfieldID payload_field = m_env->GetStaticFieldID(s_adapter_class, "wiimotePayload", "[[B");
jobjectArray payload_object =
reinterpret_cast<jobjectArray>(m_env->GetStaticObjectField(s_adapter_class, payload_field));
m_java_wiimote_payload =
(jbyteArray)m_env->GetObjectArrayElement(payload_object, m_mayflash_index);
// Get function pointers
m_input_func = m_env->GetStaticMethodID(s_adapter_class, "Input", "(I)I");
m_output_func = m_env->GetStaticMethodID(s_adapter_class, "Output", "(I[BI)I");
m_input_func = m_env->GetStaticMethodID(s_adapter_class, "input", "(I)I");
m_output_func = m_env->GetStaticMethodID(s_adapter_class, "output", "(I[BI)I");
is_connected = true;
@ -110,7 +110,7 @@ int WiimoteAndroid::IOWrite(u8 const* buf, size_t len)
void InitAdapterClass()
{
JNIEnv* env = IDCache::GetEnvForThread();
jclass adapter_class = env->FindClass("org/dolphinemu/dolphinemu/utils/Java_WiimoteAdapter");
jclass adapter_class = env->FindClass("org/dolphinemu/dolphinemu/utils/WiimoteAdapter");
s_adapter_class = reinterpret_cast<jclass>(env->NewGlobalRef(adapter_class));
}
} // namespace WiimoteReal

View File

@ -180,14 +180,14 @@ static void ReadThreadFunc()
bool first_read = true;
JNIEnv* const env = IDCache::GetEnvForThread();
const jfieldID payload_field = env->GetStaticFieldID(s_adapter_class, "controller_payload", "[B");
const jfieldID payload_field = env->GetStaticFieldID(s_adapter_class, "controllerPayload", "[B");
jobject payload_object = env->GetStaticObjectField(s_adapter_class, payload_field);
auto* const java_controller_payload = reinterpret_cast<jbyteArray*>(&payload_object);
// Get function pointers
const jmethodID getfd_func = env->GetStaticMethodID(s_adapter_class, "GetFD", "()I");
const jmethodID input_func = env->GetStaticMethodID(s_adapter_class, "Input", "()I");
const jmethodID openadapter_func = env->GetStaticMethodID(s_adapter_class, "OpenAdapter", "()Z");
const jmethodID getfd_func = env->GetStaticMethodID(s_adapter_class, "getFd", "()I");
const jmethodID input_func = env->GetStaticMethodID(s_adapter_class, "input", "()I");
const jmethodID openadapter_func = env->GetStaticMethodID(s_adapter_class, "openAdapter", "()Z");
const bool connected = env->CallStaticBooleanMethod(s_adapter_class, openadapter_func);
@ -279,7 +279,7 @@ static void WriteThreadFunc()
int size = 0;
#elif GCADAPTER_USE_ANDROID_IMPLEMENTATION
JNIEnv* const env = IDCache::GetEnvForThread();
const jmethodID output_func = env->GetStaticMethodID(s_adapter_class, "Output", "([B)I");
const jmethodID output_func = env->GetStaticMethodID(s_adapter_class, "output", "([B)I");
#endif
while (s_write_adapter_thread_running.IsSet())
@ -394,7 +394,7 @@ static void ScanThreadFunc()
JNIEnv* const env = IDCache::GetEnvForThread();
const jmethodID queryadapter_func =
env->GetStaticMethodID(s_adapter_class, "QueryAdapter", "()Z");
env->GetStaticMethodID(s_adapter_class, "queryAdapter", "()Z");
while (s_adapter_detect_thread_running.IsSet())
{
@ -456,7 +456,7 @@ void Init()
#elif GCADAPTER_USE_ANDROID_IMPLEMENTATION
JNIEnv* const env = IDCache::GetEnvForThread();
const jclass adapter_class = env->FindClass("org/dolphinemu/dolphinemu/utils/Java_GCAdapter");
const jclass adapter_class = env->FindClass("org/dolphinemu/dolphinemu/utils/GCAdapter");
s_adapter_class = reinterpret_cast<jclass>(env->NewGlobalRef(adapter_class));
#endif