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

Improvements to FreeJ2ME's game compatibility by adding some missing classes (redone) #145

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3ee6a3c
javax: microedition: rms: Truncate record IDs to 0 in some cases.
AShiningRay Jun 8, 2022
35cb096
freej2me-lr: Fix rotated pointer coordinates.
AShiningRay Jun 9, 2022
255da6a
javax: io: Implement the javax.microedition.io.file.* classes.
AShiningRay Jun 11, 2022
f34c901
javax: bluetooth: Stub some missing classes and interfaces.
AShiningRay Jun 11, 2022
ac0f2dc
javax: io: Update the file/ folder.
AShiningRay Jun 12, 2022
0522ab4
freej2me: libretro: Make the pointer position calc more readable.
AShiningRay Jun 12, 2022
2086bc4
src: javax: Stub the obex folder.
AShiningRay Jun 12, 2022
f9f113f
javax: bluetooth: Finish the file additions.
AShiningRay Jun 12, 2022
dc1e467
javax: bluetooth: Some cleanups to the files.
AShiningRay Jun 12, 2022
424df51
javax: io: Cleanups to the file/ folder.
AShiningRay Jun 12, 2022
d242d61
src: javax: Minor cleanup on the obex folder.
AShiningRay Jun 12, 2022
30ea5f0
javax: io: More cleanups and adjustments to the file/ folder.
AShiningRay Jun 14, 2022
c14d5c4
javax: obex: More adjustments to the obex files.
AShiningRay Jun 14, 2022
2f6ca2c
javax: bluetooth: Clean up LocalDevice and implement UUID
AShiningRay Jun 14, 2022
4e0cab9
Revert "Truncate record IDs to 0 in some cases."
AShiningRay Jun 22, 2022
08f6a91
javax: bluetooth: UUID: Fix some uuid conversion problems.
AShiningRay Jun 28, 2022
c40e573
javax: bluetooth: UUID: Improve the code with a few ideas.
AShiningRay Jun 29, 2022
bcd09cc
javax: bluetooth: UUID: Fixing a small typo.
AShiningRay Jun 29, 2022
25da782
javax: bluetooth: UUID: Clearing an empty line at the start.
AShiningRay Jun 29, 2022
805b073
Revert "freej2me: libretro: Make the pointer position calc more reada…
AShiningRay Jun 29, 2022
5dda662
Revert "freej2me-lr: Fix rotated pointer coordinates."
AShiningRay Jun 29, 2022
83fe551
javax: bluetooth: UUID: Fixing one of the UUID constructors.
AShiningRay Jun 30, 2022
929af84
javax: bluetooth: UUID: Adjusting the UUID variables' types.
AShiningRay Jul 1, 2022
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
30 changes: 30 additions & 0 deletions src/javax/bluetooth/DeviceClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
This file is part of FreeJ2ME.

FreeJ2ME is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

FreeJ2ME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with FreeJ2ME. If not, see http://www.gnu.org/licenses/
*/
package javax.bluetooth;

public class DeviceClass
{

public DeviceClass(int record) { System.out.println("DeviceClass record:" + record); }

public int getMajorDeviceClass() { return 0x200; }

public int getMinorDeviceClass() { return 0x04; }

public int getServiceClasses() { return 0x22000 | 0x100000; }

}
44 changes: 44 additions & 0 deletions src/javax/bluetooth/DiscoveryAgent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
This file is part of FreeJ2ME.

FreeJ2ME is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

FreeJ2ME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with FreeJ2ME. If not, see http://www.gnu.org/licenses/
*/
package javax.bluetooth;

public class DiscoveryAgent
{

public static final int CACHED = 0x00;

public static final int GIAC = 0x9E8B33;

public static final int LIAC = 0x9E8B00;

public static final int NOT_DISCOVERABLE = 0x00;

public static final int PREKNOWN = 0x01;

public boolean cancelInquiry(DiscoveryListener listener) { return false; }

public boolean cancelServiceSearch(int transID) { return false; }

public RemoteDevice[] retrieveDevices(int option) { return null; }

public int searchServices(int[] attrSet, UUID[] uuidSet, RemoteDevice btDev, DiscoveryListener discListener) { return 0; }

public String selectService(UUID uuid, int security, boolean master) { return null; }

public boolean startInquiry(int accessCode, DiscoveryListener listener) { return false; }

}
46 changes: 46 additions & 0 deletions src/javax/bluetooth/DiscoveryListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
This file is part of FreeJ2ME.

FreeJ2ME is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

FreeJ2ME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with FreeJ2ME. If not, see http://www.gnu.org/licenses/
*/
package javax.bluetooth;

public interface DiscoveryListener
{

static final int INQUIRY_COMPLETED = 0x00;

static final int INQUIRY_ERROR = 0x07;

static final int INQUIRY_TERMINATED = 0x05;

static final int SERVICE_SEARCH_COMPLETED = 0x01;

static final int SERVICE_SEARCH_DEVICE_NOT_REACHABLE = 0x06;

static final int SERVICE_SEARCH_ERROR = 0x03;

static final int SERVICE_SEARCH_NO_RECORDS = 0x04;

static final int SERVICE_SEARCH_TERMINATED = 0x02;

void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod);

void inquiryCompleted(int discType);

void servicesDiscovered(int transID, ServiceRecord[] servRecord);

void serviceSearchCompleted(int transID, int respCode);

}
41 changes: 41 additions & 0 deletions src/javax/bluetooth/L2CAPConnection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
This file is part of FreeJ2ME.

FreeJ2ME is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

FreeJ2ME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with FreeJ2ME. If not, see http://www.gnu.org/licenses/
*/
package javax.bluetooth;

import java.io.IOException;
import java.io.InterruptedIOException;

import javax.microedition.io.Connection;

public interface L2CAPConnection extends Connection
{

static final int DEFAULT_MTU = 0x02A0;

static final int MINIMUM_MTU = 0x30;

int getTransmitMTU() throws IOException;

int getReceiveMTU() throws IOException;

void send(byte[] data) throws IOException, NullPointerException;

int receive(byte[] inBuf) throws IOException, NullPointerException, InterruptedIOException;

boolean ready() throws IOException;

}
28 changes: 28 additions & 0 deletions src/javax/bluetooth/L2CAPConnectionNotifier.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
This file is part of FreeJ2ME.

FreeJ2ME is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

FreeJ2ME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with FreeJ2ME. If not, see http://www.gnu.org/licenses/
*/
package javax.bluetooth;

import java.io.IOException;

import javax.microedition.io.Connection;

public interface L2CAPConnectionNotifier extends Connection
{

L2CAPConnection acceptAndOpen() throws IOException, ServiceRegistrationException, BluetoothStateException;

}
74 changes: 74 additions & 0 deletions src/javax/bluetooth/LocalDevice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
This file is part of FreeJ2ME.

FreeJ2ME is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

FreeJ2ME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with FreeJ2ME. If not, see http://www.gnu.org/licenses/
*/
package javax.bluetooth;

import javax.microedition.io.Connection;

import java.util.Hashtable;

import javax.obex.SessionNotifier;

public class LocalDevice
{

private static LocalDevice locDevc;

private static DiscoveryAgent disAgnt;

private static DeviceClass devcCls;

private static ServiceRecord srvcRcd;

private static Hashtable<String, String> properties = new Hashtable<String, String>();

static
{ /* We won't have functional Bluetooth yet */
properties.put("bluetooth.api.version", "0.0");
properties.put("bluetooth.master.switch", "false");
properties.put("bluetooth.sd.attr.retrievable.max", "0");
properties.put("bluetooth.connected.devices.max", "0");
properties.put("bluetooth.l2cap.receiveMTU.max", "0");
properties.put("bluetooth.sd.trans.max", "0");
properties.put("bluetooth.connected.inquiry.scan", "false");
properties.put("bluetooth.connected.page.scan", "false");
properties.put("bluetooth.connected.inquiry", "false");
properties.put("bluetooth.connected.page", "false");
}

public static String getBluetoothAddress() throws BluetoothStateException { return "000000000000"; }

public static DeviceClass getDeviceClass() { return devcCls; }

public static int getDiscoverable() { return DiscoveryAgent.NOT_DISCOVERABLE; }

public static DiscoveryAgent getDiscoveryAgent() { return disAgnt; }

public static String getFriendlyName() { return "noDevice"; }

public static LocalDevice getLocalDevice() throws BluetoothStateException { return locDevc; }

public static String getProperty(String property) { return properties.get(property); }

public static ServiceRecord getRecord(Connection notifier) throws IllegalArgumentException, NullPointerException { return srvcRcd; }

public static boolean isPowerOn() { return false; }

public static boolean setDiscoverable(int mode) throws IllegalArgumentException, BluetoothStateException { return false; }

public static void updateRecord(ServiceRecord srvRecord) throws NullPointerException, IllegalArgumentException, ServiceRegistrationException { }

}
83 changes: 83 additions & 0 deletions src/javax/bluetooth/UUID.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
This file is part of FreeJ2ME.

FreeJ2ME is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

FreeJ2ME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with FreeJ2ME. If not, see http://www.gnu.org/licenses/
*/
package javax.bluetooth;

public class UUID
{

private static final long[] baseUUID = { 0x0000_0000L, 0x0000_1000L, 0x8000_0080L, 0x5F9B_34FBL };

private long[] UUIDval = { 0x0000_0000L, 0x0000_0000L, 0x0000_0000L, 0x0000_0000L };


public UUID(long uuidValue) throws IllegalArgumentException
{
if (uuidValue < 0L || uuidValue > 0xffffffffL) { throw new IllegalArgumentException("Invalid UUID Value, must be between 0 an (2^32)-1"); }
else
{
UUIDval[0] = uuidValue;
UUIDval[1] = baseUUID[1];
UUIDval[2] = baseUUID[2];
UUIDval[3] = baseUUID[3];
}
}

public UUID(String uuidValue, boolean shortUUID) throws IllegalArgumentException, NullPointerException, NumberFormatException
{
int length = uuidValue.length();

if(length == 0 || length > 32 || (shortUUID && length > 8) )
{
throw new IllegalArgumentException("Received an UUID with invalid length.");
}

if (shortUUID)
{
String formattedUuidValue = String.format("%1$" + 8 + "s", uuidValue).replace(' ', '0');
UUIDval[0] = Long.parseUnsignedLong(formattedUuidValue, 16);
UUIDval[1] = baseUUID[1];
UUIDval[2] = baseUUID[2];
UUIDval[3] = baseUUID[3];
}
else
{
String formattedUuidValue = String.format("%1$" + 32 + "s", uuidValue).replace(' ', '0');
UUIDval[0] = Long.parseUnsignedLong(formattedUuidValue.substring(0, 8), 16);
UUIDval[1] = Long.parseUnsignedLong(formattedUuidValue.substring(8, 16), 16);
UUIDval[2] = Long.parseUnsignedLong(formattedUuidValue.substring(16, 24), 16);
UUIDval[3] = Long.parseUnsignedLong(formattedUuidValue.substring(24, 32), 16);
}
}

@Override
public boolean equals(Object value)
{
if (value == null || (value instanceof UUID) == false) { return false; }

return ((UUID)value).toString().equals(this.toString());
}

@Override
public int hashCode() { return (int)(UUIDval[0] & 0xFFFFFFFF); }

@Override
public String toString()
{
String uuidString = String.format("%08X", UUIDval[0]) + String.format("%08X", UUIDval[1]) + String.format("%08X", UUIDval[2]) + String.format("%08X", UUIDval[3]);
return uuidString.replaceFirst("^0+", "");
}
}
26 changes: 26 additions & 0 deletions src/javax/microedition/io/file/ConnectionClosedException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
This file is part of FreeJ2ME.

FreeJ2ME is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

FreeJ2ME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with FreeJ2ME. If not, see http://www.gnu.org/licenses/
*/
package javax.microedition.io.file;

public class ConnectionClosedException extends RuntimeException
{

public ConnectionClosedException() { }

public ConnectionClosedException(String detailMessage) { System.out.println("ConnectionClosedException: " + detailMessage); }

}
Loading