Thursday, October 24, 2019

Tada68 Keymap Flashing

Heyo (first time in forever)

So this is just a super quick post about something not very related to TechArt stuff, but I recently bought a new keyboard as my Razer Lycosa Mirror finally bit it (the space bar finally stopped working for good this time...it's threatened to die a few times before but never fully given up)

So I bought a Tada68 from KBD Fans on recommendation from one of my friend's who is very much into custom keyboards (which I always said I probably wouldn't go down that route cause I know jack about custom boards). Anyways, it's shown up and since it's not a full keyboard I was missing a few creature comforts such as media buttons and I wanted my Home/End Keys back (since the board has PgUp/PgDown by default instead)

I had to try to look up how to change the keymap since I know you can program this keyboard to do a ton of things if you so desire, but I founda  lot of outdated or just very convoluted info on how to get a new keymap installed on the board. 

Now that I've done it I wanted to just write it down so maybe someone else will happen across it. This is how I managed to get my own key map on my Tada68.

Obviously I assume you have a Tada68 board as I have no idea how to do it for other boards (but I think some of them are pretty similar?)

  1. Watch this video on how to use the QMK Configurator This is the video that I found on how to setup a keymap for my board and it allows you to do it in a browser with no need to download extra softwares and all that jazz. It was super easy and straight forward (and the video is pretty short)
  2. After you've downloaded the compiled .bin file from QMK Configurator, I made a copy (in case I want to have different version and swap between them later on) and named that copy to FLASH.bin. 
  3. NOTE: This next step "disables" your keyboard, so you'll have to use the right click menu to copy/paste etc.    On the back of your Tada68, you'll see a little reset button, press it and it will make your board start to flash and should connect to your computer so you can access the on board memory.
  4. There should be a FLASH.bin file on your board already, copy this to somewhere else so you have a backup of it. Delete the file on your board and then drag your FLASH.bin file that you got from QMK Configurator on to the board and hit ESC,
    NOTE: I've seen it said in other places to NOT do the eject device from computer as it can cause issues, so Please Please Please, hit the ESC key instead.
  5. That's it, you're done. You should have your keymap on your board all ready to go. 

I by no means take responsibility for any damage that could be caused by doing it this way, but it worked completely fine for me ~3 times now (small key changes and what not) so hopefully it will work for you :) 


Saturday, September 3, 2016

Unity Fitbit Class finally online!

T.StartPost();

Hey everyone. So I've done 2 posts on Unity and Fitbit and how to get it up and running before.
Lots of people have been asking about the UnityFitbit class that I either mentioned I would get online (and have just been busy/not wanting to refactor so you guys can actually use it :P )

Well today I finally sat down and refactored it out so it "should be" ready to be used by other people

Find it on Github and feel free to submit fixes/updates etc. to it as well.

https://github.com/TravisEvashkevich/UnityFitbit

By all means there is some crap in there that I should clean up (the Json convert to XML for starters)
But this is just what I've been using because it's what "I" need personally for my project.

If you think you can help out by making it work better and just in the JSON by all means please make a branch and submit some pull requests :D

T.Out();

PS: Make sure to check out http://technicalartistry.blogspot.ca/2016/01/fitbit-unity-oauth-2-and-native.html  if you need to figure out how to get it all working natively (as per Fitbit's ToS)

Thursday, June 2, 2016

Photoshop Extensions

T.StartPost();

Well it's another post about Photoshop and some extensions I've made.

If you remember from a few months back I made and released Layer Cake out into the world and just last week I released another called Normally Panel.

So Normally Panel allows you to do things like Rotations, Inverting and 2 different types of blending on Normal Maps in Photoshop.

Today I released (like literally 30 mins ago) Lazy Save.
Lazy Save was made for my own use at the start because I was getting annoyed that I had to keep doing
  • Save As
  • Select my image output type
  • Append or even change the name of the file I was going to save out
  • Finally Save
So Lazy Save you select the folder you want to Save to. 
Select your naming convention (there's 4 options to choose from currently)

-Do not use Group Names -> this will save your image out as your file name (if it's Example.psd, your image will be Example.jpg/png etc.)
-GroupName as prefix -> this will save your image out as MyGroup_Example.jpg/png
-GroupName as postfix -> this will save your image out as Example_MyGroup.jpg/png
-GroupName as output name -> this will save your image out as MyGroup.jpg/png


Here's an example of it in action also with going through all the types of naming conventions.

TGA also pre looks at your channels to determine if you are in RGB mode and then if you have an alpha channel. If you do, it will auto save it as a 32bit TGA and if you don't have any extra or you're in a non RGB mode, it will save it as a 24bit.

I hope people find this handy I know I will/have already.

T.Out();





Sunday, March 6, 2016

Layer Cake, Growth from a script to an extension!

T.StartPost();

So my last post was about how I made a little script for Photoshop called Layer Cake that allowed for offsetting multiple layers at once (instead of the tedious manual way that people are doin it now :P )

So, since that post, I gained feedback and feature requests on  the Polycount thread and because of this, Layer Cake is now a 4 script Photoshop Extension.

Grab the extension from
http://travisevashkevich.com/LayerCake.html

It's currently available (known and tested) in CS6, CC 2014 and CC 2015!

You can see a NEW AND IMPROVED feature video about Layer Cake below!


In short, Layer Cake is now:
Layer Cake 
Multi-Layer Offsetting of selected layers.  No more hiding layers you don't want to offset, just select what you want to offset (even groups!) and hit Layer Cake. You can even preview your offset, so you know where it's going to end up.

Rebake
Whatever values you used last to offset with Layer Cake, you can now hit Rebake to use the same values to offset WITHOUT having to open the UI.  Great when you're doing the same offset amount multiple times!

Icing
Preview your Tile in a 2x2 size document to quickly check for seams or see how busy it is. Want to see it in a bigger set? Hit Icing again on your new document to essentially see it in a 4x4 (you can keep hitting Icing to get bigger and bigger but beware of how your computer handles big documents)

Spectacles
Gaussian Blur and Smart Sharpen for tiling textures.  Run Spectacles on your tile to have Spectacles put it in a 3x3 where you can put some Gaussian Blur or Smart sharpen on it with less chance of making seams.  When you're done, hit "Done!" to end up with your newly made layer back in your starter document.


I believe there is always more to do, so if you think there is more things I can make to help speed up (note SPEED UP, not DO FOR ME) tiling texture creation I'm all ears.

And I'd LOVE to see or HEAR about what you guys are making with Layer Cake so feel free to let me know!

T.Out();

Wednesday, February 10, 2016

Layer Cake, a Photoshop script to Offset Multiple layers at once!

T.StartPost();

So I have been working on a script recently for Photoshop at the request of Jessie Van Aelst who was working on a tileable texture and hated having to manually offset each layer with Adobe's built in Offset filter.

I agree that it's quite tedious that to offset more than 1 layer at a time you have to keep hitting Ctrl F after you do it once...and keep tweaking your offset etc.  So I started working on Layer Cake!

Layer Cake is a script that will take your visible selected layers and offset them all the same amount as you specify.  I had found another script that offset every visible layer in your document but that isn't very user friendly since you'd have to turn off any layer you don't want offset etc. so Layer Cake fills a void pretty well I think :)
Click to Enlarge
I gave all the same options as the built in Offset has (currently minus the preview, but I'm working on it!) to make users feel at home with it.  I also Ctrl Z a few times in the gifs to make sure you can see the images are offset.

Click to Enlarge

You can grab the script HERE. It comes with a Read me that tells you where to put it and how to use it  as well :)

I hope people find this script useful and feel free to let me know if you run into problems with it so I can try to improve it and make it as useful as I can!

T.Out();

Tuesday, January 12, 2016

Fitbit, Unity, OAuth 2 and NATIVE browser...and about a week of cursing.

T.StartPost();

SO! I found out not too long after my last post that I (and everyone else using Fitbit data) would not longer be allowed to use Webview based solutions for gaining access to Fitbit data via OAuth 2.

This creates quite the predicament as when you're using Unity there's no Unity specific way of getting the OAuth return code from the browser (such as Chrome, Safari etc.)

This meant that I had to spend about the last week cursing while trawling the internet for solutions. Unfortunately there is a bunch but some of them do not seem to work. THANKFULLY, how ever, there is one that I found that DID work and I have to definitely give credit where credit is due and say that without Ofer Reichman's blog post I probably would not have gotten this to work.

You can pretty much follow his verbatim to get it working but I will also transcribe some small differences in things that work for Fitbit .  Also I'm working on refactoring my FitbitAPI class for Unity. I'm likely to just release it on Github for the betterment of the community and so others can help to make it better and learn from it as well.)

So without Further-Ado:

How to Do OAuth 2 authentication in Unity FOR Fitbit..With a Native Browser (Known to work with Android)


**If you want more in depth reading you can read Ofer's post but I'm just going to cover the nitty gritty of getting it to work with Fitbit**

Assumptions by me:
-You already have an app registered with Fitbit
-You already have Android SDK's installed
-You already have decent knowledge of Unity

I'm using :
Windows 10
Eclipse Juno (but shouldn't make a difference if you're using a higher version)
Unity 5




Hope this helps :) Feel free to comment and hopefully I can help (no promises though)

T.Out();

Wednesday, July 1, 2015

Fitbit, OAuth2, Unity and a Month of Cursing.

UPDATE:
UnityFitbit C# class is finally up on Github
http://technicalartistry.blogspot.ca/2016/09/unity-fitbit-class-finally-online.html
Go check it out and hope it helps :D

T.StartPost();

So it's been a while since I posted (what's new :P seems to be my MO)

Recently I've been trying to get my game started which is finally getting started.  The biggest hurdle for me was the fact that I wasn't going with a traditional "I create all the data" game but am relying on an outside source to create the data.  This data comes from Fitbit.

So the problem for me was mainly 3 things:

1. I've never done a game for mobile explicitly
2. I've never used OAuth2
3. There's little to no good documentation on how to do OAuth2 nicely in Unity.

I've made the choice to use Unity as I want to be able to develop for as many mobile platforms as fast as possible (the fact also that I've never done native Android/iOS or WP doesn't help that :P )

So, the way I'm trying (as this is still a work in progress and the development has only earnestly gotten under way about....2 days ago?) to get around the mobile part is through Unity as I have done a "mobile" game for the Surface in my final year of university (for the surface)

I've done mostly C# for the last few years so it's the easiest for me to jump right into as well.

The OAuth2 part and the lack of good follow up on how people are doing it is the thing that took me a good month (while working a full time job) to finally get.

The thing for Fitbit OAuth2 that is annoying is the documentation seems structured for someone that has done either webdev or OAuth2 previously.

Now that I've done it, it seems fairly easy but man oh man was I cursing it and Unity for the last month.

So I decided to put a small article up about how I got it going in the hopes it helps others in the future.

SO Let's Get To It!

**I'm not going to cover the HOW OAuth2 works as it'll be more or less described through the steps anyways. **
In the code bits, if it's got a Yellow highlight, it means it's something YOU have to provide from the api (the clientID, ConsumerKey, CallBackUrl etc.)

Step 1:
***EDIT: PLEASE NOTE THAT FOR Fitbit the use of Webviews is NO LONGER allowed. All the OAuth specific code stays the same but you will want to go check this other post
http://technicalartistry.blogspot.ca/2016/01/fitbit-unity-oauth-2-and-native.html
***

You're going to need a webview. This is something that you can start a webpage in Unity on.
This is essential as you will need to get your "code" back from whatever OAuth2 service you're going to be pinging.  Depending on your webview this can range from cheap to VERY expensive.

The plugin I'm using currently for this part is Cross Platform Native Plugins.  It has the webview, it has GREAT support from the devs (seriously I send them an email and usually within a few hours to one day it's answered) and also it will have extra stuff for me to use later (twitter,FB etc.)

You can set the Scheme that the webview will look for so that way when you get the redirect with the code, the webview will grab the message and you can do stuff with it :)


Step 2:
Now that you  have your webview and have it configured and ready to go, what do we do?
Well OAuth2 is a strangely strange beast that likes to sometimes just tell you to get stuffed...
 makes it so we never touch the users credentials. No username or password is stored or touched by us, it's all by the service itself.

The general way we'll get the first Code to get started is by configuring a URL that will tell the service who we are (app) and what we want (stuff)

For Fitbit for example it would be like this
 https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=ClientID&redirect_uri=" +  
 WWW.EscapeURL(CallBackUrl) +   
 "&scope=activity%20nutrition%20heartrate%20location%20profile%20sleep%20weight%20social  

This will tell Fitbit that you want to start the OAuth2 process and would like access to the things in the scope (nutrition, heartrate etc.)When you Register an app with Fitbit you'll get a ClientID and you can also specify a CallBackUrl. In your code you define the same things and that's more or less it.

One thing to note about the Callbackurl here, it has to be ESCAPED. In Unity you do this with the WWW class by going WWW.EscapeURL("UrlToBeEscaped");  This makes it weburl ready (replaces / with %20 for example)

What you would get back if you were not using a webview would be something like Callbackurl/?code=bunchOfRandomNumbersAndLetters

With the webview like CPNP, you won't likely see that page at all (IF you're using a scheme like myapp://   as it will just not load the page since your callbackurl doesn't have to be a valid alive website) and it will just be grabbed by the webview in the WebViewMessage.

Step 3:
When you've grabbed your code from the url/message, then you can move onto the next step which is requesting an actual Authorization Token. This is the token that allows you to then make calls to Fitbit and get data.

This is the part that took me the longest to get right and also the part that no one else seems to be documenting nicely.

The part that was hard for me was the fact that this uses webcalls which I've never done and couldn't find much on what for example GET or POST calls were, what I needed to fill in where etc.

 var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(_clientID + ":" + _consumerSecret);  
 var encoded = Convert.ToBase64String(plainTextBytes);  
 var form = new WWWForm();  
 form.AddField("client_id", _clientID);  
 form.AddField("grant_type", "authorization_code");  
 form.AddField("redirect_uri", WWW.UnEscapeURL(CallBackUrl));  
 form.AddField("code", _returnCode);  
 var headers = form.headers;  
 headers["Authorization"] = "Basic " + encoded;  
 _wwwRequest = new WWW("https://api.fitbit.com/oauth2/token", form.data, headers);  

So, This is the step by step part for what's happening in this code.
OAuth2 requires that you encode your ClientID and your ConsumerSecret in Base64 WITH a colon (:) between them.
I honestly messed up for a few days because I had a semi-colon(;) instead and it took a friend looking at it and the documentation to go ...You're Dumb. (Thanks Gerard)

Next is setting up the data. This is also a part that I had NO IDEA where to put it and how to do the call itself. Again, this is thanks to a my buddy Gerard that was looking over the code for a while and telling me how to formulate it cause I had it SO SO SO wrong before.

From the Fitbit Docs
 This example assumes that the code URI parameter value in the callback URI was 1234567890.  
 POST https://api.fitbit.com/oauth2/token  
 Authorization: Basic Y2xpZW50X2lkOmNsaWVudCBzZWNyZXQ=  
 Content-Type: application/x-www-form-urlencoded  
 client_id=22942C&grant_type=authorization_code&redirect_uri=http%3A%2F%2Fexample.com%2Fcallback&code=1234567890  
With this example you can see that we do the same setup although the AddFields break up the whole URL/data that we have to POST.  If you're keen you'll also notice that their redirect_uri is escaped, this is another hiccup that took me a good few days to get to finally go (and was actually the last thing I fixed to make it all work) This has to be NOT escaped when you put it in the form.addfield.

 So we make the data by using the wwwForm and adding it all to the fields like above, then we make the Authorization Header which needs a value of "Basic " +  our encoded clientID:ConsumerSecret

After that is all done, we make a new WWW and put the url as our Token url, put the data from the form in it, and then the headers.

One thing to note, in the fitbit doc you'll see the Content-Type:  that is AUTO added by wwwform so you don't have to add it yourself.


Step 4:
If all goes well, you'll get a bunch of JSON back with
access_token, expires_in, refresh_token, and token_type
The main things that I care about are access_token and refresh_token.

The expires is always the same and so is the token_type.

You parse out the JSON and get your access_token and then you can start getting data :D

 var headers = new Dictionary<string, string>();  
       headers["Authorization"] = "Bearer " + _oAuth2.Token;  
       _wwwRequest = new WWW("https://api.fitbit.com/1/user/-/profile.json", null, headers);  

You pretty much copy paste the other requests/posts that you made BUT instead of filling in data in the 2nd parameter, you put it null. This tells the WWW that you're doing a GET request

One of the things I only just figured out yesterday was that the url you put in this request will NOT give you everything you want. It's annoying but you will still have to make other calls. This one for example will ONLY get you the profile data of the user.
Unfortunately this doesn't do half of what I need so I will need to do more calls for things like Activities to get the current steps, floors etc.

Things for that can be found in the Fitbit Docs
https://wiki.fitbit.com/display/API/API-Get-Activities
For example.

Well I hope this has informed and helped people out. I hope that it also will make people's lives easier when it comes to what is needed and how to do it for OAuth2.  This is generally the same way that you do it for other OAuth2 things (at least from looking at the flow/docs for things like the Jawbone for instance.)

T.Out();