Dealing with DisplayPort plug and play

So, I’m having an issue at work with my display setup. I have three monitors connected to my workstation, two via DisplayPort and one via DVI. Every time the monitors go to sleep it does the following:

  1. Windows gets a signal that the monitor has been disconnected
  2. Windows then re-arranges the windows that I had on the display port monitors to a desktop that it considers active(The DVI monitor)

When the monitor wakes up, I have to re-arrange my windows back to where I want them and this is an incredibly annoying task, especially as I take numerous coffee and bio breaks daily.

This is not special to any graphics card and there are numerous posts on this issue. This is the behavior of display port as it’s supposed to be “Plug and Play”. if I pull out the cable, that makes sense. However, powering off shouldn’t exhibit the same behavior as unplugging. Nvidia has a solution implemented in their drivers, that basically stores the monitor information and brute forces the state of the screen. However, I’ve got an AMD card on my workstation and it currently has no solutions.

So what’s my solution? I’m going to write one for a Random Coding project. I’ll have it freely available to download and will have a little bit of a video on the usage of it. While it may be interesting recording writing it from scratch and the dev journal, my schedule is insanely fragmented these days with two little boys and it would be hard to record as most of the days I’ll work on the project, lighting and my voice has to be low to let those guys sleep.

So MVP specs to get something out the door. Begin by building a polling implementation application that’s manually started with a window. Later we’ll try to find the right windows events, make it event driven and modify it to be a task tray application.

  1. Create a hash of the desktop display metrics as the key and a list of the window display metrics as a value
  2. Poll Number of monitors and screen resolutions and store as desktop display metrics
  3. Every second scan all windows and store window display metrics
  4. If the desktop display metrics change, check if the desktop hash key exists
    1. If it exists restore window positions.
    2. If it doesn’t store new positions of all windows

Facebook Unity – Keystore missing

So I just recently noticed that the Facebook team wrote a unity plugin to make your games easily integrate with Facebook! I’m super excited to get Conflicademia connected so off I went.

Apparently, a while ago, I attempted this before and found an old Facebook assembly that I couldn’t get working. It also conflicted with the new library and so step one was to remove that booger. This is not likely something anyone else will have to do.

The next thing was to correct an issue with the imported module. In the Assets/Facebook/Editor/android/FacebookAndroidUtil.cs class, there is a method to return the debug key store path. When imported it looked like the following

private static string DebugKeyStorePath
{
    get
    {
         return (Application.platform == RuntimePlatform.WindowsEditor) ?
            System.Environment.GetEnvironmentVariable("HOMEPATH") + @"\.android\debug.keystore" : 
            System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + @"/.android/debug.keystore";
    }
}

Problem is that the HOMEPATH variable doesn’t include the root drive on my machine. I assume it must include the root drive on the devs @ Facebook who worked on it. So I modified it to the following

private static string DebugKeyStorePath
{
    get
    {
        return (Application.platform == RuntimePlatform.WindowsEditor) ?
            System.Environment.GetEnvironmentVariable("HOMEDRIVE") + 
            System.Environment.GetEnvironmentVariable("HOMEPATH") + @"\.android\debug.keystore" : 
            System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + @"/.android/debug.keystore";
    }
}

Once that went though, I also went through the steps of creating a keystore and key in Unity through the Player/Platform settings. Facebook wasn’t working, most likely because I actually created this keystore. So I thought it was most likely due to the Key hash that Facebook requests. I used the popular keytool command that I’ve regularly seen on stackoverflow to get the keyhash but that didn’t work. I then enabled development mode and monitored the Android logging output. When I filtered to “Unity” I discovered the following line in the verbose settings

02-16 13:05:24.388: V/FBUnitySDK(22110): sending to Unity OnInitComplete({"key_hash":"[SuperDuperSecretHashKey]\n"})

I want to note that it actually put a line feed at the end of the key, so when I copied and pasted the key into facebook I had to make sure it didn’t include the has key. With that, I did a little bit more experiments and I am connected!

Conflicademia with facebook!
Conflicademia with facebook!

I’d like to get back to my next Topcoding video and this time it’s seriously a challenge! I’m not even at the coding part of it yet either! :p

SysWOW64 burns a few hours

My latest adventure involves me setting a profile for Powershell to import a module so that I can use a custom script without manually loading it each time. So run off to find that the environment variable is $profile.allusersallhosts. It maps to a file “C:\Windows\SysWOW64\WindowsPowerShell\v1.0\profile.ps1”, so I open up Notepad++, place my import statements in there and life should be good!

However, it’s not working. Not only is it not working, when I go into that folder the file isn’t showing. I have literally no clue where it’s saving so I use SysInternals ProcMon and watch Notepad++ to see the resources it’s using. Turns out that since notepad++ is built as a 32bit application, anytime it looks for the folder c:\windows\system32, some magical internal windows thing routes it to c:\windows\syswow64. So even though Notepad++ shows the folder to be system32, it actually isn’t.

In the end the solution was to use notepad.exe or any other 64bit editor that won’t discreetly change the folder on you and lead you on a wild goose chase.

Happy Coding!

 

 

Fighting Git with many tools

So I decided to create a branch in Git to implement a nice new feature and after about a week or so, I get to a section of code that was shared with my cohort and course changes were made that I wanted. So I figured, “This is what Git is good at, right?”

In theory yes, but still coming from Subversion it took a lot of pain and many tools to figure out how to get it working.

I attempted to “Rebase” from subversion unsuccessfully many times as when conflicts were discovered, the progress bar just kept spinning and spinning and spinning. So while testing I corrupted my local code base… many times over. I literally cloned from the safe point about 4 times before I finally got it right.

I used the Git/Git-bash tool to initiate the rebase doing

git checkout MyAwesomeBranchOrSoIThought
git rebase master

Now it would stop midway and mention to fix the conflicts before resuming… well.. the bash utility is, in my opinion, not the best visual merge tool, so I went to the TortoiseGit to resolve the conflicts. After each conflicted file was resolved, I then went back to Git-bash and ran

git rebase –continue

All the way until it finally completed and then sure enough it finally made it all the way through. Once that was done, I went back into VS, where we use Microsoft’s TFS Git provider to sync the last change set.

Painful, but hopefully the UI tools mature to the point where I no longer have to go back to Git-bash.

Android Studio – Local path doesn’t exist

Playing with Android Studio again tonight and my little Facebook test app, I received an annoying error that I thought was resolved by cleaning the project and importing it fresh again. Sadly, the error came back again

Uploading file

local path: D:\Ninjacrab\Projects\FacebookTesterProject\FacebookTester\build\classes\debug\FacebookTester.apk
remote path: /data/local/tmp/com.ninjacrab.facebooktester
Local path doesn't exist.

When I review the file system I see that the apk is generated but in a different folder and with a different name.

D:\Ninjacrab\Projects\FacebookTesterProject\FacebookTester\build\apk\FacebookTester-debug-unaligned.apk

However, it seems as though AndroidStudio doesn’t want to use that APK for debugging. After some painful experimentation it turns out that there is an poorly documented option that is not included in the “.iml” file that you can configure to fix it. (My .iml was located at D:\Ninjacrab\Projects\FacebookTesterProject\FacebookTester)

There are multiple “.iml” files, one for the master project, one for the module that contains that produces the apk. If you edit the “.iml” file for the module and add the following option with path respective to your project

<option name="APK_PATH" value="/build/apk/FacebookTester-debug-unaligned.apk" />

You should be able to debug again from AndroidStudio. Happy coding!

I’m still alive!

Well, there have been some big changes in my career recently and so the game as well as the coding YouTube videos have been put on hold. Things are finally starting to settle down and I’ll be able to put some weekend time again on these and hopefully the one or two web crawlers that access my site will enjoy.

I’m hoping to get at least one video out there for the month of July!

Cheers!

Game scripting engine

So I’m starting to get back into the groove of coding my game and I’m at somewhat of a roadblock on how much I should make scriptable.

So for a brain dump, I’ll state what am I looking for right now?

Dialog sequencing
Entity administration(adding/removing/altering)
Triggering other sequences
I’m wanting at least these features so at any given level I can do the following.

Tell a story as the level begins
Add stuff to kill
Do something if you die
Do something when the boss dies
Perhaps this is too much and should be hard coded in the game for a unique kind of boss mob. Not sure, but I feel that’s restrictive. I’ll start with the goal of these things now using some sort of xml scripting syntax.

I thought about using Lua or JS, but I just can’t imagine that it would be easier using that than some fixed rule system. So homegrown ScriptML it is.

Suggestions welcome!

I Cried!!!

OMGEES!!!!

Ok seriously, I found this on youtube while searching for the evolution of dance. This has no programming food for the brain, but I cried from laughter while watching this video. OMG, I remember forcing myself to cry before too, and it is hilarious watching this guy do it. Drooling in the middle part of the video is icing on the cake.

LOLLERSKATES!!!!! ROFLCOPTER!!!!!