1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-03 10:01:21 +00:00

WINDOWS ONLY: _TITLE$ & _MOUSEMOVEMENTX/Y

This commit is contained in:
Galleon 2013-01-28 20:03:09 +11:00
parent 20c028411f
commit fe18ade92c
8 changed files with 2292 additions and 2201 deletions

View file

@ -23,10 +23,11 @@ extern void evnt(uint32 linenumber);
extern "C" int QB64_Custom_Event(int event,int v1,int v2,int v3,int v4,int v5,int v6,int v7,int v8,void *p1,void *p2);
#define QB64_EVENT_CLOSE 1 #define QB64_EVENT_CLOSE 1
#define QB64_EVENT_KEY 2 #define QB64_EVENT_KEY 2
#define QB64_EVENT_KEY_PAUSE 1000 #define QB64_EVENT_RELATIVE_MOUSE_MOVEMENT 3
extern "C" int QB64_Custom_Event(int event,int v1,int v2,int v3,int v4,int v5,int v6,int v7,int v8,void *p1,void *p2); #define QB64_EVENT_KEY_PAUSE 1000
@ -18862,14 +18863,9 @@ mousemovementfix_state=1;
float func__mousemovementx(){ float func__mousemovementx(){
device_mouse_relative=1;
mousemovementfix();
return mouse_messages[current_mouse_message].movementx; return mouse_messages[current_mouse_message].movementx;
} }
float func__mousemovementy(){ float func__mousemovementy(){
device_mouse_relative=1;
mousemovementfix();
return mouse_messages[current_mouse_message].movementy; return mouse_messages[current_mouse_message].movementy;
} }
@ -28202,15 +28198,31 @@ if (direction<0){GLUT_MouseButton_Down(5,x,y); GLUT_MouseButton_Up(5,x,y);}
void *generic_window_handle=NULL;
#ifdef QB64_WINDOWS
HWND window_handle=NULL;
#endif
//...
extern "C" void QB64_Window_Handle(void *handle){
generic_window_handle=handle;
#ifdef QB64_WINDOWS
window_handle=(HWND)handle;
#endif
//...
}
void sub__title(qbs *title){
if (new_error) return;
static qbs *sz=NULL; if (!sz) sz=qbs_new(0,0);
static qbs *cz=NULL; if (!cz){cz=qbs_new(1,0); cz->chr[0]=0;}
qbs_set(sz,qbs_add(title,cz));
#ifdef QB64_WINDOWS
while (!generic_window_handle) Sleep(10);//wait for window creation
SetWindowText(window_handle,(char*)sz->chr);
#endif
//...
}//title
@ -31833,11 +31845,33 @@ if (event==QB64_EVENT_KEY){
if (v2>0) keydown_vk(v1); else keyup_vk(v1); if (v2>0) keydown_vk(v1); else keyup_vk(v1);
return NULL; return NULL;
} }
return -1; return -1;
}//key }//key
return -1;//Unknown command (used for debugging purposes only) if (event==QB64_EVENT_RELATIVE_MOUSE_MOVEMENT){ //QB64_Custom_Event(QB64_EVENT_RELATIVE_MOUSE_MOVEMENT,xPosRelative,yPosRelative,0,0,0,0,0,0,NULL,NULL);
static int32 i;
//message #1
i=(last_mouse_message+1)&65535;
if (i==current_mouse_message) current_mouse_message=(current_mouse_message+1)&65535;//if buffer full, skip oldest message
mouse_messages[i].x=mouse_messages[last_mouse_message].x;
mouse_messages[i].y=mouse_messages[last_mouse_message].y;
mouse_messages[i].movementx=v1;
mouse_messages[i].movementy=v2;
mouse_messages[i].buttons=mouse_messages[last_mouse_message].buttons;
last_mouse_message=i;
//message #2 (clears movement values to avoid confusion)
i=(last_mouse_message+1)&65535;
if (i==current_mouse_message) current_mouse_message=(current_mouse_message+1)&65535;//if buffer full, skip oldest message
mouse_messages[i].x=mouse_messages[last_mouse_message].x;
mouse_messages[i].y=mouse_messages[last_mouse_message].y;
mouse_messages[i].movementx=0;
mouse_messages[i].movementy=0;
mouse_messages[i].buttons=mouse_messages[last_mouse_message].buttons;
last_mouse_message=i;
return NULL;
}//QB64_EVENT_RELATIVE_MOUSE_MOVEMENT
return -1;//Unknown command (use for debugging purposes only)
}//QB64_Custom_Event }//QB64_Custom_Event

View file

@ -2,10 +2,10 @@
#define FREEGLUT_STATIC #define FREEGLUT_STATIC
#endif #endif
int QB64_Custom_Event(int event,int v1,int v2,int v3,int v4,int v5,int v6,int v7,int v8,void *p1,void *p2);
#define QB64_EVENT_CLOSE 1 #define QB64_EVENT_CLOSE 1
#define QB64_EVENT_KEY 2 #define QB64_EVENT_KEY 2
int QB64_Custom_Event(int event,int v1,int v2,int v3,int v4,int v5,int v6,int v7,int v8,void *p1,void *p2); #define QB64_EVENT_RELATIVE_MOUSE_MOVEMENT 3
#define QBK 200000 #define QBK 200000
#define VK 100000 #define VK 100000
@ -13,16 +13,16 @@ int QB64_Custom_Event(int event,int v1,int v2,int v3,int v4,int v5,int v6,int v7
/* QBK codes: /* QBK codes:
200000-200010: Numpad keys with Num-Lock off 200000-200010: Numpad keys with Num-Lock off
NO_NUMLOCK_KP0=INSERT NO_NUMLOCK_KP0=INSERT
NO_NUMLOCK_KP1=END NO_NUMLOCK_KP1=END
NO_NUMLOCK_KP2=DOWN NO_NUMLOCK_KP2=DOWN
NO_NUMLOCK_KP3=PGDOWN NO_NUMLOCK_KP3=PGDOWN
NO_NUMLOCK_KP4... NO_NUMLOCK_KP4...
NO_NUMLOCK_KP5 NO_NUMLOCK_KP5
NO_NUMLOCK_KP6 NO_NUMLOCK_KP6
NO_NUMLOCK_KP7 NO_NUMLOCK_KP7
NO_NUMLOCK_KP8 NO_NUMLOCK_KP8
NO_NUMLOCK_KP9 NO_NUMLOCK_KP9
NO_NUMLOCK_KP_PERIOD=DEL NO_NUMLOCK_KP_PERIOD=DEL
200011: SCROLL_LOCK_ON 200011: SCROLL_LOCK_ON
200012: INSERT_MODE_ON 200012: INSERT_MODE_ON
*/ */
@ -2208,8 +2208,56 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
*/ */
return 0; return 0;
static int raw_setup=0;
static RAWINPUTDEVICE Rid[1];
case WM_INPUT:
{
if (raw_setup){
//QB64
//adapted from http://msdn.microsoft.com/en-us/library/windows/desktop/ee418864%28v=vs.85%29.aspx#WM_INPUT
UINT dwSize = 40;
static BYTE lpb[40];
GetRawInputData((HRAWINPUT)lParam, RID_INPUT,
lpb, &dwSize, sizeof(RAWINPUTHEADER));
RAWINPUT* raw = (RAWINPUT*)lpb;
if (raw->header.dwType == RIM_TYPEMOUSE)
{
int xPosRelative = raw->data.mouse.lLastX;
int yPosRelative = raw->data.mouse.lLastY;
if (xPosRelative||yPosRelative) QB64_Custom_Event(QB64_EVENT_RELATIVE_MOUSE_MOVEMENT,xPosRelative,yPosRelative,0,0,0,0,0,0,NULL,NULL);
}
}
break;
}
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
{ {
if (!raw_setup){
raw_setup=1;
#ifndef HID_USAGE_PAGE_GENERIC
#define HID_USAGE_PAGE_GENERIC ((USHORT) 0x01)
#endif
#ifndef HID_USAGE_GENERIC_MOUSE
#define HID_USAGE_GENERIC_MOUSE ((USHORT) 0x02)
#endif
Rid[0].usUsagePage = HID_USAGE_PAGE_GENERIC;
Rid[0].usUsage = HID_USAGE_GENERIC_MOUSE;
Rid[0].dwFlags = RIDEV_INPUTSINK;
Rid[0].hwndTarget = window->Window.Handle;
RegisterRawInputDevices(Rid, 1, sizeof(Rid[0]));
}
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
window->State.MouseX = 320-HIWORD( lParam ); window->State.MouseX = 320-HIWORD( lParam );
window->State.MouseY = LOWORD( lParam ); window->State.MouseY = LOWORD( lParam );

File diff suppressed because it is too large Load diff

View file

@ -90,7 +90,7 @@ extern int32 FontRenderTextASCII(int i,uint8*codepoint,int32 codepoints,int32 op
uint8**out_data,int32*out_x,int32 *out_y,int32*out_x_pre_increment,int32*out_x_post_increment); uint8**out_data,int32*out_x,int32 *out_y,int32*out_x_pre_increment,int32*out_x_post_increment);
extern void sub__title(qbs *title);
extern void sub__glrender(int32 method); extern void sub__glrender(int32 method);
extern int64 GetTicks(); extern int64 GetTicks();
extern void sub__memfill(mem_block* dblk,ptrszint doff,ptrszint dbytes,ptrszint soff,ptrszint sbytes); extern void sub__memfill(mem_block* dblk,ptrszint doff,ptrszint dbytes,ptrszint soff,ptrszint sbytes);
@ -954,13 +954,7 @@ void sub__limit(double fps);
void sub__display(); void sub__display();
void sub__autodisplay(); void sub__autodisplay();
void sub__title(qbs *s){
if (new_error) return;
static qbs *sz=NULL; if (!sz) sz=qbs_new(0,0);
static qbs *cz=NULL; if (!cz){cz=qbs_new(1,0); cz->chr[0]=0;}
qbs_set(sz,qbs_add(s,cz));
/////SDL_WM_SetCaption((const char *)sz->chr,(const char *)sz->chr);
}

View file

@ -8,6 +8,10 @@ rmdir /s /q temp,temp2,temp3,temp4,temp5,temp6,temp7,temp8,temp9 2>nul
echo Replacing main temp folder echo Replacing main temp folder
md temp md temp
echo Replacing dummy file in temp folder to maintain directory structure
copy source\temp.bin temp\temp.bin
echo Pruning source folder echo Pruning source folder
del source\undo2.bin 2>nul del source\undo2.bin 2>nul
del source\recompile.bat 2>nul del source\recompile.bat 2>nul
@ -28,4 +32,5 @@ del c\qbx2.cpp,c\qbx3.cpp,c\qbx4.cpp,c\qbx5.cpp,c\qbx6.cpp,c\qbx7.cpp,c\qbx8.cpp
echo Culling Windows executable files from root folder echo Culling Windows executable files from root folder
del ..\*.exe 2>nul del ..\*.exe 2>nul
pause pause

View file

@ -120,7 +120,7 @@ if(!qbevent)break;evnt(34);}while(r);
do{ do{
if(!qbevent)break;evnt(35);}while(r); if(!qbevent)break;evnt(35);}while(r);
do{ do{
qbs_set(__STRING_VERSION,qbs_new_txt_len("0.973",5)); qbs_set(__STRING_VERSION,qbs_new_txt_len("0.974",5));
qbs_cleanup(qbs_tmp_base,0); qbs_cleanup(qbs_tmp_base,0);
if(!qbevent)break;evnt(36);}while(r); if(!qbevent)break;evnt(36);}while(r);
do{ do{

View file

@ -2,5 +2,5 @@
cd %0\..\ cd %0\..\
echo Recompiling... echo Recompiling...
cd ../c cd ../c
c_compiler\bin\g++ -mconsole -s -Wfatal-errors -w -Wall qbx.cpp libqb\os\win\libqb_0_971_10000.o -D DEPENDENCY_LOADFONT parts\video\font\ttf\os\win\src.o -lws2_32 -lwinspool parts\core\os\win\src.a -lopengl32 -lglu32 -lwinmm -lgdi32 -Wl,--subsystem,windows -static-libgcc -static-libstdc++ -D FREEGLUT_STATIC -lksguid -lole32 -lwinmm -ldxguid -o "..\..\qb64.exe" c_compiler\bin\g++ -mconsole -s -Wfatal-errors -w -Wall qbx.cpp libqb\os\win\libqb_0_973_10000.o -D DEPENDENCY_LOADFONT parts\video\font\ttf\os\win\src.o -lws2_32 -lwinspool parts\core\os\win\src.a -lopengl32 -lglu32 -lwinmm -lgdi32 -Wl,--subsystem,windows -static-libgcc -static-libstdc++ -D FREEGLUT_STATIC -lksguid -lole32 -lwinmm -ldxguid -o "..\..\qb64.exe"
pause pause

View file

@ -33,7 +33,7 @@ DIM SHARED UseGL 'declared SUB _GL (no params)
DIM SHARED Version AS STRING DIM SHARED Version AS STRING
DIM SHARED C_Core AS LONG '0=SDL, 1=GLUT+OpenGL DIM SHARED C_Core AS LONG '0=SDL, 1=GLUT+OpenGL
DIM SHARED Debug AS LONG 'debug logging is off by default DIM SHARED Debug AS LONG 'debug logging is off by default
Version$ = "0.973": Debug = 0: C_Core = 1 Version$ = "0.974": Debug = 0: C_Core = 1
_TITLE "QB64" _TITLE "QB64"