Skip to content

Commit

Permalink
update prep for 1.0.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
electronstudio committed Mar 26, 2020
1 parent 65dc685 commit af85788
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 30 deletions.
20 changes: 10 additions & 10 deletions build.gradle
@@ -1,4 +1,4 @@
apply plugin: "java"
apply plugin: "java-library"

buildscript{
repositories {
Expand All @@ -16,7 +16,7 @@ apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'


//group = 'com.github.WilliamAHartman'


sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand All @@ -36,9 +36,9 @@ repositories {
}

dependencies {
compile "com.badlogicgames.gdx:gdx-jnigen:1.9.10"
compile "com.badlogicgames.gdx:gdx:1.9.9"
compile "com.badlogicgames.gdx:gdx-controllers:1.9.9"
implementation "com.badlogicgames.gdx:gdx-jnigen:1.9.10"
api "com.badlogicgames.gdx:gdx:1.9.10"
api "com.badlogicgames.gdx:gdx-controllers:1.9.10"
}

task deleteJniFolder(type: Delete) {
Expand Down Expand Up @@ -85,7 +85,7 @@ task allNatives(dependsOn: classes, type: JavaExec) {
task uberjar(dependsOn: classes, type: Jar) {
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
//from {configurations.compile.collect {zipTree(it)}}

manifest {
attributes 'Main-Class': 'uk.co.electronstudio.sdl2gdx.tests.SDLTest'
Expand Down Expand Up @@ -147,7 +147,7 @@ publishing {
}
groupId 'uk.co.electronstudio.sdl2gdx'
artifactId 'sdl2gdx'
version '1.0.3-jimbly'
version '1.0.4-beta2'

pom.withXml {
def root = asNode()
Expand Down Expand Up @@ -180,10 +180,10 @@ bintray {
licenses = ["GPL-2.0+CE"]
vcsUrl = 'https://github.com/electronstudio/sdl2gdx.git'
version {
name = '1.0.3-jimbly'
desc = '1.0.3-jimbly'
name = '1.0.4-beta2'
desc = '1.0.4-beta2'
released = new Date()
vcsTag = '1.0.3-jimbly'
vcsTag = '1.0.4-beta2'
}
}
}
Expand Down
Binary file modified libs/macosx64/libsdl2gdx64.dylib
Binary file not shown.
Binary file modified libs/windows32/sdl2gdx.dll
Binary file not shown.
Binary file modified libs/windows64/sdl2gdx64.dll
Binary file not shown.
19 changes: 15 additions & 4 deletions src/org/libsdl/SDL.java
Expand Up @@ -7,7 +7,6 @@ final public class SDL {
#include "SDL.h"
SDL_Event event;
*/

static {
Expand Down Expand Up @@ -427,11 +426,17 @@ final public class SDL {



public static native int SDL_PollEvent(); /*
public static native boolean SDL_PollEvent(Event jobj); /*
SDL_Event event;
if (SDL_PollEvent(&event)){
return event.type;
jclass class_Event = env->GetObjectClass(jobj);
jfieldID id_type = env->GetFieldID(class_Event, "type", "I");
jfieldID id_timestamp = env->GetFieldID(class_Event, "timestamp", "I");
env->SetIntField(jobj, id_type, event.type);
env->SetIntField(jobj, id_timestamp, event.common.timestamp);
return JNI_TRUE;
}
return 0;
return JNI_FALSE;
*/

// */
Expand All @@ -440,5 +445,11 @@ final public class SDL {
// return event
// */

public static class Event{
public static int SDL_JOYDEVICEADDED=0x605;
public static int SDL_JOYDEVICEREMOVED=0x606;
public int type;
public int timestamp;
}

}
36 changes: 20 additions & 16 deletions src/uk/co/electronstudio/sdl2gdx/SDL2Controller.java
@@ -1,7 +1,6 @@
package uk.co.electronstudio.sdl2gdx;


import com.badlogic.gdx.controllers.Controller;
import com.badlogic.gdx.controllers.ControllerListener;
import com.badlogic.gdx.controllers.PovDirection;
import com.badlogic.gdx.math.Vector3;
Expand Down Expand Up @@ -48,7 +47,6 @@ public SDL2Controller(SDL2ControllerManager manager, int device_index) throws SD
if (joystick == null && controller == null) throw new SDL_Error();



}

public boolean isConnected() {
Expand Down Expand Up @@ -258,24 +256,30 @@ public boolean rumble(float leftMagnitude, float rightMagnitude, int duration_ms
return joystick.rumble(leftMagnitude, rightMagnitude, duration_ms);
}

public enum PowerLevel{
public enum PowerLevel {
UNKNOWN, EMPTY, LOW, MEDIUM, FULL, WIRED, MAX
}

public PowerLevel getPowerLevel(){
switch (joystick.currentPowerLevel()){
case SDL.SDL_JOYSTICK_POWER_EMPTY: return PowerLevel.EMPTY;
case SDL.SDL_JOYSTICK_POWER_LOW: return PowerLevel.LOW;
case SDL.SDL_JOYSTICK_POWER_MEDIUM: return PowerLevel.MEDIUM;
case SDL.SDL_JOYSTICK_POWER_FULL: return PowerLevel.FULL;
case SDL.SDL_JOYSTICK_POWER_WIRED: return PowerLevel.WIRED;
case SDL.SDL_JOYSTICK_POWER_MAX: return PowerLevel.MAX;
public PowerLevel getPowerLevel() {
switch (joystick.currentPowerLevel()) {
case SDL.SDL_JOYSTICK_POWER_EMPTY:
return PowerLevel.EMPTY;
case SDL.SDL_JOYSTICK_POWER_LOW:
return PowerLevel.LOW;
case SDL.SDL_JOYSTICK_POWER_MEDIUM:
return PowerLevel.MEDIUM;
case SDL.SDL_JOYSTICK_POWER_FULL:
return PowerLevel.FULL;
case SDL.SDL_JOYSTICK_POWER_WIRED:
return PowerLevel.WIRED;
case SDL.SDL_JOYSTICK_POWER_MAX:
return PowerLevel.MAX;
}
return PowerLevel.UNKNOWN;
}

public ControllerType getType(){
if(controller != null) {
public ControllerType getType() {
if (controller != null) {
switch (controller.getType()) {
case SDL_CONTROLLER_TYPE_XBOX360:
return ControllerType.XBOX360;
Expand All @@ -294,16 +298,16 @@ public ControllerType getType(){
return ControllerType.UNKNOWN;
}

public int getPlayerIndex(){
if(controller != null) {
public int getPlayerIndex() {
if (controller != null) {
return controller.getPlayerIndex();
}
return -1;
}


public enum ControllerType {
UNKNOWN, XBOX360, XBOXONE,PS3,PS4,NINTENDO_SWITCH_PRO,VIRTUAL
UNKNOWN, XBOX360, XBOXONE, PS3, PS4, NINTENDO_SWITCH_PRO, VIRTUAL
}

}
20 changes: 20 additions & 0 deletions src/uk/co/electronstudio/sdl2gdx/tests/SDLTest.java
Expand Up @@ -31,6 +31,7 @@ public static void main(String[] args) {

//rumbleExample(controllerManager);
//reflectionExample(controllerManager);
//testEventPoll();


JTabbedPane tabbedPane = new JTabbedPane();
Expand All @@ -42,6 +43,25 @@ public static void main(String[] args) {
}
}

private static void testEventPoll(){
SDL.Event event = new SDL.Event();
event.type = 100;

while(true) {
if(SDL.SDL_PollEvent(event)) {

System.out.println("EVENT TYPE: " + event.type + " time "+event.timestamp);
if(event.type==SDL.Event.SDL_JOYDEVICEADDED){
System.out.println("joydeviceadded");
}
if(event.type==SDL.Event.SDL_JOYDEVICEREMOVED){
System.out.println("joydeviceremoved");
}

}
}
}

private static void init() {

//System.setProperty("SDL.input","DIRECT_INPUT");
Expand Down

0 comments on commit af85788

Please sign in to comment.