Taking input and redirecting it to an emulated rom (Twitch Plays Pokemon) - emulation

So if anyone has been following Twitch Plays Pokemon for the last week or so (http://www.twitch.tv/twitchplayspokemon) you'll know what I'm talking about. They are streaming an emulated version of Pokemon Red and allowing members to type controls into the chat. The controls they type correspond to that on an actual gameboy and are somehow 'sent' to the emulator as controls. For example, if someone types 'start' it pops up the start menu in the game.
Is there any documentation online which could show me how to do something like this (albeit smaller scale)?
Thanks!

It's actually quite simple once you get the hang of emulating keystrokes.
On windows you can use the keybd_event WinAPI to simulate keystrokes, here's some example c++ code that holds down the A key for 150 milliseconds:
keybd_event(0x41, 0, 0, 0); // starts holding down key 0x41 (A)
Sleep(150);
keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0); // releases key 0x41 (A)
(you can find values for other keys here)
Once you get keystroke emulation working, you just need to either make your software connect to the IRC channel of your twitch chat or run HexChat or any other IRC client, make it connect to the twitch chat by following this guide, enabling logging and parsing the chat log on your software by simply reading the file line by line and waiting for new lines once you get to the end of it.
I wrote my own Twitch Plays ... software on Windows in c# in a matter of minutes and then released a polished, configurable version that should work on any game here.

Related

createBond doesn't always show pin dialog

After performing a bleScan and giving the user their device to select, I then take that get that device via the getRemoteDevice(address) call.
Once I get that BluetoothDevice object, I then call createBond(). Since createBond() triggers an async operation, I have BroadcastReceiver listening for the results and confirm that the device has paired/bonded when I received a BONDED result in the receiver.
This is pretty standard procedure for bonding with a BT device.
The issue I'm running into is that under seemingly random conditions, the built in pair/connect dialog does not appear.
Through some testing I found that if I swipe down on the phone, long press bluetooth and click "Pair a New Device" and the device shows up in the list...I can then return to my app, call createBond() and the PIN dialog appears.
This tells me there's something iffy with some type of Bluetooth Cache or something along those lines.
I'm trying to determine why this might be and if there's something I should be ensuring that I do BEFORE calling createBond to ensure the pin dialog appears.
I can post relevant code but it's really just a one-liner
boolean bondInitiated = getDevice().createBond();
After I call create bond there's typically a 1-2 second pause and then the pin dialog appears.
Can someone offer some insight here? Is there a better way to pair with a BT device from Android other than calling createBond()
I'd LOVE to just give the user a PIN text box, let them enter the pin shown on the BT device (it's a glucometer) and then pair that way but I've not seen a way to do that.
Unfortunately, there isn't a standard way to always show the pairing dialog to the user. This is because the pairing process is dependant on the hardware, and some OEMs have modified how it works at the OS level. As such, there are variations depending on the hardware that is being used.
However, there might be some "hacks" that you can implement to get this to work. Have a look at this link as it includes details on the bondong process and the pairing popup. It's a bit outdated (3 years ago), but it includes the following paragraph:-
So if you want you can try to make the popup always appear in the
foreground by doing discovering for 1 second before connecting to a
device. It is a bit of a hack but it works.

Is there a reliable way to reconnect a paired ZAGG - Logitech Bluetooth Keyboard upon power-up?

I have a bluetooth keyboard that I use on a regular basis. It has a Logitech logo, but is manufactured by ZAGG and has model number Y-R0023.
I have paired the keyboard with my Ubuntu desktop and it works great.
Upon powering up my computer and keyboard, I can sometimes reconnect without having to pair again, but other times I have to remove the existing pairing and reconnect before Ubuntu can receive keystrokes.
Extra information: Ubuntu displays a bluetooth symbol as a status when it connects (regardless if it is able to receive keystrokes or not). This symbol will appear and disappear roughly every 10 seconds until the two devices are able to successfully negotiate a valid connection.
I notice that I have best success when I press 'delete-delete-enter-enter' after powering the ZAGG keyboard up. (Sometimes, just repeatedly pressing a key every second or so seems to work too.)
I am wondering if the "delete-delete-enter" keystroke combination (or some other that I haven't discovered) is recognized by the Logitech BIOS as a special sequence to help retry a paired re-connection. I'd be interested in finding out if this trick works for devices other than those made by ZAGG. Otherwise, it would help just to know if there is a reliable script I can run that calls bluetoothctl to help improve the re-connection. (I want to avoid having to enter a pairing code on subsequent connections).
ZAGG sites and Logitech ones don't say anything about this key combination. So I don't think it's recognized as a special sequence, only advice they give is to re-pair the device when it's not working.
In summary I'm sure they would include this troubleshooting option in manual and/or troubleshooting guide if it was present.

Detecting when an Apple TV 4th generation has woken from sleep

I'm working on some home automation programs and one of the things I want to be able to do is detect when my 4th generation Apple TV has woken from sleep. This will generally only ever happen when someone pressed a button on its Siri remote to wake it up.
I have a PC (connected to the same TV as the Apple TV) that has a Pulse-Eight USB-CEC adapter, so naturally the first thing I tried was using CEC to determine when the Apple TV is awake. Unfortunately it's not reliable, since monitoring the Apple TV's power status to see when it wakes up produces false positives. (I should note that I do not have "Control TVs and Receivers" enabled on the Apple TV, and can't turn it on for the particular project I'm working on because I need the Apple TV to not change the TV's input.)
I'm trying to think of some other way to do this. I'm open to any possibilities, including things like:
Making use of private APIs on the Apple TV
Running an 'always on' program in the background of the Apple TV that sends a signal when the Apple TV wakes up, if that's even possible. (I suspect that it isn't.)
Monitoring the bluetooth communication between the Siri Remote and the Apple TV, if that's possible
Somehow filtering HDMI-CEC commands so that I can turn on 'Control TVs and Receivers', allow the Apple TV's CEC commands for turning on and off the TV, and exclude commands for changing the TV's input.
Any other method, no matter how hacky or ridiculous, as long as it works!
Does anyone have any suggestions? I'm running out of things to try!
I tried to post below on apple discussion / support communities but was told i don't have the right to post this content. Maybe someone in this group can succeed in doing it:
Apple TV 4 CEC integration is great when it works, but it doesn't work all the time and not with all the various equipment out there, you can do a search across forums and you will see lots of unhappy users. I would like to use a raspberry PI to detect when my AppleTV goes to sleep and wakes up and programmatically turn my tv on or off using its RS232C or custom CEC commands.
I used a bonjour services explorer and compared every single result between sleep and on states and there are no differences whatsoever.  I would have expected Apple to welcome such automation projects and make this information readily available with a variable such as status: sleep or status: on. 
Is there a way I could tell the two states apart via the network connection?
If not, could one build a TvOS app which runs on the background and makes this information available to clients somehow?
I finally found a method that seems to work consistently. This method is incredibly hacky and not at all the sort of way I'd prefer to do this, but it's the only one I've found so far that works consistently.
I have taken an old USB webcam and affixed it to the front of my Apple TV so that its lens is directly in front of the Apply TV's front facing light. Whenever the Apple TV is asleep, I simply check for the light turning on by taking images from the camera and analyzing their average luminosity. Since the lens is right next to the light, when it turns on it'll create a huge blown out white circle in the image that's incredibly easy to detect.
As long as the Apple TV is asleep, the light turning on seems to indicate 100% of the time that it has woken up. I have yet to find a single incident of either a false positive or false negative.
Since pressing buttons on the Siri remote causes this light to blink, this also means that I can detect buttons being pressed by looking for changes in the light while the Apple TV is awake. It's not 100% accurate, since some button presses are faster than the frame rate of my crappy old USB webcam, but it works well enough.
I would vastly prefer to find a better method of doing this, like making a request over the LAN to the Apple TV where the response clearly indicates it being awake or asleep, but so far it doesn't look like that's possible.
Here I am, six and a half years later, and I've finally found a better way to get the power state of my Apple TV.
I can simply use pyatv, which has a function named power_state that returns the Apple TV's current power state.

Samsung Fame GT S6812 Call Recorder Not working

I am using samsung fame, this phone actually without java.
I want to record my calls, for that I used almost all applications in google play. But calls are not recording properly.
Its recording like noice. example if u ever fast forward song in type-recorder how that sound to here same like that calls are recording.
Is there any solution/app. I need to record important calls.
Please give me the solution.
Note: Jelly Bean 4.1.2, No java.
Few apps are showing message something like call recording not started, Java not started.

low latency sounds on key presses

I am trying to write an application(I'm a gui first timer) for my son, he has autism. There is a video player in the top half and a text entry area in the bottom. When letters are typed sounds are produced to mimic the words in the video.
There have been other posts on this site in regard to playing sounds on key presses, using gstreamer as a system call. I have also tried libcanberra but both seem to have significant delays between sounds. I can write the app in python or C but will likely do at least some of it in C.
I also want to mention that the video portion is being played by gstreamer. I tried to create two instances of gstreamer, to avoid expensive system calls but the audio instance seemed to kill the app when called.
If anyone has any tips on creating faster responding sounds I would really appreciate it.
You can upload a raw audio sample directly to PulseAudio so there will be no decoding and (perhaps save) extra switches by using the following function from Canberra:
http://developer.gnome.org/libcanberra/unstable/libcanberra-canberra.html#ca-context-cache
The next ca_context_play() will use it.
However, the biggest problem you'll encounter with this scenario (with simultaneous video playback) is that the audio device might be configured with large latency with PulseAudio (up to 1/2s or more for normal playback). It may be reasonable to file a bug to libcanberra to support a LOW_LATENCY flag, as it currently doesn't attempt to minimize delay for sound events afaik. That would be great to have.
GStreamer pulsesink could probably get low latency too (it has some properties for that), but I am afraid it won't be as lightweight as libcanberra, and you won't be able to cache a sample for instance. Ideally, GStreamer could also learn to cache samples, or pre-fill PulseAudio...

Resources