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

0.8.12 #28

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
[![CodeQL](https://github.com/umjammer/rococoa/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/umjammer/rococoa/actions/workflows/codeql-analysis.yml)
![Java](https://img.shields.io/badge/Java-17-b07219)

#  Welcome to Rococoa
# Rococoa

<img alt="rococoa" src="https://github.com/umjammer/rococoa/assets/493908/416ded41-08d0-4360-9163-0c594b1f554a" width="200" />

Rococoa is a generic Java binding to the Mac Objective-C object system. It
Rococoa is a generic Java binding to the Mac Objective-C object system. It
allows the creation and use of Objective-C objects in Java, and the
implementation of Objective-C interfaces in Java.

Expand Down Expand Up @@ -55,7 +55,7 @@ implementation of Objective-C interfaces in Java.
* gamepad
* http://eleccelerator.com/wiki/index.php?title=DualShock_4
* https://github.com/born2snipe/gamepad4j/blob/master/gamepad4j-desktop/src/main/c/macos/Gamepad_macosx.c
* port [hidapi](https://github.com/libusb/hidapi) mac part
* back port [hidapi](https://github.com/libusb/hidapi) mac part
* obj-block
* https://github.com/nativelibs4java/BridJ/
* http://cocoawithlove.com/2009/10/how-blocks-are-implemented-and.html
Expand All @@ -73,8 +73,10 @@ implementation of Objective-C interfaces in Java.

* NSUrl tags (wip)
* obj-block (wip)
* how about panama?
* ~~CIFilter~~ (done)
* CGImage fails around density related
* ~~tall free bridging?~~ none
* ~~`cglib` is mostly [suspended](https://github.com/cglib/cglib#readme)~~
* ~~`cglib` recommends [ByteBuddy](https://bytebuddy.net/) that is based on `asm` same as the `cglib`~~ (done)
* cache classes (ByteBuddy)
Expand All @@ -91,6 +93,8 @@ implementation of Objective-C interfaces in Java.
* ByteBuddy's method interception???
* CGController
* https://stackoverflow.com/a/65999820
* works on 14.3.1
* using block? avoidable?
* activate application
* https://developer.apple.com/documentation/appkit/nsrunningapplication?language=objc
* separate same parts of jna-platform (like jna-platform-extended)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.rococoa</groupId>
<artifactId>rococoa-parent</artifactId>
<version>0.8.10</version>
<version>0.8.12</version>
<packaging>pom</packaging>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion rococoa-cocoa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>org.rococoa</groupId>
<artifactId>rococoa-parent</artifactId>
<version>0.8.10</version>
<version>0.8.12</version>
</parent>

<name>Rococoa Cocoa Mappings</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static NSImage imageWithContentsOfFile(String filename) {
return CLASS.alloc().initWithContentsOfFile(filename);
}

public static NSImage initWithCGImageSize(Pointer/*CGImageRef*/ cgImage, NSSize size) {
public static NSImage initWithCGImageSize(Pointer /* CGImageRef */ cgImage, NSSize size) {
return CLASS.alloc().initWithCGImage_size(cgImage, size);
}

Expand Down Expand Up @@ -200,8 +200,8 @@ public interface _Class extends ObjCClass {
*/
public abstract NSImage initWithPasteboard(NSPasteboard pasteboard);

/** */
public abstract NSImage initWithCGImage_size(Pointer/*CGImageRef*/ cgImage, NSSize size);
/** Creates a new image using the contents of the provided image. */
public abstract NSImage initWithCGImage_size(Pointer /* CGImageRef */ cgImage, NSSize size);

/**
* <i>native declaration : :88</i><br>
Expand Down Expand Up @@ -514,7 +514,7 @@ public void drawInRect(NSRect rect, NSRect fromRect, int operation, double delta
public abstract void setTemplate(boolean isTemplate);

/** */
public abstract Pointer/*CGImageRef*/ CGImageForProposedRect_context_hints(
public abstract Pointer /* CGImageRef */ CGImageForProposedRect_context_hints(
Structure.ByReference proposedDestRect,
NSGraphicsContext referenceContext,
NSDictionary hints);
Expand Down
2 changes: 1 addition & 1 deletion rococoa-contrib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>org.rococoa</groupId>
<artifactId>rococoa-parent</artifactId>
<version>0.8.10</version>
<version>0.8.12</version>
</parent>

<name>Rococoa Contrib</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ public interface _Class extends ObjCClass {
CIContext contextWithOptions(NSDictionary options);
}

public abstract Pointer/*CGImageRef*/ createCGImage_fromRect(CIImage image, CGRect fromRect);
/** Creates a Quartz 2D image from a region of a Core Image image object. */
public abstract Pointer /* CGImageRef */ createCGImage_fromRect(CIImage image, CGRect fromRect);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2024 by Naohide Sano, All rights reserved.
*
* Programmed by Naohide Sano
*/

package org.rococoa.cocoa.gamecontroller;

import java.util.Arrays;
import java.util.List;

import com.sun.jna.Structure;


/**
* A three-dimensional acceleration vector.
*
* @author <a href="mailto:umjammer@gmail.com">Naohide Sano</a> (nsano)
* @version 0.00 2024-03-28 nsano initial version <br>
*/
public class GCAcceleration extends Structure {

/** The acceleration measurement along the x-axis, in multiples of earth’s gravity. */
public double x;
/** The acceleration measurement along the y-axis, in multiples of earth’s gravity. */
public double y;
/** The acceleration measurement along the z-axis, in multiples of earth’s gravity. */
public double z;

@Override
protected List<String> getFieldOrder() {
return Arrays.asList("x", "y", "z");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2024 by Naohide Sano, All rights reserved.
*
* Programmed by Naohide Sano
*/

package org.rococoa.cocoa.gamecontroller;

import java.util.logging.Logger;

import org.rococoa.ObjCClass;
import org.rococoa.Rococoa;
import org.rococoa.cocoa.foundation.NSObject;


/**
* The colored light on a device.
*
* @author <a href="mailto:umjammer@gmail.com">Naohide Sano</a> (nsano)
* @version 0.00 2024-03-27 nsano initial version <br>
*/
public abstract class GCColor extends NSObject {

static {
GameControllerLibrary.library.toString();
}

private static final Logger logger = Logger.getLogger(GCColor.class.getName());

public static final _Class CLASS = Rococoa.createClass("GCDeviceLight", _Class.class);

public interface _Class extends ObjCClass {
GCColor alloc();
}

/** Creates a color with the specified red, green, and blue values. */
public abstract GCColor initWithRed_green_blue(float red, float green, float blue);

/** The normalized value of the red component ranging from 0 to 1. */
public abstract float red();

/** The normalized value of the green component ranging from 0 to 1. */
public abstract float green();

/** The normalized value of the blue component ranging from 0 to 1. */
public abstract float blue();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.List;
import java.util.logging.Logger;

import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinDef.BOOL;
import org.rococoa.ObjCClass;
import org.rococoa.Rococoa;
import org.rococoa.cocoa.foundation.NSArray;
Expand All @@ -34,16 +36,20 @@ public abstract class GCController extends NSObject {
public static final _Class CLASS = Rococoa.createClass("GCController", _Class.class);

public interface _Class extends ObjCClass {
NSArray controllers();
GCController alloc();
NSArray controllers();
boolean supportsHIDDevice(Pointer /* IOHIDDeviceRef */ device);
}

public abstract GCController init();

/** A notification that posts when a controller becomes the current controller. */
public static final String GCControllerDidConnectNotification = "GCControllerDidConnectNotification";

public static final String GCControllerDidDisconnectNotification = "GCControllerDidDisconnectNotification";
/** A notification that posts when a controller stops being the current controller. */
public static final String GCControllerDidDisconnectNotification = "GCControllerDidDisconnectNotification";

/** Returns cast ready controllers list. */
public static List<GCController> controllers() {
List<GCController> result = new ArrayList<>();
NSArray a = GCController.CLASS.controllers();
Expand All @@ -53,4 +59,20 @@ public static List<GCController> controllers() {
}
return result;
}

/** Returns the connected controllers for the device. */
public abstract GCExtendedGamepad extendedGamepad();

/** The most recently used game controller. */
public abstract GCController current();

/** The motion input profile. */
public abstract GCMotion motion();

/** The controller’s battery information. */
public abstract GCDeviceBattery battery();
/** The controller’s haptics information. */
public abstract GCDeviceHaptics haptics();
/** The controller’s light settings. */
public abstract GCDeviceLight light();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2024 by Naohide Sano, All rights reserved.
*
* Programmed by Naohide Sano
*/

package org.rococoa.cocoa.gamecontroller;

import java.util.logging.Logger;

import org.rococoa.ID;
import org.rococoa.ObjCBlock;
import org.rococoa.ObjCBlocks.BlockLiteral;
import org.rococoa.ObjCClass;
import org.rococoa.Rococoa;


/**
* GCControllerAxisInput.
*
* @author <a href="mailto:umjammer@gmail.com">Naohide Sano</a> (nsano)
* @version 0.00 2024-03-27 nsano initial version <br>
*/
public abstract class GCControllerAxisInput extends GCControllerElement {

static {
GameControllerLibrary.library.toString();
}

private static final Logger logger = Logger.getLogger(GCControllerAxisInput.class.getName());

public static final _Class CLASS = Rococoa.createClass("GCControllerAxisInput", _Class.class);

public interface _Class extends ObjCClass {
GCControllerAxisInput alloc();
}

public abstract GCControllerAxisInput init();

// Accessing the input values

/** The current value of the axis. */
public abstract float value();

/** Sets the normalized value of the axis. */
public abstract void setValue(float value);

// Getting change information

/** The block that the element calls when the user changes the axis value. */
public abstract BlockLiteral /* GCControllerAxisValueChangedHandler */ valueChangedHandler();
public abstract void setValueChangedHandler(BlockLiteral /* GCControllerAxisValueChangedHandler */ handler);
/** The signature for the block that executes when the user changes the axis value. */
public interface GCControllerAxisValueChangedHandler extends ObjCBlock {
void callback(BlockLiteral literal, ID /* GCControllerAxisInput */ axis, float value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2024 by Naohide Sano, All rights reserved.
*
* Programmed by Naohide Sano
*/

package org.rococoa.cocoa.gamecontroller;

import java.util.logging.Logger;

import org.rococoa.ID;
import org.rococoa.ObjCBlock;
import org.rococoa.ObjCBlocks.BlockLiteral;
import org.rococoa.ObjCClass;
import org.rococoa.Rococoa;


/**
* GCControllerButtonInput.
*
* @author <a href="mailto:umjammer@gmail.com">Naohide Sano</a> (nsano)
* @version 0.00 2024-03-27 nsano initial version <br>
*/
public abstract class GCControllerButtonInput extends GCControllerElement {

static {
GameControllerLibrary.library.toString();
}

private static final Logger logger = Logger.getLogger(GCControllerButtonInput.class.getName());

public static final _Class CLASS = Rococoa.createClass("GCControllerButtonInput", _Class.class);

public interface _Class extends ObjCClass {
GCControllerButtonInput alloc();
}

public abstract GCControllerButtonInput init();

/** A Boolean value that indicates whether the user is touching the button. */
public abstract boolean touched();
/** A Boolean value that indicates whether the user is pressing the button. */
public abstract boolean pressed();
/** The level of pressure the user is applying to the button. */
public abstract float value();

/** The block that the element calls when the user touches the button. */
public abstract BlockLiteral /* GCControllerButtonTouchedChangedHandler */ touchedChangedHandler();
public abstract void setTouchedChangedHandler(BlockLiteral /* GCControllerButtonTouchedChangedHandler */ handler);
/** The signature for the block that executes when the user touches the button if the controller supports that feature. */
public interface GCControllerButtonTouchedChangedHandler extends ObjCBlock {
void callbak(BlockLiteral literal, ID /* GCControllerButtonInput */ button, float value, boolean pressed, boolean touched);
}
/** The block that the element calls when the user presses or releases the button. */
public abstract BlockLiteral /* GCControllerButtonValueChangedHandler */ pressedChangedHandler();
public abstract void setPressedChangedHandler(BlockLiteral /* GCControllerButtonValueChangedHandler */ handler);
/** The block that the element calls when the user changes the level of pressure on the button. */
public abstract BlockLiteral /* GCControllerButtonValueChangedHandler */ valueChangedHandler();
public abstract void setValueChangedHandler(BlockLiteral /* GCControllerButtonValueChangedHandler */ handler);
/** The signature for the block that executes when a button’s state changes. */
public interface GCControllerButtonValueChangedHandler extends ObjCBlock {
void callbak(BlockLiteral literal, ID /* GCControllerButtonInput */ button, float value, boolean pressed);
}
}
Loading
Loading