Fixed compile warnings

This commit is contained in:
Endolf 2018-05-31 19:09:13 +01:00
parent 981587abbc
commit a775a55c46
6 changed files with 167 additions and 220 deletions

View file

@ -1,10 +1,4 @@
/* /*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -35,7 +29,7 @@
* You acknowledge that this software is not designed or intended for us in * You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility * the design, construction, operation or maintenance of any nuclear facility
* *
*****************************************************************************/ */
package net.java.games.input; package net.java.games.input;
import java.util.Map; import java.util.Map;

View file

@ -1,10 +1,4 @@
/* /*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -35,7 +29,7 @@
* You acknowledge that this software is not designed or intended for us in * You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility * the design, construction, operation or maintenance of any nuclear facility
* *
*****************************************************************************/ */
package net.java.games.input; package net.java.games.input;
/** Generic Desktop Usages /** Generic Desktop Usages

View file

@ -1,10 +1,4 @@
/* /*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -35,12 +29,9 @@
* You acknowledge that this software is not designed or intended for us in * You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility * the design, construction, operation or maintenance of any nuclear facility
* *
*****************************************************************************/ */
package net.java.games.input; package net.java.games.input;
import java.util.Map;
import java.util.HashMap;
/** Mapping from Keyboard HID usages to Component.Identifier.Key /** Mapping from Keyboard HID usages to Component.Identifier.Key
* @author elias * @author elias
* @version 1.0 * @version 1.0

View file

@ -104,7 +104,7 @@ final class OSXHIDDevice {
private final long device_address; private final long device_address;
private final long device_interface_address; private final long device_interface_address;
private final Map properties; private final Map<String,?> properties;
private boolean released; private boolean released;
@ -130,7 +130,7 @@ final class OSXHIDDevice {
return (String)properties.get(kIOHIDProductKey); return (String)properties.get(kIOHIDProductKey);
} }
private final OSXHIDElement createElementFromElementProperties(Map element_properties) { private final OSXHIDElement createElementFromElementProperties(Map<String,?> element_properties) {
/* long size = getLongFromProperties(element_properties, kIOHIDElementSizeKey); /* long size = getLongFromProperties(element_properties, kIOHIDElementSizeKey);
// ignore elements that can't fit into the 32 bit value field of a hid event // ignore elements that can't fit into the 32 bit value field of a hid event
if (size > 32) if (size > 32)
@ -161,12 +161,13 @@ final class OSXHIDDevice {
} }
} }
private final void addElements(List elements, Map properties) { @SuppressWarnings("unchecked")
private final void addElements(List<OSXHIDElement> elements, Map<String,?> properties) {
Object[] elements_properties = (Object[])properties.get(kIOHIDElementKey); Object[] elements_properties = (Object[])properties.get(kIOHIDElementKey);
if (elements_properties == null) if (elements_properties == null)
return; return;
for (int i = 0; i < elements_properties.length; i++) { for (int i = 0; i < elements_properties.length; i++) {
Map element_properties = (Map)elements_properties[i]; Map<String,?> element_properties = (Map<String,?>)elements_properties[i];
OSXHIDElement element = createElementFromElementProperties(element_properties); OSXHIDElement element = createElementFromElementProperties(element_properties);
if (element != null) { if (element != null) {
elements.add(element); elements.add(element);
@ -175,28 +176,28 @@ final class OSXHIDDevice {
} }
} }
public final List getElements() { public final List<OSXHIDElement> getElements() {
List elements = new ArrayList(); List<OSXHIDElement> elements = new ArrayList<>();
addElements(elements, properties); addElements(elements, properties);
return elements; return elements;
} }
private final static long getLongFromProperties(Map properties, String key, long default_value) { private final static long getLongFromProperties(Map<String,?> properties, String key, long default_value) {
Long long_obj = (Long)properties.get(key); Long long_obj = (Long)properties.get(key);
if (long_obj == null) if (long_obj == null)
return default_value; return default_value;
return long_obj.longValue(); return long_obj.longValue();
} }
private final static boolean getBooleanFromProperties(Map properties, String key, boolean default_value) { private final static boolean getBooleanFromProperties(Map<String,?> properties, String key, boolean default_value) {
return getLongFromProperties(properties, key, default_value ? 1 : 0) != 0; return getLongFromProperties(properties, key, default_value ? 1 : 0) != 0;
} }
private final static int getIntFromProperties(Map properties, String key) { private final static int getIntFromProperties(Map<String,?> properties, String key) {
return (int)getLongFromProperties(properties, key); return (int)getLongFromProperties(properties, key);
} }
private final static long getLongFromProperties(Map properties, String key) { private final static long getLongFromProperties(Map<String,?> properties, String key) {
Long long_obj = (Long)properties.get(key); Long long_obj = (Long)properties.get(key);
return long_obj.longValue(); return long_obj.longValue();
} }
@ -217,28 +218,6 @@ final class OSXHIDDevice {
return createUsagePair(usage_page_id, usage_id); return createUsagePair(usage_page_id, usage_id);
} }
/*
public final List getUsagePairs() {
List usage_pairs_list = new ArrayList();
Object[] usage_pairs = (Object[])properties.get(kIOHIDDeviceUsagePairsKey);
if (usage_pairs == null) {
int usage_page_id = getIntFromProperties(properties, kIOHIDPrimaryUsagePageKey);
int usage_id = getIntFromProperties(properties, kIOHIDPrimaryUsageKey);
UsagePair pair = createUsagePair(usage_page_id, usage_id);
if (pair != null)
usage_pairs_list.add(pair);
}
for (int i = 0; i < usage_pairs.length; i++) {
Map usage_pair = (Map)usage_pairs[i];
int usage_page_id = getIntFromProperties(usage_pair, kIOHIDDeviceUsagePageKey);
int usage_id = getIntFromProperties(usage_pair, kIOHIDDeviceUsageKey);
UsagePair pair = createUsagePair(usage_page_id, usage_id);
if (pair != null)
usage_pairs_list.add(pair);
}
return usage_pairs_list;
}
*/
private final void dumpProperties() { private final void dumpProperties() {
log.info(toString()); log.info(toString());
dumpMap("", properties); dumpMap("", properties);
@ -253,8 +232,8 @@ final class OSXHIDDevice {
log.info(prefix + "}"); log.info(prefix + "}");
} }
private final static void dumpMap(String prefix, Map map) { private final static void dumpMap(String prefix, Map<String,?> map) {
Iterator keys = map.keySet().iterator(); Iterator<String> keys = map.keySet().iterator();
while (keys.hasNext()) { while (keys.hasNext()) {
Object key = keys.next(); Object key = keys.next();
Object value = map.get(key); Object value = map.get(key);
@ -263,22 +242,23 @@ final class OSXHIDDevice {
} }
} }
@SuppressWarnings("unchecked")
private final static void dumpObject(String prefix, Object obj) { private final static void dumpObject(String prefix, Object obj) {
if (obj instanceof Long) { if (obj instanceof Long) {
Long l = (Long)obj; Long l = (Long)obj;
log.info(prefix + "0x" + Long.toHexString(l.longValue())); log.info(prefix + "0x" + Long.toHexString(l.longValue()));
} else if (obj instanceof Map) } else if (obj instanceof Map)
dumpMap(prefix, (Map)obj); dumpMap(prefix, (Map<String,?>)obj);
else if (obj.getClass().isArray()) else if (obj.getClass().isArray())
dumpArray(prefix, (Object[])obj); dumpArray(prefix, (Object[])obj);
else else
log.info(prefix + obj); log.info(prefix + obj);
} }
private final Map getDeviceProperties() throws IOException { private final Map<String,?> getDeviceProperties() throws IOException {
return nGetDeviceProperties(device_address); return nGetDeviceProperties(device_address);
} }
private final static native Map nGetDeviceProperties(long device_address) throws IOException; private final static native Map<String,?> nGetDeviceProperties(long device_address) throws IOException;
public final synchronized void release() throws IOException { public final synchronized void release() throws IOException {
try { try {

View file

@ -1,10 +1,4 @@
/* /*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -35,7 +29,7 @@
* You acknowledge that this software is not designed or intended for us in * You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility * the design, construction, operation or maintenance of any nuclear facility
* *
*****************************************************************************/ */
package net.java.games.input; package net.java.games.input;
/** Generic Desktop Usages /** Generic Desktop Usages

View file

@ -1,10 +1,4 @@
/* /*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -35,7 +29,7 @@
* You acknowledge that this software is not designed or intended for us in * You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility * the design, construction, operation or maintenance of any nuclear facility
* *
*****************************************************************************/ */
package net.java.games.input; package net.java.games.input;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -77,7 +71,7 @@ final class UsagePage {
/* ReservedPointofSalepages 0x8E - 0X8F */ /* ReservedPointofSalepages 0x8E - 0X8F */
public final static UsagePage CAMERACONTROL= new UsagePage(0x90); /* USB Device Class Definition for Image Class Devices */ public final static UsagePage CAMERACONTROL= new UsagePage(0x90); /* USB Device Class Definition for Image Class Devices */
public final static UsagePage ARCADE = new UsagePage(0x91); /* OAAF Definitions for arcade and coinop related Devices */ public final static UsagePage ARCADE = new UsagePage(0x91); /* OAAF Definitions for arcade and coinop related Devices */
private final Class usage_class; private final Class<? extends Usage> usage_class;
private final int usage_page_id; private final int usage_page_id;
public final static UsagePage map(int page_id) { public final static UsagePage map(int page_id) {
@ -86,7 +80,7 @@ final class UsagePage {
return map[page_id]; return map[page_id];
} }
private UsagePage(int page_id, Class usage_class) { private UsagePage(int page_id, Class<? extends Usage> usage_class) {
map[page_id] = this; map[page_id] = this;
this.usage_class = usage_class; this.usage_class = usage_class;
this.usage_page_id = page_id; this.usage_page_id = page_id;
@ -104,8 +98,8 @@ final class UsagePage {
if (usage_class == null) if (usage_class == null)
return null; return null;
try { try {
Method map_method = usage_class.getMethod("map", new Class[]{int.class}); Method map_method = usage_class.getMethod("map", int.class);
Object result = map_method.invoke(null, new Object[]{new Integer(usage_id)}); Object result = map_method.invoke(null, usage_id);
return (Usage)result; return (Usage)result;
} catch (Exception e) { } catch (Exception e) {
throw new Error(e); throw new Error(e);