Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NI Traktor Kontrol S2 Mk1: add controller mapping #3905

Merged
merged 18 commits into from
Jan 26, 2023

Conversation

leifhelm
Copy link
Contributor

@leifhelm leifhelm commented May 24, 2021

This adds a controller mapping for the Traktor Kontrol S2 Mk1. It is based on the mapping from the Traktor Kontrol S2 Mk2.

Things to do before merge:

  • Add documentation to the manual (#412)

Please give feedback especially if something does not work (as expected).

@uklotzde uklotzde added this to the 2.3.1 milestone May 24, 2021
@uklotzde
Copy link
Contributor

As a First-time contributor we need your consent by formally signing the contributor agreement:

https://docs.google.com/forms/d/e/1FAIpQLScC9QG327sjLL0eWftmfGUasxFFLxg6LCXJ2xHDYRzFIRqyiw/viewform?formkey=dEpYN2NkVEFnWWQzbkFfM0ZYYUZ5X2c6MQ

@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2021

I'm confused... I thought this wasn't an HID device?? Can you post the output of lsusb -v?

@leifhelm
Copy link
Contributor Author

leifhelm commented Jul 18, 2021

It is contains HID device according to lsusb -v. The protocol is very similar to the S2 Mk2. Just a few things got moved around and one message was added.

Output of lsusb -v
Bus 001 Device 003: ID 17cc:1101 Native Instruments Traktor Kontrol S2
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x17cc Native Instruments
  idProduct          0x1101
  bcdDevice            0.1b
  iManufacturer          12 Native Instruments
  iProduct                7 Traktor Kontrol S2
  iSerial                13 55054651
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x00d0
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              480mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass          1 Audio
      bFunctionSubClass       0
      bFunctionProtocol      32
      iFunction               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol     32
      iInterface              7 Traktor Kontrol S2
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               2.00
        bCategory               8
        wTotalLength       0x0048
        bmControls           0x00
      AudioControl Interface Descriptor:
        bLength                 8
        bDescriptorType        36
        bDescriptorSubtype     10 (CLOCK_SOURCE)
        bClockID               40
        bmAttributes            1 Internal fixed clock
        bmControls           0x07
          Clock Frequency Control (read/write)
          Clock Validity Control (read-only)
        bAssocTerminal          0
        iClockSource           26 Internal Clock
      AudioControl Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             2
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bCSourceID             40
        bNrChannels             4
        bmChannelConfig    0x00000000
        iChannelNames          16 Main Left
        bmControls         0x0000
        iTerminal               2 Input
      AudioControl Interface Descriptor:
        bLength                26
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                10
        bSourceID               2
        bmaControls(0)     0x00000000
        bmaControls(1)     0x00000000
        bmaControls(2)     0x00000000
        bmaControls(3)     0x00000000
        bmaControls(4)     0x00000000
        iFeature               15 Output Volume Control
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            20
        wTerminalType      0x0301 Speaker
        bAssocTerminal          0
        bSourceID              10
        bCSourceID             40
        bmControls         0x0000
        iTerminal               5 Audio Output Terminal
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32
      iInterface              8 Traktor Kontrol S2
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           2
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol     32
      iInterface              9 Audio Out Alt
      AudioStreaming Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           2
        bmControls           0x00
        bFormatType             1
        bmFormats          0x00000001
          PCM
        bNrChannels             4
        bmChannelConfig    0x00000000
        iChannelNames          16 Main Left
      AudioStreaming Interface Descriptor:
        bLength                 6
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bSubslotSize            4
        bBitResolution         24
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x00f0  1x 240 bytes
        bInterval               1
        AudioStreaming Endpoint Descriptor:
          bLength                 8
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bmControls           0x00
          bLockDelayUnits         2 Decoded PCM samples
          wLockDelay         0x0008
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes           17
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Feedback
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval               4
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       254 Application Specific Interface
      bInterfaceSubClass      1 Device Firmware Update
      bInterfaceProtocol      1
      iInterface              0
      Device Firmware Upgrade Interface Descriptor:
        bLength                             7
        bDescriptorType                    33
        bmAttributes                        7
          Will Not Detach
          Manifestation Tolerant
          Upload Supported
          Download Supported
        wDetachTimeout                    250 milliseconds
        wTransferSize                      64 bytes
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     614
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  bNumConfigurations      1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)

@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2021

Ah, I think I was confusing this with the S4 Mk1. I think the S2 Mk1 may have been one of the first controllers where NI switched from a Vendor Defined Class for a Bulk endpoint to HID.

@leifhelm
Copy link
Contributor Author

The manual states that it uses a proprietary protocol named NHL.

@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2021

Ah, that explains my confusion. The manufacturer's documentation is incorrect.

@leifhelm leifhelm marked this pull request as ready for review July 19, 2021 17:54
@uklotzde uklotzde added the changelog This PR should be included in the changelog label Sep 7, 2021
@uklotzde
Copy link
Contributor

uklotzde commented Sep 7, 2021

  • Contributor agreement has been signed
  • Manual PR is linked and CI passes

@Be-ing @Holzhaus Include in 2.3.1?

@Be-ing
Copy link
Contributor

Be-ing commented Sep 7, 2021

Let's not delay 2.3.1 further for PRs that haven't started review and get to work reviewing the backlog of mapping PRs for 2.3.2.

@Be-ing Be-ing modified the milestones: 2.3.1, 2.3.2 Sep 7, 2021
@github-actions
Copy link

github-actions bot commented Dec 7, 2021

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions bot added the stale Stale issues that haven't been updated for a long time. label Dec 7, 2021
@daschuer
Copy link
Member

Who is able and has interest to review this?

@github-actions github-actions bot removed the stale Stale issues that haven't been updated for a long time. label Jan 16, 2022
@nPrevail
Copy link

nPrevail commented Mar 8, 2022

Does this need to be tested? I have a S4 MK1 available.

@ronso0 ronso0 modified the milestones: 2.3.2, 2.3.3 May 11, 2022
@shellkjell
Copy link

I'll give this a go and report back with results

@shellkjell
Copy link

I've been using this setup with the S2 "Mk1" for two days now without any issues I can attribute to the mappings themselves.

I'm running Mixxx 2.3.2 on a Raspberry Pi 4

@JoergAtGithub
Copy link
Member

@leifhelm I would like to start with the code review of the S2 Mk1 HID mapping. But before I start, I would like to hear, if you are still available to address findings of the code review?

@leifhelm
Copy link
Contributor Author

Yes :)

@leifhelm
Copy link
Contributor Author

leifhelm commented Jan 21, 2023

I do not like that I hard-coded the thresholds for the jog wheels. I had to adjust both values to get reliable jog wheel touch to work. Maybe it is more nice to measure the value when not pressed at startup. This is also not that nice. I do not know how Traktor solves this problem either.

Copy link
Member

@JoergAtGithub JoergAtGithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are some findings. Either fix them, or explain, why you think it's correct as it is.

res/controllers/Traktor Kontrol S2 Mk1.hid.xml Outdated Show resolved Hide resolved
res/controllers/Traktor-Kontrol-S2-MK1-hid-scripts.js Outdated Show resolved Hide resolved
res/controllers/Traktor-Kontrol-S2-MK1-hid-scripts.js Outdated Show resolved Hide resolved
res/controllers/Traktor-Kontrol-S2-MK1-hid-scripts.js Outdated Show resolved Hide resolved
res/controllers/Traktor-Kontrol-S2-MK1-hid-scripts.js Outdated Show resolved Hide resolved
res/controllers/Traktor-Kontrol-S2-MK1-hid-scripts.js Outdated Show resolved Hide resolved
res/controllers/Traktor-Kontrol-S2-MK1-hid-scripts.js Outdated Show resolved Hide resolved
res/controllers/Traktor-Kontrol-S2-MK1-hid-scripts.js Outdated Show resolved Hide resolved
MessageShort.addControl("[EffectRack1_EffectUnit1]", "group_[Channel2]_enable", 0x0A, "B", 0x08);
MessageShort.addControl("[EffectRack1_EffectUnit2]", "group_[Channel2]_enable", 0x0A, "B", 0x04);

MessageShort.addControl("[Master]", "maximize_library", 0x0E, "B", 0x08, false, this.toggleButton);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which button is mapped here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The browse encoder press

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment in the code, this is not self-explaining

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might also try

if (shift) {
                engine.setValue("[Library]", "sort_column_toggle", 0);
            } else {
                engine.setValue("[Library]", "MoveFocusForward", 1);
            }

instead of maximize_library. This would allow to navigate through the library, and as shifted operation allows to sort by selected library column.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it but it does not work. It just adds a marker around the left or the right window. Nothing more. Should you be able to navigate the left window?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use "[Playlist]", "SelectTrackKnob". Maybe I should be using something like [Library] MoveVertical

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try something like

if (shift) {
            engine.setValue("[Library]", "MoveHorizontal", delta);
        } else {
            engine.setValue("[Library]", "MoveVertical", delta);
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot figure out how to do what I want: Move to the next/prev song without shift and browse the sidebar with shift. There is no way to set a focus, just to set it to the next window 😞.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this feature requires 2.4 work. Here this code snippets work with 2.4. Maybe you can provide a follow-up PR for 2.4 once this is merged.

Copy link
Contributor Author

@leifhelm leifhelm Jan 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes [Library] focus_widget is what i am looking for.

res/controllers/Traktor-Kontrol-S2-MK1-hid-scripts.js Outdated Show resolved Hide resolved
@JoergAtGithub JoergAtGithub modified the milestones: 2.3.3, 2.3.4 Jan 22, 2023
Copy link
Member

@JoergAtGithub JoergAtGithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Please address the open points in mixxxdj/manual#412 too.

@JoergAtGithub
Copy link
Member

  • Mapping code looks good for me
  • A second user confirmed, that the mapping works for him too
  • Manual is in place
    Let's try what happens, if I press the button Merge pull request which I never used before...

@JoergAtGithub JoergAtGithub merged commit 50b780d into mixxxdj:2.3 Jan 26, 2023
@JoergAtGithub
Copy link
Member

@leifhelm Thank you for your contribution and your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog This PR should be included in the changelog controller mappings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants