9 Replies - 485 Views - Last Post: 23 January 2013 - 10:24 AM Rate Topic: -----

#1 mager1794  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 133
  • Joined: 23-March 09

Keyboard Output In Game

Posted 16 January 2013 - 02:28 PM

I've doing a lot of research to create a program that will allow me to use my xbox 360 controller while playing the game League Of Legends.

I understand there are many software pieces that already do this, but none of them work the way I would like.'

My primary question is, how I make the key presses be read by LoL. I have tried multiple combinations but the fact is
my mouse clicks work perfect all of the errors are when for example. I press the 'X' button on my controller it should be emulating to the game that I actually pressed the 'Q' button on the keyboard. But in game it gives no response. Yet outside of a game say for example I open up notepad, It will type in the letter 'Q' like i intended. I would appreciate any assistance possible.

I've tried the SendKey and the SendInput approach and neither have worked.

Is This A Good Question/Topic? 0
  • +

Replies To: Keyboard Output In Game

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5467
  • View blog
  • Posts: 11,745
  • Joined: 02-June 10

Re: Keyboard Output In Game

Posted 16 January 2013 - 03:03 PM

Are you sure its the 'right' Q?
For example are you sending a capital Q when the game is looking for a lower-case q ?
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3535
  • View blog
  • Posts: 10,944
  • Joined: 05-May 12

Re: Keyboard Output In Game

Posted 16 January 2013 - 03:10 PM

The keyword you are looking for in your searches should be "USB" and "HID". HID == Human Interface Device.

The short story is that you either have to write a device driver that exposes the controller as a keyboard device, or you have to write a program that reads the input from the USB port and does SendKeys() after translating the input from the USB port.
Was This Post Helpful? 0
  • +
  • -

#4 mager1794  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 133
  • Joined: 23-March 09

Re: Keyboard Output In Game

Posted 16 January 2013 - 03:44 PM

Im not finding anyway to directly access the keyboard, any assistance or tips in the right direction would be awesome


== Edit ==
I misinterpretted your statement. Is that the only way to access league of legends with key functions? All I need to to find a way for league of legends to receive the messages I've posted to it

IntPtr hwnd = IntPtr.Zero;
            while (hwnd == IntPtr.Zero)
            {
                try
                {
                    hwnd = FindWindow(null, "League Of Legends (TM) Client");
                    if (hwnd != IntPtr.Zero)
                        Console.WriteLine("League Of Legends Found");
                }
                catch
                {
                }

               
            }


///In use
 if (gPad.IsButtonDown(Buttons.X) && gPadprev.IsButtonUp(Buttons.X))
                {
                    //Communication.SendKeyDown(VirtualKeyCode.VK_Q, keyboard);
                    SendMessage(hwnd, WM_SYSKEYDOWN, (int)Keys.Q, 0);
                    
                }

                if (gPad.IsButtonUp(Buttons.X) && gPadprev.IsButtonDown(Buttons.X))
                {
                    //Communication.SendKeyUp(VirtualKeyCode.VK_Q, keyboard);
                    SendMessage(hwnd, WM_SYSKEYUP, (int)Keys.Q, 0);

                }


This post has been edited by mager1794: 16 January 2013 - 03:50 PM

Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5467
  • View blog
  • Posts: 11,745
  • Joined: 02-June 10

Re: Keyboard Output In Game

Posted 16 January 2013 - 03:48 PM

Skydiver: It reads like the OP has already done that and getting results for some of it - just not the key strokes.

View Postmager1794, on 16 January 2013 - 03:28 PM, said:

my mouse clicks work perfect

I've tried the SendKey and the SendInput approach and neither have worked.

This post has been edited by tlhIn`toq: 16 January 2013 - 03:48 PM

Was This Post Helpful? 0
  • +
  • -

#6 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3535
  • View blog
  • Posts: 10,944
  • Joined: 05-May 12

Re: Keyboard Output In Game

Posted 17 January 2013 - 05:26 AM

Good catch about the SendKeys. I missed that part reading on a small screen.

Anyway, hopefully mager1794 can go into detail how (s)he was using the two approaches. Some people write code that depend on the keydown event, others depend on the keyup, and yet others depend on GetAsyncKeyState() (especially based on the code and questions posted in the C++ forum) when using keyboard input for games. Well written games used DirectInput and/or XInput and let the OS deal with the issue for getting input signals.
Was This Post Helpful? 1
  • +
  • -

#7 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5467
  • View blog
  • Posts: 11,745
  • Joined: 02-June 10

Re: Keyboard Output In Game

Posted 17 January 2013 - 07:31 AM

Agreed. But I can imagine a developer's thinking to deliberately NOT go that DirectIn route in an effort to make things harder on hackers. Nobody wants to see their program ruined by someone that codes up a 'bot to play the game on behalf of the user.
Was This Post Helpful? 0
  • +
  • -

#8 mager1794  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 133
  • Joined: 23-March 09

Re: Keyboard Output In Game

Posted 23 January 2013 - 10:06 AM

I know that its possible, ive seen a bunch of bots do it through scripts. I fail to see why I am unable in C#
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9059
  • View blog
  • Posts: 34,017
  • Joined: 12-June 08

Re: Keyboard Output In Game

Posted 23 January 2013 - 10:21 AM

Can't this just be mapped with the driver install?

http://support.xbox....or-windows-info
Was This Post Helpful? 0
  • +
  • -

#10 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3535
  • View blog
  • Posts: 10,944
  • Joined: 05-May 12

Re: Keyboard Output In Game

Posted 23 January 2013 - 10:24 AM

Why are you using WM_SYSKEYDOWN? Do you really mean to send ALT-Q as per MSDN:
http://msdn.microsof...6(v=vs.85).aspx
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1