A few questions about hard/software

Need help? Ask here and someone will help
Post Reply
Pain
Posts: 10
Joined: Sun Nov 30, 2014 12:59 pm

A few questions about hard/software

Post by Pain »

Hey,
first of all, thanks for your awesome work. It seems like it has a high potential. Ive read the Wiki but i still have a few uanswered questions in my mind:
In the wiki it says:
This is done using a specific Do-It-Yourself USB adapter.
It also can work with a Titan One (formerly known as GamepadProxy/Cronus/CronusMax), which can work with the PS3, the Xbox 360, the Xbox One, and the PS4 (with no touchpad support).
Forget about using any other USB to USB cable (like file transfer cables, or direct cables), they are not suited to this use.
For 360 only: a genuine wired 360 controller is required because the USB adapter has to authenticate to the 360. A wireless 360 controller with a play and charge kit will NOT work.
Does this mean if I build myself an "DIY Usb adapter" that i still need a 360 wired controller? Or do i only need a 360 controller if i buy the Cronus/CronusMax...?

My purpose is to remote control my Xbox 360 to do a few automatic tasks. Here it comes to a second question. I would like to send keystrokes from my c# application to my xbox. I merely read a short answer that it is possible that gimx recoginze a certain window for keystrokes. Sadly i couldnt find an explanation of such feature. Is there a tutorial or wiki description for such feature?

Keep up the good work!
Pain
Posts: 10
Joined: Sun Nov 30, 2014 12:59 pm

Re: A few questions about hard/software

Post by Pain »

Hey everyone ive bought the hardware and will now solve some questions:
You always need a 360 Controller I bought this one: http://www.amazon.de/gp/product/B004JU0 ... ge_o01_s00

Then I tried to send keyboard events to the gimx window but as there is no documentation about it. I found out that with c# you have to sen Keystrokes by using the SendInput Api also note that you have to send ScanCodes instead of Virtual Keys like so:

So for example to press "s"

Code: Select all

[DllImport("user32.dll")]
        static extern bool SetForegroundWindow(IntPtr hWnd);
private void button1_Click(object sender, EventArgs e)
        {
            Process p = Process.GetProcessById(6740); // My PID of gimx Process
            IntPtr test = p.MainWindowHandle;
            SetForegroundWindow(test);
            

            SendSKey(50);
        }


public static void SendSKey(int HoldTime)
        {
            INPUT INPUT1 = new INPUT();
            INPUT1.type = (int)InputType.INPUT_KEYBOARD;
            //INPUT1.ki.wVk = (short)key;
            INPUT1.ki.wScan = 31; // 31 = s 
            INPUT1.ki.dwFlags = 8;
            INPUT1.ki.dwExtraInfo = GetMessageExtraInfo();

            SendInput(1, new INPUT[] { INPUT1 }, Marshal.SizeOf(INPUT1));

            Thread.Sleep(HoldTime);

            INPUT INPUT2 = new INPUT();
            INPUT2.type = (int)InputType.INPUT_KEYBOARD;
            INPUT2.ki.wScan = 31;
            INPUT2.ki.dwFlags = 10;
            INPUT2.ki.dwExtraInfo = GetMessageExtraInfo();
            SendInput(1, new INPUT[] { INPUT2 }, Marshal.SizeOf(INPUT2));

        }

        [StructLayout(LayoutKind.Explicit)]
        public struct INPUT
        {
            [FieldOffset(4)]
            public HARDWAREINPUT hi;
            [FieldOffset(4)]
            public KEYBDINPUT ki;
            [FieldOffset(4)]
            public MOUSEINPUT mi;
            [FieldOffset(0)]
            public int type;
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct MOUSEINPUT
        {
            public int dx;
            public int dy;
            public int mouseData;
            public int dwFlags;
            public int time;
            public IntPtr dwExtraInfo;
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct KEYBDINPUT
        {
            public short wVk;
            public short wScan;
            public int dwFlags;
            public int time;
            public IntPtr dwExtraInfo;
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct HARDWAREINPUT
        {
            public int uMsg;
            public short wParamL;
            public short wParamH;
        }

        [Flags]
        public enum InputType
        {
            INPUT_MOUSE = 0,
            INPUT_KEYBOARD = 1,
            INPUT_HARDWARE = 2
        }

        [Flags]
        public enum MOUSEEVENTF
        {
            MOVE = 0x0001, /* mouse move */
            LEFTDOWN = 0x0002, /* left button down */
            LEFTUP = 0x0004, /* left button up */
            RIGHTDOWN = 0x0008, /* right button down */
            RIGHTUP = 0x0010, /* right button up */
            MIDDLEDOWN = 0x0020, /* middle button down */
            MIDDLEUP = 0x0040, /* middle button up */
            XDOWN = 0x0080, /* x button down */
            XUP = 0x0100, /* x button down */
            WHEEL = 0x0800, /* wheel button rolled */
            MOVE_NOCOALESCE = 0x2000, /* do not coalesce mouse moves */
            VIRTUALDESK = 0x4000, /* map to entire virtual desktop */
            ABSOLUTE = 0x8000 /* absolute move */
        }

        [Flags]
        public enum KEYEVENTF
        {
            KEYDOWN = 0,
            EXTENDEDKEY = 0x0001,
            KEYUP = 0x0002,
            UNICODE = 0x0004,
            SCANCODE = 0x0008,
        }
Thnks
User avatar
Matlo
Posts: 5764
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: A few questions about hard/software

Post by Matlo »

Hi,

To make gimx receive your generated events you have to select "Window events" as "Input" in gimx-launcher.
The window that recognizes the generated events is named "gimx".
As I'm not a c# expert I can't tell if your code will work.
The only thing I can suggest is to get the process with its name instead of its PID.
GIMX creator
Post Reply