зеркало из https://github.com/mono/njb-sharp.git
2005-12-18 Aaron Bockover <aaron@aaronbock.net>
* njb-sharp.mdp: Updated MonoDevelop project * src/njb-sharp.dll.config.in: DLL Map; should remain unused directly in consuming applications for now, but can serve as a template for the end application to use * configure.ac: Added expanded_libdir variable and generate a DLL map * src/Device.cs (Dispose): Only call NJB_Close if Handle is still valid * src/Discoverer.cs: Added a Rescan method which may need to be used for rediscovering potentially new devices. Refreshes the device list cache. Very useful if consuming application also uses HAL for device notification. * src/Makefile.am: Added DeviceId.cs * src/DeviceId.cs: Simple class and static table to perform pre device lookup to verify if a USB device will most likely be supported by libnjb. Lookups to table are performed based on USB vendor and product IDs. This is useful for HAL-based detection, where probing Njb.Discoverer may be costly for each [USB] device in the system. Also maps device names to something more suitable for display. svn path=/trunk/njb-sharp/; revision=54573
This commit is contained in:
Родитель
6a359309a9
Коммит
8e6e943aa8
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,29 @@
|
|||
2005-12-18 Aaron Bockover <aaron@aaronbock.net>
|
||||
|
||||
* njb-sharp.mdp: Updated MonoDevelop project
|
||||
|
||||
* src/njb-sharp.dll.config.in: DLL Map; should remain unused directly
|
||||
in consuming applications for now, but can serve as a template for the
|
||||
end application to use
|
||||
|
||||
* configure.ac: Added expanded_libdir variable and generate a DLL map
|
||||
|
||||
* src/Device.cs (Dispose): Only call NJB_Close if Handle is still valid
|
||||
|
||||
* src/Discoverer.cs: Added a Rescan method which may need to be used
|
||||
for rediscovering potentially new devices. Refreshes the device list
|
||||
cache. Very useful if consuming application also uses HAL for device
|
||||
notification.
|
||||
|
||||
* src/Makefile.am: Added DeviceId.cs
|
||||
|
||||
* src/DeviceId.cs: Simple class and static table to perform "pre" device
|
||||
lookup to verify if a USB device will most likely be supported by libnjb.
|
||||
Lookups to table are performed based on USB vendor and product IDs. This
|
||||
is useful for HAL-based detection, where probing Njb.Discoverer may be
|
||||
costly for each [USB] device in the system. Also maps device names to
|
||||
something more suitable for display.
|
||||
|
||||
2005-12-17 Aaron Bockover <aaron@aaronbock.net>
|
||||
|
||||
* src/Device.cs: Added support for finding the USB bus and file path
|
||||
|
|
|
@ -50,10 +50,16 @@ else
|
|||
AM_CONDITIONAL(BUILD_DOCS, false)
|
||||
fi
|
||||
|
||||
expanded_libdir=`( case $prefix in NONE) prefix=$ac_default_prefix ;; *) ;; esac
|
||||
case $exec_prefix in NONE) exec_prefix=$prefix ;; *) ;; esac
|
||||
eval echo $libdir )`
|
||||
AC_SUBST(expanded_libdir)
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
njb-sharp.pc
|
||||
src/Makefile
|
||||
src/AssemblyInfo.cs
|
||||
src/njb-sharp.dll.config
|
||||
])
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<File name="./src/SongFrame.cs" subtype="Code" buildaction="Compile" />
|
||||
<File name="./src/Utility.cs" subtype="Code" buildaction="Compile" />
|
||||
<File name="./src/DataFile.cs" subtype="Code" buildaction="Compile" />
|
||||
<File name="./src/DeviceId.cs" subtype="Code" buildaction="Compile" />
|
||||
</Contents>
|
||||
<References>
|
||||
<ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
|
||||
|
|
|
@ -146,7 +146,9 @@ namespace Njb
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
NJB_Close(Handle);
|
||||
if(Handle != IntPtr.Zero) {
|
||||
NJB_Close(Handle);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Capture()
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/* -*- Mode: csharp; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: t -*- */
|
||||
/***************************************************************************
|
||||
* DeviceId.cs
|
||||
*
|
||||
* Copyright (C) 2005 Novell
|
||||
* Written by Aaron Bockover (aaron@aaronbock.net)
|
||||
****************************************************************************/
|
||||
|
||||
/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW:
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Njb
|
||||
{
|
||||
public class DeviceId
|
||||
{
|
||||
private static DeviceId [] device_id_list = {
|
||||
new DeviceId("Creative Nomad Jukebox", "Nomad Jukebox", 0x0471, 0x0222),
|
||||
new DeviceId("Creative Nomad Jukebox 2", "Nomad Jukebox", 0x041e, 0x4100),
|
||||
new DeviceId("Creative Nomad Jukebox 3", "Nomad Jukebox", 0x041e, 0x4101),
|
||||
new DeviceId("Creative Nomad Jukebox Zen", "Zen Jukebox", 0x041e, 0x4108),
|
||||
new DeviceId("Creative Nomad Jukebox Zen USB 2.0", "Zen Jukebox", 0x041e, 0x410b),
|
||||
new DeviceId("Creative Nomad Jukebox Zen NX", "Zen NX Jukebox", 0x041e, 0x4109),
|
||||
new DeviceId("Creative Nomad Jukebox Zen Xtra", "Zen Xtra Jukebox", 0x041e, 0x4110),
|
||||
new DeviceId("Dell Digital Jukebox", "Dell Jukebox", 0x041e, 0x4111),
|
||||
new DeviceId("Creative Nomad Jukebox Zen Touch", "Nomad Jukebox", 0x041e, 0x411b),
|
||||
new DeviceId("Creative Zen (Zen Micro variant)", "Zen Micro", 0x041e, 0x411d),
|
||||
new DeviceId("Creative Nomad Jukebox Zen Micro", "Zen Micro", 0x041e, 0x411e),
|
||||
new DeviceId("Second Generation Dell Digital Jukebox", "Dell Jukebox", 0x041e, 0x4126),
|
||||
new DeviceId("Dell Pocket DJ", "Dell Pocket DJ", 0x041e, 0x4127),
|
||||
new DeviceId("Creative Zen Sleek", "Zen Sleek", 0x041e, 0x4136)
|
||||
};
|
||||
|
||||
public static DeviceId [] ListAll {
|
||||
get {
|
||||
return device_id_list;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsNjbDevice(short vendorId, short productId)
|
||||
{
|
||||
return GetDeviceId(vendorId, productId) != null;
|
||||
}
|
||||
|
||||
public static DeviceId GetDeviceId(short vendorId, short productId)
|
||||
{
|
||||
foreach(DeviceId id in ListAll) {
|
||||
if(id.VendorId == vendorId && id.ProductId == productId) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string name;
|
||||
private string display_name;
|
||||
private short vendor_id;
|
||||
private short product_id;
|
||||
|
||||
private DeviceId(string name, string displayName, short vendorId, short productId)
|
||||
{
|
||||
this.name = name;
|
||||
this.display_name = displayName;
|
||||
this.vendor_id = vendorId;
|
||||
this.product_id = productId;
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public string DisplayName {
|
||||
get {
|
||||
return display_name;
|
||||
}
|
||||
}
|
||||
|
||||
public short VendorId {
|
||||
get {
|
||||
return vendor_id;
|
||||
}
|
||||
}
|
||||
|
||||
public short ProductId {
|
||||
get {
|
||||
return product_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -45,11 +45,15 @@ namespace Njb
|
|||
private Device [] devices;
|
||||
|
||||
public Discoverer()
|
||||
{
|
||||
Global.Unicode = true;
|
||||
Rescan();
|
||||
}
|
||||
|
||||
public void Rescan()
|
||||
{
|
||||
int count;
|
||||
|
||||
Global.Unicode = true;
|
||||
|
||||
if(NJB_Discover(NJB_Glue_Get_Device_Array(), 0, out count) == -1) {
|
||||
throw new ApplicationException("Could not run NJB Discover");
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ DOC_ASSEMBLER = @MDASSEMBLER@ --out njb-sharp-docs --ecma
|
|||
|
||||
njbdir = $(prefix)/lib/njb-sharp
|
||||
njb_SCRIPTS = $(ASSEMBLY) $(ASSEMBLY).mdb
|
||||
njb_DATA = $(ASSEMBLY).config
|
||||
njb_LTLIBRARIES = libnjbglue.la
|
||||
|
||||
noinst_DATA = $(TESTASM)
|
||||
|
@ -20,6 +21,7 @@ libnjbglue_la_LIBADD = $(NJB_LIBS)
|
|||
ASSEMBLY_SOURCES = \
|
||||
$(srcdir)/Discoverer.cs \
|
||||
$(srcdir)/Device.cs \
|
||||
$(srcdir)/DeviceId.cs \
|
||||
$(srcdir)/DataFile.cs \
|
||||
$(srcdir)/Song.cs \
|
||||
$(srcdir)/SongFrame.cs \
|
||||
|
@ -64,7 +66,8 @@ EXTRA_DIST = \
|
|||
$(srcdir)/en/*.xml \
|
||||
$(srcdir)/en/*/*.xml \
|
||||
njb-sharp-docs.source \
|
||||
AssemblyInfo.cs.in
|
||||
AssemblyInfo.cs.in \
|
||||
$(ASSEMBLY).config.in
|
||||
|
||||
CLEANFILES = $(ASSEMBLY) $(TESTASM) *.mdb
|
||||
DISTCLEANFILES = Makefile.in njb-sharp-docs.zip njb-sharp-docs.tree
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<configuration>
|
||||
<dllmap dll="libnjb" target="libnjb.so.5.1.0" />
|
||||
<dllmap dll="libusb" target="libusb-0.1.so.4.4.2" />
|
||||
<dllmap dll="libusb" target="@expanded_libdir@/@PACKAGE@/libnjbglue.so" />
|
||||
</configuration>
|
||||
|
Загрузка…
Ссылка в новой задаче