diff --git a/android/app-android.cpp b/android/app-android.cpp index 987f7c4b85..a8066b7d2c 100644 --- a/android/app-android.cpp +++ b/android/app-android.cpp @@ -252,15 +252,13 @@ extern "C" void JNICALL Java_com_turboviking_libnative_NativeApp_touch } float scaledX = (int)(x * dp_xscale); // why the (int) cast? float scaledY = (int)(y * dp_yscale); - input_state.mouse_x[pointerId] = scaledX; - input_state.mouse_y[pointerId] = scaledY; + input_state.pointer_x[pointerId] = scaledX; + input_state.pointer_y[pointerId] = scaledY; if (code == 1) { - input_state.mouse_last[pointerId] = input_state.mouse_down[pointerId]; - input_state.mouse_down[pointerId] = true; + input_state.pointer_down[pointerId] = true; NativeTouch(pointerId, scaledX, scaledY, 0, TOUCH_DOWN); } else if (code == 2) { - input_state.mouse_last[pointerId] = input_state.mouse_down[pointerId]; - input_state.mouse_down[pointerId] = false; + input_state.pointer_down[pointerId] = false; NativeTouch(pointerId, scaledX, scaledY, 0, TOUCH_UP); } else { NativeTouch(pointerId, scaledX, scaledY, 0, TOUCH_MOVE); diff --git a/android/src/com/turboviking/libnative/NativeActivity.java b/android/src/com/turboviking/libnative/NativeActivity.java index d0d920c369..29bd884d06 100644 --- a/android/src/com/turboviking/libnative/NativeActivity.java +++ b/android/src/com/turboviking/libnative/NativeActivity.java @@ -335,7 +335,7 @@ public class NativeActivity extends Activity { return null; return input.getText().toString(); } - + public void processCommand(String command, String params) { if (command.equals("launchBrowser")) { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(params)); diff --git a/base/NativeApp.h b/base/NativeApp.h index e6c2dee743..6468f9541d 100644 --- a/base/NativeApp.h +++ b/base/NativeApp.h @@ -36,7 +36,7 @@ void NativeDeviceLost(); // Called ~sixty times a second, delivers the current input state. // Main thread. -void NativeUpdate(const InputState &input); +void NativeUpdate(InputState &input); // Delivers touch events "instantly", without waiting for the next frame so that NativeUpdate can deliver. // Useful for triggering audio events, saving a few ms. diff --git a/base/PCMain.cpp b/base/PCMain.cpp index 8739633a48..d3d1c74e19 100644 --- a/base/PCMain.cpp +++ b/base/PCMain.cpp @@ -102,14 +102,22 @@ void SimulateGamepad(const uint8 *keys, InputState *input) { input->pad_buttons |= (1<pad_lstick_y=32000; - else if (keys['K']) input->pad_lstick_y=-32000; - if (keys['J']) input->pad_lstick_x=-32000; - else if (keys['L']) input->pad_lstick_x=32000; - if (keys['8']) input->pad_rstick_y=32000; - else if (keys['2']) input->pad_rstick_y=-32000; - if (keys['4']) input->pad_rstick_x=-32000; - else if (keys['6']) input->pad_rstick_x=32000; + if (keys[SDLK_i]) + input->pad_lstick_y=1; + else if (keys[SDLK_k]) + input->pad_lstick_y=-1; + if (keys[SDLK_j]) + input->pad_lstick_x=-1; + else if (keys[SDLK_l]) + input->pad_lstick_x=1; + if (keys[SDLK_KP8]) + input->pad_rstick_y=1; + else if (keys[SDLK_KP2]) + input->pad_rstick_y=-1; + if (keys[SDLK_KP4]) + input->pad_rstick_x=-1; + else if (keys[SDLK_KP6]) + input->pad_rstick_x=1; } extern void mixaudio(void *userdata, Uint8 *stream, int len) { @@ -251,19 +259,19 @@ int main(int argc, char *argv[]) { quitRequested = 1; } } else if (event.type == SDL_MOUSEMOTION) { - input_state.mouse_x[0] = mx; - input_state.mouse_y[0] = my; + input_state.pointer_x[0] = mx; + input_state.pointer_y[0] = my; NativeTouch(0, mx, my, 0, TOUCH_MOVE); } else if (event.type == SDL_MOUSEBUTTONDOWN) { if (event.button.button == SDL_BUTTON_LEFT) { //input_state.mouse_buttons_down = 1; - input_state.mouse_down[0] = true; + input_state.pointer_down[0] = true; nextFrameMD = true; NativeTouch(0, mx, my, 0, TOUCH_DOWN); } } else if (event.type == SDL_MOUSEBUTTONUP) { if (event.button.button == SDL_BUTTON_LEFT) { - input_state.mouse_down[0] = false; + input_state.pointer_down[0] = false; nextFrameMD = false; //input_state.mouse_buttons_up = 1; NativeTouch(0, mx, my, 0, TOUCH_UP); @@ -274,7 +282,6 @@ int main(int argc, char *argv[]) { if (quitRequested) break; - input_state.mouse_last[0] = input_state.mouse_down[0]; const uint8 *keys = (const uint8 *)SDL_GetKeyState(NULL); if (keys[SDLK_ESCAPE]) break; diff --git a/base/mutex.h b/base/mutex.h index 6700cc7f1f..ebceda318b 100644 --- a/base/mutex.h +++ b/base/mutex.h @@ -11,6 +11,7 @@ #include #endif +#include "base/basictypes.h" class recursive_mutex { #ifdef _WIN32 @@ -33,6 +34,7 @@ public: pthread_mutex_destroy(&mut_); #endif } + bool trylock() { #ifdef _WIN32 return TryEnterCriticalSection(&mut_) == TRUE; @@ -57,6 +59,7 @@ public: private: mutexType mut_; + DISALLOW_COPY_AND_ASSIGN(recursive_mutex); }; class lock_guard { diff --git a/input/gesture_detector.cpp b/input/gesture_detector.cpp index 6494553a76..f2ec3a81d4 100644 --- a/input/gesture_detector.cpp +++ b/input/gesture_detector.cpp @@ -27,10 +27,10 @@ static Finger fingers[MAX_FINGERS]; void update(const InputState &state) { // Mouse / 1-finger-touch control. - if (state.mouse_down[0]) { + if (state.pointer_down[0]) { fingers[0].down = true; - fingers[0].downX = state.mouse_x[0]; - fingers[0].downY = state.mouse_y[0]; + fingers[0].downX = state.pointer_x[0]; + fingers[0].downY = state.pointer_y[0]; } else { fingers[0].down = false; } diff --git a/input/input_state.h b/input/input_state.h index 8cce30920e..46d8244bd2 100644 --- a/input/input_state.h +++ b/input/input_state.h @@ -34,8 +34,7 @@ struct InputState { pad_buttons_up(0), mouse_valid(false), accelerometer_valid(false) { - memset(mouse_down, 0, sizeof(mouse_down)); - memset(mouse_last, 0, sizeof(mouse_last)); + memset(pointer_down, 0, sizeof(pointer_down)); } // Gamepad style input @@ -54,14 +53,16 @@ struct InputState { // There are up to 8 mice / fingers. volatile bool mouse_valid; - int mouse_x[MAX_POINTERS]; - int mouse_y[MAX_POINTERS]; - bool mouse_down[MAX_POINTERS]; - bool mouse_last[MAX_POINTERS]; + int pointer_x[MAX_POINTERS]; + int pointer_y[MAX_POINTERS]; + bool pointer_down[MAX_POINTERS]; // Accelerometer bool accelerometer_valid; Vec3 acc; + +private: + DISALLOW_COPY_AND_ASSIGN(InputState); }; inline void UpdateInputState(InputState *input) { diff --git a/native.vcxproj b/native.vcxproj index 470181302e..d63c9800c5 100644 --- a/native.vcxproj +++ b/native.vcxproj @@ -76,6 +76,8 @@ true WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) ..\zlib;..\native;..\RollerballGL;..\native\ext\glew;..\SDL\include;..\libpng;%(AdditionalIncludeDirectories); + StreamingSIMDExtensions2 + Fast Windows @@ -226,7 +228,9 @@ - + + AssemblyAndSourceCode +