Skip to content

Commit b24c254

Browse files
committed
Expose Framework Laptop 16 input module physical position
Introduce `FrameworkInputModulePosition` enum to describe the physical slot of input-deck modules on the Framework Laptop 16. This position information is now included in `FrameworkModuleDescriptorSnapshot`, providing more granular context for module identification and placement.
1 parent 3b483e8 commit b24c254

3 files changed

Lines changed: 61 additions & 3 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
namespace FrameworkDotnet.Enums;
2+
3+
/// <summary>
4+
/// Represents the physical position of an input-deck module on Framework Laptop 16 (the 8-wide input-deck MUX).
5+
/// Mirrors the native input-deck slots; <see cref="Unknown"/> for any module that is not input-deck-mounted or on
6+
/// platforms that do not report a deck position.
7+
/// </summary>
8+
public enum FrameworkInputModulePosition : ushort
9+
{
10+
/// <summary>Not an input-deck-mounted module, or the platform reports no deck position.</summary>
11+
Unknown = 0,
12+
13+
/// <summary>Top-row slot 0 (far left).</summary>
14+
TopRow0 = 1,
15+
16+
/// <summary>Top-row slot 1.</summary>
17+
TopRow1 = 2,
18+
19+
/// <summary>Top-row slot 2.</summary>
20+
TopRow2 = 3,
21+
22+
/// <summary>Top-row slot 3.</summary>
23+
TopRow3 = 4,
24+
25+
/// <summary>Top-row slot 4 (far right).</summary>
26+
TopRow4 = 5,
27+
28+
/// <summary>Touchpad in the lower section.</summary>
29+
Touchpad = 6,
30+
31+
/// <summary>The hub board all input modules connect through.</summary>
32+
HubBoard = 7,
33+
}

framework-dotnet/Generated/FrameworkModuleDescriptor.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,24 @@ internal readonly ManagedModuleDescriptorSnapshot ToManagedSnapshot()
1818
(FrameworkDotnet.Enums.FrameworkModuleFlags)flags,
1919
vendor_id,
2020
product_id,
21-
board_id);
21+
board_id,
22+
ToManagedPosition());
23+
}
24+
25+
private readonly FrameworkDotnet.Enums.FrameworkInputModulePosition ToManagedPosition()
26+
{
27+
return position switch
28+
{
29+
FrameworkInputModulePosition.Unknown => FrameworkDotnet.Enums.FrameworkInputModulePosition.Unknown,
30+
FrameworkInputModulePosition.TopRow0 => FrameworkDotnet.Enums.FrameworkInputModulePosition.TopRow0,
31+
FrameworkInputModulePosition.TopRow1 => FrameworkDotnet.Enums.FrameworkInputModulePosition.TopRow1,
32+
FrameworkInputModulePosition.TopRow2 => FrameworkDotnet.Enums.FrameworkInputModulePosition.TopRow2,
33+
FrameworkInputModulePosition.TopRow3 => FrameworkDotnet.Enums.FrameworkInputModulePosition.TopRow3,
34+
FrameworkInputModulePosition.TopRow4 => FrameworkDotnet.Enums.FrameworkInputModulePosition.TopRow4,
35+
FrameworkInputModulePosition.Touchpad => FrameworkDotnet.Enums.FrameworkInputModulePosition.Touchpad,
36+
FrameworkInputModulePosition.HubBoard => FrameworkDotnet.Enums.FrameworkInputModulePosition.HubBoard,
37+
_ => FrameworkDotnet.Enums.FrameworkInputModulePosition.Unknown,
38+
};
2239
}
2340

2441
private readonly FrameworkDotnet.Enums.FrameworkModuleIdentity ToManagedIdentity()

framework-dotnet/Snapshots/FrameworkModuleDescriptorSnapshot.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public sealed record FrameworkModuleDescriptorSnapshot
2222
/// <param name="vendorId">The observed vendor ID, when available.</param>
2323
/// <param name="productId">The observed product ID, when available.</param>
2424
/// <param name="boardId">The board-specific numeric identifier, when available.</param>
25-
public FrameworkModuleDescriptorSnapshot(FrameworkModuleIdentity identity, FrameworkModuleBus bus, FrameworkModuleSlotKind slotKind, FrameworkModuleConfidence confidence, bool isPresent, int slotIndex, FrameworkModuleFlags flags, uint vendorId, uint productId, int boardId)
25+
/// <param name="position">The physical input-deck position, when the module is input-deck-mounted.</param>
26+
public FrameworkModuleDescriptorSnapshot(FrameworkModuleIdentity identity, FrameworkModuleBus bus, FrameworkModuleSlotKind slotKind, FrameworkModuleConfidence confidence, bool isPresent, int slotIndex, FrameworkModuleFlags flags, uint vendorId, uint productId, int boardId, FrameworkInputModulePosition position = FrameworkInputModulePosition.Unknown)
2627
{
2728
Identity = identity;
2829
Bus = bus;
@@ -34,6 +35,7 @@ public FrameworkModuleDescriptorSnapshot(FrameworkModuleIdentity identity, Frame
3435
VendorId = vendorId;
3536
ProductId = productId;
3637
BoardId = boardId;
38+
Position = position;
3739
}
3840

3941
/// <summary>
@@ -86,8 +88,14 @@ public FrameworkModuleDescriptorSnapshot(FrameworkModuleIdentity identity, Frame
8688
/// </summary>
8789
public int BoardId { get; init; }
8890

91+
/// <summary>
92+
/// Gets the physical input-deck position (Framework Laptop 16), or
93+
/// <see cref="FrameworkInputModulePosition.Unknown"/> for modules that are not input-deck-mounted.
94+
/// </summary>
95+
public FrameworkInputModulePosition Position { get; init; }
96+
8997
public override string ToString()
9098
{
91-
return $"Module Descriptor: Identity: {Identity}, Present: {IsPresent}, Slot Kind: {SlotKind}, Slot Index: {SlotIndex.ToString(CultureInfo.InvariantCulture)}, Bus: {Bus}, Confidence: {Confidence}, Flags: {Flags}, Vendor ID: 0x{VendorId.ToString("X", CultureInfo.InvariantCulture)}, Product ID: 0x{ProductId.ToString("X", CultureInfo.InvariantCulture)}, Board ID: {BoardId.ToString(CultureInfo.InvariantCulture)}";
99+
return $"Module Descriptor: Identity: {Identity}, Present: {IsPresent}, Slot Kind: {SlotKind}, Slot Index: {SlotIndex.ToString(CultureInfo.InvariantCulture)}, Position: {Position}, Bus: {Bus}, Confidence: {Confidence}, Flags: {Flags}, Vendor ID: 0x{VendorId.ToString("X", CultureInfo.InvariantCulture)}, Product ID: 0x{ProductId.ToString("X", CultureInfo.InvariantCulture)}, Board ID: {BoardId.ToString(CultureInfo.InvariantCulture)}";
92100
}
93101
}

0 commit comments

Comments
 (0)