These are chat archives for CoraleStudios/Colore

28th
Oct 2015
Bart van Vliet
@Kapulara
Oct 28 2015 10:12
Heya!, Is there any "tutorial" out there to use Colore inside Unity? I'm kinda noob at that... :cry:
Brandon Scott
@brandonscott
Oct 28 2015 10:33
Hey there
So you can use methods like Corale.Colore.Core.Keyboard.Instance.SetWave(Direction) for example
Do you have much C# experience?
Dariusz Niemczyk
@Palid
Oct 28 2015 11:33
@brandonscott just open source your snake finally! :D
@Kapulara https://github.com/Palid/Simon-Says here's my code, you can learn from it. it's a piece of crap, but better than nothing.
Bart van Vliet
@Kapulara
Oct 28 2015 13:16
@brandonscott So i kinda have trouble importing it into unity. I'm using .NET 2.0 which i know is a problem. :/
@brandonscott I'm using this page: http://docs.unity3d.com/Manual/UsingDLL.html
Adam Hellberg
@Sharparam
Oct 28 2015 13:19
@Kapulara .NET 2.0 is mostly obsolete for most systems, Unity uses .NET 3.5 which is what Colore is targeting
Bart van Vliet
@Kapulara
Oct 28 2015 13:28
Alright i think i have everything set up correctly now, However it gives me: DllNotFoundException: RzChromaSDK.dll
Even tho the SDK is installed in the default directory. :/
Adam Hellberg
@Sharparam
Oct 28 2015 13:29
what .NET version is your app targeting? If it's still targeting 2.0 and loading an assembly compiled against 3.5 (Colore) the functions used to detect architecture can mess up and try to load the wrong version of the SDK
Bart van Vliet
@Kapulara
Oct 28 2015 13:32
I followed these instructions now: Colore is now Unity compatible!
Instructions for Unity:
Download the AnyCPU version to allow users on a 64-bit machine to use it, even if your game was built in 32-bit.
Extract the files into the Assets/plugins folder within your Unity project.
Set the API compatibility level of the player to .NET 2.0.
By default, it is set to a subset that can’t load in the Colore Library. Head over to Edit >> Project Settings >> Player and under “Other Settings” there is a section called Optimization. You will be able to adjust the API Level below that.
Rethrow as NativeCallException: Call to native Chroma SDK function CreateKeyboardEffect failed with error: RzResourceDisabled: Resource not available or disabled. (4309) <- I don't know what i did but now i get this error...
Adam Hellberg
@Sharparam
Oct 28 2015 13:36
did you run the reg file included with the SDK documentation download to enable the SDK+
?*
Bart van Vliet
@Kapulara
Oct 28 2015 13:37
I can re-run it. But every other SDK application is working... (Audio visualizer / Snake) etc
Adam Hellberg
@Sharparam
Oct 28 2015 13:37
is synapse or any other chroma app running?
Bart van Vliet
@Kapulara
Oct 28 2015 13:39
I just checked, Synapse was running, I closed it and i still get the same error. Imma restart unity now.
Still doesn't change any key.
It gives: Win32Exception: Een voor deze bewerking vereiste bron is uitgeschakeld. Which means: A requirement for this operation is switched off
Adam Hellberg
@Sharparam
Oct 28 2015 13:44
haven't seen that error before in conjunction with the sdk
@njbmartin has used Unity with Colore before, maybe he knows something
Bart van Vliet
@Kapulara
Oct 28 2015 13:46
Any repository out there that helps me?
Might be because i
I'm not running unity in administrator :)
Adam Hellberg
@Sharparam
Oct 28 2015 13:50
shouldn't matter but i haven't used unity with colore
Bart van Vliet
@Kapulara
Oct 28 2015 13:50
Oh might try to fix it with the .reg file or restart my computer (again)
Yeah administrator wasn't the deal
Alright the .reg file fixed it... My bad...
You guys might want to make a Wiki page or something like that for retarted people like my LOL
Or some Q&A things
Adam Hellberg
@Sharparam
Oct 28 2015 13:52
i just don't get why Razer has the reg file in the documentation download which is completely irrelevant to installing the SDK
Bart van Vliet
@Kapulara
Oct 28 2015 13:52
^
I can't recall me clicking on both .reg files. I think i just picked the wrong one. :)
Adam Hellberg
@Sharparam
Oct 28 2015 13:54
there's one for each system architecture
Bart van Vliet
@Kapulara
Oct 28 2015 14:26
What was the documentation again?
Bart van Vliet
@Kapulara
Oct 28 2015 14:27
Thanks! :)
Bart van Vliet
@Kapulara
Oct 28 2015 14:47
Any example on this? void Corale.Colore.Core.IKeyboard.Set ( Color colors[][] )
Brandon Scott
@brandonscott
Oct 28 2015 14:47
It's a grid layout
Of rows and columns
Bart van Vliet
@Kapulara
Oct 28 2015 14:47
How would i implement it ? :)
Adam Hellberg
@Sharparam
Oct 28 2015 14:47
you'd probably be better off just using the indexer directly
Color IKeyboard[Size row, Size column] { get; set; }
Bart van Vliet
@Kapulara
Oct 28 2015 14:49
I kinda want to create Schemes and then Load them in :)
Yeah i tried that, How would i set the size?
Adam Hellberg
@Sharparam
Oct 28 2015 14:49
the size corresponds to row or column (row is between 0 and Constants.MaxRows, column is between 0 and Constants.MaxColumns, both exclusive upper ranges)
Bart van Vliet
@Kapulara
Oct 28 2015 14:49
Corale.Colore.Core.Size.set(43) ?
Adam Hellberg
@Sharparam
Oct 28 2015 14:50
there is no set method on the Size struct
Keyboard.Instance[5, 3] = Color.Red; will set the 2nd column on the 4th row to the red color (indexes in C# are 0-based)
Bart van Vliet
@Kapulara
Oct 28 2015 21:23
Alrighty, I wan't to detect what key is pressed on the keyboard and then set that color to red for example
How would i do that ?
Brandon Scott
@brandonscott
Oct 28 2015 21:24
Do you know how to do key detection?
Because that's a different feature entirely and outside of the scope of the library
Bart van Vliet
@Kapulara
Oct 28 2015 21:25
IKeyboardInterceptor i guess :)
I'm just trying to find a direction i need to go in. I'm kinda making paint in C# to export and use later on. I'll explain a bit more once i get it working :)
(With Chroma)
Brandon Scott
@brandonscott
Oct 28 2015 21:27
Okay, so first thing first
Are you using WPF or WinForms?
Bart van Vliet
@Kapulara
Oct 28 2015 21:33
I'm guessing WinForms...
How can i check ?
Brandon Scott
@brandonscott
Oct 28 2015 21:36
Lets assume winforms
So do you know how to add an event handler?
Bart van Vliet
@Kapulara
Oct 28 2015 21:37
Yeah.
Brandon Scott
@brandonscott
Oct 28 2015 21:37
Awesome
On your form
Bart van Vliet
@Kapulara
Oct 28 2015 21:37
As key handler with event
Brandon Scott
@brandonscott
Oct 28 2015 21:37
Perfect!
Nice job.
Bart van Vliet
@Kapulara
Oct 28 2015 21:37
But it's not triggering Macro keys xD
Brandon Scott
@brandonscott
Oct 28 2015 21:38
Does it work for any key>?
Brandon Scott
@brandonscott
Oct 28 2015 21:39
Awesome
Adam Hellberg
@Sharparam
Oct 28 2015 21:39
WinForms handles keys that propagate through the system, macro keys on the blackwidow are not system keys and are handled specifically by Razer's drivers. you cannot intercept them through regular system calls (and AFAIK razer doesn't expose anything to capture them)
Brandon Scott
@brandonscott
Oct 28 2015 21:39
That is correct.
I wish they did though.
So you'; have to work with the System keys I'm afraid.
Bart van Vliet
@Kapulara
Oct 28 2015 21:39
Yeah, Cause now i can't kinda detect whether or not the key is pressed :/
Brandon Scott
@brandonscott
Oct 28 2015 21:40
Ignore Macro keys for now
Bart van Vliet
@Kapulara
Oct 28 2015 21:40
Alrighty
Ah i could use them for navigating / menu etc.
OH no
I can't detect
....
Nvm. Il leave them blank :)
So now i have a KeyCode, Can i use a KeyCode with Colore?
Or do i have to convert it to numeric ?
I'm guessing this is a yes.
Brandon Scott
@brandonscott
Oct 28 2015 21:43
@Sharparam Did something similar to this
Adam Hellberg
@Sharparam
Oct 28 2015 21:44
i just manually mapped system keys to razer keys, as there's no efficient way to make an automatic mapping due to the philosophy of the designs
razer's key enums are defined based on grid location while system keys are defined based on some standard in the libraries
Bart van Vliet
@Kapulara
Oct 28 2015 21:45
Do you have a source?
Bart van Vliet
@Kapulara
Oct 28 2015 21:47
@Sharparam thank you so mutch! :heart:
Adam Hellberg
@Sharparam
Oct 28 2015 21:48
these are for WPF keys, mind
you'll have to adapt it to the enum WinForms uses
Brandon Scott
@brandonscott
Oct 28 2015 21:48
That must have been tedious @Sharparam
Adam Hellberg
@Sharparam
Oct 28 2015 21:48
determination is a hell of a drug
Adrian
@WolfspiritM
Oct 28 2015 23:04
Heya. :-) Till now I've send updates to the Keyboard all at once including sending already set Keys with Chroma.Instance.Keyboard.SetKeys(keys, Color); today I noticed that sometimes a change is not successfully send to the keyboard somehow. It seems to be random to me when it works and when it doesn't. If I repeat the SetKeys a few times in my method it always works (but that's just ugly). For now I've included a ColorCache to only send the keys that changed and that seems to work. Is there a known issue or limit of updates within a second (even so I don't think I'm hitting that)? Or can this have something to do with Threading? A lock around the SetKeys didn't work either.
Brandon Scott
@brandonscott
Oct 28 2015 23:06
It should work every time you set it without doubt
there's no rate limiting
@Sharparam any thoughts?
Adrian
@WolfspiritM
Oct 28 2015 23:10
Hm that's weird then. I even logged the request to setkeys and I'm pretty sure setkeys is called with the right color and key. But the Keyboard doesn't set the Color. A few calls later it finally does.
Adam Hellberg
@Sharparam
Oct 28 2015 23:11
in WaM with frequent updates it would not always register every change (~250ms between changes). havent' checked with latest updates but if brandon could get 24fps working which is an update every ~41.67 seconds then anything down to at least that delay should work fine
milliseconds*
41.67 milliseconds
Adrian
@WolfspiritM
Oct 28 2015 23:14
Sometimes there are updates every half a second for me and it seems to work with just a few keys. Just all Keys at once seem to be causing issues.
Adam Hellberg
@Sharparam
Oct 28 2015 23:14
how are you performing the update when changing all keys
Adrian
@WolfspiritM
Oct 28 2015 23:17
Multiple Chroma.Instance.Keyboard.SetKeys(new List<Key> { Key.W, Key.A, Key.S, Key.D }, Color1); for each color
Adam Hellberg
@Sharparam
Oct 28 2015 23:18
a cache of some sort might be more performant in reducing the number of created objects on the heap, but it shouldn't be related to the issue. it should just change the speed of updates if there are a lot of such new object creations
is this single- or multithreaded app?
Adrian
@WolfspiritM
Oct 28 2015 23:22
It's Multithreaded...using Tasks
Adam Hellberg
@Sharparam
Oct 28 2015 23:22
@brandonscott are your updates in your apps handled by their own threads separate from main thread?
Brandon Scott
@brandonscott
Oct 28 2015 23:23
No
And I haven't tried the thread safe implementation you've done across multiple threads
But no, all of my keyboard updates are from the main thread normally
Adrian
@WolfspiritM
Oct 28 2015 23:24
Could be a problem with the Taskhandling then. Maybe it only works on the first Thread that calls Chroma while other Tasks under load might be opened on another thread in the threadpool
Adam Hellberg
@Sharparam
Oct 28 2015 23:25
isn't EA using a separate thread for updates
@WolfspiritM it could be worth making a test having only one thread handle keyboard updates, and see if it experiences the issue
i'm taking it you're firing of several one-off threads (tasks) that do one update and die?
Brandon Scott
@brandonscott
Oct 28 2015 23:26
No it's not @Sharparam as we hadn't implemented the thread safety at that point
So it was all using dispatcher timer
Adam Hellberg
@Sharparam
Oct 28 2015 23:26
dispatcher-timer does the tick on a separate thread doesn't it
Brandon Scott
@brandonscott
Oct 28 2015 23:27
Yes but it's intrinsically linked to the UI
But yes you are rigbt
Rigbt
Adam Hellberg
@Sharparam
Oct 28 2015 23:27
hence why you need to make use of the invoker if doing UI updates from a dispatchertimer tick since it's not running on UI thread
Brandon Scott
@brandonscott
Oct 28 2015 23:27
*right
Correct to some extent, you can make a dispatcher timer run on the UI thread though
It's one of the unique features for it
Adrian
@WolfspiritM
Oct 28 2015 23:28
I'm handling some Network Stuff in different Tasks then fire the update with an event which should still be in the same Task and Thread.
Will try to sync them back to the UI Thread
Adam Hellberg
@Sharparam
Oct 28 2015 23:33
not entirely sure how C#/.NET handles event threads
firing an event will run the event handler in its own thread, but how those threads are managed and if they are re-used i'm not sure
maybe we should get jon skeet in here lol
@brandonscott make it happen
Adrian
@WolfspiritM
Oct 28 2015 23:38
According to System.Threading.Thread.CurrentThread.ManagedThreadId right before SetKeys it's always the same Thread.
However...I will try a few more things tomorrow. For now I need to go. Thanks for the help! :-)
Adam Hellberg
@Sharparam
Oct 28 2015 23:43
always