| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -24,7 +24,7 @@ | |||
| /** | |||
| Represents an individual block device. | |||
| Represents an individual BLOCKS device. | |||
| */ | |||
| class Block : public juce::ReferenceCountedObject | |||
| { | |||
| @@ -33,67 +33,56 @@ public: | |||
| /** Destructor. */ | |||
| virtual ~Block(); | |||
| /** The Block class is reference-counted, so always use a Block::Ptr to | |||
| keep references to them. | |||
| /** The different block types. | |||
| @see Block::getType() | |||
| */ | |||
| enum Type | |||
| { | |||
| unknown = 0, | |||
| lightPadBlock, | |||
| liveBlock, | |||
| loopBlock, | |||
| developerControlBlock | |||
| }; | |||
| /** The Block class is reference-counted, so always use a Block::Ptr when | |||
| you are keeping references to them. | |||
| */ | |||
| using Ptr = juce::ReferenceCountedObjectPtr<Block>; | |||
| /** The Block class is reference-counted, so Block::Array is a handy array | |||
| type when working with lists of them. | |||
| /** The Block class is reference-counted, so Block::Array is useful when | |||
| you are storing lists of them. | |||
| */ | |||
| using Array = juce::ReferenceCountedArray<Block>; | |||
| /** | |||
| */ | |||
| /** The Block's serial number. */ | |||
| const juce::String serialNumber; | |||
| /** The UID for a Block. */ | |||
| using UID = uint64; | |||
| /** This Block's UID. This will be globally unique, and remains constant for | |||
| a particular device. | |||
| /** This Block's UID. | |||
| This will be globally unique, and remains constant for a particular device. | |||
| */ | |||
| const UID uid; | |||
| /** Preset types of block. | |||
| @see Block::getType() | |||
| */ | |||
| enum Type | |||
| { | |||
| unknown = 0, | |||
| lightPadBlock, | |||
| liveBlock, | |||
| loopBlock, | |||
| developerControlBlock, | |||
| seaboardBlock, | |||
| rotaryDialBlock | |||
| }; | |||
| //============================================================================== | |||
| /** Returns the type of this device. | |||
| /** Returns the type of this device. */ | |||
| @see Block::Type | |||
| */ | |||
| virtual Type getType() const = 0; | |||
| /** Returns a textual description of this device type */ | |||
| /** Returns a human-readable description of this device type. */ | |||
| virtual juce::String getDeviceDescription() const = 0; | |||
| /** Returns the battery level in the range 0 to 1.0 */ | |||
| /** Returns the battery level in the range 0.0 to 1.0. */ | |||
| virtual float getBatteryLevel() const = 0; | |||
| /** Returns true if the battery is currently charging. */ | |||
| /** Returns true if the battery is charging. */ | |||
| virtual bool isBatteryCharging() const = 0; | |||
| //============================================================================== | |||
| /** Returns the width of the device in logical device units. */ | |||
| virtual int getWidth() const = 0; | |||
| /** Returns the height of the device in logical device units. */ | |||
| virtual int getHeight() const = 0; | |||
| /** Returns the length of one logical device unit as physical millimeters. */ | |||
| virtual float getMillimetersPerUnit() const = 0; | |||
| /** Returns true if the device is a physical hardware block (i.e. not a virtual block). */ | |||
| virtual bool isHardwareBlock() const = 0; | |||
| //============================================================================== | |||
| /** Returns true if this block is connected and active. */ | |||
| virtual bool isConnected() const = 0; | |||
| @@ -105,14 +94,20 @@ public: | |||
| */ | |||
| virtual bool isMasterBlock() const = 0; | |||
| /** If this block has a pressure-sensitive surface, this will return an object to | |||
| access its data. | |||
| Note that the pointer returned does is owned by this object, and the caller must | |||
| neither delete it or use it after the lifetime of this Block object has finished. | |||
| If the device is not touch-sensitive, then this method will return nullptr. | |||
| */ | |||
| virtual TouchSurface* getTouchSurface() const = 0; | |||
| //============================================================================== | |||
| /** Returns the width of the device in logical device units. */ | |||
| virtual int getWidth() const = 0; | |||
| /** Returns the height of the device in logical device units. */ | |||
| virtual int getHeight() const = 0; | |||
| /** Returns true if the device is a physical hardware block (i.e. not a virtual block). */ | |||
| virtual bool isHardwareBlock() const = 0; | |||
| /** Returns the length of one logical device unit as physical millimeters. */ | |||
| virtual float getMillimetersPerUnit() const = 0; | |||
| //============================================================================== | |||
| /** If this block has a grid of LEDs, this will return an object to control it. | |||
| Note that the pointer that is returned belongs to this object, and the caller must | |||
| neither delete it or use it after the lifetime of this Block object has finished. | |||
| @@ -133,13 +128,21 @@ public: | |||
| */ | |||
| virtual juce::Array<StatusLight*> getStatusLights() const = 0; | |||
| /** If this block has a pressure-sensitive surface, this will return an object to | |||
| access its data. | |||
| Note that the pointer returned does is owned by this object, and the caller must | |||
| neither delete it or use it after the lifetime of this Block object has finished. | |||
| If the device is not touch-sensitive, then this method will return nullptr. | |||
| */ | |||
| virtual TouchSurface* getTouchSurface() const = 0; | |||
| /** If this block has any control buttons, this will return an array of objects to control them. | |||
| Note that the objects in the array belong to this Block object, and the caller must | |||
| neither delete them or use them after the lifetime of this Block object has finished. | |||
| */ | |||
| virtual juce::Array<ControlButton*> getButtons() const = 0; | |||
| //============================================================================== | |||
| /** This returns true if the block supports generating graphics by drawing into a JUCE | |||
| Graphics context. This should only be true for virtual on-screen blocks; hardware | |||
| blocks will instead use the LED Grid for visuals. | |||
| @@ -200,10 +203,12 @@ public: | |||
| using Timestamp = uint32; | |||
| protected: | |||
| //============================================================================== | |||
| Block (const juce::String& serialNumberToUse); | |||
| juce::ListenerList<DataInputPortListener> dataInputPortListeners; | |||
| private: | |||
| //============================================================================== | |||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Block) | |||
| }; | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -24,7 +24,7 @@ | |||
| /** | |||
| Represents the touch surface of a block device. | |||
| Represents the touch surface of a BLOCKS device. | |||
| */ | |||
| class TouchSurface | |||
| { | |||
| @@ -41,55 +41,62 @@ public: | |||
| int index; | |||
| /** The X position of this touch on the device, in logical units starting from 0 (left). | |||
| See Block::getWidth() for the maximum X value on the device. | |||
| */ | |||
| float x; | |||
| /** An approximation of the velocity at which the X value is changing. | |||
| Measured in units/second. This is intended as a useful hint to help with gesture | |||
| detection, but may be 0 if the device doesn't provide this data. | |||
| /** An approximation of the velocity at which the X value is changing, measured in | |||
| units/second. This is intended as a useful hint to help with gesture detection, but | |||
| may be 0 if the device doesn't provide this data. | |||
| */ | |||
| float xVelocity; | |||
| /** The Y position of this touch on the device, in logical units starting from 0 (top). | |||
| See Block::getHeight() to find the maximum Y on the device. | |||
| */ | |||
| float y; | |||
| /** An approximation of the velocity at which the Y value is changing. | |||
| Measured in units/second. This is intended as a useful hint to help with gesture | |||
| detection, but may be 0 if the device doesn't provide this data. | |||
| /** An approximation of the velocity at which the Y value is changing, measured in | |||
| units/second. This is intended as a useful hint to help with gesture detection, but | |||
| may be 0 if the device doesn't provide this data. | |||
| */ | |||
| float yVelocity; | |||
| /** The current pressure of this touch, in the range 0 (no pressure) to 1 (very hard) */ | |||
| /** The current pressure of this touch, in the range 0.0 (no pressure) to 1.o (very hard). */ | |||
| float z; | |||
| /** The rate at which pressure is currently changing. | |||
| Measured in units/second. This is intended as a useful hint to help with gesture | |||
| detection, but may be 0 if the device doesn't provide this data. | |||
| /** The rate at which pressure is currently changing, measured in units/second. This is | |||
| intended as a useful hint to help with gesture detection, but may be 0 if the device | |||
| doesn't provide this data. | |||
| */ | |||
| float zVelocity; | |||
| /** The timestamp of this event, in milliseconds since the device was booted. */ | |||
| Block::Timestamp eventTimestamp; | |||
| /** True if this is the first event for this finger. */ | |||
| /** True if this is the first event for this finger/index. */ | |||
| bool isTouchStart; | |||
| /** True if this is the final event as this finger is lifted off. */ | |||
| /** True if this is the final event as this finger/index is lifted off. */ | |||
| bool isTouchEnd; | |||
| /** The ID of the block that generated this touch. */ | |||
| Block::UID blockUID; | |||
| /** The initial X position of the touchStart event corresponding to this finger. */ | |||
| /** The initial X position of the touchStart event corresponding to this finger/index. */ | |||
| float startX; | |||
| /** The initial Y position of the touchStart event corresponding to this finger. */ | |||
| /** The initial Y position of the touchStart event corresponding to this finger/index. */ | |||
| float startY; | |||
| }; | |||
| //============================================================================== | |||
| /** Forces a touch-off message for all active touches. */ | |||
| virtual void cancelAllActiveTouches() noexcept = 0; | |||
| //============================================================================== | |||
| /** Receives callbacks when a touch moves or changes pressure. */ | |||
| struct Listener | |||
| { | |||
| @@ -98,30 +105,24 @@ public: | |||
| virtual void touchChanged (TouchSurface&, const Touch&) = 0; | |||
| }; | |||
| /** Adds a listener to be called when there's a change to this surface. */ | |||
| /** Testing feature: this allows you to inject touches onto a touch surface. */ | |||
| void callListenersTouchChanged (const TouchSurface::Touch& t) | |||
| { | |||
| listeners.call (&Listener::touchChanged, *this, t); | |||
| } | |||
| /** Adds a listener to be called when the surface is touched. */ | |||
| void addListener (Listener*); | |||
| /** Removes a previously-registered listener. */ | |||
| void removeListener (Listener*); | |||
| /** For a Seaboard unit, this will return the number of keys. | |||
| For other types of touch-surface, it will return 0. | |||
| */ | |||
| virtual int getNumberOfKeywaves() const = 0; | |||
| //============================================================================== | |||
| /** The block that owns this touch surface. */ | |||
| Block& block; | |||
| /** Testing feature: allows you to inject touches into a touch-surface. */ | |||
| void callListenersTouchChanged (const TouchSurface::Touch& t) | |||
| { | |||
| listeners.call (&Listener::touchChanged, *this, t); | |||
| } | |||
| /** Forces touch-off messages for all active touches. */ | |||
| virtual void cancelAllActiveTouches() noexcept = 0; | |||
| protected: | |||
| //============================================================================== | |||
| juce::ListenerList<Listener> listeners; | |||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TouchSurface) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -1416,11 +1416,6 @@ struct PhysicalTopologySource::Internal | |||
| det->activeTouchSurfaces.removeFirstMatchingValue (this); | |||
| } | |||
| int getNumberOfKeywaves() const noexcept override | |||
| { | |||
| return blockImpl.modelData.numKeywaves; | |||
| } | |||
| void broadcastTouchChange (const TouchSurface::Touch& touchEvent) | |||
| { | |||
| auto& status = touches.getValue (touchEvent); | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||
| @@ -2,7 +2,7 @@ | |||
| ============================================================================== | |||
| This file is part of the JUCE library. | |||
| Copyright (c) 2015 - ROLI Ltd. | |||
| Copyright (c) 2016 - ROLI Ltd. | |||
| Permission is granted to use this software under the terms of either: | |||
| a) the GPL v2 (or any later version) | |||