Click here to Skip to main content
15,891,253 members
Home / Discussions / C#
   

C#

 
GeneralEvent handling in Custom Server Controls Pin
gorebash1-Sep-04 7:50
gorebash1-Sep-04 7:50 
GeneralRe: Event handling in Custom Server Controls Pin
Charlie Williams1-Sep-04 8:40
Charlie Williams1-Sep-04 8:40 
Generallocation based system Pin
mathon1-Sep-04 7:16
mathon1-Sep-04 7:16 
GeneralRe: location based system Pin
Heath Stewart1-Sep-04 15:33
protectorHeath Stewart1-Sep-04 15:33 
QuestionHow to cut a picture...?? Pin
Member 9401251-Sep-04 6:47
Member 9401251-Sep-04 6:47 
QuestionHow can I get width of window of my program when it change? Pin
arbrsoft1-Sep-04 5:51
arbrsoft1-Sep-04 5:51 
AnswerRe: How can I get width of window of my program when it change? Pin
LongRange.Shooter1-Sep-04 7:34
LongRange.Shooter1-Sep-04 7:34 
QuestionUnable to capture USB Gamepad using DirectInput? Pin
zhaonian1-Sep-04 4:57
zhaonian1-Sep-04 4:57 
I'm trying to caputre Logitech's USB gamepad using DirectInput with the following code. I use a timer to poll the gamepad's state. It seems the gamepad is captured but the buttons are not as I always get:

X: 32767
Y: 32767

Any ideas what could be the problem? Thanks in advance.

public class InputHandler
{
protected Device gamepad = null;

public InputHandler(Control Owner)
{
foreach (
DeviceInstance di in
Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly))
{
if (di.DeviceType == DeviceType.Joystick)
{
gamepad = new Device(di.InstanceGuid);
break;
}
}
gamepad.Properties.AxisModeAbsolute = true;
gamepad.SetCooperativeLevel(Owner,
CooperativeLevelFlags.Foreground |
CooperativeLevelFlags.NonExclusive);
gamepad.Acquire();
}

public JoystickState GetGamepadState()
{
return gamepad.CurrentJoystickState;
}

}

private void tmrPollInput_Tick(object sender, System.EventArgs e)
{
InputHandler input = new InputHandler(this);
JoystickState padstate = input.GetGamepadState();
byte [] buttons = padstate.GetButtons();
string info = "";
for (int i = 0; i < buttons.Length; i++)
{
if (buttons[i] != 0)
info += "Button: " + i + "\r\n";
}
txtGamepad.Text = "X: " + padstate.X + "\r\n"
+ "Y: " + padstate.Y + "\r\n"
+ info;
}
AnswerRe: Unable to capture USB Gamepad using DirectInput? Pin
Heath Stewart1-Sep-04 15:27
protectorHeath Stewart1-Sep-04 15:27 
GeneralData Marshalling issues when Calling C++ dll in C# using P/Invoke Pin
KZHU011-Sep-04 4:17
KZHU011-Sep-04 4:17 
GeneralRe: Data Marshalling issues when Calling C++ dll in C# using P/Invoke Pin
Heath Stewart1-Sep-04 15:23
protectorHeath Stewart1-Sep-04 15:23 
GeneralNUnit - Specifying the order of Tests Pin
matthias s.1-Sep-04 3:44
matthias s.1-Sep-04 3:44 
GeneralRe: NUnit - Specifying the order of Tests Pin
Marc Clifton1-Sep-04 4:12
mvaMarc Clifton1-Sep-04 4:12 
GeneralRe: NUnit - Specifying the order of Tests Pin
Steven Campbell1-Sep-04 7:44
Steven Campbell1-Sep-04 7:44 
GeneralAxWebBrowser, BeforeNavigate2Event, postData problem Pin
Member 12847121-Sep-04 3:14
Member 12847121-Sep-04 3:14 
QuestionDrawing Window on Second Display...? Pin
jkersch1-Sep-04 1:14
jkersch1-Sep-04 1:14 
AnswerRe: Drawing Window on Second Display...? Pin
Marc Clifton1-Sep-04 2:58
mvaMarc Clifton1-Sep-04 2:58 
GeneralRe: Drawing Window on Second Display...? Pin
jkersch1-Sep-04 3:36
jkersch1-Sep-04 3:36 
GeneralRe: Drawing Window on Second Display...? Pin
Marc Clifton1-Sep-04 4:18
mvaMarc Clifton1-Sep-04 4:18 
GeneralDrag 'n' Drop with WebBrowser problems Pin
cheesepirate1-Sep-04 0:51
cheesepirate1-Sep-04 0:51 
QuestionAccessing other forms control? Pin
sachinkalse31-Aug-04 22:49
sachinkalse31-Aug-04 22:49 
AnswerRe: Accessing other forms control? Pin
sreejith ss nair31-Aug-04 23:02
sreejith ss nair31-Aug-04 23:02 
GeneralRe: Accessing other forms control? Pin
sachinkalse31-Aug-04 23:46
sachinkalse31-Aug-04 23:46 
GeneralRe: Accessing other forms control? Pin
sreejith ss nair1-Sep-04 0:15
sreejith ss nair1-Sep-04 0:15 
GeneralRe: Accessing other forms control? Pin
sachinkalse1-Sep-04 1:01
sachinkalse1-Sep-04 1:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.