Integer representation of Samsung remote keycodes - upnp

I am trying to send key codes to a samsung smart tv using UPnP. I found the list of available key codes here. But How can i represent the same in integer, because samsung wants to receive this as integer values in the UPnP services.
Thanks

You can use the emulator to get a list of the key codes:
tvKey = new Common.API.TVKeyValue()
for(key in tvKey) {
alert(key+": "+tvKey[key]);
}
Not a great solution, but might work for your purposes.

Here you have manual way. So pressing any button on remote give you info what int value it has:
$('body').keydown(function(event) {
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
alert("You pressed: " + keyCode);
}

Related

Change the default camera app in Windows 10 desktop

How to change the default camera app in Windows 10 desktop ? The option is available from Settings in Phones but not from Desktops
If you want to make 'advanced' photo capture, then you can use MediaCapture class. Everything about this you will find at MSDN. There are also quite nice samples at GitHub.
It also seems that my old post for WinRT is still quite relevant. You will find there that I'm using GetCameraID:
private static async Task<DeviceInformation> GetCameraID(Windows.Devices.Enumeration.Panel desired)
{
DeviceInformation deviceID = (await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture))
.FirstOrDefault(x => x.EnclosureLocation != null && x.EnclosureLocation.Panel == desired);
if (deviceID != null) return deviceID;
else throw new Exception(string.Format("Camera of type {0} doesn't exist.", desired));
}
to choose a device to be used to capture the photo. In your app you can enumerate devices and choose the one that suits you.

how to correctly map normal browser keyboard event into key code of page.event in phantomjs

I'm trying to record user keyboard event and replay it in phantomjs
The client's page (i.e. a firefox browser) code as below:
document.onkeydown=function(e){
sendToPhantom( e.which) //this will send browser key code to phantomjs
}
in phantomjs:
....
function keyFromClient(which){
var c = which
if (c==8) {
c = page.event.key.Backspace //0x01000003 in Qt
} else if (c==13) {
c = page.event.key.Enter //0x01000004 in Qt
} else {
c = String.fromCharCode(c)
}
page.sendEvent('keydown', c)
}
as you can see, it have to do a convertion from e.which to page.event.key for some special keys, like BackSpace, Enter etc., the Qt::Key enum
Question
How to correctly convert all e.which to page.event.key? There's so many possibilities, and it must be some standard ways to do this, any one knows?

Mac OS X: Intercept keyboard layout change

I have a problem. I have two keyboard layouts in my Mac because I have to type in two different languages while communicating with different people. I use the keyboard shortcut Cmd+Space to switch from one layout (language) to another.
I wonder if I can run custom script when Cmd+Space is pressed? I know there is an app called Punto Switcher that can do that.
My idea is to change keyboard highlighting level to indicate current language.
Bright = German (or Russian or whatever)
Dim = English
The question is where to find API that can
intercept keyboard layout in Mac OS X
change brightness of the keyboard highlight
Neat pointer to the LED brightness stuff from #Anoop Vaidya -- looks interesting!
The system sends a notification when the input method changes.
First, declare a function to receive the notification:
void theKeyboardChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
NSLog(#"Keyboard/input method changed.");
}
Then register for the change notification:
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(),
myContextInfo, theKeyboardChanged,
kTISNotifySelectedKeyboardInputSourceChanged, NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
I found a blog of Amit Singh, where he gave idea as in undocumented APIs , he used C, for this, you can surely find some sort of help from this.
Experimenting With Light.
Or you can try with these codes:
UInt64 lightInsideGetLEDBrightness(){
kern_return_t kr = 0;
IOItemCount scalarInputCount = 1;
IOItemCount scalarOutputCount = 1;
UInt64 in_unknown = 0, out_brightness;
kr = IOConnectCallScalarMethod(dataPort, kGetLEDBrightnessID, &in_unknown, scalarInputCount, &out_brightness, &scalarOutputCount);
return out_brightness;
}

Linea pro device detection

In my application i need to scan the bar code. for that i am using Linea pro bar code scanning device attached with my iPhone. i need to know the presence of device through code. is it possible? I am new to objective C . Help me to fix this issue.
Thank you.
Yes, it is possible.
All you have to do is this:
int lineaStatus = [[Linea sharedDevice] connstate];
Them just compare them to the different connection states like this.
if(lineaStatus == CONN_DISCONNECTED) {
//Device is connected
} else if(status == CONN_CONNECTED) {
//Device is disconnected.
}

windows 8 metro app - toast notification

I am developing a Windows 8 metro-style application using toast notification. (C# + xaml combination)
I looked into MS metro style sample code and tried to apply it to my project,
looks like I used the code exactly the same way, but I don't know why it is not working..
(There is no error, it builds successfully but just doesn't work.)
What I'm trying to do is very simple:
There is a button.
When the button_click event occurs, I'd like to pop a toast notification.
This is what I did:
namespace Application1
{
public sealed partial class BlankPage : Page
{
public BlankPage()
{
this.InitializeComponent();
Scenario2Init();
}
void Scenario2Init()
{
toastTest.Click += (sender, e) => { ToastAlarm(true); };
}
void ToastAlarm(bool loopAudio)
{
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
// Toasts can optionally be set to long duration by adding the 'duration' attribute
IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
((XmlElement)toastNode).SetAttribute("duration", "long");
// This XmlNodeList will have two items since the template we are using has two text fields.
XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
stringElements.Item(0).AppendChild(toastXml.CreateTextNode("Long Duration Toast"));
XmlElement audioElement = toastXml.CreateElement("audio");
if (loopAudio)
{
// Long-duration Toasts can optionally loop audio using the 'loop' attribute
audioElement.SetAttribute("src", "ms-winsoundevent:Notification.Looping.Alarm");
audioElement.SetAttribute("loop", "true");
stringElements.Item(1).AppendChild(toastXml.CreateTextNode("Looping audio"));
}
else
{
audioElement.SetAttribute("src", "ms-winsoundevent:Notification.IM");
}
toastNode.AppendChild(audioElement);
ToastNotification toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(toast);
//Scenario2OutputText.Text = toastXml.GetXml();
}
}
}
If I click the button, nothing happens. Why?
Your code looks correct to me; I don't have Win8 with me here right now so I can't test it. However, you may want to check your app's manifest if you enabled Toast or not in the "Toast Capable" field in VS. Hope this helps.
Did you enable "Toast capable" in Package.appxmanifest?
I think, there are two reasons,
First may be relating to toast capability of your application. For this set ToastCapable="true" in your Package.appxmanifest
Second one is run application in Local Machine rather than Simulator. I found that Simulator is not able to produce Toast notification.
i think you can just use Xml String
// Create the toast content by direct string manipulation.
// See the Toasts SDK Sample for other ways of generating toasts.
string toastXmlString =
"<toast duration=\"long\">\n" +
"<visual>\n" +
"<binding template=\"ToastText02\">\n" +
"<text id=\"1\">Alarms Notifications SDK Sample App</text>\n" +
"<text id=\"2\">" + alarmName + "</text>\n" +
"</binding>\n" +
"</visual>\n" +
"<commands scenario=\"alarm\">\n" +
"<command id=\"snooze\"/>\n" +
"<command id=\"dismiss\"/>\n" +
"</commands>\n" +
"<audio src=\"ms-winsoundevent:Notification.Looping.Alarm5\" loop=\"true\" />\n" +
"</toast>\n";