mbuesch / razer

Razer device library and tools
http://bues.ch/h/razercfg
GNU General Public License v2.0
251 stars 50 forks source link

Mamba 2012 Support #21

Open webgeek1234 opened 10 years ago

webgeek1234 commented 10 years ago

I started trying to add support for my Mamba 2012 (productId 0x0024 / 0x0025) here, but am not able to get very far. I don't have nor want Windows, so I can't capture usb traffic from the official driver to find the magic numbers and message structure.

I did notice that I get a feasible firmware version (1.06) using the code for the Deathadder 2013, so that's where I started. Unfortunately, that's all that works. But I'm thinking if the firmware request works, then the message structure should be the same. Is that a safe assumption? If I change the footer, the request fails and I'm given a firmware version of 0.00.

Is there anyone with a Mamba and the Windows driver that can get usb traffic dumps?

mbuesch commented 10 years ago

I don't have nor want Windows, so I can't capture usb traffic from the official driver to find the magic numbers and message structure.

That's bad. I strongly suggest to get Windows running inside of a virtual machine (qemu or something) and then capture the traffic. That's way easier and safer than poking around. It is possible to brick devices by poking around, after all.

But I'm thinking if the firmware request works, then the message structure should be the same. Is that a safe assumption?

Absolutely not. The protocols differ in layout for all known mice.

webgeek1234 commented 10 years ago

Not what I wanted to hear, but kinda what I was expecting. The protocols have to be pretty close if the firmware request works, though.

I might still have a KVM install of XP 64 laying around. Don't know if Razer supports that. Haven't ever done USB forwarding either, but that shouldn't be hard to figure out. That or I might be able to borrow a Windows 7 netbook. Either way, it'll be a few days before I can. If someone else can get the dumps, it'll help speed things up.

mbuesch commented 10 years ago

The protocols have to be pretty close if the firmware request works, though.

I would not count on that.

I might still have a KVM install of XP 64 laying around.

I never tried 64-bit. But XP 32-bit should be fine. You can also download Win-7 ISOs legally somewhere with a 3 day evaluation period. That should be enough.

darkman1983 commented 9 years ago

You're not alone DUDE... I'm also trying to add the support for that mouse... Im using the Approach with Synapse...but also got that MAGIC problem... If I'm Debuggin, i get... librazer: synapse: Invalid magic on received request (READ) librazer: synapse: Failed to get firmware version

darkman1983 commented 9 years ago

Okay, i was on win 7 with USBPcap and the device was the only one on that Port... It's the Mamba 2012, connected wireless with the dock...

What i've done: Changed DPI up and down... Changed Sensitivity Enabled XY Separation and done it again... LED Colors changed around... Clicked Buttons... And so on... Hope it works for that...

http://www.file-upload.net/download-10120517/mamba.pcap.html

P.S. It's a Shame that i can't understand that Sniffs my Self... Maybe you could explain later...

P.P.S. Man Michi, du bist ja deutsch ^^

darkman1983 commented 9 years ago

http://www.file-upload.net/download-10120537/mamba-wired.pcap.html

darkman1983 commented 9 years ago

Are all the data you need in the Sniffs?

mbuesch commented 9 years ago

I think currently nobody is working on a mamba driver. However, pull requests are welcome. So don't hesitate to start an implementation, if you want to.

webgeek1234 commented 8 years ago

I started taking a look at this again and got some usbmon captures. Having trouble parsing it out, though. Still seems pretty similar to the deathadder 2013 so far. Status at the front, a few front loaded values, bunch of padding and some footer at the end, always 90 bytes. But being unfamiliar with the syntax and commands, it's not all clicking yet. mbuesch, can you take a look at these captures and see if the command struct is obvious? (all captures are very limited, only a single action done without extra movement data)

Razer configuration tool startup: http://pastebin.com/UmayUg46 Setting led brightness to normal: http://pastebin.com/EFYLe279 Setting led brightness of off: http://pastebin.com/v9p8U8kq

mbuesch commented 8 years ago

Well, it looks like you captured the correct data. I did not check what format that is. But you can easily do that on your own. First check whether it's (related to) the synapse format, implemented in synapse.c. If it's not, just compare it to other formats. Just see the (packed) data structures in the c files.

webgeek1234 commented 8 years ago

Put a few more hours in tonight and got most of the basic functionality working (see fork linked above). Seems like a cross between the deathadder 2013 and the deathadder chroma. Only thing I know of that isn't working yet is the led color. Need to see if there's a way to set the hardware dpi levels (mouse has 5 of them) as well. Somewhere in there, I want to clean it up a lot too, make it closer to the chroma implementation.

There seems to be a lot of unused functionality on this mouse, are all of them like that? Like, I can send the DA2013 led on/off commands in and they work. And the firmware version request. But those are not what the official driver uses. Then the led brightness command works on a full gradient 00-FF, but the driver only allows 4 levels (00, 54, A8, and FF). Kinda seems like the hardware is leagues better than the drivers or at least more flexible.

mbuesch commented 8 years ago

(see fork linked above).

Where is it? :)

Seems like a cross between the deathadder 2013 and the deathadder chroma.

Nice. Kind of expected, that it's yet another protocol. Razer calls all mice "synapse" with "one" driver, but in reality they are almost all different. Even the real synapse ones are not compatible.

There seems to be a lot of unused functionality on this mouse, are all of them like that?

There are quite some, yes. I guess it's the way new protocols are developed at razer. Just take an existing protocol and smack it with a hammer until it works.

Kinda seems like the hardware is leagues better than the drivers or at least more flexible.

That's interesting indeed.

You didn't find a firmware bug yet? ;)

webgeek1234 commented 8 years ago

The link in my opening post: https://github.com/webgeek1234/razer/tree/mamba2012

Yeah, it appears to use the same command structure as the DA2013, but many of the request ids from DA Chroma. I started doing captures from the official driver and searching for the request id from the Chroma and I've found what I was looking for so far.

Firmware bugs? Not yet... Then again, I've only got simple stuff working so far.

Now, I have run into a fun problem. This mouse is a wired/wireless edition and those have different USB product ids. I did my initial work wired. When I tested it wireless, nothing worked... The only response I got was turning the led on/off. And that triggered on the base station (supposed to be the scroll wheel led). I really hope I won't have to split the implementation, but I'll have to see once I have time to get captures from the official driver in wireless mode.

I've got some cleanup done, but I'm not pushing it up until I can test that it really works. Like the endiness stuff was all messed up and working by accident. Hoping I'll have time to finish this all up this week, but I don't know.

mbuesch commented 8 years ago

Very nice. I'm looking forward to your pull request.

This mouse is a wired/wireless edition

Interesting. I have no clue about these devices at all.

webgeek1234 commented 8 years ago

I think I've got 90% of the functionality working, seemingly equivalent for wired and wireless. Only thing I can think of that I haven't found the proper command for is enabling/disabling/brightness of the scrollwheel led when in wireless mode. It's somehow saved independently from the normal led settings. That and the hardware saved dpi levels, but I don't know if I'll dig through all that right now, maybe for a v2.

That being said, this device has other functionality other devices don't implement (or I've missed), namely the led brightness level. How do you want to handle that? I presume it would require another set of options in razerd and the clients. If you don't want to implement that, I could just force the brightness to full (0xFF) whenever the led is toggled on.

I've still got at least one round of cleanup, though. And several pieces of documentation to fixup.

mbuesch commented 8 years ago

I think the cleanest solution would be to change the LED command from an on/off parameter type to a brightness parameter (8 bit would be enough I guess). And also add a flag to GETMOUSEINFO that indicates whether the mouse can do brightness, so the gui/cli can handle that correctly. Existing devices would simply turn the LED off if brightness==0 and turn it on otherwise. This should be pretty straightforward to implement and does not require a daemon communication protocol change (just rename the LED command's new_state to new_brightness or such).

haoanw commented 8 years ago

Hi all ! I've tried to write driver for my new Mamba Tournament Edition(new version of Mamba Mouse) but i choose the Deathadder Chroma as a template, as @webgeek1234 mentioned that they are quite similar. Now the razercfg can detect the mouse (appeared after razercfg -s) and DPI adjusting is also working (but the buttons for it didn't work anymore, it use to work without the driver, of course the DA Chroma doesnt have these buttons so they are not mapped). The lights didn't work as well cos it has much more lights than DA Chroma. That's what ive got so far, now i try to analyze the pcap files i recorded in oder to find some informtion about commands for lights. It is quite difficult for me cos i know nothing about USB HID agreement. I also attached it here if anyone interesed , could take a look. pcap files for both device.zip

haoanw commented 8 years ago

The link in my opening post: https://github.com/webgeek1234/razer/tree/mamba2012

@webgeek1234 this page is no longer available.

webgeek1234 commented 8 years ago

https://gitlab.incom.co/webgeek1234/razer/tree/mamba2012

I moved my stuff off of github onto a personal gitlab instance, so see the link here. I never got back to cleaning my mamba support up. As far as I know, it's feature complete (with what razerd supported at the time) for the 2012 edition, though. I'm planning a new computer build next year when Zen is released and was planning on getting a new mamba then and working on that. Won't complain if someone beats me to it, though.

haoanw commented 8 years ago

https://gitlab.incom.co/webgeek1234/razer/tree/mamba2012 I moved my stuff off of github onto a personal gitlab instance, so see the link here. I never got back to cleaning my mamba support up. As far as I know, it's feature complete (with what razerd supported at the time) for the 2012 edition, though.

thanks for your reply! i tried the driver you provided. it didn't fully work with the new mamba tournament edition(almost everything except the lights). i see all the differences between hw_mamba2012.c and hw_deathadder_chroma.c, you add the wireless mode and brightness for the lights, i assume these two devices are quite similar, and this line (Ln77, Col9)

MAMBA_TOURNAMENT_EDITION_REQUEST_INIT = 0x0581, the value is different. the rest part are almost the same.

for the new mamba, it has lights for scrolling wheel, logo, and also two sets of light on each side of the mouse. Each set has 7 individual lights which can be programmed independently (in windows). so i think the lights commends are quite different from the previous devices.

I'm planning a new computer build next year when Zen is released and was planning on getting a new mamba then and working on that. Won't complain if someone beats me to it, though.

a new mamba is absolutely a good idea, but the design of the shape is a bit different to mamba2012, it is smaller. i wish i could figure out the light commands from pcap files i attached here, but right now i didn't know how to analyze them...