Page 1 of 4

Code question

Posted: Wed Aug 17, 2011 9:02 pm
by Zero
Hello guys I have a few code questions.
I don't see a development form section so I guess I'll post here. :?

I've been looking at the emulator code, I see that you're sending the structure s_report_data that's got the X,Y,Z and Rz? axis ( I don't know what the Z and Rz axis stand for O.o) ... anyways the values are declared as int16_t and a few lines below i see that you write a uint16_t in the values.

#define DEFAULT_MAX_AXIS_VALUE 65535
data.X = clamp(0, state->user.axis[0][0] + DEFAULT_MEAN_AXIS_VALUE, DEFAULT_MAX_AXIS_VALUE);

Should this work? Am I misreading this.

hmm ... additionally in the usb_joystick code file I see that the axis are uint8_t joystick_axis_x;
Shouldn't the report structure send uint8_t?

Re: Code question

Posted: Wed Aug 17, 2011 10:48 pm
by Matlo
Please don't double post, edit your last post instead.

2 sticks x 2 axis = 4 axis = (X,Y,Z,Rz)

And yes, the assignment works.

The stuff in the usb_joystick file is the old ps/2 version, it's not the right file. Look at joystick-serial/Joystick.h instead.

Re: Code question

Posted: Thu Aug 18, 2011 7:17 am
by Zero
I'm sorry about the double post. Ok I understand :)
Tank you :D

I have an additional question. The struct from Joystick.h is:

typedef struct
{
int16_t X;
int16_t Y;
int16_t Z;
int16_t Rz;
int16_t Hat;
uint16_t Bt;
} USB_JoystickReport_Data_t;

is that 16bits x 6 = 96 bits? and int16_t can take values from − 32,768 to 32,767?

Also at what rate do you recommend the refresh should happen? My planed approach is to create 2 additional threads that handle input and output, to and from the controlling board. The input thread will send a report at x interval. I see that in emuclient.c an update is done every second.


-------------------- More recent edit

In the serial_con.h i see that the struct being sent to the controller is slightly different in it Hat is not int16_t but unsigned

typedef struct
{
int16_t X;
int16_t Y;
int16_t Z;
int16_t Rz;
uint16_t Hat;
uint16_t Bt;
} s_report_data;

Re: Code question

Posted: Thu Aug 18, 2011 8:43 pm
by Zero
hello :cry:



I really like the development forum :)
I wish Matlo would come by more often :oops:

Re: Code question

Posted: Thu Aug 18, 2011 10:07 pm
by Matlo
Everything should be uint16_t, but it works as there's no storage difference between an int16_t and an uint16_t.

I don't understand the purpose of your two threads. What do you want to code? An adapter for your 360?

You misread the refresh rate in emuclient.c. It's 100, 125, or 250Hz depending on what the user sets.

Re: Code question

Posted: Thu Aug 18, 2011 11:20 pm
by Zero
I would but sadly I don't know anything about the communication process between the 360 controller and the console.
I do know that the 360 controller uses wifi not Bluetooth and the communication is probably some MS proprietary protocol.

I'll probably get a ps3 with the new price drop :roll: I really wana play resistance and uncharted.

Re: Code question

Posted: Fri Aug 19, 2011 7:58 am
by Matlo
I still don't understand the purpose of the two threads :)

Re: Code question

Posted: Fri Aug 19, 2011 5:12 pm
by Zero
oh well its just to clear some things up on how to use the controller. I'm not 100% sure on the structure that needs to be sent to the controller (teensy++), values and stuff. I'm not a master in C/C++ and in my view some things did not add up.

I wana build my own application to talk to the controller you've created, however I'd like to code it in Java or C#. At the moment I'm leaning more towards C# ... that will lock its usage to windows platform but I don't care, I do this for the fun of it.


Once I have something solid I'd like to post it here, get feedback from you. I'll probably be using WPF. Maybe we can work together? :roll:

Re: Code question

Posted: Mon Aug 22, 2011 5:33 pm
by Matlo
Sorry, but I don't really like windows exclusive software. As a developer, I work on my OS first (Linux), and only after that I may port it to other OSes (which is easy as I use cross platform development tools). I'm developing GIMX to meet my needs (I'm the first user of it), and I don't have the time to help you build something I will never use.

Re: Code question

Posted: Tue Aug 23, 2011 4:41 am
by cldfusion
Which tools do you use?