Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Everyday Everything

Pages: [1]
1
Network / Extracting sf::Int/Uint array from sf::Packet
« on: June 18, 2012, 07:09:14 pm »
I'm trying to extract an sf::Uint8 array from a packet but receiving this compiler error in code::blocks with SFML 2.0:
C:\BW Gaming\Sandbox RPG - Server\Incoming UDP.cpp|20|error: invalid conversion from 'sf::Uint8*' to 'char*'|

even just the simple code below gives me this error, though if I change it to char it works fine. . . should this work or am I doing something wrong?

#include <SFML/Network.hpp>
void function() {
    sf::Uint8 uint8[2];
    sf::Packet packet;
    packet >> uint8;
}
 

Thanks!

2
Window / Non-Cursor Dependant Mouse Input
« on: December 10, 2010, 10:49:37 pm »
First off, this being my first post, I would like to say that SFML is pretty awesome. I've had trouble finding something that really allowed me to dable in game programming the way I wanted to. I always find myself quickly outgrowing the constraints of what ever I've tried or ending up way over my head, sometimes unable to even get a working program at all.

But on to my question. I've been looking into using a more "raw" type of input from the mouse to look around a 3D environment. To be honest, setting the cursor to the middle of the screen, then reading/reseting the coordinates has worked pretty good, thus far save for a few unexplained jumps in my view now and then.

However I would like to avoid troubles with desktop mouse adjustments, like mouse acceleration. I am also concerned that reading the pixel change limits the accuracy of the mouse.

Could someone give me any ideas or suggestions?

EDIT:
After doing even more googling and thinking, I now imagine that offering the option to change the mouse settings in game is probably my best solution, such as being able to turn on/off pointer acceleration/enhanced pointer precision.

Also, when looking around the scene I could potentially increase windows pointer speed and then scale back the rotation speed in the game thereby increasing accuracy, if I decide that it is not accurate enough. Of course, now this self taught novice programmer (me) needs to figure out how to program in that . . .  :shock: . . . maybe just in Windows for now.

If I figure it out, I'll post it for anyone else having similar thoughts . . .

EDIT 2:
Here is some example functions, in case anyone else is looking for this type of solution.  This WILL change the windows settings for the user and I suggest that if you plan to use this, you save the default settings and apply them any time the program does not have focus and especially once it is closed. If your program crashes, you will obviously leave your user with the new mouse settings.

Since I am using SFML I am not certain what all you have to include to use this command, however I am certain you require <winuser.h>. Also, I should note that the SystemParametersInfo() function returns a bool but I am not capturing it.

Code: [Select]

void SetMouseSpeed(int speed) {
    SystemParametersInfo(SPI_SETMOUSESPEED, NULL, reinterpret_cast<void*>(speed), SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE );
}

int GetMouseSpeed() {
    int speed;
    SystemParametersInfo(SPI_GETMOUSESPEED, NULL, &speed, 0);
    return speed;
}

///Mouse Acceleration
/*The system applies two tests to the specified relative mouse motion when applying acceleration.
If the specified distance along either the x or y axis is greater than the first mouse threshold
value, and the mouse acceleration level is not zero, the operating system doubles the distance.
If the specified distance along either the x- or y-axis is greater than the second mouse threshold
value, and the mouse acceleration level is equal to two, the operating system doubles the distance
that resulted from applying the first threshold test. It is thus possible for the operating system
to multiply relatively-specified mouse motion along the x- or y-axis by up to four times.*/

//Sets the two mouse threshold values and the mouse acceleration. The pvParam parameter must point to an array of three integers that specifies these values.
void SetMouseAccel(int threshold1,int threshold2,int speed) {
    int info[3];
    info[0]=threshold1;
    info[1]=threshold2;
    SystemParametersInfo(SPI_SETMOUSE, NULL, info, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE );
}

//Retrieves the two mouse threshold values and the mouse acceleration. The pvParam parameter must point to an array of three integers that receives these values.
int GetMouseAccel(int *threshold1,int *threshold2) {
    int info[3];
    SystemParametersInfo(SPI_GETMOUSE, NULL, &info, 0);
    *threshold1 = info[0];
    *threshold2 = info[1];
    return info[2];

}


ps. If anyone has a better idea or knows how to get non-cursor dependent mouse input, let me know  :D

I'm sure there are better ways than my hack.

Pages: [1]
anything